diff --git a/app/jobs/update_dqt_trn_request_job.rb b/app/jobs/update_dqt_trn_request_job.rb index 4806991bf2..71e9eb30cb 100644 --- a/app/jobs/update_dqt_trn_request_job.rb +++ b/app/jobs/update_dqt_trn_request_job.rb @@ -20,7 +20,13 @@ def perform(dqt_trn_request) ApplicationFormStatusUpdater.call(application_form:, user: "DQT") unless potential_duplicate - AwardQTS.call(application_form:, user: "DQT", trn: response[:trn]) + AwardQTS.call( + application_form:, + user: "DQT", + trn: response[:trn], + access_your_teaching_qualifications_url: + response[:access_your_teaching_qualifications_link], + ) dqt_trn_request.complete! end diff --git a/app/services/award_qts.rb b/app/services/award_qts.rb index 1e83747dd3..57cb59b18e 100644 --- a/app/services/award_qts.rb +++ b/app/services/award_qts.rb @@ -3,10 +3,17 @@ class AwardQTS include ServicePattern - def initialize(application_form:, user:, trn:) + def initialize( + application_form:, + user:, + trn:, + access_your_teaching_qualifications_url: + ) @application_form = application_form @user = user @trn = trn + @access_your_teaching_qualifications_url = + access_your_teaching_qualifications_url end def call @@ -20,7 +27,7 @@ def call raise MissingTRN if trn.blank? ActiveRecord::Base.transaction do - teacher.update!(trn:) + teacher.update!(trn:, access_your_teaching_qualifications_url:) application_form.update!(awarded_at: Time.zone.now) ApplicationFormStatusUpdater.call(application_form:, user:) end @@ -36,7 +43,10 @@ class MissingTRN < StandardError private - attr_reader :application_form, :user, :trn + attr_reader :application_form, + :user, + :trn, + :access_your_teaching_qualifications_url delegate :teacher, to: :application_form end diff --git a/spec/jobs/update_dqt_trn_request_job_spec.rb b/spec/jobs/update_dqt_trn_request_job_spec.rb index fe0eb2578e..9041c7be05 100644 --- a/spec/jobs/update_dqt_trn_request_job_spec.rb +++ b/spec/jobs/update_dqt_trn_request_job_spec.rb @@ -20,7 +20,11 @@ context "with a successful response" do before do expect(DQT::Client::CreateTRNRequest).to receive(:call).and_return( - { potential_duplicate: false, trn: "abcdef" }, + { + potential_duplicate: false, + trn: "abcdef", + access_your_teaching_qualifications_link: "https://aytq.com", + }, ) end @@ -40,6 +44,7 @@ application_form:, user: "DQT", trn: "abcdef", + access_your_teaching_qualifications_url: "https://aytq.com", ) perform end @@ -128,7 +133,11 @@ context "with a successful response" do before do expect(DQT::Client::ReadTRNRequest).to receive(:call).and_return( - { potential_duplicate: false, trn: "abcdef" }, + { + potential_duplicate: false, + trn: "abcdef", + access_your_teaching_qualifications_link: "https://aytq.com", + }, ) end @@ -148,6 +157,7 @@ application_form:, user: "DQT", trn: "abcdef", + access_your_teaching_qualifications_url: "https://aytq.com", ) perform end diff --git a/spec/services/award_qts_spec.rb b/spec/services/award_qts_spec.rb index 8680cd4733..d57a685c0d 100644 --- a/spec/services/award_qts_spec.rb +++ b/spec/services/award_qts_spec.rb @@ -6,8 +6,16 @@ let(:teacher) { create(:teacher) } let(:user) { create(:staff, :confirmed) } let(:trn) { "abcdef" } - - subject(:call) { described_class.call(application_form:, user:, trn:) } + let(:access_your_teaching_qualifications_url) { "https://aytq.com" } + + subject(:call) do + described_class.call( + application_form:, + user:, + trn:, + access_your_teaching_qualifications_url:, + ) + end context "with a submitted application form" do let(:application_form) { create(:application_form, :submitted, teacher:) } @@ -26,6 +34,13 @@ expect { call }.to change(teacher, :trn).to("abcdef") end + it "sets the access your teaching qualifications URL" do + expect { call }.to change( + teacher, + :access_your_teaching_qualifications_url, + ).to("https://aytq.com") + end + it "sends an email" do expect { call }.to have_enqueued_mail( TeacherMailer, @@ -63,6 +78,13 @@ expect { call }.to change(teacher, :trn).to("abcdef") end + it "sets the access your teaching qualifications URL" do + expect { call }.to change( + teacher, + :access_your_teaching_qualifications_url, + ).to("https://aytq.com") + end + it "sends an email" do expect { call }.to have_enqueued_mail( TeacherMailer, @@ -94,10 +116,17 @@ context "with an awarded application form" do let(:application_form) { create(:application_form, :awarded, teacher:) } - it "doesn't set the TRN" do + it "doesn't change the TRN" do expect { call }.to_not change(teacher, :trn) end + it "doesn't change the access your teaching qualifications URL" do + expect { call }.to_not change( + teacher, + :access_your_teaching_qualifications_url, + ) + end + it "doesn't send an email" do expect { call }.to_not have_enqueued_mail( TeacherMailer,