diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb index c0fe9b754..96137b2bb 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -32,6 +32,6 @@ <% end %> -<% if FeatureToggle.scheme_toggle_enabled? %> +<% if FeatureToggle.scheme_toggle_enabled? && user_can_edit_scheme?(current_user, @scheme) %> <%= toggle_scheme_link(@scheme) %> <% end %> diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 81fe920c4..9aeaac6ca 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -339,6 +339,7 @@ RSpec.describe SchemesController, type: :request do let!(:specific_scheme) { FactoryBot.create(:scheme, owning_organisation: parent_organisation) } before do + FactoryBot.create(:location, scheme: specific_scheme) create(:organisation_relationship, parent_organisation:, child_organisation: user.organisation) get "/schemes/#{specific_scheme.id}" end @@ -349,6 +350,8 @@ RSpec.describe SchemesController, type: :request do it "does not allow editing the scheme" do expect(page).not_to have_link("Change") + expect(page).not_to have_content("Reactivate this scheme") + expect(page).not_to have_content("Deactivate this scheme") end end end