From ea6c930c04762bef00b42dad16a17b71b8acc93b Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sun, 9 Apr 2017 11:11:37 -0400 Subject: [PATCH] Helper cleanup (#1348) * Remove unused helper files * Add coverage for application helper * Add coverage for StreamEntriesHelper #display_name --- app/helpers/about_helper.rb | 4 ---- app/helpers/admin/domain_blocks_helper.rb | 4 ---- app/helpers/admin/pubsubhubbub_helper.rb | 4 ---- app/helpers/authorize_follow_helper.rb | 4 ---- app/helpers/tags_helper.rb | 4 ---- app/helpers/xrd_helper.rb | 4 ---- spec/helpers/about_helper_spec.rb | 5 ----- spec/helpers/admin/domain_blocks_helper_spec.rb | 5 ----- spec/helpers/admin/pubsubhubbub_helper_spec.rb | 5 ----- spec/helpers/application_helper_spec.rb | 16 +++++++++++++++- spec/helpers/authorize_follow_helper_spec.rb | 5 ----- spec/helpers/stream_entries_helper_spec.rb | 12 +++++++++++- spec/helpers/tags_helper_spec.rb | 5 ----- spec/helpers/xrd_helper_spec.rb | 5 ----- 14 files changed, 26 insertions(+), 56 deletions(-) delete mode 100644 app/helpers/about_helper.rb delete mode 100644 app/helpers/admin/domain_blocks_helper.rb delete mode 100644 app/helpers/admin/pubsubhubbub_helper.rb delete mode 100644 app/helpers/authorize_follow_helper.rb delete mode 100644 app/helpers/tags_helper.rb delete mode 100644 app/helpers/xrd_helper.rb delete mode 100644 spec/helpers/about_helper_spec.rb delete mode 100644 spec/helpers/admin/domain_blocks_helper_spec.rb delete mode 100644 spec/helpers/admin/pubsubhubbub_helper_spec.rb delete mode 100644 spec/helpers/authorize_follow_helper_spec.rb delete mode 100644 spec/helpers/tags_helper_spec.rb delete mode 100644 spec/helpers/xrd_helper_spec.rb diff --git a/app/helpers/about_helper.rb b/app/helpers/about_helper.rb deleted file mode 100644 index 0f57a7b5e3..0000000000 --- a/app/helpers/about_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -module AboutHelper -end diff --git a/app/helpers/admin/domain_blocks_helper.rb b/app/helpers/admin/domain_blocks_helper.rb deleted file mode 100644 index d66c8d5e14..0000000000 --- a/app/helpers/admin/domain_blocks_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -module Admin::DomainBlocksHelper -end diff --git a/app/helpers/admin/pubsubhubbub_helper.rb b/app/helpers/admin/pubsubhubbub_helper.rb deleted file mode 100644 index c2fc2e7da5..0000000000 --- a/app/helpers/admin/pubsubhubbub_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -module Admin::PubsubhubbubHelper -end diff --git a/app/helpers/authorize_follow_helper.rb b/app/helpers/authorize_follow_helper.rb deleted file mode 100644 index 99ee03c2fe..0000000000 --- a/app/helpers/authorize_follow_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -module AuthorizeFollowHelper -end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb deleted file mode 100644 index 5b2b3ca596..0000000000 --- a/app/helpers/tags_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -module TagsHelper -end diff --git a/app/helpers/xrd_helper.rb b/app/helpers/xrd_helper.rb deleted file mode 100644 index 2281a02785..0000000000 --- a/app/helpers/xrd_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -module XrdHelper -end diff --git a/spec/helpers/about_helper_spec.rb b/spec/helpers/about_helper_spec.rb deleted file mode 100644 index 6efc9f5bd2..0000000000 --- a/spec/helpers/about_helper_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe AboutHelper, type: :helper do - -end diff --git a/spec/helpers/admin/domain_blocks_helper_spec.rb b/spec/helpers/admin/domain_blocks_helper_spec.rb deleted file mode 100644 index cc7ead84e3..0000000000 --- a/spec/helpers/admin/domain_blocks_helper_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Admin::DomainBlocksHelper, type: :helper do - -end diff --git a/spec/helpers/admin/pubsubhubbub_helper_spec.rb b/spec/helpers/admin/pubsubhubbub_helper_spec.rb deleted file mode 100644 index 673236a7ec..0000000000 --- a/spec/helpers/admin/pubsubhubbub_helper_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Admin::PubsubhubbubHelper, type: :helper do - -end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index c2063c9958..a2eeb443c4 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,5 +1,19 @@ require 'rails_helper' -RSpec.describe ApplicationHelper, type: :helper do +describe ApplicationHelper do + describe 'active_nav_class' do + it 'returns active when on the current page' do + allow(helper).to receive(:current_page?).and_return(true) + result = helper.active_nav_class("/test") + expect(result).to eq "active" + end + + it 'returns empty string when not on current page' do + allow(helper).to receive(:current_page?).and_return(false) + + result = helper.active_nav_class("/test") + expect(result).to eq "" + end + end end diff --git a/spec/helpers/authorize_follow_helper_spec.rb b/spec/helpers/authorize_follow_helper_spec.rb deleted file mode 100644 index ba5b0a70b9..0000000000 --- a/spec/helpers/authorize_follow_helper_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe AuthorizeFollowHelper, type: :helper do - -end diff --git a/spec/helpers/stream_entries_helper_spec.rb b/spec/helpers/stream_entries_helper_spec.rb index 6227f92809..221e1e32d6 100644 --- a/spec/helpers/stream_entries_helper_spec.rb +++ b/spec/helpers/stream_entries_helper_spec.rb @@ -2,7 +2,17 @@ require 'rails_helper' RSpec.describe StreamEntriesHelper, type: :helper do describe '#display_name' do - pending + it 'uses the display name when it exists' do + account = Account.new(display_name: "Display", username: "Username") + + expect(helper.display_name(account)).to eq "Display" + end + + it 'uses the username when display name is nil' do + account = Account.new(display_name: nil, username: "Username") + + expect(helper.display_name(account)).to eq "Username" + end end describe '#avatar_for_status_url' do diff --git a/spec/helpers/tags_helper_spec.rb b/spec/helpers/tags_helper_spec.rb deleted file mode 100644 index f661e44ac9..0000000000 --- a/spec/helpers/tags_helper_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe TagsHelper, type: :helper do - -end diff --git a/spec/helpers/xrd_helper_spec.rb b/spec/helpers/xrd_helper_spec.rb deleted file mode 100644 index 0bc71b6577..0000000000 --- a/spec/helpers/xrd_helper_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe XrdHelper, type: :helper do - -end