From 9300484e5a1f475ee9cdf32a59febec27c5c86a3 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Mon, 6 Jan 2025 15:15:42 +0000 Subject: [PATCH] add school info to applications CSV report (#448) --- app/models/reports/applications.rb | 12 ++++++++++++ spec/models/reports/applications_spec.rb | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/models/reports/applications.rb b/app/models/reports/applications.rb index f3a32b9f..b435aa97 100644 --- a/app/models/reports/applications.rb +++ b/app/models/reports/applications.rb @@ -35,6 +35,12 @@ def header visa_type rejection_reason ip_address + school_name + school_headteacher + school_address_line_1 + school_address_line_2 + school_city + school_postcode ].map { _1.to_s.titleize } end @@ -65,6 +71,12 @@ def columns(application) application.visa_type, application.application_progress.rejection_reason, applicant.ip_address, + applicant.school.name, + applicant.school.headteacher_name, + applicant.school.address.address_line_1, + applicant.school.address.address_line_2, + applicant.school.address.city, + applicant.school.address.postcode, ] end diff --git a/spec/models/reports/applications_spec.rb b/spec/models/reports/applications_spec.rb index 7821416c..d446642b 100644 --- a/spec/models/reports/applications_spec.rb +++ b/spec/models/reports/applications_spec.rb @@ -64,6 +64,12 @@ module Reports "Visa Type", "Rejection Reason", "Ip Address", + "School Name", + "School Headteacher", + "School Address Line 1", + "School Address Line 2", + "School City", + "School Postcode", ].join(",") end @@ -79,6 +85,17 @@ module Reports it { expect(report.generate).to include(paid.urn) } it { expect(report.generate).to include(rejected.urn) } end + + it "generates correct data" do + csv = CSV.parse(report.generate, headers: true) + + expect(csv[6]["School Name"]).to eql(application.applicant.school.name) + expect(csv[6]["School Headteacher"]).to eql(application.applicant.school.headteacher_name) + expect(csv[6]["School Address Line 1"]).to eql(application.applicant.school.address.address_line_1) + expect(csv[6]["School Address Line 2"]).to eql(application.applicant.school.address.address_line_2) + expect(csv[6]["School City"]).to eql(application.applicant.school.address.city) + expect(csv[6]["School Postcode"]).to eql(application.applicant.school.address.postcode) + end end end end