Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2016-03-14 18:49:24 +0300
committerJacob Vosmaer <contact@jacobvosmaer.nl>2016-03-14 18:49:24 +0300
commit021d53c96d308df7c721984435442993357a3414 (patch)
tree13bd15cb10952efd5c759a5dee5b8de6f243e056 /spec
parenta02fe251df7ea7316f51850fe603e7e5ac4431e2 (diff)
Run 'git gc' every 10 pushes
Diffstat (limited to 'spec')
-rw-r--r--spec/services/git_push_service_spec.rb27
-rw-r--r--spec/services/projects/housekeeping_service_spec.rb10
2 files changed, 36 insertions, 1 deletions
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index a7e2e1b1792..ebf3ec1f5fd 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -401,6 +401,33 @@ describe GitPushService, services: true do
end
end
+ describe "housekeeping" do
+ let(:housekeeping) { instance_double('Projects::HousekeepingService', increment!: nil, needed?: false) }
+
+ before do
+ allow(Projects::HousekeepingService).to receive(:new).and_return(housekeeping)
+ end
+
+ it 'does not perform housekeeping when not needed' do
+ expect(housekeeping).not_to receive(:execute)
+
+ execute_service(project, user, @oldrev, @newrev, @ref)
+ end
+
+ it 'performs housekeeping when needed' do
+ expect(housekeeping).to receive(:needed?).and_return(true)
+ expect(housekeeping).to receive(:execute)
+
+ execute_service(project, user, @oldrev, @newrev, @ref)
+ end
+
+ it 'increments the push counter' do
+ expect(housekeeping).to receive(:increment!)
+
+ execute_service(project, user, @oldrev, @newrev, @ref)
+ end
+ end
+
def execute_service(project, user, oldrev, newrev, ref)
service = described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref )
service.execute
diff --git a/spec/services/projects/housekeeping_service_spec.rb b/spec/services/projects/housekeeping_service_spec.rb
index 7cddeb5c354..32552d882aa 100644
--- a/spec/services/projects/housekeeping_service_spec.rb
+++ b/spec/services/projects/housekeeping_service_spec.rb
@@ -37,4 +37,12 @@ describe Projects::HousekeepingService do
expect(subject.needed?).to eq(true)
end
end
-end \ No newline at end of file
+
+ describe :increment! do
+ it 'increments the pushes_since_gc counter' do
+ expect(project.pushes_since_gc).to eq(0)
+ subject.increment!
+ expect(project.pushes_since_gc).to eq(1)
+ end
+ end
+end