require'spec_helper'describeUpdateUserActivityWorker,:redisdolet(:user_active_2_days_ago){create(:user,current_sign_in_at: 10.months.ago)}let(:user_active_yesterday_1){create(:user)}let(:user_active_yesterday_2){create(:user)}let(:user_active_today){create(:user)}let(:data)do{user_active_2_days_ago.id.to_s=>2.days.ago.at_midday.to_i.to_s,user_active_yesterday_1.id.to_s=>1.day.ago.at_midday.to_i.to_s,user_active_yesterday_2.id.to_s=>1.day.ago.at_midday.to_i.to_s,user_active_today.id.to_s=>Time.now.to_i.to_s}endit'updates users.last_activity_on'dosubject.perform(data)aggregate_failuresdoexpect(user_active_2_days_ago.reload.last_activity_on).toeq(2.days.ago.to_date)expect(user_active_yesterday_1.reload.last_activity_on).toeq(1.day.ago.to_date)expect(user_active_yesterday_2.reload.last_activity_on).toeq(1.day.ago.to_date)expect(user_active_today.reload.reload.last_activity_on).toeq(Date.today)endendit'deletes the pairs from Redis'dodata.each{|id,time|Gitlab::UserActivities.record(id,time)}subject.perform(data)expect(Gitlab::UserActivities.new.to_a).tobe_emptyendend