From c96c2acd89e19663a310d91a150f846c3cc53a4c Mon Sep 17 00:00:00 2001 From: Ted-U Date: Mon, 8 Aug 2022 15:02:14 +0100 Subject: [PATCH] added to organisation factory and fixed tests --- spec/factories/organisation.rb | 1 + spec/features/organisation_spec.rb | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/spec/factories/organisation.rb b/spec/factories/organisation.rb index e88abf0c5..5ce6cfc03 100644 --- a/spec/factories/organisation.rb +++ b/spec/factories/organisation.rb @@ -8,6 +8,7 @@ FactoryBot.define do postcode { "SW1P 4DF" } created_at { Time.zone.now } updated_at { Time.zone.now } + holds_own_stock { true } end factory :organisation_la do diff --git a/spec/features/organisation_spec.rb b/spec/features/organisation_spec.rb index cfac9f98a..d034468dd 100644 --- a/spec/features/organisation_spec.rb +++ b/spec/features/organisation_spec.rb @@ -40,21 +40,25 @@ RSpec.describe "User Features" do expect(page).to have_current_path("/organisations/#{org_id}/details") end - context "when the user is a coordinator and the organisation holds housing stock" do - let(:organisation) { FactoryBot.create(:organisation, holds_own_stock: true) } + context "when the user is a coordinator and the organisation does not hold housing stock" do + before do + organisation.update(holds_own_stock: false) + end - it "shows schemes in the navigation bar" do + it "does not show schemes in the navigation bar" do visit("/logs") - expect(page).to have_link("Schemes", href: "/schemes") + expect(page).not_to have_link("Schemes", href: "/schemes") end end - context "when the user is a coordinator and the organisation does not hold housing stock" do - let(:organisation) { FactoryBot.create(:organisation, holds_own_stock: false) } + context "when the user is a coordinator and the organisation holds housing stock" do + before do + organisation.update(holds_own_stock: true) + end - it "does not show schemes in the navigation bar" do + it "shows schemes in the navigation bar" do visit("/logs") - expect(page).not_to have_link("Schemes", href: "/schemes") + expect(page).to have_link("Schemes", href: "/schemes") end end end