Browse Source

Show deactivate this location when location is reactivating soon

pull/1007/head
Kat 4 years ago
parent
commit
2ecfb6919a
  1. 4
      app/models/location.rb
  2. 2
      app/views/locations/show.html.erb
  3. 9
      spec/requests/locations_controller_spec.rb

4
app/models/location.rb

@ -390,6 +390,10 @@ class Location < ApplicationRecord
status == :active status == :active
end end
def reactivating_soon?
status == :reactivating_soon
end
def run_deactivation_validations! def run_deactivation_validations!
@run_deactivation_validations = true @run_deactivation_validations = true
end end

2
app/views/locations/show.html.erb

@ -24,7 +24,7 @@
</div> </div>
</div> </div>
<% if FeatureToggle.location_toggle_enabled? %> <% if FeatureToggle.location_toggle_enabled? %>
<% if @location.active? %> <% if @location.active? || @location.reactivating_soon? %>
<%= govuk_button_link_to "Deactivate this location", scheme_location_new_deactivation_path(scheme_id: @scheme.id, location_id: @location.id), warning: true %> <%= govuk_button_link_to "Deactivate this location", scheme_location_new_deactivation_path(scheme_id: @scheme.id, location_id: @location.id), warning: true %>
<% else %> <% else %>
<%= govuk_button_link_to "Reactivate this location", scheme_location_new_reactivation_path(scheme_id: @scheme.id, location_id: @location.id) %> <%= govuk_button_link_to "Reactivate this location", scheme_location_new_reactivation_path(scheme_id: @scheme.id, location_id: @location.id) %>

9
spec/requests/locations_controller_spec.rb

@ -1440,6 +1440,15 @@ RSpec.describe LocationsController, type: :request do
expect(page).to have_link("Reactivate this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/new-reactivation") expect(page).to have_link("Reactivate this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/new-reactivation")
end end
end end
context "with location that's reactivating soon" do
let(:location_deactivation_period) { FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 4, 12), reactivation_date: Time.zone.local(2022, 10, 12)) }
it "renders reactivate this location" do
expect(response).to have_http_status(:ok)
expect(page).to have_link("Deactivate this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/new-deactivation")
end
end
end end
end end

Loading…
Cancel
Save