File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,24 +160,23 @@ def online_consent_links
160160
161161 ProgrammeGrouper
162162 . call ( session . programmes )
163- . map do |_group , programmes |
164- names =
165- programmes . map do |programme |
166- # TODO: This enables us to show "MMR" for the "MMR(V)" programme
167- # but will probably need fixing once we collect consent for MMRV.
168- I18n . t ( programme . type , scope : :programme_types )
163+ . flat_map do |_group , programmes |
164+ variants =
165+ if programmes . first . mmr?
166+ programmes . first . variants . map { [ it . name , it . to_param ] }
167+ else
168+ names = programmes . map ( &:name ) . to_sentence
169+ param = programmes . map ( &:to_param ) . join ( "-" )
170+ [ [ names , param ] ]
169171 end
170172
171- label = "View the #{ names . to_sentence } online consent form"
172-
173- helpers . govuk_link_to (
174- label ,
175- start_parent_interface_consent_forms_path (
176- session ,
177- programmes . map ( &:to_param ) . join ( "-" )
178- ) ,
179- new_tab : true
180- )
173+ variants . map do |name , param |
174+ helpers . govuk_link_to (
175+ "View the #{ name } online consent form" ,
176+ start_parent_interface_consent_forms_path ( session , param ) ,
177+ new_tab : true
178+ )
179+ end
181180 end
182181 end
183182
Original file line number Diff line number Diff line change 5858 context "for MMR(V) programme" do
5959 let ( :programmes ) { [ Programme . mmr ] }
6060
61- it { should have_link ( "View the MMR online consent form" ) }
61+ it "shows separate links for MMR and MMRV variants" do
62+ expect ( rendered ) . to have_link (
63+ "View the MMR online consent form (opens in new tab)"
64+ )
65+ expect ( rendered ) . to have_link (
66+ "View the MMRV online consent form (opens in new tab)"
67+ )
68+ end
69+
70+ it "links to the correct MMR variant consent form" do
71+ expect ( rendered ) . to have_link (
72+ "View the MMR online consent form (opens in new tab)" ,
73+ href : %r{/consents/#{ session . slug } /mmr/start$}
74+ )
75+ end
76+
77+ it "links to the correct MMRV variant consent form" do
78+ expect ( rendered ) . to have_link (
79+ "View the MMRV online consent form (opens in new tab)" ,
80+ href : %r{/consents/#{ session . slug } /mmrv/start$}
81+ )
82+ end
6283 end
6384 end
6485 end
You can’t perform that action at this time.
0 commit comments