From feec0a24cf1e718858820a926ea34318f4065787 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Mon, 6 Jun 2022 13:20:44 +0100 Subject: [PATCH] Check params are set correctly --- .../requests/organisations_controller_spec.rb | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index 138effaaa..74d7aba46 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -844,17 +844,25 @@ RSpec.describe OrganisationsController, type: :request do end describe "#create" do + let(:name) { "Unique new org name" } + let(:address_line1) { "12 Random Street" } + let(:address_line2) { "Manchester" } + let(:postcode) { "MD1 5TR" } + let(:phone) { "011101101" } + let(:provider_type) { "LA" } + let(:holds_own_stock) { "true" } + let(:housing_registration_no) { "7917937" } let(:params) do { "organisation": { - name: "new organisation", - address_line1: "12 Random Street", - address_line2: "Manchester", - postcode: "MD1 5TR", - phone: "011101101", - provider_type: "LA", - holds_own_stock: "true", - housing_registration_no: "7917937", + name:, + address_line1:, + address_line2:, + postcode:, + phone:, + provider_type:, + holds_own_stock:, + housing_registration_no:, }, } end @@ -864,6 +872,17 @@ RSpec.describe OrganisationsController, type: :request do expect { request }.to change(Organisation, :count).by(1) end + it "sets the organisation attributes correctly" do + request + organisation = Organisation.find_by(housing_registration_no:) + expect(organisation.name).to eq(name) + expect(organisation.address_line1).to eq(address_line1) + expect(organisation.address_line2).to eq(address_line2) + expect(organisation.postcode).to eq(postcode) + expect(organisation.phone).to eq(phone) + expect(organisation.holds_own_stock).to be true + end + it "redirects to the organisation list" do request expect(response).to redirect_to("/organisations")