-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the controller and views for downloading the ops reports.
- Loading branch information
Showing
5 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Admin | ||
class ReportsController < BaseAdminController | ||
before_action :ensure_service_operator | ||
|
||
def index | ||
end | ||
|
||
def show | ||
respond_to do |format| | ||
format.csv do | ||
send_data(report.to_csv, filename: report.filename) | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def report | ||
@report ||= case params[:name] | ||
when "fe-approved-claims-with-failing-provider-verification" | ||
Reports::FeApprovedClaimsWithFailingProviderVerification.new | ||
else | ||
raise ActiveRecord::RecordNotFound | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<% content_for :back_link do %> | ||
<%= govuk_back_link href: admin_claims_path %> | ||
<% end %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-full"> | ||
<h1 class="govuk-heading-xl"> | ||
Reports | ||
</h1> | ||
|
||
<%= govuk_button_link_to( | ||
"FE TRI approved claims whereby the provider check status is 'failed'", | ||
admin_report_path("fe-approved-claims-with-failing-provider-verification", format: :csv), | ||
secondary: true | ||
) %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "Admin reports" do | ||
around do |example| | ||
travel_to Date.new(2024, 12, 6) do | ||
example.run | ||
end | ||
end | ||
|
||
describe "Approved FE claims with failing provider verification" do | ||
it "returns a CSV report" do | ||
claim = create( | ||
:claim, | ||
:approved, | ||
policy: Policies::FurtherEducationPayments, | ||
first_name: "Elizabeth", | ||
surname: "Hoover", | ||
qa_required: true, | ||
eligibility_attributes: { | ||
award_amount: 2_000, | ||
contract_type: "permanent", | ||
verification: { | ||
assertions: [ | ||
{ | ||
name: "contract_type", | ||
outcome: true | ||
}, | ||
{ | ||
name: "teaching_responsibilities", | ||
outcome: true | ||
}, | ||
{ | ||
name: "further_education_teaching_start_year", | ||
outcome: true | ||
}, | ||
{ | ||
name: "teaching_hours_per_week", | ||
outcome: true | ||
}, | ||
{ | ||
name: "half_teaching_hours", | ||
outcome: false | ||
}, | ||
{ | ||
name: "subjects_taught", | ||
outcome: false | ||
}, | ||
{ | ||
name: "subject_to_formal_performance_action", | ||
outcome: true | ||
}, | ||
{ | ||
name: "subject_to_disciplinary_action", | ||
outcome: true | ||
} | ||
] | ||
} | ||
} | ||
) | ||
|
||
create( | ||
:task, | ||
:failed, | ||
name: "provider_verification", | ||
claim: claim | ||
) | ||
|
||
sign_in_as_service_operator | ||
|
||
visit admin_claims_path | ||
|
||
click_on "Reports" | ||
|
||
click_on( | ||
"FE TRI approved claims whereby the provider check status is 'failed'" | ||
) | ||
|
||
csv_data = page.body | ||
|
||
csv = CSV.parse(csv_data, headers: true) | ||
row = csv.first | ||
|
||
expect(row.fetch("Claim reference")).to eq(claim.reference) | ||
expect(row.fetch("Full name")).to eq("Elizabeth Hoover") | ||
expect(row.fetch("Claim amount")).to eq("£2,000") | ||
expect(row.fetch("Claim status")).to eq("Approved awaiting QA") | ||
expect(row.fetch("Decision date")).to eq("06/12/2024") | ||
expect(row.fetch("Decision agent")).to eq("Aaron Admin") | ||
expect(row.fetch("Contract of employment")).to eq("Yes") | ||
expect(row.fetch("Teaching responsibilities")).to eq("Yes") | ||
expect(row.fetch("First 5 years of teaching")).to eq("Yes") | ||
expect(row.fetch("One full term")).to eq("N/A") | ||
expect(row.fetch("Timetabled teaching hours")).to eq("Yes") | ||
expect(row.fetch("Age range taught")).to eq("No") | ||
expect(row.fetch("Subject")).to eq("No") | ||
expect(row.fetch("Course")).to eq("??") | ||
expect(row.fetch("2.5 hours weekly teaching")).to eq("N/A") | ||
expect(row.fetch("Performance")).to eq("Yes") | ||
expect(row.fetch("Disciplinary")).to eq("Yes") | ||
end | ||
end | ||
end |