diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index 008738944..c08ce099e 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -155,6 +155,8 @@ private end when "new_organisation_name" @merge_request.errors.add(:new_organisation_name, :blank) if merge_request_params[:new_organisation_name].blank? + when "new_organisation_telephone_number" + @merge_request.errors.add(:new_organisation_telephone_number, :blank) if merge_request_params[:new_organisation_telephone_number].blank? end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 0e2500dce..c323a257e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -135,7 +135,8 @@ en: new_organisation_name: blank: "Enter an organisation name" invalid: "An organisation with this name already exists" - + new_organisation_telephone_number: + blank: "Enter a valid telephone number" validations: diff --git a/spec/requests/merge_requests_controller_spec.rb b/spec/requests/merge_requests_controller_spec.rb index 5d1add64a..d76cf07e0 100644 --- a/spec/requests/merge_requests_controller_spec.rb +++ b/spec/requests/merge_requests_controller_spec.rb @@ -687,33 +687,10 @@ RSpec.describe MergeRequestsController, type: :request do it "renders the error" do request - expect(page).to have_content("Enter a telephone number") - end - - it "does not update the organisation name" do - expect { request }.not_to(change { merge_request.reload.attributes }) - end - end - - context "when the new organisation telephone number already exists" do - before do - create(:organisation, phone: "1234") - end - - let(:params) do - { merge_request: { new_organisation_telephone_number: "1234", page: "new_organisation_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("An organisation with this telephone number already exists") + expect(page).to have_content("Enter a valid telephone number") end - it "does not update the organisation name" do + it "does not update the organisation telephone number" do expect { request }.not_to(change { merge_request.reload.attributes }) end end