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:
authorRémy Coutable <remy@rymai.me>2017-03-07 21:34:43 +0300
committerRémy Coutable <remy@rymai.me>2017-04-14 16:20:55 +0300
commitcfe19b795e076b73df75ee57839640667283651c (patch)
treee5de8f36de866a24a9e1068063a115640062e801 /spec/services/users
parent91ac0e038ab51dd2f30f2bb7c91837fa588ca250 (diff)
Add a new Gitlab::UserActivities class to track user activities
This new class uses a Redis Hash instead of a Sorted Set. Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/services/users')
-rw-r--r--spec/services/users/activity_service_spec.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/spec/services/users/activity_service_spec.rb b/spec/services/users/activity_service_spec.rb
index 07715ad4ca0..8d67ebe3231 100644
--- a/spec/services/users/activity_service_spec.rb
+++ b/spec/services/users/activity_service_spec.rb
@@ -14,18 +14,18 @@ describe Users::ActivityService, services: true do
end
it 'sets the last activity timestamp for the user' do
- expect(last_hour_members).to eq([user.username])
+ expect(last_hour_user_ids).to eq([user.id])
end
it 'updates the same user' do
service.execute
- expect(last_hour_members).to eq([user.username])
+ expect(last_hour_user_ids).to eq([user.id])
end
it 'updates the timestamp of an existing user' do
Timecop.freeze(Date.tomorrow) do
- expect { service.execute }.to change { user_score }.to(Time.now.to_i)
+ expect { service.execute }.to change { user_activity(user) }.to(Time.now.to_i.to_s)
end
end
@@ -34,9 +34,15 @@ describe Users::ActivityService, services: true do
other_user = create(:user)
described_class.new(other_user, 'type').execute
- expect(last_hour_members).to match_array([user.username, other_user.username])
+ expect(last_hour_user_ids).to match_array([user.id, other_user.id])
end
end
end
end
+
+ def last_hour_user_ids
+ Gitlab::UserActivities.new.
+ select { |k, v| v >= 1.hour.ago.to_i.to_s }.
+ map { |k, _| k.to_i }
+ end
end