|
|
|
|
@ -111,6 +111,51 @@ RSpec.describe Form::Sales::Questions::OwningOrganisationId, type: :model do
|
|
|
|
|
expect(question.displayed_answer_options(log, user)).to eq(options) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when user's org has recently absorbed other orgs" do |
|
|
|
|
let(:merged_organisation) { create(:organisation, name: "Merged org") } |
|
|
|
|
let(:options) do |
|
|
|
|
{ |
|
|
|
|
"" => "Select an option", |
|
|
|
|
user.organisation.id => "User org (Your organisation, active as of 2 February 2021)", |
|
|
|
|
owning_org_1.id => "Owning org 1", |
|
|
|
|
merged_organisation.id => "Merged org (inactive as of 2 February 2023)", |
|
|
|
|
owning_org_2.id => "Owning org 2", |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
merged_organisation.update!(merge_date: Time.zone.local(2023, 2, 2), absorbing_organisation: user.organisation) |
|
|
|
|
user.organisation.update!(created_at: Time.zone.local(2021, 2, 2)) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "shows merged organisation as an option" do |
|
|
|
|
expect(question.displayed_answer_options(log, user)).to eq(options) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when user's org has recently absorbed other orgs with parent organisations" do |
|
|
|
|
let(:merged_organisation) { create(:organisation, name: "Merged org") } |
|
|
|
|
let(:options) do |
|
|
|
|
{ |
|
|
|
|
"" => "Select an option", |
|
|
|
|
user.organisation.id => "User org (Your organisation, active as of 2 February 2021)", |
|
|
|
|
owning_org_1.id => "Owning org 1", |
|
|
|
|
merged_organisation.id => "Merged org (inactive as of 2 February 2023)", |
|
|
|
|
owning_org_2.id => "Owning org 2 (inactive as of 2 February 2023)", |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
org_rel.update!(child_organisation: merged_organisation) |
|
|
|
|
merged_organisation.update!(merge_date: Time.zone.local(2023, 2, 2), absorbing_organisation: user.organisation) |
|
|
|
|
user.organisation.update!(created_at: Time.zone.local(2021, 2, 2)) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "shows merged organisation as an option" do |
|
|
|
|
expect(question.displayed_answer_options(log, user)).to eq(options) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when user is support" do |
|
|
|
|
|