Browse Source

fixed (#766)

pull/770/head
J G 2 years ago committed by GitHub
parent
commit
913ad2ad00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/controllers/locations_controller.rb
  2. 20
      spec/requests/locations_controller_spec.rb

2
app/controllers/locations_controller.rb

@ -62,7 +62,7 @@ private
end end
def is_integer?(string) def is_integer?(string)
string.to_i.to_s == string string.sub(/^0+/, "").to_i.to_s == string.sub(/^0+/, "")
end end
def find_scheme def find_scheme

20
spec/requests/locations_controller_spec.rb

@ -123,6 +123,26 @@ RSpec.describe LocationsController, type: :request do
end end
end end
context "when startdate is submitted with leading zeroes" do
let(:params) do
{ location: {
name: "Test",
units: "5",
type_of_unit: "Bungalow",
add_another_location: "No",
postcode: "zz1 1zz",
mobility_type: "N",
"startdate(3i)" => "01",
"startdate(2i)" => "01",
"startdate(1i)" => "2022",
} }
end
it "creates a new location for scheme with postcode " do
expect(Location.last.startdate).to eq(Time.utc(2022, 1, 1))
end
end
context "when trying to add location to a scheme that belongs to another organisation" do context "when trying to add location to a scheme that belongs to another organisation" do
let(:another_scheme) { FactoryBot.create(:scheme) } let(:another_scheme) { FactoryBot.create(:scheme) }
let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", add_another_location: "No", postcode: "ZZ1 1ZZ", mobility_type: "N" } } } let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", add_another_location: "No", postcode: "ZZ1 1ZZ", mobility_type: "N" } } }

Loading…
Cancel
Save