Skip to content

Commit

Permalink
Record who sent the email to the provider
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rjlynch committed Sep 16, 2024
1 parent c2367ea commit 7915866
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(claim)
end

def provider_verification
AdminProviderVerificationTaskPresenter.new(claim).rows
AdminProviderVerificationTaskPresenter.new(claim)
end

def provider_name
Expand Down
20 changes: 14 additions & 6 deletions app/views/admin/tasks/provider_verification.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</tr>
</thead>
<tbody class="govuk-table__body">
<% @tasks_presenter.provider_verification.each do |row| %>
<% @tasks_presenter.provider_verification.rows.each do |row| %>
<tr class="govuk-table__row govuk-!-width-one-quarter">
<th scope="row" class="govuk-table__header">
<%= row.label %>
Expand All @@ -54,11 +54,19 @@
</p>

<div class="govuk-inset-text">
<p>
You need to check the matching details and confirm if this is a
duplicate claim. If it isn't a duplicate claim, send the verification
request to the provider.
</p>
<% if @tasks_presenter.provider_verification.latest_email.present? %>
<% verification_email = @tasks_presenter.provider_verification.latest_email %>
<p>
The verification request was sent to the provider by
<%= user_details(verification_email.created_by) %> on <%= l(verification_email.created_at) %>
</p>
<% else %>
<p>
You need to check the matching details and confirm if this is a
duplicate claim. If it isn't a duplicate claim, send the verification
request to the provider.
</p>
<% end %>
<%= govuk_button_to(
"Send provider verification request",
admin_claim_further_education_payments_provider_verification_emails_path(@claim),
Expand Down
11 changes: 11 additions & 0 deletions spec/features/admin/admin_claim_further_education_payments_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7915866

Please sign in to comment.