diff options
author | Vincent Wong <wingyu64@gmail.com> | 2016-12-22 01:59:54 +1100 |
---|---|---|
committer | Vincent Wong <wingyu64@gmail.com> | 2017-01-09 04:15:39 +1100 |
commit | b6df93a51f90c7ed29ce6667c6b1a8debf02506e (patch) | |
tree | ff13ffc730ceeb52635bad3204db1050d0e74947 /spec/workers | |
parent | f264ec6ee74a0263b4e5212e921c4638c25f8fcd (diff) | |
download | gitlab-ce-b6df93a51f90c7ed29ce6667c6b1a8debf02506e.tar.gz |
Record and show last used date of SSH Keys
Addresses: Issue #13810
1. Adds a last_used_at attribute to the Key table/model
2. Update a key's last_used_at whenever it gets used
3. Display how long ago an ssh key was last used
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/use_key_worker_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/workers/use_key_worker_spec.rb b/spec/workers/use_key_worker_spec.rb new file mode 100644 index 00000000000..e50c788b82a --- /dev/null +++ b/spec/workers/use_key_worker_spec.rb @@ -0,0 +1,23 @@ +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 |