Browse Source

lint and typos

pull/981/head
Kat 4 years ago
parent
commit
9e2508f418
  1. 4
      app/controllers/locations_controller.rb
  2. 4
      app/helpers/tag_helper.rb
  3. 4
      app/models/location.rb
  4. 2
      app/views/locations/toggle_active.html.erb
  5. 2
      config/locales/en.yml
  6. 2
      spec/requests/locations_controller_spec.rb

4
app/controllers/locations_controller.rb

@ -31,7 +31,7 @@ class LocationsController < ApplicationController
@location.deactivation_date_type = params[:location][:deactivation_date_type] @location.deactivation_date_type = params[:location][:deactivation_date_type]
render "toggle_active", locals: { action: "deactivate" }, status: :unprocessable_entity render "toggle_active", locals: { action: "deactivate" }, status: :unprocessable_entity
else else
render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: deactivation_date } render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: }
end end
end end
end end
@ -168,7 +168,6 @@ private
flash[:notice] = "#{@location.name || @location.postcode} has been deactivated" flash[:notice] = "#{@location.name || @location.postcode} has been deactivated"
end end
redirect_to scheme_location_path(@scheme, @location) redirect_to scheme_location_path(@scheme, @location)
return
end end
def deactivation_date_errors def deactivation_date_errors
@ -197,6 +196,7 @@ private
def deactivation_date def deactivation_date
return if params[:location].blank? return if params[:location].blank?
collection_start_date = FormHandler.instance.current_collection_start_date collection_start_date = FormHandler.instance.current_collection_start_date
return collection_start_date if params[:location][:deactivation_date_type] == "default" return collection_start_date if params[:location][:deactivation_date_type] == "default"
return params[:location][:deactivation_date] if params[:location][:deactivation_date_type].blank? return params[:location][:deactivation_date] if params[:location][:deactivation_date_type].blank?

4
app/helpers/tag_helper.rb

@ -8,7 +8,7 @@ module TagHelper
completed: "Completed", completed: "Completed",
active: "Active", active: "Active",
deactivating_soon: "Deactivating soon", deactivating_soon: "Deactivating soon",
deactivated: "Deactivated" deactivated: "Deactivated",
}.freeze }.freeze
COLOUR = { COLOUR = {
@ -18,7 +18,7 @@ module TagHelper
completed: "green", completed: "green",
active: "green", active: "green",
deactivating_soon: "yellow", deactivating_soon: "yellow",
deactivated: "grey" deactivated: "grey",
}.freeze }.freeze
def status_tag(status, classes = []) def status_tag(status, classes = [])

4
app/models/location.rb

@ -10,7 +10,7 @@ class Location < ApplicationRecord
auto_strip_attributes :name auto_strip_attributes :name
attr_accessor :add_another_location attr_accessor :add_another_location, :deactivation_date_type
scope :search_by_postcode, ->(postcode) { where("REPLACE(postcode, ' ', '') ILIKE ?", "%#{postcode.delete(' ')}%") } scope :search_by_postcode, ->(postcode) { where("REPLACE(postcode, ' ', '') ILIKE ?", "%#{postcode.delete(' ')}%") }
scope :search_by_name, ->(name) { where("name ILIKE ?", "%#{name}%") } scope :search_by_name, ->(name) { where("name ILIKE ?", "%#{name}%") }
@ -18,8 +18,6 @@ class Location < ApplicationRecord
scope :started, -> { where("startdate <= ?", Time.zone.today).or(where(startdate: nil)) } scope :started, -> { where("startdate <= ?", Time.zone.today).or(where(startdate: nil)) }
scope :active, -> { where(confirmed: true).and(started) } scope :active, -> { where(confirmed: true).and(started) }
attribute :deactivation_date_type
LOCAL_AUTHORITIES = { LOCAL_AUTHORITIES = {
"E07000223": "Adur", "E07000223": "Adur",
"E07000026": "Allerdale", "E07000026": "Allerdale",

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

@ -13,7 +13,7 @@
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<% collection_start_date = FormHandler.instance.current_collection_start_date %> <% collection_start_date = FormHandler.instance.current_collection_start_date %>
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
<%= f.govuk_radio_buttons_fieldset :deactivation_date, <%= f.govuk_radio_buttons_fieldset :deactivation_date_type,
legend: { text: I18n.t("questions.location.deactivation.apply_from") }, legend: { text: I18n.t("questions.location.deactivation.apply_from") },
caption: { text: "Deactivate #{@location.postcode}" }, caption: { text: "Deactivate #{@location.postcode}" },
hint: { text: I18n.t("hints.location.deactivation", date: collection_start_date.to_formatted_s(:govuk_date)) } do %> hint: { text: I18n.t("hints.location.deactivation", date: collection_start_date.to_formatted_s(:govuk_date)) } do %>

2
config/locales/en.yml

@ -388,7 +388,7 @@ en:
warnings: warnings:
location: location:
deactivation: deactivation:
existing_logs: "It will not be possible to add logs with this scheme if their tenancy start date is on or after the date you enter. Any existing logs may be affected." existing_logs: "It will not be possible to add logs with this location if their tenancy start date is on or after the date you enter. Any existing logs may be affected."
review_logs: "Your data providers will need to review these logs and answer a few questions again. We’ll email each log creator with a list of logs that need updating." review_logs: "Your data providers will need to review these logs and answer a few questions again. We’ll email each log creator with a list of logs that need updating."
test: test:

2
spec/requests/locations_controller_spec.rb

@ -1267,7 +1267,7 @@ RSpec.describe LocationsController, type: :request do
end end
context "when confirming deactivation" do context "when confirming deactivation" do
let(:params) { { location: { deactivation_date: deactivation_date, confirm: true } } } let(:params) { { location: { deactivation_date:, confirm: true } } }
it "updates existing location with valid deactivation date and renders location page" do it "updates existing location with valid deactivation date and renders location page" do
follow_redirect! follow_redirect!

Loading…
Cancel
Save