summaryrefslogtreecommitdiff
path: root/spec/models/member_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/member_spec.rb')
-rw-r--r--spec/models/member_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb
index 1957c58ec81..79491edba94 100644
--- a/spec/models/member_spec.rb
+++ b/spec/models/member_spec.rb
@@ -173,6 +173,8 @@ RSpec.describe Member do
let_it_be(:group) { create(:group) }
let_it_be(:blocked_pending_approval_user) { create(:user, :blocked_pending_approval ) }
let_it_be(:blocked_pending_approval_project_member) { create(:project_member, :invited, :developer, project: project, invite_email: blocked_pending_approval_user.email) }
+ let_it_be(:awaiting_group_member) { create(:group_member, :awaiting, group: group) }
+ let_it_be(:awaiting_project_member) { create(:project_member, :awaiting, project: project) }
before_all do
@owner_user = create(:user).tap { |u| group.add_owner(u) }
@@ -471,6 +473,8 @@ RSpec.describe Member do
it { is_expected.to include @blocked_maintainer }
it { is_expected.to include @blocked_developer }
it { is_expected.not_to include @member_with_minimal_access }
+ it { is_expected.not_to include awaiting_group_member }
+ it { is_expected.not_to include awaiting_project_member }
end
describe '.connected_to_user' do
@@ -509,6 +513,8 @@ RSpec.describe Member do
it { is_expected.not_to include @invited_member }
it { is_expected.not_to include @requested_member }
it { is_expected.not_to include @member_with_minimal_access }
+ it { is_expected.not_to include awaiting_group_member }
+ it { is_expected.not_to include awaiting_project_member }
end
describe '.distinct_on_user_with_max_access_level' do
@@ -561,6 +567,21 @@ RSpec.describe Member do
end
end
end
+
+ describe '.active_state' do
+ let_it_be(:active_group_member) { create(:group_member, group: group) }
+ let_it_be(:active_project_member) { create(:project_member, project: project) }
+
+ it 'includes members with an active state' do
+ expect(group.members.active_state).to include active_group_member
+ expect(project.members.active_state).to include active_project_member
+ end
+
+ it 'does not include members with an awaiting state' do
+ expect(group.members.active_state).not_to include awaiting_group_member
+ expect(project.members.active_state).not_to include awaiting_project_member
+ end
+ end
end
describe 'Delegate methods' do
@@ -894,4 +915,15 @@ RSpec.describe Member do
end
end
end
+
+ describe '#set_member_namespace_id' do
+ let(:group) { create(:group) }
+ let(:member) { create(:group_member, group: group) }
+
+ describe 'on create' do
+ it 'sets the member_namespace_id' do
+ expect(member.member_namespace_id).to eq group.id
+ end
+ end
+ end
end