Skip to content

Commit fc57051

Browse files
committed
Ensure programmes are shown in alphabetical order
When looking at the table of programmes this ensures that the programmes are listed in an alphabetical order like other parts of the service.
1 parent ac45578 commit fc57051

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

app/controllers/programmes_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class ProgrammesController < ApplicationController
1212
layout "full"
1313

1414
def index
15-
@programmes = policy_scope(Programme).includes(:active_vaccines)
15+
@programmes =
16+
policy_scope(Programme).order(:type).includes(:active_vaccines)
1617
end
1718

1819
def show
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# frozen_string_literal: true
2+
3+
describe "Programmes index" do
4+
around { |example| travel_to(Date.new(2024, 5, 20)) { example.run } }
5+
6+
scenario "Viewing all programmes" do
7+
given_an_organisation_exists_that_administered_all_programmes
8+
9+
when_i_visit_the_programmes_page
10+
then_i_see_the_programmes_in_alphabetical_order
11+
end
12+
13+
def given_an_organisation_exists_that_administered_all_programmes
14+
programmes = [
15+
create(:programme, :hpv),
16+
create(:programme, :menacwy),
17+
create(:programme, :td_ipv)
18+
]
19+
20+
@organisation = create(:organisation, programmes:)
21+
end
22+
23+
def when_i_visit_the_programmes_page
24+
user = create(:nurse, organisations: [@organisation])
25+
26+
sign_in user
27+
visit dashboard_path
28+
click_on "Programmes", match: :first
29+
end
30+
31+
def then_i_see_the_programmes_in_alphabetical_order
32+
cohort_cards = page.all(".nhsuk-table__cell a")
33+
expect(cohort_cards[0]).to have_content("HPV")
34+
expect(cohort_cards[1]).to have_content("MenACWY")
35+
expect(cohort_cards[2]).to have_content("Td/IPV")
36+
end
37+
end

0 commit comments

Comments
 (0)