|
|
|
|
@ -5,48 +5,6 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
|
|
|
|
|
|
|
|
|
|
let(:validator_class) { Class.new { include Validations::Sales::SaleInformationValidations } } |
|
|
|
|
|
|
|
|
|
describe "#validate_deposit_range" do |
|
|
|
|
context "when within permitted bounds" do |
|
|
|
|
let(:record) { build(:sales_log, deposit: 0) } |
|
|
|
|
|
|
|
|
|
it "does not add an error" do |
|
|
|
|
sale_information_validator.validate_deposit_range(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors[:deposit]).not_to be_present |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when blank" do |
|
|
|
|
let(:record) { build(:sales_log, deposit: nil) } |
|
|
|
|
|
|
|
|
|
it "does not add an error" do |
|
|
|
|
sale_information_validator.validate_deposit_range(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors[:deposit]).not_to be_present |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when below lower bound" do |
|
|
|
|
let(:record) { build(:sales_log, deposit: -1) } |
|
|
|
|
|
|
|
|
|
it "adds an error" do |
|
|
|
|
sale_information_validator.validate_deposit_range(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors[:deposit]).to be_present |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when higher than upper bound" do |
|
|
|
|
let(:record) { build(:sales_log, deposit: 1_000_000) } |
|
|
|
|
|
|
|
|
|
it "adds an error" do |
|
|
|
|
sale_information_validator.validate_deposit_range(record) |
|
|
|
|
|
|
|
|
|
expect(record.errors[:deposit]).to be_present |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#validate_pratical_completion_date_before_saledate" do |
|
|
|
|
context "when hodate blank" do |
|
|
|
|
let(:record) { build(:sales_log, hodate: nil) } |
|
|
|
|
|