diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index b6414ac8e..2c2363c47 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" RSpec.describe Organisation, type: :model do describe "#new" do - let!(:user) { FactoryBot.create(:user) } - let(:organisation) { Organisation.first } + let(:user) { FactoryBot.create(:user) } + let(:organisation) { user.organisation } it "has expected fields" do expect(organisation.attribute_names).to include("name", "phone", "org_type") diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 999931a6c..21ae656c9 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3,10 +3,9 @@ require "rails_helper" RSpec.describe User, type: :model do describe "#new" do let(:user) { FactoryBot.create(:user) } - let(:organisation) { Organisation.first } it "belongs to an organisation" do - expect(user.organisation).to eq(organisation) + expect(user.organisation).to be_a(Organisation) end end end