diff options
author | Rémy Coutable <remy@rymai.me> | 2017-03-07 21:34:43 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-04-14 16:20:55 +0300 |
commit | cfe19b795e076b73df75ee57839640667283651c (patch) | |
tree | e5de8f36de866a24a9e1068063a115640062e801 /spec/support | |
parent | 91ac0e038ab51dd2f30f2bb7c91837fa588ca250 (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/support')
-rw-r--r-- | spec/support/matchers/user_activity_matchers.rb | 5 | ||||
-rw-r--r-- | spec/support/user_activities_helpers.rb | 18 |
2 files changed, 9 insertions, 14 deletions
diff --git a/spec/support/matchers/user_activity_matchers.rb b/spec/support/matchers/user_activity_matchers.rb new file mode 100644 index 00000000000..ce3b683b6d2 --- /dev/null +++ b/spec/support/matchers/user_activity_matchers.rb @@ -0,0 +1,5 @@ +RSpec::Matchers.define :have_an_activity_record do |expected| + match do |user| + expect(Gitlab::UserActivities.new.find { |k, _| k == user.id.to_s }).to be_present + end +end diff --git a/spec/support/user_activities_helpers.rb b/spec/support/user_activities_helpers.rb index ef88dab6c91..f7ca9a31edd 100644 --- a/spec/support/user_activities_helpers.rb +++ b/spec/support/user_activities_helpers.rb @@ -1,17 +1,7 @@ module UserActivitiesHelpers - def last_hour_members - Gitlab::Redis.with do |redis| - redis.zrangebyscore(user_activities_key, 1.hour.ago.to_i, Time.now.to_i) - end - end - - def user_score - Gitlab::Redis.with do |redis| - redis.zscore(user_activities_key, user.username).to_i - end - end - - def user_activities_key - 'user/activities' + def user_activity(user) + Gitlab::UserActivities.new. + find { |k, _| k == user.id.to_s }&. + second end end |