commit: ea6c930c04762bef00b42dad16a17b71b8acc93b
parent: 12e29c9660df3ce85f46715bb62a4a15ce38f6a5
Author: Matt Jankowski <mjankowski@thoughtbot.com>
Date: Sun, 9 Apr 2017 11:11:37 -0400
Helper cleanup (#1348)
* Remove unused helper files
* Add coverage for application helper
* Add coverage for StreamEntriesHelper #display_name
Diffstat:
14 files changed, 26 insertions(+), 56 deletions(-)
diff --git a/app/helpers/about_helper.rb b/app/helpers/about_helper.rb
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1,5 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe XrdHelper, type: :helper do
-
-end