|
|
|
|
@ -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 |
|
|
|
|
|