From 2ae09df82be0b9d5d1877414d59a9c492d029676 Mon Sep 17 00:00:00 2001 From: JG Date: Fri, 10 Jun 2022 08:33:25 +0100 Subject: [PATCH] testing org schemes for coordiantor user --- config/routes.rb | 2 +- .../requests/organisations_controller_spec.rb | 30 +++++++++++++++++++ spec/requests/schemes_controller_spec.rb | 18 ----------- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 4f64b1575..c7b3df36e 100644 --- a/config/routes.rb +++ b/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 diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index 8470d50ef..e67aa82e1 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/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 diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index cbe254f61..7dbbbc699 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/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