Browse Source

rubocop

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

2
app/controllers/locations_controller.rb

@ -51,7 +51,7 @@ private
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[: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
end
end

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

@ -3,7 +3,7 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: "/schemes/#{@scheme.id}/support"
href: "/schemes/#{@scheme.id}/support",
) %>
<% end %>

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

@ -3,7 +3,7 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: "/schemes/#{@scheme.id}/support"
href: "/schemes/#{@scheme.id}/support",
) %>
<% end %>

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

@ -94,7 +94,7 @@
<% row.cell(text: location.id) %>
<% 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: 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") %>
<% end %>
<% end %>

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

@ -41,7 +41,7 @@
<% row.cell(text: location.id) %>
<% row.cell(text: location.postcode) %>
<% 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") %>
<% 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"
end
context "changing location details" do
context "when changing location details" do
before do
click_link "XX11XX"
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(:user) { FactoryBot.build(:user, organisation:) }
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
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
location.postcode = "M1 1AE"
location.save
location.save!
expect(location.errors).to be_empty
end
it "does add an error when the postcode is invalid" do
location.postcode = "invalid"
location.save
location.save!
expect(location.errors).not_to be_empty
expect(location.errors["postcode"]).to include(match I18n.t("validations.postcode"))
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
let(:user) { FactoryBot.create(:user, :data_coordinator) }
let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) }
let!(:location) { FactoryBot.create(:location, scheme: scheme) }
let!(:location) { FactoryBot.create(:location, scheme:) }
before do
sign_in user
@ -349,7 +349,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a support user" do
let(:user) { FactoryBot.create(:user, :support) }
let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) }
let!(:location) { FactoryBot.create(:location, scheme: scheme) }
let!(:location) { FactoryBot.create(:location, scheme:) }
before do
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
let(:user) { FactoryBot.create(:user, :data_coordinator) }
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" } } }
before do
@ -502,7 +502,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a support user" do
let(:user) { FactoryBot.create(:user, :data_coordinator) }
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" } } }
before do

Loading…
Cancel
Save