Browse Source

tests: add tests for add housing provider page

pull/954/head
natdeanlewissoftwire 3 years ago
parent
commit
7f34602566
  1. 21
      spec/requests/organisations_controller_spec.rb

21
spec/requests/organisations_controller_spec.rb

@ -288,7 +288,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that the user belongs to" do context "with an organisation that the user belongs to" do
let!(:housing_provider) { FactoryBot.create(:organisation) } let!(:housing_provider) { FactoryBot.create(:organisation) }
let!(:other_org_housing_provider) { FactoryBot.create(:organisation, name: "Foobar LTD") } let!(:other_org_housing_provider) { FactoryBot.create(:organisation, name: "Foobar LTD") }
let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD") } let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD 2") }
before do 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: organisation, parent_organisation: housing_provider, relationship_type: OrganisationRelationship.relationship_types[:owning])
@ -319,18 +319,23 @@ RSpec.describe OrganisationsController, type: :request do
it "shows the pagination count" do it "shows the pagination count" do
expect(page).to have_content("1 total housing providers") expect(page).to have_content("1 total housing providers")
end end
end
context "when adding a housing provider" do context "when adding a housing provider" do
before do before do
get "/organisations/#{organisation.id}/housing-providers/add", headers:, params: {} get "/organisations/#{organisation.id}/housing-providers/add", headers:, params: {}
end end
it "has the correct header" do
expect(response.body).to include("What is the name of your housing provider?")
end
it "has the correct header" do it "shows an add button" do
expect(response.body).to include("What is the name of your housing provider?") expect(page).to have_button("Add")
end
end end
end end
context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do
before do before do
get "/organisations/#{unauthorised_organisation.id}/housing-providers", headers:, params: {} get "/organisations/#{unauthorised_organisation.id}/housing-providers", headers:, params: {}

Loading…
Cancel
Save