Browse Source

Update policy tests

pull/2432/head
Kat 2 years ago
parent
commit
0385c1d452
  1. 10
      spec/policies/location_policy_spec.rb
  2. 12
      spec/policies/scheme_policy_spec.rb
  3. 9
      spec/policies/user_policy_spec.rb

10
spec/policies/location_policy_spec.rb

@ -44,18 +44,12 @@ RSpec.describe LocationPolicy do
context "with deactivated location" do context "with deactivated location" do
before do before do
location.location_deactivation_periods << create(:location_deactivation_period, deactivation_date: Time.zone.local(2024, 4, 10), location:) location.location_deactivation_periods << create(:location_deactivation_period, deactivation_date: Time.zone.today, location:)
location.save! location.save!
Timecop.freeze(Time.utc(2024, 4, 10)) log = build(:lettings_log, scheme: location.scheme, location:, startdate: Time.zone.today - 2.years)
log = create(:lettings_log, scheme: location.scheme, location:)
log.startdate = Time.zone.local(2022, 10, 10)
log.save!(validate: false) log.save!(validate: false)
end end
after do
Timecop.unfreeze
end
context "and associated logs in editable collection period" do context "and associated logs in editable collection period" do
before do before do
create(:lettings_log, scheme: location.scheme, location:) create(:lettings_log, scheme: location.scheme, location:)

12
spec/policies/scheme_policy_spec.rb

@ -46,21 +46,15 @@ RSpec.describe SchemePolicy do
context "with deactivated scheme" do context "with deactivated scheme" do
before do before do
scheme.scheme_deactivation_periods << create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2024, 4, 10), scheme:) scheme.scheme_deactivation_periods << create(:scheme_deactivation_period, deactivation_date: Time.zone.today, scheme:)
scheme.save! scheme.save!
Timecop.freeze(Time.utc(2024, 4, 10)) log = build(:lettings_log, :sh, owning_organisation: scheme.owning_organisation, scheme:, startdate: Time.zone.today - 2.years)
log = create(:lettings_log, :sh, owning_organisation: scheme.owning_organisation, scheme:)
log.startdate = Time.zone.local(2022, 10, 10)
log.save!(validate: false) log.save!(validate: false)
end end
after do
Timecop.unfreeze
end
context "and associated logs in editable collection period" do context "and associated logs in editable collection period" do
before do before do
create(:lettings_log, :sh, owning_organisation: scheme.owning_organisation, scheme:, startdate: Time.zone.local(2024, 4, 9)) create(:lettings_log, :sh, owning_organisation: scheme.owning_organisation, scheme:, startdate: Time.zone.yesterday)
end end
it "does not allow deleting a scheme as a provider" do it "does not allow deleting a scheme as a provider" do

9
spec/policies/user_policy_spec.rb

@ -144,19 +144,14 @@ RSpec.describe UserPolicy do
let(:user) { create(:user, active: false) } let(:user) { create(:user, active: false) }
before do before do
Timecop.freeze(Time.utc(2024, 4, 10)) log = build(:lettings_log, owning_organisation: user.organisation, assigned_to: user, startdate: Time.zone.today - 2.years)
log = create(:lettings_log, owning_organisation: user.organisation, assigned_to: user)
log.startdate = Time.zone.local(2022, 10, 10)
log.save!(validate: false) log.save!(validate: false)
end end
after do
Timecop.unfreeze
end
context "and associated logs in editable collection period" do context "and associated logs in editable collection period" do
before do before do
create(:lettings_log, :sh, owning_organisation: user.organisation, assigned_to: user, startdate: Time.zone.local(2024, 4, 9)) create(:lettings_log, :sh, owning_organisation: user.organisation, assigned_to: user, startdate: Time.zone.yesterday)
end end
it "does not allow deleting a user as a provider" do it "does not allow deleting a user as a provider" do

Loading…
Cancel
Save