debian-mirror-gitlab/spec/controllers/dashboard/groups_controller_spec.rb

58 lines
1.6 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe Dashboard::GroupsController do
2019-07-07 11:18:12 +05:30
include ExternalAuthorizationServiceHelpers
2018-03-17 18:26:18 +05:30
let(:user) { create(:user) }
before do
sign_in(user)
end
it 'renders group trees' do
expect(described_class).to include(GroupTree)
end
2019-07-07 11:18:12 +05:30
describe '#index' do
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)
2018-03-17 18:26:18 +05:30
2019-07-07 11:18:12 +05:30
get :index
2018-03-17 18:26:18 +05:30
2019-07-07 11:18:12 +05:30
expect(assigns(:groups)).to contain_exactly(member_of_group)
end
2019-05-18 00:54:41 +05:30
2019-10-12 21:52:04 +05:30
context 'when rendering an expanded hierarchy with public groups you are not a member of' do
2019-07-07 11:18:12 +05:30
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') }
2019-05-18 00:54:41 +05:30
2019-07-07 11:18:12 +05:30
before do
top_level_result.add_maintainer(user)
top_level_a.add_maintainer(user)
end
it 'renders only groups the user is a member of when searching hierarchy correctly' do
get :index, params: { filter: 'chef' }, format: :json
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:ok)
2019-07-07 11:18:12 +05:30
all_groups = [top_level_result, top_level_a, sub_level_result_a]
expect(assigns(:groups)).to contain_exactly(*all_groups)
end
2018-03-17 18:26:18 +05:30
end
2019-07-07 11:18:12 +05:30
it 'works when the external authorization service is enabled' do
enable_external_authorization_service_check
get :index
2018-03-17 18:26:18 +05:30
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:ok)
2018-03-17 18:26:18 +05:30
end
end
end