Browse Source

Updates

pull/2798/head
Manny Dinssa 1 year ago
parent
commit
d3077ae156
  1. 2
      spec/factories/location.rb
  2. 36
      spec/models/location_spec.rb
  3. 4
      spec/models/validations/setup_validations_spec.rb

2
spec/factories/location.rb

@ -22,7 +22,7 @@ FactoryBot.define do
end end
trait :incomplete do trait :incomplete do
mobility_type { nil } units { nil }
confirmed { false } confirmed { false }
end end

36
spec/models/location_spec.rb

@ -740,10 +740,38 @@ RSpec.describe Location, type: :model do
describe "#units" do describe "#units" do
let(:location) { FactoryBot.build(:location) } let(:location) { FactoryBot.build(:location) }
it "does add an error when the number of units is invalid" do context "when the number of units is invalid" do
location.units = nil it "adds an error when units is nil" do
location.valid?(:units) location.units = nil
expect(location.errors.count).to eq(2) location.valid?(:units)
expect(location.errors.count).to eq(2)
end
it "adds an error when units is 0" do
location.units = 0
location.valid?(:units)
expect(location.errors.count).to eq(2)
end
end
context "when the number of units is valid" do
it "does not add an error when units is 1" do
location.units = 1
location.valid?(:units)
expect(location.errors.count).to eq(0)
end
it "does not add an error when units is 10" do
location.units = 10
location.valid?(:units)
expect(location.errors.count).to eq(0)
end
it "does not add an error when units is 200" do
location.units = 200
location.valid?(:units)
expect(location.errors.count).to eq(0)
end
end end
end end

4
spec/models/validations/setup_validations_spec.rb

@ -703,8 +703,8 @@ RSpec.describe Validations::SetupValidations do
.to include("This location is incomplete. Select another location or update this one.") .to include("This location is incomplete. Select another location or update this one.")
end end
it "produces no error when location is completes" do it "produces no error when location is complete" do
location.update!(mobility_type: "A") location.update!(units: 1)
location.reload location.reload
record.location = location record.location = location
setup_validator.validate_location(record) setup_validator.validate_location(record)

Loading…
Cancel
Save