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/show.html.erb
  5. 2
      app/views/locations/toggle_active.html.erb
  6. 2
      config/locales/en.yml
  7. 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]
render "toggle_active", locals: { action: "deactivate" }, status: :unprocessable_entity
else
render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: deactivation_date }
render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: }
end
end
end
@ -168,7 +168,6 @@ private
flash[:notice] = "#{@location.name || @location.postcode} has been deactivated"
end
redirect_to scheme_location_path(@scheme, @location)
return
end
def deactivation_date_errors
@ -197,6 +196,7 @@ private
def deactivation_date
return if params[:location].blank?
collection_start_date = FormHandler.instance.current_collection_start_date
return collection_start_date if params[:location][:deactivation_date_type] == "default"
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",
active: "Active",
deactivating_soon: "Deactivating soon",
deactivated: "Deactivated"
deactivated: "Deactivated",
}.freeze
COLOUR = {
@ -18,7 +18,7 @@ module TagHelper
completed: "green",
active: "green",
deactivating_soon: "yellow",
deactivated: "grey"
deactivated: "grey",
}.freeze
def status_tag(status, classes = [])

4
app/models/location.rb

@ -10,7 +10,7 @@ class Location < ApplicationRecord
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_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 :active, -> { where(confirmed: true).and(started) }
attribute :deactivation_date_type
LOCAL_AUTHORITIES = {
"E07000223": "Adur",
"E07000026": "Allerdale",

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

@ -28,5 +28,5 @@
<%= govuk_button_link_to "Deactivate this location", scheme_location_deactivate_path(scheme_id: @scheme.id, location_id: @location.id), warning: true %>
<% else %>
<%= govuk_button_link_to "Reactivate this location", scheme_location_reactivate_path(scheme_id: @scheme.id, location_id: @location.id) %>
<% end%>
<% end %>
<% end %>

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

@ -13,7 +13,7 @@
<div class="govuk-grid-column-two-thirds">
<% collection_start_date = FormHandler.instance.current_collection_start_date %>
<%= 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") },
caption: { text: "Deactivate #{@location.postcode}" },
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:
location:
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."
test:

2
spec/requests/locations_controller_spec.rb

@ -1267,7 +1267,7 @@ RSpec.describe LocationsController, type: :request do
end
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
follow_redirect!

Loading…
Cancel
Save