From ab4ea5f78cef930e82d49e8cced6cd179bc7a387 Mon Sep 17 00:00:00 2001 From: Jack S Date: Fri, 28 Oct 2022 10:45:54 +0100 Subject: [PATCH] tidy up specs --- ...anisation_relationships_controller_spec.rb | 105 ++++- .../requests/organisations_controller_spec.rb | 438 ------------------ 2 files changed, 102 insertions(+), 441 deletions(-) diff --git a/spec/requests/organisation_relationships_controller_spec.rb b/spec/requests/organisation_relationships_controller_spec.rb index 8cda4cce6..9fdb01ec9 100644 --- a/spec/requests/organisation_relationships_controller_spec.rb +++ b/spec/requests/organisation_relationships_controller_spec.rb @@ -5,11 +5,10 @@ RSpec.describe OrganisationRelationshipsController, type: :request do let!(:unauthorised_organisation) { FactoryBot.create(:organisation) } let(:headers) { { "Accept" => "text/html" } } let(:page) { Capybara::Node::Simple.new(response.body) } - let(:user) { FactoryBot.create(:user, :data_coordinator) } - let(:new_value) { "Test Name 35" } - let(:params) { { id: organisation.id, organisation: { name: new_value } } } context "when user is signed in" do + let(:user) { FactoryBot.create(:user, :data_coordinator) } + context "with a data coordinator user" do before do sign_in user @@ -369,6 +368,106 @@ RSpec.describe OrganisationRelationshipsController, type: :request do expect(response).to redirect_to("/organisations/#{organisation.id}/managing-agents?related_organisation_id=#{managing_agent.id}") end end + + context "when viewing a specific organisation's housing providers" do + let!(:housing_provider) { FactoryBot.create(:organisation) } + let!(:other_org_housing_provider) { FactoryBot.create(:organisation, name: "Foobar LTD") } + let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD 2") } + + before do + FactoryBot.create(:organisation_relationship, child_organisation: organisation, parent_organisation: housing_provider, relationship_type: OrganisationRelationship.relationship_types[:owning]) + FactoryBot.create(:organisation_relationship, child_organisation: other_organisation, parent_organisation: other_org_housing_provider, relationship_type: OrganisationRelationship.relationship_types[:owning]) + get "/organisations/#{organisation.id}/housing-providers", headers:, params: {} + end + + it "displays the name of the organisation" do + expect(page).to have_content(organisation.name) + end + + it "has a sub-navigation with correct tabs" do + expect(page).to have_css(".app-sub-navigation") + expect(page).to have_content("Users") + end + + it "shows a table of housing providers" do + expected_html = "