Skip to content

Commit

Permalink
add school info to applications CSV report (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega authored Jan 6, 2025
1 parent 665d9e3 commit 9300484
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/models/reports/applications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions spec/models/reports/applications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

0 comments on commit 9300484

Please sign in to comment.