Browse Source

Updates

pull/2798/head
Manny Dinssa 1 year ago
parent
commit
d3077ae156
  1. 2
      spec/factories/location.rb
  2. 30
      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
trait :incomplete do
mobility_type { nil }
units { nil }
confirmed { false }
end

30
spec/models/location_spec.rb

@ -740,11 +740,39 @@ RSpec.describe Location, type: :model do
describe "#units" do
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
it "adds an error when units is nil" do
location.units = nil
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
describe "#type_of_unit" do

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.")
end
it "produces no error when location is completes" do
location.update!(mobility_type: "A")
it "produces no error when location is complete" do
location.update!(units: 1)
location.reload
record.location = location
setup_validator.validate_location(record)

Loading…
Cancel
Save