about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-04-09 11:11:37 -0400
committerEugen <eugen@zeonfederated.com>2017-04-09 17:11:37 +0200
commitea6c930c04762bef00b42dad16a17b71b8acc93b (patch)
tree3760237e43060ee0ffe0362570266d95021cc910
parent12e29c9660df3ce85f46715bb62a4a15ce38f6a5 (diff)
Helper cleanup (#1348)
* Remove unused helper files

* Add coverage for application helper

* Add coverage for StreamEntriesHelper #display_name
-rw-r--r--app/helpers/about_helper.rb4
-rw-r--r--app/helpers/admin/domain_blocks_helper.rb4
-rw-r--r--app/helpers/admin/pubsubhubbub_helper.rb4
-rw-r--r--app/helpers/authorize_follow_helper.rb4
-rw-r--r--app/helpers/tags_helper.rb4
-rw-r--r--app/helpers/xrd_helper.rb4
-rw-r--r--spec/helpers/about_helper_spec.rb5
-rw-r--r--spec/helpers/admin/domain_blocks_helper_spec.rb5
-rw-r--r--spec/helpers/admin/pubsubhubbub_helper_spec.rb5
-rw-r--r--spec/helpers/application_helper_spec.rb16
-rw-r--r--spec/helpers/authorize_follow_helper_spec.rb5
-rw-r--r--spec/helpers/stream_entries_helper_spec.rb12
-rw-r--r--spec/helpers/tags_helper_spec.rb5
-rw-r--r--spec/helpers/xrd_helper_spec.rb5
14 files changed, 26 insertions, 56 deletions
diff --git a/app/helpers/about_helper.rb b/app/helpers/about_helper.rb
deleted file mode 100644
index 0f57a7b5e..000000000
--- 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 d66c8d5e1..000000000
--- 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 c2fc2e7da..000000000
--- 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 99ee03c2f..000000000
--- 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 5b2b3ca59..000000000
--- 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 2281a0278..000000000
--- 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 6efc9f5bd..000000000
--- 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 cc7ead84e..000000000
--- 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 673236a7e..000000000
--- 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 c2063c995..a2eeb443c 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 ba5b0a70b..000000000
--- 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 6227f9280..221e1e32d 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 f661e44ac..000000000
--- 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 0bc71b657..000000000
--- a/spec/helpers/xrd_helper_spec.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe XrdHelper, type: :helper do
-
-end