Skip to content

Commit

Permalink
Merge pull request #1861 from DFE-Digital/chore/enable-persons-api-fo…
Browse files Browse the repository at this point in the history
…r-mp

Return a Member of parliament from Project
  • Loading branch information
mec authored Sep 4, 2024
2 parents 2ad1a91 + fa82810 commit ae2d7af
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased][unreleased]

### Changed

- the Member of parliament for a school is now included in the RPA, SUG and FA
letters export when one can be found via the new Persons API.

## [Release-86][release-86]

### Fixed
Expand Down
5 changes: 1 addition & 4 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ def new_trust_object
end

def member_of_parliament
# until the Persons API is available in production, we have to return nil
# call `fetch_member_of_parliament` when the API goes live.
nil
# @member_of_parliament ||= fetch_member_of_parliament
@member_of_parliament ||= fetch_member_of_parliament
end

def unassigned_to_user?
Expand Down
1 change: 1 addition & 0 deletions spec/accessibility/contacts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
before do
sign_in_with_user(user)
mock_all_academies_api_responses
mock_successful_persons_api_client
end

scenario "show contacts page" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@

context "when the project has no contacts" do
it "directs the user to add contacts" do
mock_successful_persons_api_client

visit project_tasks_path(project)
click_on "Confirm the main contact"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

before do
mock_successful_api_responses(urn: any_args, ukprn: any_args)
mock_successful_persons_api_client
sign_in_with_user(user)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
RSpec.feature "Users can add new external contacts" do
before do
mock_successful_api_response_to_create_any_project
mock_successful_persons_api_client
sign_in_with_user(user)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
RSpec.feature "Users can edit external contacts" do
before do
mock_successful_api_response_to_create_any_project
mock_successful_persons_api_client
sign_in_with_user(user)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
RSpec.feature "Users can view external contacts" do
before do
mock_successful_api_response_to_create_any_project
mock_successful_persons_api_client
sign_in_with_user(user)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

before do
mock_all_academies_api_responses
mock_successful_persons_api_client
sign_in_with_user(user)
visit project_tasks_path(project)
end
Expand Down
2 changes: 2 additions & 0 deletions spec/features/transfers/users_can_view_a_transfer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
end

scenario "they can view the external contacts" do
mock_successful_persons_api_client

visit project_contacts_path(transfer_project)

expect(page).to have_content(transfer_project.urn)
Expand Down
4 changes: 2 additions & 2 deletions spec/models/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
end
end

describe "#member_of_parliament", skip: "Waiting for production Persons API" do
describe "#member_of_parliament" do
it "returns the details of the MP for the projects establishment constituency" do
mock_all_academies_api_responses
project = build(:conversion_project)
Expand All @@ -374,7 +374,7 @@
it "only goes to the API once per instance of Project" do
mock_all_academies_api_responses
project = build(:conversion_project)
client = mock_successful_persons_api
client = mock_successful_persons_api_client

project.member_of_parliament
project.member_of_parliament
Expand Down
2 changes: 1 addition & 1 deletion spec/presenters/export/csv/mp_presenter_module_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe Export::Csv::MpPresenterModule, skip: "Waiting for Person API" do
RSpec.describe Export::Csv::MpPresenterModule do
before do
mock_all_academies_api_responses
allow(project.establishment).to receive(:parliamentary_constituency).and_return("Constituency Name")
Expand Down
1 change: 1 addition & 0 deletions spec/requests/external_contacts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
before do
sign_in_with(user)
mock_successful_api_responses(urn: 123456, ukprn: 10061021)
mock_successful_persons_api_client
end

describe "#index" do
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/member_of_parliament_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let(:project) { create(:conversion_project, assigned_to: user) }

describe "#show" do
context "when the Member of Parliament is found", skip: "Waiting for Persons API" do
context "when the Member of Parliament is found" do
before do
test_successful_persons_api_call
end
Expand Down

0 comments on commit ae2d7af

Please sign in to comment.