From 890866dd5b3062d1b6b7b38c40baa864a271a25a Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Mon, 9 Sep 2024 16:40:42 +0100 Subject: [PATCH] Record who sent the email to the provider The figma designs require us to display the admin who resent the provider verification email. To capture this information we use the existing note mechanism on claims. This is a bit fragile as we assume the only "provider_verification" note is for emails being sent. It seems like the label on notes maps to a task name, so we went with that for the label. If in future we can take other provider verification notes we may want to consider renaming this email specific label. --- .../provider_verification_emails_controller.rb | 6 ++++++ .../admin_provider_verification_task_presenter.rb | 4 ++++ .../admin_tasks_presenter.rb | 2 +- app/views/admin/tasks/provider_verification.html.erb | 9 ++++++++- .../admin_claim_further_education_payments_spec.rb | 11 +++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/further_education_payments/provider_verification_emails_controller.rb b/app/controllers/admin/further_education_payments/provider_verification_emails_controller.rb index d847cdf80f..d82194ff20 100644 --- a/app/controllers/admin/further_education_payments/provider_verification_emails_controller.rb +++ b/app/controllers/admin/further_education_payments/provider_verification_emails_controller.rb @@ -6,6 +6,12 @@ class ProviderVerificationEmailsController < Admin::BaseAdminController def create claim = Claim.find(params[:claim_id]) + claim.notes.create!( + created_by: admin_user, + label: "provider_verification", + body: "Verification email sent to #{claim.school.name}" + ) + ClaimMailer.further_education_payment_provider_verification_email(claim).deliver_later flash[:notice] = "Verification email sent to #{claim.school.name}" diff --git a/app/models/policies/further_education_payments/admin_provider_verification_task_presenter.rb b/app/models/policies/further_education_payments/admin_provider_verification_task_presenter.rb index b30052f3ed..6483a94a52 100644 --- a/app/models/policies/further_education_payments/admin_provider_verification_task_presenter.rb +++ b/app/models/policies/further_education_payments/admin_provider_verification_task_presenter.rb @@ -25,6 +25,10 @@ def rows end end + def latest_email + claim.notes.by_label("provider_verification").order(created_at: :desc).first + end + private def verification diff --git a/app/models/policies/further_education_payments/admin_tasks_presenter.rb b/app/models/policies/further_education_payments/admin_tasks_presenter.rb index da9c1dfb17..a8c78e631b 100644 --- a/app/models/policies/further_education_payments/admin_tasks_presenter.rb +++ b/app/models/policies/further_education_payments/admin_tasks_presenter.rb @@ -10,7 +10,7 @@ def initialize(claim) end def provider_verification - AdminProviderVerificationTaskPresenter.new(claim).rows + AdminProviderVerificationTaskPresenter.new(claim) end def provider_name diff --git a/app/views/admin/tasks/provider_verification.html.erb b/app/views/admin/tasks/provider_verification.html.erb index 4f3eff60ae..d4f738979e 100644 --- a/app/views/admin/tasks/provider_verification.html.erb +++ b/app/views/admin/tasks/provider_verification.html.erb @@ -33,7 +33,7 @@ - <% @tasks_presenter.provider_verification.each do |row| %> + <% @tasks_presenter.provider_verification.rows.each do |row| %> <%= row.label %> @@ -59,6 +59,13 @@ duplicate claim. If it isn't a duplicate claim, send the verification request to the provider.

+ <% if @tasks_presenter.provider_verification.latest_email.present? %> + <% verification_email = @tasks_presenter.provider_verification.latest_email %> +

+ The verification request was sent to the provider by + <%= user_details(verification_email.created_by) %> on <%= l(verification_email.created_at) %> +

+ <% end %> <%= govuk_button_to( "Send provider verification request", admin_claim_further_education_payments_provider_verification_emails_path(@claim), diff --git a/spec/features/admin/admin_claim_further_education_payments_spec.rb b/spec/features/admin/admin_claim_further_education_payments_spec.rb index 4ad7846782..3796367334 100644 --- a/spec/features/admin/admin_claim_further_education_payments_spec.rb +++ b/spec/features/admin/admin_claim_further_education_payments_spec.rb @@ -1,6 +1,12 @@ require "rails_helper" RSpec.feature "Admin claim further education payments" do + around do |example| + travel_to DateTime.new(AcademicYear.current.start_year, 9, 9, 10, 0, 0) do + example.run + end + end + before do create(:journey_configuration, :further_education_payments_provider) sign_in_as_service_operator @@ -49,6 +55,11 @@ click_on "Send provider verification request" end + expect(page).to have_content( + "The verification request was sent to the provider by " \ + "Aaron Admin on 9 September 2024 11:00am" + ) + provider_email_address = claim.school.eligible_fe_provider.primary_key_contact_email_address expect(provider_email_address).to(