diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/models/members/group_member_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/models/members/group_member_spec.rb')
-rw-r--r-- | spec/models/members/group_member_spec.rb | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb index fdb71b7ec7d..9af620e70a5 100644 --- a/spec/models/members/group_member_spec.rb +++ b/spec/models/members/group_member_spec.rb @@ -2,52 +2,20 @@ require 'spec_helper' -describe GroupMember do +RSpec.describe GroupMember do context 'scopes' do - shared_examples '.count_users_by_group_id' do - it 'counts users by group ID' do - user_1 = create(:user) - user_2 = create(:user) - group_1 = create(:group) - group_2 = create(:group) - - group_1.add_owner(user_1) - group_1.add_owner(user_2) - group_2.add_owner(user_1) - - expect(described_class.count_users_by_group_id).to eq(group_1.id => 2, - group_2.id => 1) - end - end - - describe '.count_users_by_group_id with optimized_count_users_by_group_id feature flag on' do - before do - stub_feature_flags(optimized_count_users_by_group_id: true) - end - - it_behaves_like '.count_users_by_group_id' - - it 'does not JOIN users' do - scope = described_class.all - expect(scope).not_to receive(:joins).with(:user) - - scope.count_users_by_group_id - end - end - - describe '.count_users_by_group_id with optimized_count_users_by_group_id feature flag off' do - before do - stub_feature_flags(optimized_count_users_by_group_id: false) - end - - it_behaves_like '.count_users_by_group_id' - - it 'does JOIN users' do - scope = described_class.all - expect(scope).to receive(:joins).with(:user).and_call_original - - scope.count_users_by_group_id - end + it 'counts users by group ID' do + user_1 = create(:user) + user_2 = create(:user) + group_1 = create(:group) + group_2 = create(:group) + + group_1.add_owner(user_1) + group_1.add_owner(user_2) + group_2.add_owner(user_1) + + expect(described_class.count_users_by_group_id).to eq(group_1.id => 2, + group_2.id => 1) end describe '.of_ldap_type' do |