summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2016-04-04 17:23:43 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2016-04-04 17:23:43 +0200
commitbf9526739b5c90790907c1d8b9410dd339e3d395 (patch)
treecce5be3bbb11b2baf2e5fce5c2e49339e552a7ca /spec/workers
parent213ee62469c6518af8423f00fb902b7665d61204 (diff)
downloadgitlab-ce-bf9526739b5c90790907c1d8b9410dd339e3d395.tar.gz
Rebase repo check MR
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/repo_check_worker_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/workers/repo_check_worker_spec.rb b/spec/workers/repo_check_worker_spec.rb
new file mode 100644
index 00000000000..7ef3eba9ac5
--- /dev/null
+++ b/spec/workers/repo_check_worker_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper'
+
+describe RepoCheckWorker do
+ subject { RepoCheckWorker.new }
+
+ it 'prefers projects that have never been checked' do
+ projects = 3.times.map { create(:project) }
+ projects[0].update_column(:last_repo_check_at, 1.month.ago)
+ projects[2].update_column(:last_repo_check_at, 3.weeks.ago)
+
+ expect(subject.perform).to eq(projects.values_at(1, 0, 2).map(&:id))
+ end
+
+ it 'sorts projects by last_repo_check_at' do
+ projects = 3.times.map { create(:project) }
+ projects[0].update_column(:last_repo_check_at, 2.weeks.ago)
+ projects[1].update_column(:last_repo_check_at, 1.month.ago)
+ projects[2].update_column(:last_repo_check_at, 3.weeks.ago)
+
+ expect(subject.perform).to eq(projects.values_at(1, 2, 0).map(&:id))
+ end
+
+ it 'excludes projects that were checked recently' do
+ projects = 3.times.map { create(:project) }
+ projects[0].update_column(:last_repo_check_at, 2.days.ago)
+ projects[1].update_column(:last_repo_check_at, 1.month.ago)
+ projects[2].update_column(:last_repo_check_at, 3.days.ago)
+
+ expect(subject.perform).to eq([projects[1].id])
+ end
+end