Browse Source

feat: update tests

pull/1604/head
natdeanlewissoftwire 3 years ago
parent
commit
2100b87443
  1. 2
      app/controllers/merge_requests_controller.rb
  2. 3
      config/locales/en.yml
  3. 27
      spec/requests/merge_requests_controller_spec.rb

2
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

3
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:

27
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

Loading…
Cancel
Save