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
diff options
context:
space:
mode:
authorImre Farkas <ifarkas@gitlab.com>2019-02-07 17:36:50 +0300
committerImre Farkas <ifarkas@gitlab.com>2019-02-14 13:14:00 +0300
commita0e97b1c6a786462733a73b681cff60b103d729c (patch)
tree4d687deaffeed2400daa166b188c8d49a07b5fff /spec/services
parentc8fe0d6a8a76ee5865c71b5b6627608e5075797d (diff)
Optimize Redis usage in User::ActivityService
Avoid checking Redis when User#last_activity_on is already up to date.
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/users/activity_service_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/services/users/activity_service_spec.rb b/spec/services/users/activity_service_spec.rb
index 719b4adf212..3c0a4ac8e18 100644
--- a/spec/services/users/activity_service_spec.rb
+++ b/spec/services/users/activity_service_spec.rb
@@ -26,6 +26,12 @@ describe Users::ActivityService do
.from(last_activity_on)
.to(Date.today)
end
+
+ it 'tries to obtain ExclusiveLease' do
+ expect(Gitlab::ExclusiveLease).to receive(:new).and_call_original
+
+ subject.execute
+ end
end
context 'when a bad object is passed' do
@@ -46,6 +52,12 @@ describe Users::ActivityService do
it 'does not update last_activity_on' do
expect { subject.execute }.not_to change(user, :last_activity_on)
end
+
+ it 'does not try to obtain ExclusiveLease' do
+ expect(Gitlab::ExclusiveLease).not_to receive(:new)
+
+ subject.execute
+ end
end
context 'when in GitLab read-only instance' do