summaryrefslogtreecommitdiff
path: root/spec/finders/groups_finder_spec.rb
blob: d5d111e8d15be73ef1b8497d31bf1930089ff965 (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
31
32
33
require 'spec_helper'

describe GroupsFinder do
  describe '#execute' do
    let(:user)            { create(:user) }
    let!(:private_group)  { create(:group, :private) }
    let!(:internal_group) { create(:group, :internal) }
    let!(:public_group)   { create(:group, :public) }
    let(:finder)          { described_class.new }

    describe 'execute' do
      describe 'without a user' do
        subject { finder.execute }

        it { is_expected.to eq([public_group]) }
      end

      describe 'with a user' do
        subject { finder.execute(user) }

        context 'normal user' do
          it { is_expected.to eq([public_group, internal_group]) }
        end

        context 'external user' do
          let(:user) { create(:user, external: true) }

          it { is_expected.to eq([public_group]) }
        end
      end
    end
  end
end