Browse Source

thanks rubocop

pull/704/head
JG 3 years ago
parent
commit
68d7614efe
  1. 5
      app/controllers/locations_controller.rb
  2. 6
      db/migrate/20220630114748_add_name_to_locations.rb
  3. 6
      db/migrate/20220630120251_change_location_type_of_unit.rb
  4. 1
      spec/requests/locations_controller_spec.rb

5
app/controllers/locations_controller.rb

@ -14,7 +14,7 @@ class LocationsController < ApplicationController
if @location.save
redirect_to scheme_check_answers_path(scheme_id: @scheme.id) if location_params[:add_another_location] == "No"
redirect_to location_new_scheme_path if location_params[:add_another_location] == "Yes"
elsif
else
render :new, status: :unprocessable_entity
end
end
@ -26,7 +26,6 @@ private
end
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)
end
end

6
db/migrate/20220630114748_add_name_to_locations.rb

@ -1,6 +1,6 @@
class AddNameToLocations < ActiveRecord::Migration[7.0]
def change
add_column :locations, :name, :string
add_column :locations, :total_units, :integer
change_table :locations, :bulk => true do |t|
t.string :name
t.integer :total_units
end
end

6
db/migrate/20220630120251_change_location_type_of_unit.rb

@ -1,6 +1,6 @@
class ChangeLocationTypeOfUnit < ActiveRecord::Migration[7.0]
def change
remove_column :locations, :type_of_unit
add_column :locations, :type_of_unit, :integer
change_table :locations, :bulk => true do |t|
t.remove :type_of_unit
t.integer :type_of_unit
end
end

1
spec/requests/locations_controller_spec.rb

@ -105,6 +105,7 @@ RSpec.describe LocationsController, type: :request do
context "when do you want to add another location is selected as yes" do
let(:params) { { location: { name: "Test", total_units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "Yes" } } }
it "creates a new location for scheme with valid params and redirects to correct page" do
expect { post "/schemes/#{scheme.id}/location/create", params: }.to change(Location, :count).by(1)
follow_redirect!

Loading…
Cancel
Save