summaryrefslogtreecommitdiff
path: root/spec/workers/remove_expired_group_links_worker_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/workers/remove_expired_group_links_worker_spec.rb')
-rw-r--r--spec/workers/remove_expired_group_links_worker_spec.rb41
1 files changed, 32 insertions, 9 deletions
diff --git a/spec/workers/remove_expired_group_links_worker_spec.rb b/spec/workers/remove_expired_group_links_worker_spec.rb
index 9557aa3086c..b637802cd78 100644
--- a/spec/workers/remove_expired_group_links_worker_spec.rb
+++ b/spec/workers/remove_expired_group_links_worker_spec.rb
@@ -23,30 +23,53 @@ describe RemoveExpiredGroupLinksWorker do
subject.perform
expect(non_expiring_project_group_link.reload).to be_present
end
- end
- context 'GroupGroupLinks' do
- let(:mock_destroy_service) { instance_double(Groups::GroupLinks::DestroyService) }
+ it 'removes project authorization' do
+ user = create(:user)
+
+ project = expired_project_group_link.project
+ group = expired_project_group_link.group
+
+ group.add_maintainer(user)
- before do
- allow(Groups::GroupLinks::DestroyService).to(
- receive(:new).and_return(mock_destroy_service))
+ expect { subject.perform }.to(
+ change { user.can?(:read_project, project) }.from(true).to(false))
end
+ end
+ context 'GroupGroupLinks' do
context 'expired GroupGroupLink exists' do
- before do
- create(:group_group_link, expires_at: 1.hour.ago)
- end
+ let!(:group_group_link) { create(:group_group_link, expires_at: 1.hour.ago) }
it 'calls Groups::GroupLinks::DestroyService' do
+ mock_destroy_service = instance_double(Groups::GroupLinks::DestroyService)
+ allow(Groups::GroupLinks::DestroyService).to(
+ receive(:new).and_return(mock_destroy_service))
+
expect(mock_destroy_service).to receive(:execute).once
subject.perform
end
+
+ it 'removes project authorization' do
+ shared_group = group_group_link.shared_group
+ shared_with_group = group_group_link.shared_with_group
+ project = create(:project, group: shared_group)
+
+ user = create(:user)
+ shared_with_group.add_maintainer(user)
+
+ expect { subject.perform }.to(
+ change { user.can?(:read_project, project) }.from(true).to(false))
+ end
end
context 'expired GroupGroupLink does not exist' do
it 'does not call Groups::GroupLinks::DestroyService' do
+ mock_destroy_service = instance_double(Groups::GroupLinks::DestroyService)
+ allow(Groups::GroupLinks::DestroyService).to(
+ receive(:new).and_return(mock_destroy_service))
+
expect(mock_destroy_service).not_to receive(:execute)
subject.perform