Browse Source

rubocop

pull/704/head
JG 3 years ago
parent
commit
4942dd81d9
  1. 2
      app/controllers/locations_controller.rb
  2. 2
      app/models/location.rb
  3. 4
      app/views/locations/details.html.erb
  4. 4
      app/views/locations/new.html.erb
  5. 12
      app/views/schemes/check_answers.html.erb
  6. 4
      app/views/schemes/locations.html.erb
  7. 2
      spec/features/schemes_spec.rb
  8. 2
      spec/helpers/tab_nav_helper_spec.rb
  9. 4
      spec/models/location_spec.rb
  10. 8
      spec/requests/locations_controller_spec.rb

2
app/controllers/locations_controller.rb

@ -51,7 +51,7 @@ private
def location_params def location_params
required_params = params.require(:location).permit(:postcode, :name, :total_units, :type_of_unit, :wheelchair_adaptation, :add_another_location).merge(scheme_id: @scheme.id) required_params = params.require(:location).permit(:postcode, :name, :total_units, :type_of_unit, :wheelchair_adaptation, :add_another_location).merge(scheme_id: @scheme.id)
required_params[:postcode] = required_params[:postcode].gsub(" ", "").upcase.encode("ASCII", "UTF-8", invalid: :replace, undef: :replace, replace: "") if required_params[:postcode] required_params[:postcode] = required_params[:postcode].delete(" ").upcase.encode("ASCII", "UTF-8", invalid: :replace, undef: :replace, replace: "") if required_params[:postcode]
required_params required_params
end end
end end

2
app/models/location.rb

@ -31,7 +31,7 @@ class Location < ApplicationRecord
{ name: "Type of building", value: type_of_building, suffix: false }, { name: "Type of building", value: type_of_building, suffix: false },
{ name: "Wheelchair adaptation", value: wheelchair_adaptation, suffix: false }, { name: "Wheelchair adaptation", value: wheelchair_adaptation, suffix: false },
] ]
end end
private private

4
app/views/locations/details.html.erb

@ -3,8 +3,8 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: "/schemes/#{@scheme.id}/support" href: "/schemes/#{@scheme.id}/support",
) %> ) %>
<% end %> <% end %>
<%= render partial: "organisations/headings", locals: { main: "Add a location to this scheme", sub: @scheme.service_name } %> <%= render partial: "organisations/headings", locals: { main: "Add a location to this scheme", sub: @scheme.service_name } %>

4
app/views/locations/new.html.erb

@ -3,8 +3,8 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: "/schemes/#{@scheme.id}/support" href: "/schemes/#{@scheme.id}/support",
) %> ) %>
<% end %> <% end %>
<%= render partial: "organisations/headings", locals: { main: "Add a location to this scheme", sub: @scheme.service_name } %> <%= render partial: "organisations/headings", locals: { main: "Add a location to this scheme", sub: @scheme.service_name } %>

12
app/views/schemes/check_answers.html.erb

@ -17,7 +17,7 @@
<% row.action( <% row.action(
text: "Change", text: "Change",
href: scheme_details_path(scheme_id: @scheme.id, check_answers: true), href: scheme_details_path(scheme_id: @scheme.id, check_answers: true),
) %> ) %>
<% end %> <% end %>
<% end %> <% end %>
<% @scheme.check_primary_client_attributes.each do |attr| %> <% @scheme.check_primary_client_attributes.each do |attr| %>
@ -27,7 +27,7 @@
<% row.action( <% row.action(
text: "Change", text: "Change",
href: scheme_primary_client_group_path(scheme_id: @scheme.id, check_answers: true), href: scheme_primary_client_group_path(scheme_id: @scheme.id, check_answers: true),
) %> ) %>
<% end %> <% end %>
<% end %> <% end %>
<% @scheme.check_secondary_client_confirmation_attributes.each do |attr| %> <% @scheme.check_secondary_client_confirmation_attributes.each do |attr| %>
@ -37,7 +37,7 @@
<% row.action( <% row.action(
text: "Change", text: "Change",
href: scheme_confirm_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true), href: scheme_confirm_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true),
) %> ) %>
<% end %> <% end %>
<% end %> <% end %>
<% if @scheme.has_other_client_group == "Yes" %> <% if @scheme.has_other_client_group == "Yes" %>
@ -48,7 +48,7 @@
<% row.action( <% row.action(
text: "Change", text: "Change",
href: scheme_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true), href: scheme_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true),
) %> ) %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
@ -59,7 +59,7 @@
<% row.action( <% row.action(
text: "Change", text: "Change",
href: scheme_support_path(scheme_id: @scheme.id, check_answers: true), href: scheme_support_path(scheme_id: @scheme.id, check_answers: true),
) %> ) %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
@ -94,7 +94,7 @@
<% row.cell(text: location.id) %> <% row.cell(text: location.id) %>
<% row.cell(text: simple_format(location_cell(location), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> <% row.cell(text: simple_format(location_cell(location), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: location.total_units) %> <% row.cell(text: location.total_units) %>
<% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>#{location.wheelchair_adaptation == "Yes" ? "\n<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">With wheelchair adaptations</span>" : ""}")) %> <% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>#{location.wheelchair_adaptation == 'Yes' ? "\n<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">With wheelchair adaptations</span>" : ''}")) %>
<% row.cell(text: "Delete") %> <% row.cell(text: "Delete") %>
<% end %> <% end %>
<% end %> <% end %>

4
app/views/schemes/locations.html.erb

@ -4,7 +4,7 @@
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: "/schemes/#{@scheme.id}", href: "/schemes/#{@scheme.id}",
) %> ) %>
<% end %> <% end %>
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<% location_caption = @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations" %> <% location_caption = @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations" %>
@ -41,7 +41,7 @@
<% row.cell(text: location.id) %> <% row.cell(text: location.id) %>
<% row.cell(text: location.postcode) %> <% row.cell(text: location.postcode) %>
<% row.cell(text: location.total_units) %> <% row.cell(text: location.total_units) %>
<% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>#{location.wheelchair_adaptation == "Yes" ? "\n<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">With wheelchair adaptations</span>" : ""}")) %> <% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>#{location.wheelchair_adaptation == 'Yes' ? "\n<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">With wheelchair adaptations</span>" : ''}")) %>
<% row.cell(text: "Delete") %> <% row.cell(text: "Delete") %>
<% end %> <% end %>
<% end %> <% end %>

2
spec/features/schemes_spec.rb

@ -461,7 +461,7 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_content "Self-contained house" expect(page).to have_content "Self-contained house"
end end
context "changing location details" do context "when changing location details" do
before do before do
click_link "XX11XX" click_link "XX11XX"
fill_in "Postcode", with: "ZZ1 1ZZ" fill_in "Postcode", with: "ZZ1 1ZZ"

2
spec/helpers/tab_nav_helper_spec.rb

@ -4,7 +4,7 @@ RSpec.describe TabNavHelper do
let(:organisation) { FactoryBot.create(:organisation) } let(:organisation) { FactoryBot.create(:organisation) }
let(:user) { FactoryBot.build(:user, organisation:) } let(:user) { FactoryBot.build(:user, organisation:) }
let(:scheme) { FactoryBot.create(:scheme, service_name: "Some name") } let(:scheme) { FactoryBot.create(:scheme, service_name: "Some name") }
let(:location) { FactoryBot.create(:location, scheme: scheme) } let(:location) { FactoryBot.create(:location, scheme:) }
describe "#user_cell" do describe "#user_cell" do
it "returns user link and email separated by a newline character" do it "returns user link and email separated by a newline character" do

4
spec/models/location_spec.rb

@ -14,13 +14,13 @@ RSpec.describe Location, type: :model do
it "does not add an error if postcode is valid" do it "does not add an error if postcode is valid" do
location.postcode = "M1 1AE" location.postcode = "M1 1AE"
location.save location.save!
expect(location.errors).to be_empty expect(location.errors).to be_empty
end end
it "does add an error when the postcode is invalid" do it "does add an error when the postcode is invalid" do
location.postcode = "invalid" location.postcode = "invalid"
location.save location.save!
expect(location.errors).not_to be_empty expect(location.errors).not_to be_empty
expect(location.errors["postcode"]).to include(match I18n.t("validations.postcode")) expect(location.errors["postcode"]).to include(match I18n.t("validations.postcode"))
end end

8
spec/requests/locations_controller_spec.rb

@ -324,7 +324,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a data coordinator" do context "when signed in as a data coordinator" do
let(:user) { FactoryBot.create(:user, :data_coordinator) } let(:user) { FactoryBot.create(:user, :data_coordinator) }
let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) } let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) }
let!(:location) { FactoryBot.create(:location, scheme: scheme) } let!(:location) { FactoryBot.create(:location, scheme:) }
before do before do
sign_in user sign_in user
@ -349,7 +349,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a support user" do context "when signed in as a support user" do
let(:user) { FactoryBot.create(:user, :support) } let(:user) { FactoryBot.create(:user, :support) }
let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) } let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) }
let!(:location) { FactoryBot.create(:location, scheme: scheme) } let!(:location) { FactoryBot.create(:location, scheme:) }
before do before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false) allow(user).to receive(:need_two_factor_authentication?).and_return(false)
@ -389,7 +389,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a data coordinator" do context "when signed in as a data coordinator" do
let(:user) { FactoryBot.create(:user, :data_coordinator) } let(:user) { FactoryBot.create(:user, :data_coordinator) }
let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) } let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) }
let!(:location) { FactoryBot.create(:location, scheme: scheme) } let!(:location) { FactoryBot.create(:location, scheme:) }
let(:params) { { location: { name: "Test", total_units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "No", postcode: "ZZ1 1ZZ" } } } let(:params) { { location: { name: "Test", total_units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "No", postcode: "ZZ1 1ZZ" } } }
before do before do
@ -502,7 +502,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a support user" do context "when signed in as a support user" do
let(:user) { FactoryBot.create(:user, :data_coordinator) } let(:user) { FactoryBot.create(:user, :data_coordinator) }
let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) } let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) }
let!(:location) { FactoryBot.create(:location, scheme: scheme) } let!(:location) { FactoryBot.create(:location, scheme:) }
let(:params) { { location: { name: "Test", total_units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "No", postcode: "ZZ1 1ZZ" } } } let(:params) { { location: { name: "Test", total_units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "No", postcode: "ZZ1 1ZZ" } } }
before do before do

Loading…
Cancel
Save