2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-15 06:16:12 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe Projects::RunnersController do
|
2017-02-15 06:16:12 -05:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2018-05-23 07:23:49 -04:00
|
|
|
let(:runner) { create(:ci_runner, :project, projects: [project]) }
|
2017-02-15 06:16:12 -05:00
|
|
|
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
|
|
|
id: runner
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-02-15 06:16:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#update' do
|
|
|
|
it 'updates the runner and ticks the queue' do
|
|
|
|
new_desc = runner.description.swapcase
|
|
|
|
|
2017-02-15 07:21:51 -05:00
|
|
|
expect do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :update, params: params.merge(runner: { description: new_desc } )
|
2017-02-15 07:21:51 -05:00
|
|
|
end.to change { runner.ensure_runner_queue_value }
|
2017-02-15 06:16:12 -05:00
|
|
|
|
|
|
|
runner.reload
|
|
|
|
|
2020-01-28 07:08:44 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2017-02-15 06:16:12 -05:00
|
|
|
expect(runner.description).to eq(new_desc)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#destroy' do
|
|
|
|
it 'destroys the runner' do
|
2018-12-17 17:52:17 -05:00
|
|
|
delete :destroy, params: params
|
2017-02-15 06:16:12 -05:00
|
|
|
|
2020-01-28 07:08:44 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2017-02-15 06:16:12 -05:00
|
|
|
expect(Ci::Runner.find_by(id: runner.id)).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#resume' do
|
|
|
|
it 'marks the runner as active and ticks the queue' do
|
|
|
|
runner.update(active: false)
|
|
|
|
|
2017-02-15 07:21:51 -05:00
|
|
|
expect do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :resume, params: params
|
2017-02-15 07:21:51 -05:00
|
|
|
end.to change { runner.ensure_runner_queue_value }
|
2017-02-15 06:16:12 -05:00
|
|
|
|
|
|
|
runner.reload
|
|
|
|
|
2020-01-28 07:08:44 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2017-02-15 06:16:12 -05:00
|
|
|
expect(runner.active).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#pause' do
|
|
|
|
it 'marks the runner as inactive and ticks the queue' do
|
|
|
|
runner.update(active: true)
|
|
|
|
|
2017-02-15 07:21:51 -05:00
|
|
|
expect do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :pause, params: params
|
2017-02-15 07:21:51 -05:00
|
|
|
end.to change { runner.ensure_runner_queue_value }
|
2017-02-15 06:16:12 -05:00
|
|
|
|
|
|
|
runner.reload
|
|
|
|
|
2020-01-28 07:08:44 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2017-02-15 06:16:12 -05:00
|
|
|
expect(runner.active).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|