about summary refs log tree commit diff
path: root/spec/helpers
diff options
context:
space:
mode:
authorMatt Jankowski <matt@jankowski.online>2023-03-10 07:33:30 -0500
committerGitHub <noreply@github.com>2023-03-10 13:33:30 +0100
commit688287c59d526ef76089322a368789f5846c6ac3 (patch)
tree0a89ad3e71b45b123388898cc67f93ed5a022b91 /spec/helpers
parent56bddfbfa39956ea3a8c52721eb364b1120634f6 (diff)
Coverage improvement round-out following up previous work (#23987)
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/statuses_helper_spec.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/spec/helpers/statuses_helper_spec.rb b/spec/helpers/statuses_helper_spec.rb
index c8ca2ed32..105da7e1b 100644
--- a/spec/helpers/statuses_helper_spec.rb
+++ b/spec/helpers/statuses_helper_spec.rb
@@ -2,7 +2,33 @@
 
 require 'rails_helper'
 
-RSpec.describe StatusesHelper, type: :helper do
+describe StatusesHelper do
+  describe 'status_text_summary' do
+    context 'with blank text' do
+      let(:status) { Status.new(spoiler_text: '') }
+
+      it 'returns immediately with nil' do
+        result = helper.status_text_summary(status)
+        expect(result).to be_nil
+      end
+    end
+
+    context 'with present text' do
+      let(:status) { Status.new(spoiler_text: 'SPOILERS!!!') }
+
+      it 'returns the content warning' do
+        result = helper.status_text_summary(status)
+        expect(result).to eq(I18n.t('statuses.content_warning', warning: 'SPOILERS!!!'))
+      end
+    end
+  end
+
+  def status_text_summary(status)
+    return if status.spoiler_text.blank?
+
+    I18n.t('statuses.content_warning', warning: status.spoiler_text)
+  end
+
   describe 'link_to_newer' do
     it 'returns a link to newer content' do
       url = 'https://example.com'