File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments