diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb
index 8f663ae80..26d20139f 100644
--- a/app/controllers/locations_controller.rb
+++ b/app/controllers/locations_controller.rb
@@ -29,7 +29,6 @@ class LocationsController < ApplicationController
deactivation_date_errors
if @location.errors.present?
@location.deactivation_date_type = params[:location][:deactivation_date_type]
- @location.deactivation_date = nil
render "toggle_active", locals: { action: "deactivate" }, status: :unprocessable_entity
else
render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: }
@@ -184,7 +183,7 @@ private
collection_start_date = FormHandler.instance.current_collection_start_date
if [day, month, year].any?(&:blank?)
- @location.errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.not_entered", period: period.to_s))
+ @location.errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.not_entered"))
elsif !Date.valid_date?(year.to_i, month.to_i, day.to_i)
@location.errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.invalid"))
elsif !Date.new(year.to_i, month.to_i, day.to_i).between?(collection_start_date, Date.new(2200, 1, 1))
diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb
index 3470507a8..50c0d294b 100644
--- a/app/controllers/schemes_controller.rb
+++ b/app/controllers/schemes_controller.rb
@@ -30,7 +30,6 @@ class SchemesController < ApplicationController
deactivation_date_errors
if @scheme.errors.present?
@scheme.deactivation_date_type = params[:scheme][:deactivation_date_type]
- @scheme.deactivation_date = nil
render "toggle_active", locals: { action: "deactivate" }, status: :unprocessable_entity
else
render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: }
diff --git a/app/helpers/locations_helper.rb b/app/helpers/locations_helper.rb
index e21a4724e..2a02ebc94 100644
--- a/app/helpers/locations_helper.rb
+++ b/app/helpers/locations_helper.rb
@@ -23,7 +23,7 @@ module LocationsHelper
resource.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) }
end
- def display_attributes(location)
+ def display_location_attributes(location)
[
{ name: "Postcode", value: location.postcode },
{ name: "Local authority", value: location.location_admin_district },
diff --git a/app/helpers/schemes_helper.rb b/app/helpers/schemes_helper.rb
index 8662e4a4e..fae7444b0 100644
--- a/app/helpers/schemes_helper.rb
+++ b/app/helpers/schemes_helper.rb
@@ -1,5 +1,5 @@
module SchemesHelper
- def display_attributes(scheme)
+ def display_scheme_attributes(scheme)
base_attributes = [
{ name: "Scheme code", value: scheme.id_to_display },
{ name: "Name", value: scheme.service_name, edit: true },
@@ -31,15 +31,4 @@ module SchemesHelper
end
base_text
end
-
- def scheme_status(scheme)
- now = Time.zone.now
- if scheme.deactivation_date.nil?
- "active"
- elsif scheme.deactivation_date < now
- "deactivated"
- elsif now < scheme.deactivation_date
- "deactivates_soon"
- end
- end
end
diff --git a/app/models/location.rb b/app/models/location.rb
index ab1c3620a..4fb49e7c6 100644
--- a/app/models/location.rb
+++ b/app/models/location.rb
@@ -374,7 +374,7 @@ class Location < ApplicationRecord
def status
return :active if deactivation_date.blank?
- return :deactivating_soon if Time.zone.now < deactivation_date
+ return :deactivates_soon if Time.zone.now < deactivation_date
return :deactivated if Time.zone.now >= deactivation_date
end
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index e420ca9d8..cc0df4ef6 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -77,7 +77,7 @@ class Organisation < ApplicationRecord
DISPLAY_PROVIDER_TYPE[provider_type.to_sym]
end
- def display_attributes
+ def display_organisation_attributes
[
{ name: "Name", value: name, editable: true },
{ name: "Address", value: address_string, editable: true },
diff --git a/app/models/scheme.rb b/app/models/scheme.rb
index 70777c562..eaa6bce3d 100644
--- a/app/models/scheme.rb
+++ b/app/models/scheme.rb
@@ -216,7 +216,7 @@ class Scheme < ApplicationRecord
def status
return :active if deactivation_date.blank?
- return :deactivating_soon if Time.zone.now < deactivation_date
+ return :deactivates_soon if Time.zone.now < deactivation_date
return :deactivated if Time.zone.now >= deactivation_date
end
end
diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb
index ccc0163c2..61a05f3ac 100644
--- a/app/views/locations/show.html.erb
+++ b/app/views/locations/show.html.erb
@@ -13,7 +13,7 @@
<%= govuk_summary_list do |summary_list| %>
- <% display_attributes(@location).each do |attr| %>
+ <% display_location_attributes(@location).each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name] } %>
<% row.value { attr[:name].eql?("Status") ? status_tag(attr[:value]) : details_html(attr) } %>
diff --git a/app/views/organisations/show.html.erb b/app/views/organisations/show.html.erb
index 5cd8b64e0..bbe9ae67a 100644
--- a/app/views/organisations/show.html.erb
+++ b/app/views/organisations/show.html.erb
@@ -14,7 +14,7 @@
<%= govuk_summary_list do |summary_list| %>
- <% @organisation.display_attributes.each do |attr| %>
+ <% @organisation.display_organisation_attributes.each do |attr| %>
<% if can_edit_org?(current_user) && attr[:editable] %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s.humanize } %>
diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb
index bd4ef5e86..b9713f23d 100644
--- a/app/views/schemes/show.html.erb
+++ b/app/views/schemes/show.html.erb
@@ -15,11 +15,12 @@
Scheme
<%= govuk_summary_list do |summary_list| %>
- <% display_attributes(@scheme).each do |attr| %>
+ <% display_scheme_attributes(@scheme).each do |attr| %>
<% next if current_user.data_coordinator? && attr[:name] == ("Housing stock owned by") %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].eql?("Registered under Care Standards Act 2000") ? "Registered under Care Standards Act 2000" : attr[:name].to_s.humanize } %>
<% row.value { details_html(attr) } %>
+ <% row.value { attr[:name].eql?("Status") ? status_tag(attr[:value]) : details_html(attr) } %>
<% row.action(text: "Change", href: scheme_edit_name_path(scheme_id: @scheme.id)) if attr[:edit] %>
<% end %>
<% end %>
diff --git a/spec/helpers/locations_helper_spec.rb b/spec/helpers/locations_helper_spec.rb
index f2a5a67a5..2adfab35f 100644
--- a/spec/helpers/locations_helper_spec.rb
+++ b/spec/helpers/locations_helper_spec.rb
@@ -47,7 +47,7 @@ RSpec.describe LocationsHelper do
end
end
- describe "display_attributes" do
+ describe "display_location_attributes" do
let(:location) { FactoryBot.build(:location, startdate: Time.zone.local(2022, 8, 8)) }
it "returns correct display attributes" do
@@ -63,12 +63,12 @@ RSpec.describe LocationsHelper do
{ name: "Status", value: :active },
]
- expect(display_attributes(location)).to eq(attributes)
+ expect(display_location_attributes(location)).to eq(attributes)
end
it "displays created_at as availability date if startdate is not present" do
location.update!(startdate: nil)
- availability_attribute = display_attributes(location).find { |x| x[:name] == "Availability" }[:value]
+ availability_attribute = display_location_attributes(location).find { |x| x[:name] == "Availability" }[:value]
expect(availability_attribute).to eq("Available from #{location.created_at.to_formatted_s(:govuk_date)}")
end
diff --git a/spec/helpers/schemes_helper_spec.rb b/spec/helpers/schemes_helper_spec.rb
index 4410620a9..46dfbd7c2 100644
--- a/spec/helpers/schemes_helper_spec.rb
+++ b/spec/helpers/schemes_helper_spec.rb
@@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe SchemesHelper do
- describe "display_attributes" do
+ describe "display_scheme_attributes" do
let!(:scheme) { FactoryBot.create(:scheme, created_at: Time.zone.local(2022, 8, 8)) }
it "returns correct display attributes" do
@@ -21,7 +21,7 @@ RSpec.describe SchemesHelper do
{ name: "Availability", value: "Available from 8 August 2022" },
{ name: "Status", value: :active },
]
- expect(display_attributes(scheme)).to eq(attributes)
+ expect(display_scheme_attributes(scheme)).to eq(attributes)
end
end
end
diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb
index 8f9f452bc..071c55ef6 100644
--- a/spec/models/location_spec.rb
+++ b/spec/models/location_spec.rb
@@ -125,10 +125,10 @@ RSpec.describe Location, type: :model do
expect(location.status).to eq(:active)
end
- it "returns deactivating soon if deactivation_date is in the future" do
+ it "returns deactivates soon if deactivation_date is in the future" do
location.deactivation_date = Time.zone.local(2022, 8, 8)
location.save!
- expect(location.status).to eq(:deactivating_soon)
+ expect(location.status).to eq(:deactivates_soon)
end
it "returns deactivated if deactivation_date is in the past" do
diff --git a/spec/models/scheme_spec.rb b/spec/models/scheme_spec.rb
index b69629ba5..253ca6925 100644
--- a/spec/models/scheme_spec.rb
+++ b/spec/models/scheme_spec.rb
@@ -108,7 +108,7 @@ RSpec.describe Scheme, type: :model do
it "returns deactivating soon if deactivation_date is in the future" do
scheme.deactivation_date = Time.zone.local(2022, 8, 8)
scheme.save!
- expect(scheme.status).to eq(:deactivating_soon)
+ expect(scheme.status).to eq(:deactivates_soon)
end
it "returns deactivated if deactivation_date is in the past" do
diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb
index feeae2b99..361128f5b 100644
--- a/spec/requests/locations_controller_spec.rb
+++ b/spec/requests/locations_controller_spec.rb
@@ -1310,7 +1310,7 @@ RSpec.describe LocationsController, type: :request do
it "displays page with an error message" do
expect(response).to have_http_status(:unprocessable_entity)
- expect(page).to have_content(I18n.t("validations.location.deactivation_date.not_entered", period: "day"))
+ expect(page).to have_content(I18n.t("validations.location.deactivation_date.not_entered"))
end
end
@@ -1319,7 +1319,7 @@ RSpec.describe LocationsController, type: :request do
it "displays page with an error message" do
expect(response).to have_http_status(:unprocessable_entity)
- expect(page).to have_content(I18n.t("validations.location.deactivation_date.not_entered", period: "month"))
+ expect(page).to have_content(I18n.t("validations.location.deactivation_date.not_entered"))
end
end
@@ -1328,7 +1328,7 @@ RSpec.describe LocationsController, type: :request do
it "displays page with an error message" do
expect(response).to have_http_status(:unprocessable_entity)
- expect(page).to have_content(I18n.t("validations.location.deactivation_date.not_entered", period: "year"))
+ expect(page).to have_content(I18n.t("validations.location.deactivation_date.not_entered"))
end
end
end
diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb
index de2e14b83..3aa35bda9 100644
--- a/spec/requests/schemes_controller_spec.rb
+++ b/spec/requests/schemes_controller_spec.rb
@@ -1797,7 +1797,7 @@ RSpec.describe SchemesController, type: :request do
it "displays page with an error message" do
expect(response).to have_http_status(:unprocessable_entity)
- expect(page).to have_content(I18n.t("validations.scheme.deactivation_date.not_entered", period: "day"))
+ expect(page).to have_content(I18n.t("validations.scheme.deactivation_date.not_entered"))
end
end
@@ -1806,7 +1806,7 @@ RSpec.describe SchemesController, type: :request do
it "displays page with an error message" do
expect(response).to have_http_status(:unprocessable_entity)
- expect(page).to have_content(I18n.t("validations.scheme.deactivation_date.not_entered", period: "month"))
+ expect(page).to have_content(I18n.t("validations.scheme.deactivation_date.not_entered"))
end
end
@@ -1815,7 +1815,7 @@ RSpec.describe SchemesController, type: :request do
it "displays page with an error message" do
expect(response).to have_http_status(:unprocessable_entity)
- expect(page).to have_content(I18n.t("validations.scheme.deactivation_date.not_entered", period: "year"))
+ expect(page).to have_content(I18n.t("validations.scheme.deactivation_date.not_entered"))
end
end
end