summaryrefslogtreecommitdiff
path: root/spec/services/git/wiki_push_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/git/wiki_push_service_spec.rb')
-rw-r--r--spec/services/git/wiki_push_service_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/services/git/wiki_push_service_spec.rb b/spec/services/git/wiki_push_service_spec.rb
index cd38f2e97fb..df9a48d7b1c 100644
--- a/spec/services/git/wiki_push_service_spec.rb
+++ b/spec/services/git/wiki_push_service_spec.rb
@@ -257,6 +257,46 @@ RSpec.describe Git::WikiPushService, services: true do
end
end
+ describe '#perform_housekeeping', :clean_gitlab_redis_shared_state do
+ let(:housekeeping) { Repositories::HousekeepingService.new(wiki) }
+
+ subject { create_service(current_sha).execute }
+
+ before do
+ allow(Repositories::HousekeepingService).to receive(:new).and_return(housekeeping)
+ end
+
+ it 'does not perform housekeeping when not needed' do
+ expect(housekeeping).not_to receive(:execute)
+
+ subject
+ end
+
+ context 'when housekeeping is needed' do
+ before do
+ allow(housekeeping).to receive(:needed?).and_return(true)
+ end
+
+ it 'performs housekeeping' do
+ expect(housekeeping).to receive(:execute)
+
+ subject
+ end
+
+ it 'does not raise an exception' do
+ allow(housekeeping).to receive(:try_obtain_lease).and_return(false)
+
+ expect { subject }.not_to raise_error
+ end
+ end
+
+ it 'increments the push counter' do
+ expect(housekeeping).to receive(:increment!)
+
+ subject
+ end
+ end
+
# In order to construct the correct GitPostReceive object that represents the
# changes we are applying, we need to describe the changes between old-ref and
# new-ref. Old ref (the base sha) we have to capture before we perform any