Browse Source

fixup! CLDC-4145: Update tests

turns out editing the future form use is not possible for tests, too many depend on it failing

use timecop instead
CLDC-4145-dont-ask-partner-for-children
Samuel Young 3 days ago
parent
commit
d47d643d13
  1. 2
      app/services/feature_toggle.rb
  2. 41
      spec/models/lettings_log_derived_fields_spec.rb

2
app/services/feature_toggle.rb

@ -1,6 +1,6 @@
class FeatureToggle
def self.allow_future_form_use?
Rails.env.development? || Rails.env.review? || Rails.env.staging? || Rails.env.test?
Rails.env.development? || Rails.env.review? || Rails.env.staging?
end
def self.bulk_upload_duplicate_log_check_enabled?

41
spec/models/lettings_log_derived_fields_spec.rb

@ -1251,6 +1251,12 @@ RSpec.describe LettingsLog, type: :model do
context "and it is 2025", metadata: { year: 25 } do
let(:startdate) { collection_start_date_for_year(2025) }
around do |example|
Timecop.freeze(collection_start_date_for_year(2025)) do
example.run
end
end
it "does not clear the relationship" do
expect { log.set_derived_fields! }.to not_change(log, :relat2)
end
@ -1259,6 +1265,13 @@ RSpec.describe LettingsLog, type: :model do
context "and it is 2026", metadata: { year: 26 } do
let(:startdate) { collection_start_date_for_year(2026) }
around do |example|
Timecop.freeze(collection_start_date_for_year(2026)) do
Singleton.__init__(FormHandler)
example.run
end
end
it "clears the relationship" do
expect { log.set_derived_fields! }.to change(log, :relat2).from("X").to(nil)
end
@ -1276,6 +1289,13 @@ RSpec.describe LettingsLog, type: :model do
context "and it is 2025", metadata: { year: 25 } do
let(:startdate) { collection_start_date_for_year(2025) }
around do |example|
Timecop.freeze(collection_start_date_for_year(2025)) do
Singleton.__init__(FormHandler)
example.run
end
end
it "does not clear the relationship" do
expect { log.set_derived_fields! }.to not_change(log, :relat2)
end
@ -1284,6 +1304,13 @@ RSpec.describe LettingsLog, type: :model do
context "and it is 2026", metadata: { year: 26 } do
let(:startdate) { collection_start_date_for_year(2026) }
around do |example|
Timecop.freeze(collection_start_date_for_year(2026)) do
Singleton.__init__(FormHandler)
example.run
end
end
it "does not clear the relationship" do
expect { log.set_derived_fields! }.to not_change(log, :relat2)
end
@ -1301,6 +1328,13 @@ RSpec.describe LettingsLog, type: :model do
context "and it is 2025", metadata: { year: 25 } do
let(:startdate) { collection_start_date_for_year(2025) }
around do |example|
Timecop.freeze(collection_start_date_for_year(2025)) do
Singleton.__init__(FormHandler)
example.run
end
end
it "does not clear the relationship" do
expect { log.set_derived_fields! }.to not_change(log, :relat2)
end
@ -1309,6 +1343,13 @@ RSpec.describe LettingsLog, type: :model do
context "and it is 2026", metadata: { year: 26 } do
let(:startdate) { collection_start_date_for_year(2026) }
around do |example|
Timecop.freeze(collection_start_date_for_year(2026)) do
Singleton.__init__(FormHandler)
example.run
end
end
it "does not clear the relationship" do
expect { log.set_derived_fields! }.to not_change(log, :relat2)
end

Loading…
Cancel
Save