Browse Source

test: test validation raised when updating model with non-stock-owning org

pull/1027/head
Sam Seed 4 years ago
parent
commit
a83bebced4
  1. 12
      spec/models/scheme_spec.rb

12
spec/models/scheme_spec.rb

@ -209,4 +209,16 @@ RSpec.describe Scheme, type: :model do
end
end
end
describe "owning organisation" do
let(:stock_owning_org) { FactoryBot.create(:organisation, holds_own_stock: true) }
let(:non_stock_owning_org) { FactoryBot.create(:organisation, holds_own_stock: false) }
let(:scheme) { FactoryBot.create(:scheme, owning_organisation_id: stock_owning_org.id) }
context "when the owning organisation is set as a non-stock-owning organisation" do
it "throws the correct validation error" do
expect { scheme.update!({ owning_organisation_id: non_stock_owning_org.id }) }.to raise_error(ActiveRecord::RecordInvalid, /#{I18n.t("validations.scheme.owning_organisation.does_not_own_stock")}/)
end
end
end
end

Loading…
Cancel
Save