Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions app/components/app_programme_tags_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ def initialize(programmes)
@programmes = programmes
end

def call
safe_join(
programmes.map do
tag.strong(it.name, class: "nhsuk-tag nhsuk-tag--white")
end,
" "
)
end
def call = safe_join(tags, " ")

private

attr_reader :programmes

def names = programmes.map(&:name).sort

def tags = names.map { tag.strong(it, class: "nhsuk-tag nhsuk-tag--white") }
end
21 changes: 21 additions & 0 deletions spec/components/app_programme_tags_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

describe AppProgrammeTagsComponent do
subject { render_inline(component) }

let(:component) { described_class.new(programmes) }

let(:programmes) do
[create(:programme, :menacwy), create(:programme, :td_ipv)]
end

it { should have_content("MenACWY Td/IPV") }

context "with unordered programmes" do
let(:programmes) do
[create(:programme, :td_ipv), create(:programme, :menacwy)]
end

it { should have_content("MenACWY Td/IPV") }
end
end