File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,16 +177,23 @@ def parents_contactable? = parents.any?(&:contactable?)
177177
178178 def status_should_be_request_scheduled?
179179 parents_contactable? && consent_notifications . empty? &&
180- sessions . any? do
181- # Not using send_consent_requests_at.future?
182- # because it doesn't work with Timecop.
183- it . send_consent_requests_at &&
184- it . send_consent_requests_at > Time . current
185- end
180+ sessions . any? { consent_request_scheduled_in_future? ( it ) }
186181 end
187182
188183 def status_should_be_request_not_scheduled?
189184 parents_contactable? && consent_notifications . empty? &&
190- ( sessions . empty? || sessions . any? { it . send_consent_requests_at . nil? } )
185+ ( sessions . empty? || sessions . any? { consent_request_not_scheduled? ( it ) } )
186+ end
187+
188+ def consent_request_scheduled_in_future? ( session )
189+ send_at = session . send_consent_requests_at
190+
191+ # Not using future? because it doesn't work with Timecop
192+ send_at . present? && send_at > Time . current
193+ end
194+
195+ def consent_request_not_scheduled? ( session )
196+ send_at = session . send_consent_requests_at
197+ send_at . nil? || send_at < Time . current
191198 end
192199end
Original file line number Diff line number Diff line change 1515 it { should_not have_content ( /Consent (given|refused)/ ) }
1616 it { should_not have_css ( "details" , text : /Consent (given|refused) by/ ) }
1717 it { should_not have_css ( "details" , text : "Responses to health questions" ) }
18- it { should have_css ( "p" , text : "No requests have been sent. " ) }
18+ it { should have_css ( "p" , text : "No consent request is scheduled " ) }
1919 it { should have_css ( "button" , text : "Record a new consent response" ) }
2020
2121 context "when session is not in progress" do
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ def when_i_click_back
159159 end
160160
161161 def and_i_am_not_able_to_record_a_vaccination
162- expect ( page ) . to have_content ( "No response " )
162+ expect ( page ) . to have_content ( "Request not scheduled " )
163163 expect ( page ) . not_to have_content ( "ready for their HPV vaccination?" )
164164 end
165165
Original file line number Diff line number Diff line change @@ -110,7 +110,10 @@ def and_the_table_shows_other_eligible_vaccinations
110110 "td.nhsuk-table__cell" ,
111111 text : "Needs consent"
112112 )
113- expect ( row ) . to have_selector ( "td.nhsuk-table__cell" , text : "No response" )
113+ expect ( row ) . to have_selector (
114+ "td.nhsuk-table__cell" ,
115+ text : "Request not scheduled"
116+ )
114117 end
115118
116119 expect ( page ) . to have_selector (
@@ -121,7 +124,10 @@ def and_the_table_shows_other_eligible_vaccinations
121124 "td.nhsuk-table__cell" ,
122125 text : "Needs consent"
123126 )
124- expect ( row ) . to have_selector ( "td.nhsuk-table__cell" , text : "No response" )
127+ expect ( row ) . to have_selector (
128+ "td.nhsuk-table__cell" ,
129+ text : "Request not scheduled"
130+ )
125131 end
126132 end
127133
Original file line number Diff line number Diff line change 125125 prefix : "MMR" ,
126126 text : "Needs consent" ,
127127 colour : "blue" ,
128- details_text : "No response "
128+ details_text : "Request not scheduled "
129129 }
130130 )
131131 end
Original file line number Diff line number Diff line change 4848 context "with consent requests not scheduled" do
4949 it { should be ( :request_not_scheduled ) }
5050 end
51+
52+ context "when consent requests scheduled date has already passed" do
53+ let ( :send_consent_requests_at ) { 1 . day . ago . to_date }
54+
55+ it { should be ( :request_not_scheduled ) }
56+ end
5157 end
5258
5359 context "with no contactable parents" do
You can’t perform that action at this time.
0 commit comments