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 stock owners tab" do context "with an organisation that the user belongs to" do let!(:stock_owner) { FactoryBot.create(:organisation) } let!(:other_org_stock_owner) { FactoryBot.create(:organisation, name: "Foobar LTD") } let!(:inactive_stock_owner) { FactoryBot.create(:organisation, name: "Inactive LTD", active: false) } let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD 2") } before do FactoryBot.create(:organisation_relationship, child_organisation: organisation, parent_organisation: stock_owner) FactoryBot.create(:organisation_relationship, child_organisation: other_organisation, parent_organisation: other_org_stock_owner) FactoryBot.create(:organisation_relationship, child_organisation: organisation, parent_organisation: inactive_stock_owner) get "/organisations/#{organisation.id}/stock-owners", headers:, params: {} end it "shows the tab navigation" do expected_html = "