summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-09-20 14:21:15 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2017-09-20 14:24:14 +0200
commitb3566a01049cdfbde2a9221319601d8949c12a5a (patch)
tree873d695caaaec68afabf8146af5f83f0983be04e /spec/workers
parenta09d032b2a64c7b6652dcd589de2d9bcba7d9613 (diff)
downloadgitlab-ce-b3566a01049cdfbde2a9221319601d8949c12a5a.tar.gz
Stop using Sidekiq for updating Key#last_used_atremove-use-key-worker
This makes things simpler as no scheduling is involved. Further we remove the need for running a SELECT + UPDATE just to get the key and update it, whereas we only need an UPDATE when setting last_used_at directly in a request. The added service class takes care of updating Key#last_used_at without using Sidekiq. Further it makes sure we only try to obtain a Redis lease if we're confident that we actually need to do so, instead of always obtaining it. We also make sure to _only_ update last_used_at instead of also updating updated_at. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36663
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/use_key_worker_spec.rb23
1 files changed, 0 insertions, 23 deletions
diff --git a/spec/workers/use_key_worker_spec.rb b/spec/workers/use_key_worker_spec.rb
deleted file mode 100644
index e50c788b82a..00000000000
--- a/spec/workers/use_key_worker_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'spec_helper'
-
-describe UseKeyWorker do
- describe "#perform" do
- it "updates the key's last_used_at attribute to the current time when it exists" do
- worker = described_class.new
- key = create(:key)
- current_time = Time.zone.now
-
- Timecop.freeze(current_time) do
- expect { worker.perform(key.id) }
- .to change { key.reload.last_used_at }.from(nil).to be_like_time(current_time)
- end
- end
-
- it "returns false and skips the job when the key doesn't exist" do
- worker = described_class.new
- key = create(:key)
-
- expect(worker.perform(key.id + 1)).to eq false
- end
- end
-end