require "rails_helper" RSpec.describe OrganisationRelationshipsController, type: :request do let(:organisation) { user.organisation } let!(:unauthorised_organisation) { FactoryBot.create(:organisation) } let(:headers) { { "Accept" => "text/html" } } let(:page) { Capybara::Node::Simple.new(response.body) } 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 end context "when accessing the housing providers tab" do context "with an organisation that the user belongs to" 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 "shows the tab navigation" do expected_html = "