2017-09-12 08:58:44 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Dashboard::GroupsController do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2017-09-13 11:16:30 -04:00
|
|
|
it 'renders group trees' do
|
|
|
|
expect(described_class).to include(GroupTree)
|
|
|
|
end
|
2017-09-12 08:58:44 -04:00
|
|
|
|
2017-09-13 11:16:30 -04:00
|
|
|
it 'only includes projects the user is a member of' do
|
|
|
|
member_of_group = create(:group)
|
|
|
|
member_of_group.add_developer(user)
|
|
|
|
create(:group, :public)
|
2017-09-12 08:58:44 -04:00
|
|
|
|
2017-09-13 11:16:30 -04:00
|
|
|
get :index
|
2017-09-12 08:58:44 -04:00
|
|
|
|
2017-09-13 11:16:30 -04:00
|
|
|
expect(assigns(:groups)).to contain_exactly(member_of_group)
|
2017-09-12 08:58:44 -04:00
|
|
|
end
|
2018-01-19 10:10:27 -05:00
|
|
|
|
|
|
|
context 'when rendering an expanded hierarchy with public groups you are not a member of', :nested_groups do
|
|
|
|
let!(:top_level_result) { create(:group, name: 'chef-top') }
|
|
|
|
let!(:top_level_a) { create(:group, name: 'top-a') }
|
|
|
|
let!(:sub_level_result_a) { create(:group, name: 'chef-sub-a', parent: top_level_a) }
|
|
|
|
let!(:other_group) { create(:group, name: 'other') }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
top_level_result.add_maintainer(user)
|
|
|
|
top_level_a.add_maintainer(user)
|
2018-01-19 10:10:27 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders only groups the user is a member of when searching hierarchy correctly' do
|
2018-12-17 17:52:17 -05:00
|
|
|
get :index, params: { filter: 'chef' }, format: :json
|
2018-01-19 10:10:27 -05:00
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(200)
|
|
|
|
all_groups = [top_level_result, top_level_a, sub_level_result_a]
|
|
|
|
expect(assigns(:groups)).to contain_exactly(*all_groups)
|
|
|
|
end
|
|
|
|
end
|
2017-09-12 08:58:44 -04:00
|
|
|
end
|