about summary refs log tree commit diff
path: root/spec/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/emoji_helper_spec.rb20
-rw-r--r--spec/helpers/jsonld_helper_spec.rb35
-rw-r--r--spec/helpers/routing_helper_spec.rb43
-rw-r--r--spec/helpers/settings_helper_spec.rb4
4 files changed, 80 insertions, 22 deletions
diff --git a/spec/helpers/emoji_helper_spec.rb b/spec/helpers/emoji_helper_spec.rb
deleted file mode 100644
index 6edf7672f..000000000
--- a/spec/helpers/emoji_helper_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe EmojiHelper, type: :helper do
-  describe '#emojify' do
-    it 'converts shortcodes to unicode' do
-      text = ':book: Book'
-      expect(emojify(text)).to eq '📖 Book'
-    end
-
-    it 'converts composite emoji shortcodes to unicode' do
-      text = ':couple_ww:'
-      expect(emojify(text)).to eq '👩❤👩'
-    end
-
-    it 'does not convert shortcodes that are part of a string into unicode' do
-      text = ':see_no_evil::hear_no_evil::speak_no_evil:'
-      expect(emojify(text)).to eq text
-    end
-  end
-end
diff --git a/spec/helpers/jsonld_helper_spec.rb b/spec/helpers/jsonld_helper_spec.rb
new file mode 100644
index 000000000..7d3912e6c
--- /dev/null
+++ b/spec/helpers/jsonld_helper_spec.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe JsonLdHelper do
+  describe '#equals_or_includes?' do
+    it 'returns true when value equals' do
+      expect(helper.equals_or_includes?('foo', 'foo')).to be true
+    end
+
+    it 'returns false when value does not equal' do
+      expect(helper.equals_or_includes?('foo', 'bar')).to be false
+    end
+
+    it 'returns true when value is included' do
+      expect(helper.equals_or_includes?(%w(foo baz), 'foo')).to be true
+    end
+
+    it 'returns false when value is not included' do
+      expect(helper.equals_or_includes?(%w(foo baz), 'bar')).to be false
+    end
+  end
+
+  describe '#first_of_value' do
+    pending
+  end
+
+  describe '#supported_context?' do
+    pending
+  end
+
+  describe '#fetch_resource' do
+    pending
+  end
+end
diff --git a/spec/helpers/routing_helper_spec.rb b/spec/helpers/routing_helper_spec.rb
new file mode 100644
index 000000000..940392c9b
--- /dev/null
+++ b/spec/helpers/routing_helper_spec.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe RoutingHelper, type: :helper do
+  describe '.full_asset_url' do
+    around do |example|
+      use_s3 = Rails.configuration.x.use_s3
+      example.run
+      Rails.configuration.x.use_s3 = use_s3
+    end
+
+    shared_examples 'returns full path URL' do
+      it 'with host' do
+        url = helper.full_asset_url('https://example.com/avatars/000/000/002/original/icon.png')
+
+        expect(url).to eq 'https://example.com/avatars/000/000/002/original/icon.png'
+      end
+
+      it 'without host' do
+        url = helper.full_asset_url('/avatars/original/missing.png', skip_pipeline: true)
+
+        expect(url).to eq 'http://test.host/avatars/original/missing.png'
+      end
+    end
+
+    context 'Do not use S3' do
+      before do
+        Rails.configuration.x.use_s3 = false
+      end
+
+      it_behaves_like 'returns full path URL'
+    end
+
+    context 'Use S3' do
+      before do
+        Rails.configuration.x.use_s3 = true
+      end
+
+      it_behaves_like 'returns full path URL'
+    end
+  end
+end
diff --git a/spec/helpers/settings_helper_spec.rb b/spec/helpers/settings_helper_spec.rb
index 5a51e0ef1..092c37583 100644
--- a/spec/helpers/settings_helper_spec.rb
+++ b/spec/helpers/settings_helper_spec.rb
@@ -4,10 +4,10 @@ require 'rails_helper'
 
 describe SettingsHelper do
   describe 'the HUMAN_LOCALES constant' do
-    it 'has the same number of keys as I18n locales exist' do
+    it 'includes all I18n locales' do
       options = I18n.available_locales
 
-      expect(described_class::HUMAN_LOCALES.keys).to eq(options)
+      expect(described_class::HUMAN_LOCALES.keys).to include(*options)
     end
   end