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

35 lines
1.2 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe MembersFinder, '#execute' do
let(:group) { create(:group) }
let(:nested_group) { create(:group, :access_requestable, parent: group) }
let(:project) { create(:project, namespace: nested_group) }
let(:user1) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
let(:user4) { create(:user) }
2017-09-10 17:25:29 +05:30
it 'returns members for project and parent groups', :nested_groups do
2017-08-17 22:00:37 +05:30
nested_group.request_access(user1)
2018-11-18 11:00:15 +05:30
member1 = group.add_maintainer(user2)
member2 = nested_group.add_maintainer(user3)
member3 = project.add_maintainer(user4)
2017-08-17 22:00:37 +05:30
result = described_class.new(project, user2).execute
2018-03-17 18:26:18 +05:30
expect(result.to_a).to match_array([member1, member2, member3])
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
it 'includes nested group members if asked', :nested_groups do
project = create(:project, namespace: group)
nested_group.request_access(user1)
2018-11-18 11:00:15 +05:30
member1 = group.add_maintainer(user2)
member2 = nested_group.add_maintainer(user3)
member3 = project.add_maintainer(user4)
2018-11-08 19:23:39 +05:30
result = described_class.new(project, user2).execute(include_descendants: true)
expect(result.to_a).to match_array([member1, member2, member3])
end
2017-08-17 22:00:37 +05:30
end