Browse Source

Check params are set correctly

pull/636/head
baarkerlounger 3 years ago
parent
commit
feec0a24cf
  1. 35
      spec/requests/organisations_controller_spec.rb

35
spec/requests/organisations_controller_spec.rb

@ -844,17 +844,25 @@ RSpec.describe OrganisationsController, type: :request do
end end
describe "#create" do 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 let(:params) do
{ {
"organisation": { "organisation": {
name: "new organisation", name:,
address_line1: "12 Random Street", address_line1:,
address_line2: "Manchester", address_line2:,
postcode: "MD1 5TR", postcode:,
phone: "011101101", phone:,
provider_type: "LA", provider_type:,
holds_own_stock: "true", holds_own_stock:,
housing_registration_no: "7917937", housing_registration_no:,
}, },
} }
end end
@ -864,6 +872,17 @@ RSpec.describe OrganisationsController, type: :request do
expect { request }.to change(Organisation, :count).by(1) expect { request }.to change(Organisation, :count).by(1)
end 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 it "redirects to the organisation list" do
request request
expect(response).to redirect_to("/organisations") expect(response).to redirect_to("/organisations")

Loading…
Cancel
Save