Browse Source

Add informative text for schemesrbe that have logs

pull/2286/head
Kat 2 years ago
parent
commit
3108aa08ac
  1. 3
      app/views/schemes/show.html.erb
  2. 22
      spec/requests/schemes_controller_spec.rb

3
app/views/schemes/show.html.erb

@ -29,6 +29,9 @@
<% if @scheme.confirmed? && @scheme.locations.confirmed.none? && LocationPolicy.new(current_user, @scheme.locations.new).create? %>
<span class="app-!-colour-muted">Complete this scheme by adding a location using the <%= govuk_link_to("‘locations’ tab", scheme_locations_path(@scheme)) %>.</span>
<% end %>
<% if @scheme.deactivated? && current_user.support? && !SchemePolicy.new(current_user, @scheme).delete? %>
<span class="app-!-colour-muted">This scheme was active in an open or editable collection year, and cannot be deleted.</span>
<% end %>
</dd>
</div>
<% elsif attr[:id] != "secondary_client_group" || @scheme.has_other_client_group == "Yes" %>

22
spec/requests/schemes_controller_spec.rb

@ -742,6 +742,11 @@ RSpec.describe SchemesController, type: :request do
expect(response).to have_http_status(:ok)
expect(page).not_to have_link("Delete this scheme", href: "/schemes/#{scheme.id}/delete-confirmation")
end
it "does not render informative text about deleting the scheme" do
expect(response).to have_http_status(:ok)
expect(page).not_to have_content("This scheme was active in an open or editable collection year, and cannot be deleted.")
end
end
context "with deactivated scheme" do
@ -751,6 +756,23 @@ RSpec.describe SchemesController, type: :request do
expect(response).to have_http_status(:ok)
expect(page).to have_link("Delete this scheme", href: "/schemes/#{scheme.id}/delete-confirmation")
end
context "and associated logs in editable collection period" do
before do
create(:lettings_log, :sh, scheme:, startdate: Time.zone.local(2022, 9, 9), owning_organisation: user.organisation)
get "/schemes/#{scheme.id}"
end
it "does not render delete this scheme" do
expect(response).to have_http_status(:ok)
expect(page).not_to have_link("Delete this scheme", href: "/schemes/#{scheme.id}/delete-confirmation")
end
it "adds informative text about deleting the scheme" do
expect(response).to have_http_status(:ok)
expect(page).to have_content("This scheme was active in an open or editable collection year, and cannot be deleted.")
end
end
end
context "with scheme that's deactivating soon" do

Loading…
Cancel
Save