Skip to content

Commit

Permalink
Add withdrawable_title helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
KludgeKML committed Feb 13, 2025
1 parent 89e7289 commit bf89a36
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/helpers/title_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module TitleHelper
def withdrawable_title(content_item)
content_item.withdrawn? ? "[Withdrawn] #{content_item.title}" : content_item.title
end
end
17 changes: 17 additions & 0 deletions spec/helpers/title_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
RSpec.describe TitleHelper do
include described_class

describe "#withdrawable_title" do
it "returns a non-withdrawn title unchanged" do
content_item = instance_double(FatalityNotice, title: "My Title", withdrawn?: false)

expect(withdrawable_title(content_item)).to eq("My Title")
end

it "returns a withdrawn title prefixed with the text [Withdrawn]" do
content_item = instance_double(FatalityNotice, title: "My Title", withdrawn?: true)

expect(withdrawable_title(content_item)).to eq("[Withdrawn] My Title")
end
end
end

0 comments on commit bf89a36

Please sign in to comment.