summaryrefslogtreecommitdiff
path: root/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb
blob: c49e4c453bf921e06bd2d1602585d33ee174da82 (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
28
29
30
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker do
  let(:start_user_id) { 42 }
  let(:end_user_id) { 4242 }

  describe '#perform' do
    it 'calls AuthorizedProjectUpdate::RecalculateForUserRangeService' do
      expect_next_instance_of(AuthorizedProjectUpdate::RecalculateForUserRangeService) do |service|
        expect(service).to receive(:execute)
      end

      subject.perform(start_user_id, end_user_id)
    end

    context 'feature flag :periodic_project_authorization_recalculation is disabled' do
      before do
        stub_feature_flags(periodic_project_authorization_recalculation: false)
      end

      it 'does not call AuthorizedProjectUpdate::RecalculateForUserRangeService' do
        expect(AuthorizedProjectUpdate::RecalculateForUserRangeService).not_to receive(:new)

        subject.perform(start_user_id, end_user_id)
      end
    end
  end
end