Skip to content

Commit 9091882

Browse files
committed
WIP
1 parent ddc7db5 commit 9091882

File tree

3 files changed

+72
-3
lines changed

3 files changed

+72
-3
lines changed

app/controllers/teacher_interface/other_england_work_histories_controller.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ def index
5050
redirect_to school_teacher_interface_application_form_other_england_work_history_path(
5151
work_history,
5252
)
53+
elsif (
54+
work_history =
55+
application_form
56+
.work_histories
57+
.other_england_educational_role
58+
.order_by_user
59+
.find(&:invalid_email_domain_for_contact?)
60+
)
61+
redirect_to contact_teacher_interface_application_form_other_england_work_history_path(
62+
work_history,
63+
)
5364
else
5465
redirect_to %i[
5566
add_another

app/lib/application_form_section_status_updater.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def work_history_status
191191
if any_work_histories_with_invalid_contact_email_domain
192192
:update_needed
193193
else
194-
:completed
194+
:completed
195195
end
196196
else
197197
:in_progress
@@ -224,9 +224,21 @@ def other_england_work_history_status
224224
!other_england_work_histories.empty? &&
225225
other_england_work_histories.all?(&:complete?)
226226

227+
any_work_histories_with_invalid_contact_email_domain =
228+
requires_private_email_for_referee? &&
229+
other_england_work_histories.any?(&:invalid_email_domain_for_contact?)
230+
227231
return :not_started if has_other_england_work_history.nil?
228232
if !has_other_england_work_history || all_work_histories_complete
229-
return :completed
233+
return(
234+
(
235+
if any_work_histories_with_invalid_contact_email_domain
236+
:update_needed
237+
else
238+
:completed
239+
end
240+
)
241+
)
230242
end
231243

232244
:in_progress

spec/lib/application_form_section_status_updater_spec.rb

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,33 @@
522522
:application_form,
523523
has_other_england_work_history: true,
524524
).tap do |application_form|
525-
create(:work_history, :other_england_role, application_form:)
525+
create(
526+
:work_history,
527+
:other_england_role,
528+
application_form:,
529+
contact_email:,
530+
)
526531
end
527532
end
533+
let(:contact_email) { "test@gmail.com" }
528534

529535
it { is_expected.to eq("in_progress") }
536+
537+
# TODO: Once all existing draft applications have gone through post release,
538+
# we no longer need to do this check on any of the above. This would mean that
539+
# all existing draft application have started_with_private_email_for_referee is true
540+
context "when private email domain for referee feature is enabled" do
541+
before do
542+
FeatureFlags::FeatureFlag.activate(:email_domains_for_referees)
543+
described_class.call(application_form:)
544+
end
545+
546+
after do
547+
FeatureFlags::FeatureFlag.deactivate(:email_domains_for_referees)
548+
end
549+
550+
it { is_expected.to eq("in_progress") }
551+
end
530552
end
531553

532554
context "with a complete work history" do
@@ -540,11 +562,35 @@
540562
:other_england_role,
541563
:completed,
542564
application_form:,
565+
contact_email:,
543566
)
544567
end
545568
end
569+
let(:contact_email) { "test@gmail.com" }
546570

547571
it { is_expected.to eq("completed") }
572+
573+
# TODO: Once all existing draft applications have gone through post release,
574+
# we no longer need to do this check on any of the above. This would mean that
575+
# all existing draft application have started_with_private_email_for_referee is true
576+
context "when private email domain for referee feature is enabled" do
577+
before do
578+
FeatureFlags::FeatureFlag.activate(:email_domains_for_referees)
579+
described_class.call(application_form:)
580+
end
581+
582+
after do
583+
FeatureFlags::FeatureFlag.deactivate(:email_domains_for_referees)
584+
end
585+
586+
it { is_expected.to eq("update_needed") }
587+
588+
context "with contact email having a private email domain" do
589+
let(:contact_email) { "test@private.com" }
590+
591+
it { is_expected.to eq("completed") }
592+
end
593+
end
548594
end
549595
end
550596

0 commit comments

Comments
 (0)