diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-01 18:07:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-01 18:07:45 +0300 |
commit | 1219a9dce91f4edbc135dfc08299b4122b4825a8 (patch) | |
tree | e7d12a55d75a2d56e60d9527bef3724e3578866d /spec/models/member_spec.rb | |
parent | 1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/member_spec.rb')
-rw-r--r-- | spec/models/member_spec.rb | 100 |
1 files changed, 26 insertions, 74 deletions
diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 0e8ae320405..cd9d7c16f88 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -597,97 +597,49 @@ describe Member do end context 'when after_commit :update_highest_role' do - context 'with feature flag enabled' do - where(:member_type, :source_type) do - :project_member | :project - :group_member | :group - end + where(:member_type, :source_type) do + :project_member | :project + :group_member | :group + end - with_them do - describe 'create member' do - it 'initializes a new Members::UpdateHighestRoleService object' do - source = create(source_type) # source owner initializes a new service object too - user = create(:user) + with_them do + describe 'create member' do + it 'initializes a new Members::UpdateHighestRoleService object' do + source = create(source_type) # source owner initializes a new service object too + user = create(:user) - expect(Members::UpdateHighestRoleService).to receive(:new).with(user.id).and_call_original + expect(Members::UpdateHighestRoleService).to receive(:new).with(user.id).and_call_original - create(member_type, :guest, user: user, source_type => source) - end + create(member_type, :guest, user: user, source_type => source) end + end - context 'when member exists' do - let!(:member) { create(member_type) } - - describe 'update member' do - context 'when access level was changed' do - it 'initializes a new Members::UpdateHighestRoleService object' do - expect(Members::UpdateHighestRoleService).to receive(:new).with(member.user_id).and_call_original - - member.update(access_level: Gitlab::Access::GUEST) - end - end - - context 'when access level was not changed' do - it 'does not initialize a new Members::UpdateHighestRoleService object' do - expect(Members::UpdateHighestRoleService).not_to receive(:new).with(member.user_id) - - member.update(notification_level: NotificationSetting.levels[:disabled]) - end - end - end + context 'when member exists' do + let!(:member) { create(member_type) } - describe 'destroy member' do + describe 'update member' do + context 'when access level was changed' do it 'initializes a new Members::UpdateHighestRoleService object' do expect(Members::UpdateHighestRoleService).to receive(:new).with(member.user_id).and_call_original - member.destroy + member.update(access_level: Gitlab::Access::GUEST) end end - end - end - end - - context 'with feature flag disabled' do - before do - stub_feature_flags(highest_role_callback: false) - end - - where(:member_type, :source_type) do - :project_member | :project - :group_member | :group - end - - with_them do - describe 'create member' do - it 'does not initialize a new Members::UpdateHighestRoleService object' do - source = create(source_type) - user = create(:user) - - expect(Members::UpdateHighestRoleService).not_to receive(:new).with(user.id) - - create(member_type, :guest, user: user, source_type => source) - end - end - context 'when member exists' do - let!(:member) { create(member_type) } - - describe 'update member' do - context 'when access level was changed' do - it 'does not initialize a new Members::UpdateHighestRoleService object' do - expect(Members::UpdateHighestRoleService).not_to receive(:new).with(member.user_id) + context 'when access level was not changed' do + it 'does not initialize a new Members::UpdateHighestRoleService object' do + expect(Members::UpdateHighestRoleService).not_to receive(:new).with(member.user_id) - member.update(access_level: Gitlab::Access::GUEST) - end + member.update(notification_level: NotificationSetting.levels[:disabled]) end end + end - describe 'destroy member' do - it 'does not initialize a new Members::UpdateHighestRoleService object' do - expect(Members::UpdateHighestRoleService).not_to receive(:new).with(member.user_id) + describe 'destroy member' do + it 'initializes a new Members::UpdateHighestRoleService object' do + expect(Members::UpdateHighestRoleService).to receive(:new).with(member.user_id).and_call_original - member.destroy - end + member.destroy end end end |