diff --git a/app/views/organisation_relationships/managing_agents.html.erb b/app/views/organisation_relationships/managing_agents.html.erb index a01a354d2..726533e53 100644 --- a/app/views/organisation_relationships/managing_agents.html.erb +++ b/app/views/organisation_relationships/managing_agents.html.erb @@ -5,19 +5,35 @@ <%= render SubNavigationComponent.new( items: secondary_items(request.path, @organisation.id), ) %> + <% if !@organisation.active? %> + <%= govuk_notification_banner(title_text: "Important") do %> +

+ This organisation is deactivated. +

+ You cannot add any new managing agents. + <% end %> + <% end %>

Managing Agents

A managing agent can submit logs for this organisation.

<% if @total_count == 0 %>

This organisation does not currently have any managing agents.

<% end %> <% else %> + <% if !@organisation.active? %> + <%= govuk_notification_banner(title_text: "Important") do %> +

+ This organisation is deactivated. +

+ You cannot add any new managing agents. + <% end %> + <% end %> <%= render partial: "organisations/headings", locals: { main: "Your managing agents", sub: current_user.organisation.name } %>

A managing agent can submit logs for this organisation.

<% if @total_count == 0 %>

This organisation does not currently have any managing agents.

<% end %> <% end %> -<% if current_user.support? || current_user.data_coordinator? %> +<% if (current_user.support? || current_user.data_coordinator?) && @organisation.active? %> <%= govuk_button_link_to "Add a managing agent", managing_agents_add_organisation_path, html: { method: :get } %> <% end %> <% if @total_count != 0 %> diff --git a/app/views/organisation_relationships/stock_owners.html.erb b/app/views/organisation_relationships/stock_owners.html.erb index 4be22f7b9..41b7af06d 100644 --- a/app/views/organisation_relationships/stock_owners.html.erb +++ b/app/views/organisation_relationships/stock_owners.html.erb @@ -2,19 +2,35 @@ <% if current_user.support? %> <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %> + <% if !@organisation.active? %> + <%= govuk_notification_banner(title_text: "Important") do %> +

+ This organisation is deactivated. +

+ You cannot add any new stock owners. + <% end %> + <% end %>

Stock Owners

This organisation can submit logs for its stock owners.

<% if @total_count == 0 %>

This organisation does not currently have any stock owners.

<% end %> <% else %> + <% if !@organisation.active? %> + <%= govuk_notification_banner(title_text: "Important") do %> +

+ This organisation is deactivated. +

+ You cannot add any new stock owners. + <% end %> + <% end %> <%= render partial: "organisations/headings", locals: { main: "Your stock owners", sub: current_user.organisation.name } %>

Your organisation can submit logs for its stock owners.

<% if @total_count == 0 %>

You do not currently have any stock owners.

<% end %> <% end %> -<% if current_user.support? || current_user.data_coordinator? %> +<% if (current_user.support? || current_user.data_coordinator?) && @organisation.active? %> <%= govuk_button_link_to "Add a stock owner", stock_owners_add_organisation_path, html: { method: :get } %> <% end %> <% if @total_count != 0 %> diff --git a/spec/requests/organisation_relationships_controller_spec.rb b/spec/requests/organisation_relationships_controller_spec.rb index 66d9c0ec6..feb687e0c 100644 --- a/spec/requests/organisation_relationships_controller_spec.rb +++ b/spec/requests/organisation_relationships_controller_spec.rb @@ -81,6 +81,22 @@ RSpec.describe OrganisationRelationshipsController, type: :request do expect(response.body).not_to include(inactive_organisation.name) end end + + context "and current organisation is deactivated" do + before do + organisation.update!(active: false) + get "/organisations/#{organisation.id}/stock-owners", headers:, params: {} + end + + it "does not show the add stock owner button" do + expect(page).not_to have_link("Add a stock owner") + end + + it "shows a banner" do + expect(page).to have_content("This organisation is deactivated.") + expect(page).to have_content("You cannot add any new stock owners.") + end + end end context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do @@ -135,6 +151,22 @@ RSpec.describe OrganisationRelationshipsController, type: :request do it "shows the pagination count" do expect(page).to have_content("1 total managing agents") end + + context "and current organisation is deactivated" do + before do + organisation.update!(active: false) + get "/organisations/#{organisation.id}/managing-agents", headers:, params: {} + end + + it "does not show the add managing agent button" do + expect(page).not_to have_link("Add a managing agent") + end + + it "shows a banner" do + expect(page).to have_content("This organisation is deactivated.") + expect(page).to have_content("You cannot add any new managing agents.") + end + end end context "when adding a managing agent" do