BigW Consortium Gitlab

group_members_finder_spec.rb 1013 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
require 'spec_helper'

describe GroupMembersFinder, '#execute' do
  let(:group)        { create(:group) }
  let(:nested_group) { create(:group, :access_requestable, parent: group) }
  let(:user1)        { create(:user) }
  let(:user2)        { create(:user) }
  let(:user3)        { create(:user) }
  let(:user4)        { create(:user) }

  it 'returns members for top-level group' do
    member1 = group.add_master(user1)
    member2 = group.add_master(user2)
    member3 = group.add_master(user3)

    result = described_class.new(group).execute

18
    expect(result.to_a).to match_array([member3, member2, member1])
19 20
  end

21
  it 'returns members for nested group', :nested_groups do
22 23 24 25 26 27 28 29
    group.add_master(user2)
    nested_group.request_access(user4)
    member1 = group.add_master(user1)
    member3 = nested_group.add_master(user2)
    member4 = nested_group.add_master(user3)

    result = described_class.new(nested_group).execute

30
    expect(result.to_a).to match_array([member1, member3, member4])
31 32
  end
end