Skip to content

Commit 3225093

Browse files
authored
Merge pull request #4543 from nhsuk/programme-tag-order
Ensure programme tags are ordered
2 parents 4b3ff2a + ddae42a commit 3225093

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

app/components/app_programme_tags_component.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ def initialize(programmes)
55
@programmes = programmes
66
end
77

8-
def call
9-
safe_join(
10-
programmes.map do
11-
tag.strong(it.name, class: "nhsuk-tag nhsuk-tag--white")
12-
end,
13-
" "
14-
)
15-
end
8+
def call = safe_join(tags, " ")
169

1710
private
1811

1912
attr_reader :programmes
13+
14+
def names = programmes.map(&:name).sort
15+
16+
def tags = names.map { tag.strong(it, class: "nhsuk-tag nhsuk-tag--white") }
2017
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
describe AppProgrammeTagsComponent do
4+
subject { render_inline(component) }
5+
6+
let(:component) { described_class.new(programmes) }
7+
8+
let(:programmes) do
9+
[create(:programme, :menacwy), create(:programme, :td_ipv)]
10+
end
11+
12+
it { should have_content("MenACWY Td/IPV") }
13+
14+
context "with unordered programmes" do
15+
let(:programmes) do
16+
[create(:programme, :td_ipv), create(:programme, :menacwy)]
17+
end
18+
19+
it { should have_content("MenACWY Td/IPV") }
20+
end
21+
end

0 commit comments

Comments
 (0)