-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include the chair of governors in exports
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
Showing
5 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
app/presenters/export/csv/chair_of_governors_presenter_module.rb
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,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 |
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
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
53 changes: 53 additions & 0 deletions
53
spec/presenters/export/csv/chair_of_governors_presenter_module_spec.rb
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,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 |