Commit 44ca2456 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu Committed by Eugenia Grieff

Fix membership factories

The underlying association is `source` and we just add these `#project`
and `#group` methods that returns `source`.

That's why when doing something like:

```
member = build(:group_member, group: build(:group))
```

`member.group` is `nil`
parent 81ff89a6
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :group_member do factory :group_member do
access_level { GroupMember::OWNER } access_level { GroupMember::OWNER }
group source { association(:group) }
user user
trait(:guest) { access_level { GroupMember::GUEST } } trait(:guest) { access_level { GroupMember::GUEST } }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :project_member do factory :project_member do
user user
project source { association(:project) }
maintainer maintainer
trait(:guest) { access_level { ProjectMember::GUEST } } trait(:guest) { access_level { ProjectMember::GUEST } }
......
...@@ -23,7 +23,8 @@ RSpec.describe Member do ...@@ -23,7 +23,8 @@ RSpec.describe Member do
end end
context "when an invite email is provided" do context "when an invite email is provided" do
let(:member) { build(:project_member, invite_email: "user@example.com", user: nil) } let_it_be(:project) { create(:project) }
let(:member) { build(:project_member, source: project, invite_email: "user@example.com", user: nil) }
it "doesn't require a user" do it "doesn't require a user" do
expect(member).to be_valid expect(member).to be_valid
...@@ -681,7 +682,7 @@ RSpec.describe Member do ...@@ -681,7 +682,7 @@ RSpec.describe Member do
describe 'create member' do describe 'create member' do
let!(:source) { create(source_type) } let!(:source) { create(source_type) }
subject { create(member_type, :guest, user: user, source_type => source) } subject { create(member_type, :guest, user: user, source: source) }
include_examples 'update highest role with exclusive lease' include_examples 'update highest role with exclusive lease'
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment