BigW Consortium Gitlab

Commit c0c5f896 by Kamil Trzciński Committed by Dylan Griffith

Bring back deleted specs

parent 47c11248
......@@ -36,6 +36,14 @@ FactoryBot.define do
end
end
trait :without_projects do
# we use that to create invalid runner:
# the one without projects
after(:create) do |runner, evaluator|
runner.runner_projects.delete_all
end
end
trait :inactive do
active false
end
......
......@@ -766,11 +766,7 @@ describe Ci::Runner do
end
describe 'project runner without projects is destroyable' do
subject { create(:ci_runner, :project) }
before do
subject.runner_projects.delete_all
end
subject { create(:ci_runner, :project, :without_projects) }
it 'does not have projects' do
expect(subject.runner_projects).to be_empty
......
......@@ -128,6 +128,18 @@ describe API::Runners do
end
context 'when runner is not shared' do
context 'when unused runner is present' do
let!(:unused_project_runner) { create(:ci_runner, :project, :without_projects) }
it 'deletes unused runner' do
expect do
delete api("/runners/#{unused_project_runner.id}", admin)
expect(response).to have_gitlab_http_status(204)
end.to change { Ci::Runner.specific.count }.by(-1)
end
end
it "returns runner's details" do
get api("/runners/#{project_runner.id}", admin)
......@@ -561,6 +573,17 @@ describe API::Runners do
end
context 'user is admin' do
context 'when project runner is used' do
let!(:new_project_runner) { create(:ci_runner, :project) }
it 'enables any specific runner' do
expect do
post api("/projects/#{project.id}/runners", admin), runner_id: new_project_runner.id
end.to change { project.runners.count }.by(+1)
expect(response).to have_gitlab_http_status(201)
end
end
it 'enables a shared runner' do
expect do
post api("/projects/#{project.id}/runners", admin), runner_id: shared_runner.id
......@@ -578,6 +601,16 @@ describe API::Runners do
end
end
context 'user is not admin' do
let!(:new_project_runner) { create(:ci_runner, :project) }
it 'does not enable runner without access to' do
post api("/projects/#{project.id}/runners", user), runner_id: new_project_runner.id
expect(response).to have_gitlab_http_status(403)
end
end
context 'authorized user without permissions' do
it 'does not enable runner' do
post api("/projects/#{project.id}/runners", user2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment