Skip to content

Commit

Permalink
Include the chair of governors in exports
Browse files Browse the repository at this point in the history
We recently added the ability to identify the chair of governors for a
school converting into an academy, which can now be included in the
export used for preparing and sending the funding agreement letters.
  • Loading branch information
mec committed Mar 28, 2024
1 parent 360b5d3 commit 4d91779
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 3 deletions.
13 changes: 13 additions & 0 deletions app/presenters/export/csv/chair_of_governors_presenter_module.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Export::Csv::ChairOfGovernorsPresenterModule
def chair_of_governors_name
return if @project.chair_of_governors_contact.nil?

@project.chair_of_governors_contact.name
end

def chair_of_governors_email
return if @project.chair_of_governors_contact.nil?

@project.chair_of_governors_contact.email
end
end
1 change: 1 addition & 0 deletions app/presenters/export/csv/project_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Export::Csv::ProjectPresenter
include Export::Csv::OutgoingTrustPresenterModule
include Export::Csv::LocalAuthorityPresenterModule
include Export::Csv::MpPresenterModule
include Export::Csv::ChairOfGovernorsPresenterModule

def initialize(project)
@project = project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ class Export::Conversions::SchoolsDueToConvertCsvExportService < Export::CsvExpo
school_main_contact_name
school_main_contact_role
school_main_contact_email
other_contact_name
other_contact_role
other_contact_email
chair_of_governors_name
chair_of_governors_email
academy_urn
academy_ukprn
academy_name
Expand Down
2 changes: 2 additions & 0 deletions config/locales/export/csv/project.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ en:
incoming_trust_address_town: Incoming trust address town
incoming_trust_address_county: Incoming trust address county
incoming_trust_address_postcode: Incoming trust address postcode
chair_of_governors_name: Chair of governors name
chair_of_governors_email: Chair of governors email
local_authority_code: Local authority code
local_authority_name: Local authority
local_authority_contact_name: Local authority contact name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require "rails_helper"

RSpec.describe Export::Csv::ChairOfGovernorsPresenterModule do
before do
mock_successful_api_response_to_create_any_project
end

describe "#chair_of_governors_name" do
context "when there is a contact" do
it "presents the name of the contact" do
contact = build(:project_contact)
project = build(:conversion_project, chair_of_governors_contact: contact)

presenter = Export::Csv::ProjectPresenter.new(project)

expect(presenter.chair_of_governors_name).to eq contact.name
end
end

context "when there is no contact" do
it "presents nothing" do
project = build(:conversion_project)

presenter = Export::Csv::ProjectPresenter.new(project)

expect(presenter.chair_of_governors_name).to be_nil
end
end
end

describe "#chair_of_governors_email" do
context "when there is a contact" do
it "presents the name of the contact" do
contact = build(:project_contact)
project = build(:conversion_project, chair_of_governors_contact: contact)

presenter = Export::Csv::ProjectPresenter.new(project)

expect(presenter.chair_of_governors_email).to eq contact.email
end
end

context "when there is no contact" do
it "presents nothing" do
project = build(:conversion_project)

presenter = Export::Csv::ProjectPresenter.new(project)

expect(presenter.chair_of_governors_name).to be_nil
end
end
end
end

0 comments on commit 4d91779

Please sign in to comment.