|
|
@ -4,6 +4,7 @@ RSpec.describe Organisation, type: :model do |
|
|
|
describe "#new" do |
|
|
|
describe "#new" do |
|
|
|
let(:user) { FactoryBot.create(:user) } |
|
|
|
let(:user) { FactoryBot.create(:user) } |
|
|
|
let!(:organisation) { user.organisation } |
|
|
|
let!(:organisation) { user.organisation } |
|
|
|
|
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, organisation: organisation) } |
|
|
|
|
|
|
|
|
|
|
|
it "has expected fields" do |
|
|
|
it "has expected fields" do |
|
|
|
expect(organisation.attribute_names).to include("name", "phone", "provider_type") |
|
|
|
expect(organisation.attribute_names).to include("name", "phone", "provider_type") |
|
|
@ -13,6 +14,10 @@ RSpec.describe Organisation, type: :model do |
|
|
|
expect(organisation.users.first).to eq(user) |
|
|
|
expect(organisation.users.first).to eq(user) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "has schemes" do |
|
|
|
|
|
|
|
expect(organisation.schemes.first).to eq(scheme) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "validates provider_type presence" do |
|
|
|
it "validates provider_type presence" do |
|
|
|
expect { FactoryBot.create(:organisation, provider_type: nil) } |
|
|
|
expect { FactoryBot.create(:organisation, provider_type: nil) } |
|
|
|
.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Provider type can’t be blank") |
|
|
|
.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Provider type can’t be blank") |
|
|
|