2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Groups::Settings::CiCdController do
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
2019-01-03 12:48:30 +05:30
|
|
|
context 'when user is owner' do
|
|
|
|
before do
|
|
|
|
group.add_owner(user)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
it 'renders show with 200 status code' do
|
2019-02-13 22:33:31 +05:30
|
|
|
get :show, params: { group_id: group }
|
2019-01-03 12:48:30 +05:30
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(200)
|
|
|
|
expect(response).to render_template(:show)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user is not owner' do
|
|
|
|
before do
|
|
|
|
group.add_maintainer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders a 404' do
|
2019-02-13 22:33:31 +05:30
|
|
|
get :show, params: { group_id: group }
|
2019-01-03 12:48:30 +05:30
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(404)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
|
|
|
|
describe 'PUT #reset_registration_token' do
|
2019-02-13 22:33:31 +05:30
|
|
|
subject { put :reset_registration_token, params: { group_id: group } }
|
2018-12-05 23:21:45 +05:30
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
context 'when user is owner' do
|
|
|
|
before do
|
|
|
|
group.add_owner(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'resets runner registration token' do
|
|
|
|
expect { subject }.to change { group.reload.runners_token }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects the user to admin runners page' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(response).to redirect_to(group_settings_ci_cd_path)
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
context 'when user is not owner' do
|
|
|
|
before do
|
|
|
|
group.add_maintainer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders a 404' do
|
|
|
|
subject
|
2018-12-05 23:21:45 +05:30
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
expect(response).to have_gitlab_http_status(404)
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|