debian-mirror-gitlab/spec/finders/group_members_finder_spec.rb

47 lines
1.4 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe GroupMembersFinder, '#execute' do
let(:group) { create(:group) }
2019-12-21 20:55:43 +05:30
let(:nested_group) { create(:group, parent: group) }
2017-08-17 22:00:37 +05:30
let(:user1) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
let(:user4) { create(:user) }
it 'returns members for top-level group' do
2018-11-18 11:00:15 +05:30
member1 = group.add_maintainer(user1)
member2 = group.add_maintainer(user2)
member3 = group.add_maintainer(user3)
2017-08-17 22:00:37 +05:30
result = described_class.new(group).execute
2018-03-17 18:26:18 +05:30
expect(result.to_a).to match_array([member3, member2, member1])
2017-08-17 22:00:37 +05:30
end
2019-10-12 21:52:04 +05:30
it 'returns members for nested group' do
2019-02-15 15:39:39 +05:30
group.add_developer(user2)
2017-08-17 22:00:37 +05:30
nested_group.request_access(user4)
2018-11-18 11:00:15 +05:30
member1 = group.add_maintainer(user1)
member3 = nested_group.add_maintainer(user2)
member4 = nested_group.add_maintainer(user3)
2017-08-17 22:00:37 +05:30
result = described_class.new(nested_group).execute
2018-03-17 18:26:18 +05:30
expect(result.to_a).to match_array([member1, member3, member4])
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
2019-10-12 21:52:04 +05:30
it 'returns members for descendant groups if requested' do
2018-11-18 11:00:15 +05:30
member1 = group.add_maintainer(user2)
member2 = group.add_maintainer(user1)
nested_group.add_maintainer(user2)
member3 = nested_group.add_maintainer(user3)
member4 = nested_group.add_maintainer(user4)
2018-11-08 19:23:39 +05:30
result = described_class.new(group).execute(include_descendants: true)
expect(result.to_a).to match_array([member1, member2, member3, member4])
end
2017-08-17 22:00:37 +05:30
end