Browse Source

a further test

pull/1628/head
Arthur Campbell 3 years ago
parent
commit
099212fca8
  1. 12
      spec/models/sales_log_spec.rb

12
spec/models/sales_log_spec.rb

@ -26,9 +26,7 @@ RSpec.describe SalesLog, type: :model do
describe "#new" do
context "when creating a record" do
let(:sales_log) do
described_class.create
end
let(:sales_log) { described_class.create }
it "attaches the correct custom validator" do
expect(sales_log._validators.values.flatten.map(&:class))
@ -54,6 +52,14 @@ RSpec.describe SalesLog, type: :model do
end
end
describe "resetting invalid answers" do
let(:sales_log) { create(:sales_log, ownershipsch: 2, type: 8) }
it "resets attributes that have become invalid when the sales log is updated" do
expect { sales_log.update!(ownershipsch: 1) }.to change(sales_log, :type).from(8).to(nil)
end
end
describe "#optional_fields" do
context "when saledate is before 2023" do
let(:sales_log) { build(:sales_log, saledate: Time.zone.parse("2022-07-01")) }

Loading…
Cancel
Save