|
|
@ -8,22 +8,22 @@ RSpec.describe Log, type: :model do |
|
|
|
|
|
|
|
|
|
|
|
describe "#calculate_status" do |
|
|
|
describe "#calculate_status" do |
|
|
|
it "returns the correct status for a completed sales log" do |
|
|
|
it "returns the correct status for a completed sales log" do |
|
|
|
complete_sales_log = create(:sales_log, :completed, status: nil) |
|
|
|
complete_sales_log = create(:sales_log, :completed, saledate: Time.zone.local(2023, 12, 12), status: nil) |
|
|
|
expect(complete_sales_log.calculate_status).to eq "completed" |
|
|
|
expect(complete_sales_log.calculate_status).to eq "completed" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns the correct status for an in progress sales log" do |
|
|
|
it "returns the correct status for an in progress sales log" do |
|
|
|
in_progress_sales_log = create(:sales_log, :in_progress, status: nil) |
|
|
|
in_progress_sales_log = create(:sales_log, :in_progress, saledate: Time.zone.local(2023, 12, 12), status: nil) |
|
|
|
expect(in_progress_sales_log.calculate_status).to eq "in_progress" |
|
|
|
expect(in_progress_sales_log.calculate_status).to eq "in_progress" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns the correct status for a completed lettings log" do |
|
|
|
it "returns the correct status for a completed lettings log" do |
|
|
|
complete_lettings_log = create(:lettings_log, :completed, status: nil) |
|
|
|
complete_lettings_log = create(:lettings_log, :completed, startdate: Time.zone.local(2023, 12, 12), voiddate: Time.zone.local(2023, 12, 11), mrcdate: Time.zone.local(2023, 12, 11), status: nil) |
|
|
|
expect(complete_lettings_log.calculate_status).to eq "completed" |
|
|
|
expect(complete_lettings_log.calculate_status).to eq "completed" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns the correct status for an in progress lettings log" do |
|
|
|
it "returns the correct status for an in progress lettings log" do |
|
|
|
in_progress_lettings_log = create(:lettings_log, :in_progress, status: nil) |
|
|
|
in_progress_lettings_log = create(:lettings_log, :in_progress, startdate: Time.zone.local(2023, 12, 12), status: nil) |
|
|
|
expect(in_progress_lettings_log.calculate_status).to eq "in_progress" |
|
|
|
expect(in_progress_lettings_log.calculate_status).to eq "in_progress" |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -48,7 +48,7 @@ RSpec.describe Log, type: :model do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when a non setup field is invalid for a lettings log" do |
|
|
|
context "when a non setup field is invalid for a lettings log" do |
|
|
|
subject(:model) { build(:lettings_log, :completed, offered: 234) } |
|
|
|
subject(:model) { build(:lettings_log, :completed, startdate: Time.zone.local(2023, 12, 12), offered: 234) } |
|
|
|
|
|
|
|
|
|
|
|
it "blanks it" do |
|
|
|
it "blanks it" do |
|
|
|
model.valid? |
|
|
|
model.valid? |
|
|
|