1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::ProjectsController, :enable_admin_mode, feature_category: :groups_and_projects do
let_it_be(:project) { create(:project, :public, :allow_runner_registration_token, name: 'test', description: 'test') }
let_it_be(:admin) { create(:admin) }
describe 'PUT #update' do
let(:project_params) { {} }
let(:params) { { project: project_params } }
let(:path_params) { { namespace_id: project.namespace.to_param, id: project.to_param } }
before do
sign_in(admin)
end
subject do
put admin_namespace_project_path(path_params), params: params
end
context 'when changing the name' do
let(:project_params) { { name: 'new name' } }
it 'returns success' do
subject
expect(response).to have_gitlab_http_status(:found)
end
it 'changes the name' do
expect { subject }.to change { project.reload.name }.to('new name')
end
end
context 'when changing the description' do
let(:project_params) { { description: 'new description' } }
it 'returns success' do
subject
expect(response).to have_gitlab_http_status(:found)
end
it 'changes the project description' do
expect { subject }.to change { project.reload.description }.to('new description')
end
end
context 'when changing the name to an invalid name' do
let(:project_params) { { name: 'invalid/project/name' } }
it 'does not change the name' do
expect { subject }.not_to change { project.reload.name }
end
end
context 'when disabling runner registration' do
let(:project_params) { { runner_registration_enabled: false } }
it 'changes runner registration' do
expect { subject }.to change { project.reload.runner_registration_enabled }.to(false)
end
it 'resets the registration token' do
expect { subject }.to change { project.reload.runners_token }
end
end
context 'when enabling runner registration' do
before do
project.update!(runner_registration_enabled: false)
end
let(:project_params) { { runner_registration_enabled: true } }
it 'changes runner registration' do
expect { subject }.to change { project.reload.runner_registration_enabled }.to(true)
end
it 'does not reset the registration token' do
expect { subject }.not_to change { project.reload.runners_token }
end
end
end
end
|