Skip to content

Commit f9cf0d8

Browse files
committed
WIP
1 parent 4167bcd commit f9cf0d8

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

app/controllers/teacher_interface/application_forms_controller.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class ApplicationFormsController < BaseController
1111
before_action :load_application_form, except: %i[new create]
1212
before_action :update_application_and_redirect_if_passport_expired,
1313
only: %i[edit update]
14+
before_action :update_application_and_redirect_if_any_referee_has_public_email_domain,
15+
only: %i[edit update]
1416

1517
define_history_origin :show
1618
define_history_reset :show
@@ -120,5 +122,20 @@ def update_application_and_redirect_if_passport_expired
120122
redirect_to teacher_interface_application_form_path
121123
end
122124
end
125+
126+
def update_application_and_redirect_if_any_referee_has_public_email_domain
127+
if requires_private_email_for_referee? &&
128+
application_form.work_histories.any?(
129+
&:invalid_email_domain_for_contact?
130+
)
131+
ApplicationFormSectionStatusUpdater.call(application_form:)
132+
133+
redirect_to teacher_interface_application_form_path
134+
end
135+
end
136+
137+
def requires_private_email_for_referee?
138+
FeatureFlags::FeatureFlag.active?(:email_domains_for_referees)
139+
end
123140
end
124141
end

app/view_objects/teacher_interface/application_form_view_object.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ def show_work_history_under_induction_banner?
234234
:requires_preliminary_check,
235235
:includes_prioritisation_features,
236236
:work_history_status_completed?,
237+
:other_england_work_history_status_completed?,
238+
:started_with_private_email_for_referee?,
237239
to: :application_form
238240

239241
delegate :consent_requests,

app/views/teacher_interface/application_forms/show/_draft.html.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
</div>
3131
<% end %>
3232

33+
<% if FeatureFlags::FeatureFlag.active?(:email_domains_for_referees) && !view_object.started_with_private_email_for_referee? && (!view_object.work_history_status_completed? || !view_object.other_england_work_history_status_completed?) %>
34+
<%= govuk_notification_banner(title_text: "Important") do |notification_banner| %>
35+
<% notification_banner.with_heading(text: "Requirements for your references have changed") %>
36+
37+
<p class="govuk-body">Testing</p>
38+
<% end %>
39+
<% end %>
40+
3341
<% if view_object.show_work_history_under_submission_banner? || view_object.show_work_history_under_induction_banner? %>
3442
<%= govuk_notification_banner(title_text: "Important") do %>
3543
<p>You have added at least one teaching role that started before you were qualified as a teacher.</p>

spec/system/teacher_interface/submitting_spec.rb

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
end
111111
end
112112

113-
context "when the application required passport as a form of identity proof" do
113+
context "when the application requires passport as a form of identity proof" do
114114
let(:application_form) do
115115
create(
116116
:application_form,
@@ -172,6 +172,29 @@
172172
end
173173
end
174174

175+
context "when the application requires private email domain for all referees" do
176+
before do
177+
FeatureFlags::FeatureFlag.activate(:email_domains_for_referees)
178+
application_form.work_histories.last.update!(
179+
contact_email: "test@gmail.com",
180+
contact_email_domain: "gmail.com",
181+
)
182+
end
183+
184+
after { FeatureFlags::FeatureFlag.deactivate(:email_domains_for_referees) }
185+
186+
it "redirects back to application task list with work history spoke to update needed" do
187+
when_i_visit_the(:teacher_application_page)
188+
then_i_see_the(:teacher_application_page)
189+
and_i_see_the_completed_work_history_task
190+
191+
when_i_click_check_your_answers
192+
then_i_see_the(:teacher_application_page)
193+
and_i_see_the_update_needed_work_history_task
194+
and_i_see_content_that_referee_requirements_have_changed
195+
end
196+
end
197+
175198
context "when application has other England work history" do
176199
let(:application_form) do
177200
create(
@@ -321,6 +344,18 @@ def and_i_see_the_completed_passport_document_task
321344
).to eq("Completed")
322345
end
323346

347+
def and_i_see_the_completed_work_history_task
348+
expect(
349+
teacher_application_page.work_history_task_item.status_tag.text,
350+
).to eq("Completed")
351+
end
352+
353+
def and_i_see_the_update_needed_work_history_task
354+
expect(
355+
teacher_application_page.work_history_task_item.status_tag.text,
356+
).to eq("Update needed")
357+
end
358+
324359
def and_i_see_the_in_progress_passport_document_task
325360
expect(
326361
teacher_application_page.passport_document_task_item.status_tag.text,
@@ -333,6 +368,12 @@ def and_i_see_content_that_my_passport_has_expired
333368
)
334369
end
335370

371+
def and_i_see_content_that_referee_requirements_have_changed
372+
expect(teacher_application_page).to have_content(
373+
"Requirements for your references have changed",
374+
)
375+
end
376+
336377
def teacher
337378
@teacher ||= create(:teacher, email: "teacher@example.com")
338379
end

0 commit comments

Comments
 (0)