Browse Source

testing org schemes for coordiantor user

pull/648/head
JG 3 years ago
parent
commit
2ae09df82b
  1. 2
      config/routes.rb
  2. 30
      spec/requests/organisations_controller_spec.rb
  3. 18
      spec/requests/schemes_controller_spec.rb

2
config/routes.rb

@ -50,7 +50,7 @@ Rails.application.routes.draw do
get "users", to: "organisations#users"
get "users/invite", to: "users/account#new"
get "logs", to: "organisations#logs"
get "schemes", to: "organisations#schemes"
get "supported-housing", to: "organisations#schemes"
end
end

30
spec/requests/organisations_controller_spec.rb

@ -34,6 +34,36 @@ RSpec.describe OrganisationsController, type: :request do
end
context "when user is signed in" do
describe "#schemes" do
let(:user) { FactoryBot.create(:user, :data_coordinator) }
let!(:schemes) { FactoryBot.create_list(:scheme, 5) }
let!(:same_org_scheme) { FactoryBot.create(:scheme, organisation: user.organisation) }
before do
sign_in user
get "/organisations/#{organisation.id}/supported-housing", headers:, params: {}
end
it "has page heading" do
expect(page).to have_content("Supported housing services")
end
it "redirects to the organisation schemes path" do
expect(path).to match("/organisations/#{user.organisation.id}/schemes")
end
it "shows a search bar" do
expect(page).to have_field("search", type: "search")
end
it "shows only schemes belonging to the same organisation" do
expect(page).to have_content(same_org_scheme.code)
schemes.each do |scheme|
expect(page).not_to have_content(scheme.code)
end
end
end
describe "#show" do
context "with an organisation that the user belongs to" do
before do

18
spec/requests/schemes_controller_spec.rb

@ -155,24 +155,6 @@ RSpec.describe SchemesController, type: :request do
follow_redirect!
expect(page).to have_content("Supported housing services")
end
it "redirects to the organisation schemes path" do
follow_redirect!
expect(path).to match("/organisations/#{user.organisation.id}/schemes")
end
it "shows a search bar" do
follow_redirect!
expect(page).to have_field("search", type: "search")
end
it "shows only schemes belonging to the same organisation" do
follow_redirect!
expect(page).to have_content(same_org_scheme.code)
schemes.each do |scheme|
expect(page).not_to have_content(scheme.code)
end
end
end
end
end

Loading…
Cancel
Save