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 0f57a7b5e3f..00000000000 --- 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 d66c8d5e145..00000000000 --- 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 c2fc2e7da50..00000000000 --- 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 99ee03c2fef..00000000000 --- 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 5b2b3ca5966..00000000000 --- 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 2281a027858..00000000000 --- 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 6efc9f5bd2c..00000000000 --- 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 cc7ead84e39..00000000000 --- 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 673236a7ec2..00000000000 --- 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 c2063c9958d..a2eeb443c42 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 ba5b0a70b96..00000000000 --- 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 6227f92809a..221e1e32d66 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 f661e44ac9b..00000000000 --- 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 0bc71b65776..00000000000 --- a/spec/helpers/xrd_helper_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe XrdHelper, type: :helper do - -end