|
|
@ -233,6 +233,38 @@ RSpec.describe MergeRequestsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe "#confirm_telephone_number" do |
|
|
|
|
|
|
|
let(:merge_request) do |
|
|
|
|
|
|
|
MergeRequest.create!( |
|
|
|
|
|
|
|
absorbing_organisation: create(:organisation, phone: phone_number), |
|
|
|
|
|
|
|
requesting_organisation: organisation, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before { get "/merge-request/#{merge_request.id}/confirm-telephone-number", headers: } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when org has phone number" do |
|
|
|
|
|
|
|
let(:phone_number) { 123 } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "asks to confirm or provide new number" do |
|
|
|
|
|
|
|
expect(page).to have_content("This telephone number is correct") |
|
|
|
|
|
|
|
expect(page).to have_content("Confirm the telephone number on file, or enter a new one.") |
|
|
|
|
|
|
|
expect(page).to have_content(phone_number) |
|
|
|
|
|
|
|
expect(page).to have_content("What is #{merge_request.absorbing_organisation.name}'s telephone number?") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when org does not have a phone number set" do |
|
|
|
|
|
|
|
let(:phone_number) { nil } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "asks provide new number" do |
|
|
|
|
|
|
|
expect(page).not_to have_content("This telephone number is correct") |
|
|
|
|
|
|
|
expect(page).not_to have_content("Confirm the telephone number on file, or enter a new one.") |
|
|
|
|
|
|
|
expect(page).to have_content("What is #{merge_request.absorbing_organisation.name}'s telephone number?") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "#update" do |
|
|
|
describe "#update" do |
|
|
|
before { sign_in user } |
|
|
|
before { sign_in user } |
|
|
|
|
|
|
|
|
|
|
@ -260,72 +292,184 @@ RSpec.describe MergeRequestsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when not answering the question" do |
|
|
|
describe "from absorbing_organisation page" do |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, absorbing_organisation: other_organisation) } |
|
|
|
context "when not answering the question" do |
|
|
|
let(:params) do |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, absorbing_organisation: other_organisation) } |
|
|
|
{ merge_request: { page: "absorbing_organisation" } } |
|
|
|
let(:params) do |
|
|
|
end |
|
|
|
{ merge_request: { page: "absorbing_organisation" } } |
|
|
|
let(:request) do |
|
|
|
end |
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
let(:request) do |
|
|
|
|
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "renders the error" do |
|
|
|
|
|
|
|
request |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(page).to have_content("Select the organisation absorbing the others") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does not update the request" do |
|
|
|
|
|
|
|
expect { request }.not_to(change { merge_request.reload.attributes }) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "renders the error" do |
|
|
|
context "when absorbing_organisation_id set to other" do |
|
|
|
request |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, absorbing_organisation: other_organisation) } |
|
|
|
|
|
|
|
let(:params) do |
|
|
|
|
|
|
|
{ merge_request: { absorbing_organisation_id: "other", page: "absorbing_organisation" } } |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
let(:request) do |
|
|
|
|
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "redirects to new org path" do |
|
|
|
|
|
|
|
request |
|
|
|
|
|
|
|
|
|
|
|
expect(page).to have_content("Select the organisation absorbing the others") |
|
|
|
expect(response).to redirect_to(new_org_name_merge_request_path(merge_request)) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "resets absorbing_organisation and sets new_absorbing_organisation to true" do |
|
|
|
|
|
|
|
expect { request }.to change { |
|
|
|
|
|
|
|
merge_request.reload.absorbing_organisation |
|
|
|
|
|
|
|
}.from(other_organisation).to(nil).and change { |
|
|
|
|
|
|
|
merge_request.reload.new_absorbing_organisation |
|
|
|
|
|
|
|
}.from(nil).to(true) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "does not update the request" do |
|
|
|
context "when absorbing_organisation_id set to id" do |
|
|
|
expect { request }.not_to(change { merge_request.reload.attributes }) |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, new_absorbing_organisation: true) } |
|
|
|
|
|
|
|
let(:params) do |
|
|
|
|
|
|
|
{ merge_request: { absorbing_organisation_id: other_organisation.id, page: "absorbing_organisation" } } |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let(:request) do |
|
|
|
|
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "redirects telephone number path" do |
|
|
|
|
|
|
|
request |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(response).to redirect_to(confirm_telephone_number_merge_request_path(merge_request)) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "updates absorbing_organisation_id and sets new_absorbing_organisation to false" do |
|
|
|
|
|
|
|
expect { request }.to change { |
|
|
|
|
|
|
|
merge_request.reload.absorbing_organisation |
|
|
|
|
|
|
|
}.from(nil).to(other_organisation).and change { |
|
|
|
|
|
|
|
merge_request.reload.new_absorbing_organisation |
|
|
|
|
|
|
|
}.from(true).to(false) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when absorbing_organisation_id set to other" do |
|
|
|
describe "from confirm_telephone_number page" do |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, absorbing_organisation: other_organisation) } |
|
|
|
context "when confirming the number" do |
|
|
|
let(:params) do |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, new_absorbing_organisation: true, new_telephone_number: "123") } |
|
|
|
{ merge_request: { absorbing_organisation_id: "other", page: "absorbing_organisation" } } |
|
|
|
let(:params) do |
|
|
|
end |
|
|
|
{ merge_request: { telephone_number_correct: "1", page: "confirm_telephone_number" } } |
|
|
|
let(:request) do |
|
|
|
end |
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "redirects to new org path" do |
|
|
|
let(:request) do |
|
|
|
request |
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to redirect_to(new_org_name_merge_request_path(merge_request)) |
|
|
|
it "redirects telephone number path" do |
|
|
|
end |
|
|
|
request |
|
|
|
|
|
|
|
|
|
|
|
it "resets absorbing_organisation and sets new_absorbing_organisation to true" do |
|
|
|
expect(response).to redirect_to(merge_date_merge_request_path(merge_request)) |
|
|
|
expect { request }.to change { |
|
|
|
end |
|
|
|
merge_request.reload.absorbing_organisation |
|
|
|
|
|
|
|
}.from(other_organisation).to(nil).and change { |
|
|
|
it "updates telephone_number_correct and sets new_telephone_number to nil" do |
|
|
|
merge_request.reload.new_absorbing_organisation |
|
|
|
expect { request }.to change { |
|
|
|
}.from(nil).to(true) |
|
|
|
merge_request.reload.telephone_number_correct |
|
|
|
|
|
|
|
}.from(nil).to(true).and change { |
|
|
|
|
|
|
|
merge_request.reload.new_telephone_number |
|
|
|
|
|
|
|
}.from("123").to(nil) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when absorbing_organisation_id set to id" do |
|
|
|
context "when setting new number" do |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, new_absorbing_organisation: true) } |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, new_absorbing_organisation: true) } |
|
|
|
let(:params) do |
|
|
|
let(:params) do |
|
|
|
{ merge_request: { absorbing_organisation_id: other_organisation.id, page: "absorbing_organisation" } } |
|
|
|
{ merge_request: { telephone_number_correct: "0", new_telephone_number: "123", page: "confirm_telephone_number" } } |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let(:request) do |
|
|
|
|
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "redirects telephone number path" do |
|
|
|
|
|
|
|
request |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(response).to redirect_to(merge_date_merge_request_path(merge_request)) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "updates telephone_number_correct and sets new_telephone_number to nil" do |
|
|
|
|
|
|
|
expect { request }.to change { |
|
|
|
|
|
|
|
merge_request.reload.new_telephone_number |
|
|
|
|
|
|
|
}.from(nil).to("123") |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
let(:request) do |
|
|
|
context "when not answering the question and the org has phone number" do |
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, absorbing_organisation: create(:organisation, phone: "123")) } |
|
|
|
|
|
|
|
let(:params) do |
|
|
|
|
|
|
|
{ merge_request: { page: "confirm_telephone_number" } } |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
let(:request) do |
|
|
|
|
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "renders the error" do |
|
|
|
|
|
|
|
request |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(page).to have_content("Select to confirm or enter a new telephone number") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does not update the request" do |
|
|
|
|
|
|
|
expect { request }.not_to(change { merge_request.reload.attributes }) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "redirects telephone number path" do |
|
|
|
context "when not answering the question and the org does not have a phone number" do |
|
|
|
request |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, absorbing_organisation: other_organisation) } |
|
|
|
|
|
|
|
let(:params) do |
|
|
|
|
|
|
|
{ merge_request: { page: "confirm_telephone_number" } } |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
let(:request) do |
|
|
|
|
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "renders the error" do |
|
|
|
|
|
|
|
request |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(page).to have_content("Enter a valid telephone number") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to redirect_to(confirm_telephone_number_merge_request_path(merge_request)) |
|
|
|
it "does not update the request" do |
|
|
|
|
|
|
|
expect { request }.not_to(change { merge_request.reload.attributes }) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "updates absorbing_organisation_id and sets new_absorbing_organisation to false" do |
|
|
|
context "when not answering the phone number" do |
|
|
|
expect { request }.to change { |
|
|
|
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, absorbing_organisation: other_organisation) } |
|
|
|
merge_request.reload.absorbing_organisation |
|
|
|
let(:params) do |
|
|
|
}.from(nil).to(other_organisation).and change { |
|
|
|
{ merge_request: { page: "confirm_telephone_number", telephone_number_correct: "0" } } |
|
|
|
merge_request.reload.new_absorbing_organisation |
|
|
|
end |
|
|
|
}.from(true).to(false) |
|
|
|
let(:request) do |
|
|
|
|
|
|
|
patch "/merge-request/#{merge_request.id}", headers:, params: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "renders the error" do |
|
|
|
|
|
|
|
request |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(page).to have_content("Enter a valid telephone number") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does not update the request" do |
|
|
|
|
|
|
|
expect { request }.not_to(change { merge_request.reload.attributes }) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|