Browse Source

test: add test for invalid owning org id (invalid as doesn't hold stock)

pull/1027/head
Sam Seed 4 years ago
parent
commit
48e20d557a
  1. 15
      spec/requests/schemes_controller_spec.rb

15
spec/requests/schemes_controller_spec.rb

@ -585,6 +585,21 @@ RSpec.describe SchemesController, type: :request do
expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.owning_organisation_id.invalid")) expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.owning_organisation_id.invalid"))
end end
end end
context "when organisation id param refers to a non-stock-owning organisation" do
let(:organisation_which_does_not_own_stock) { FactoryBot.create(:organisation, holds_own_stock: false) }
let(:params) do
{ scheme: {
owning_organisation_id: organisation_which_does_not_own_stock.id,
} }
end
it "displays the new page with an error message" do
post "/schemes", params: params
expect(response).to have_http_status(:unprocessable_entity)
expect(page).to have_content(I18n.t("validations.scheme.owning_organisation.does_not_own_stock"))
end
end
end end
end end

Loading…
Cancel
Save