summaryrefslogtreecommitdiff
path: root/spec/workers/authorized_projects_worker_spec.rb
blob: 18a1aab766cbf652641b308ae6e1e6edb8ac14c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'spec_helper'

describe AuthorizedProjectsWorker do
  describe '#perform' do
    it "refreshes user's authorized projects" do
      user = create(:user)

      expect(User).to receive(:find_by).with(id: user.id).and_return(user)
      expect(user).to receive(:refresh_authorized_projects)

      described_class.new.perform(user.id)
    end

    context "when user is not found" do
      it "does nothing" do
        expect_any_instance_of(User).not_to receive(:refresh_authorized_projects)

        described_class.new.perform(999_999)
      end
    end
  end
end