summaryrefslogtreecommitdiff
path: root/spec/workers/schedule_update_user_activity_worker_spec.rb
blob: 362cd2a6d925998b2a0191ad713540f79aca0525 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'spec_helper'

describe ScheduleUpdateUserActivityWorker, :clean_gitlab_redis_shared_state do
  let(:now) { Time.now }

  before do
    Gitlab::UserActivities.record('1', now)
    Gitlab::UserActivities.record('2', now)
  end

  it 'schedules UpdateUserActivityWorker once' do
    expect(UpdateUserActivityWorker).to receive(:perform_async).with({ '1' => now.to_i.to_s, '2' => now.to_i.to_s })

    subject.perform
  end

  context 'when specifying a batch size' do
    it 'schedules UpdateUserActivityWorker twice' do
      expect(UpdateUserActivityWorker).to receive(:perform_async).with({ '1' => now.to_i.to_s })
      expect(UpdateUserActivityWorker).to receive(:perform_async).with({ '2' => now.to_i.to_s })

      subject.perform(1)
    end
  end

  it_behaves_like 'sidekiq worker'
end