Browse Source

feat: update tests

pull/2061/head
natdeanlewissoftwire 2 years ago
parent
commit
84e539be0b
  1. 1
      spec/models/scheme_spec.rb
  2. 9
      spec/services/merge/merge_organisations_service_spec.rb

1
spec/models/scheme_spec.rb

@ -299,7 +299,6 @@ RSpec.describe Scheme, type: :model do
end
it "returns activating soon if the scheme has a future startdate" do
Timecop.freeze(2022, 6, 4)
scheme.startdate = Time.zone.local(2022, 7, 7)
scheme.save!
expect(scheme.status).to eq(:activating_soon)

9
spec/services/merge/merge_organisations_service_spec.rb

@ -305,9 +305,6 @@ RSpec.describe Merge::MergeOrganisationsService do
context "and merging organisation schemes and locations" do
let!(:scheme) { create(:scheme, owning_organisation: merging_organisation) }
let!(:location) { create(:location, scheme:) }
let!(:location_without_startdate) { create(:location, scheme:, startdate: nil) }
let!(:location_with_past_startdate) { create(:location, scheme:, startdate: Time.zone.today - 2.months) }
let!(:location_with_future_startdate) { create(:location, scheme:, startdate: Time.zone.today + 2.months) }
let!(:deactivated_location) { create(:location, scheme:) }
let!(:deactivated_scheme) { create(:scheme, owning_organisation: merging_organisation) }
let!(:owned_lettings_log) { create(:lettings_log, :sh, scheme:, location:, startdate: Time.zone.tomorrow, owning_organisation: merging_organisation) }
@ -321,6 +318,11 @@ RSpec.describe Merge::MergeOrganisationsService do
create(:lettings_log, startdate: Time.zone.tomorrow, managing_organisation: merging_organisation)
end
context "with multiple locations" do
let!(:location_without_startdate) { create(:location, scheme:, startdate: nil) }
let!(:location_with_past_startdate) { create(:location, scheme:, startdate: Time.zone.today - 2.months) }
let!(:location_with_future_startdate) { create(:location, scheme:, startdate: Time.zone.today + 2.months) }
it "combines organisation schemes and locations" do
expect(Rails.logger).to receive(:info).with("Merged users from fake org:")
expect(Rails.logger).to receive(:info).with("\tDanny Rojas (#{merging_organisation.data_protection_officers.first.email})")
@ -341,6 +343,7 @@ RSpec.describe Merge::MergeOrganisationsService do
expect(scheme.scheme_deactivation_periods.count).to eq(1)
expect(scheme.scheme_deactivation_periods.first.deactivation_date.to_date).to eq(Time.zone.yesterday)
end
end
it "moves relevant logs and assigns the new scheme" do
merge_organisations_service.call

Loading…
Cancel
Save