summaryrefslogtreecommitdiff
path: root/spec/requests/api/runners_spec.rb
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2016-02-17 22:20:09 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2016-02-19 13:18:49 +0100
commitacfe25edc0083b5e51cf8021b862dc1419a4006e (patch)
tree0b1de326fefabae4358df31cf048ae57db651304 /spec/requests/api/runners_spec.rb
parente4d2f9972cef6268166a31c20c062b2bf42d9ed7 (diff)
downloadgitlab-ce-acfe25edc0083b5e51cf8021b862dc1419a4006e.tar.gz
Refactorize `ci_runner` factory and `let` definitions in runners API spec
Diffstat (limited to 'spec/requests/api/runners_spec.rb')
-rw-r--r--spec/requests/api/runners_spec.rb30
1 files changed, 14 insertions, 16 deletions
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index 1a4ec44a51b..78484747d6a 100644
--- a/spec/requests/api/runners_spec.rb
+++ b/spec/requests/api/runners_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe API::API, api: true do
+describe API::Runners, api: true do
include ApiHelpers
let(:admin) { create(:user, :admin) }
@@ -10,20 +10,20 @@ describe API::API, api: true do
let(:project) { create(:project, creator_id: user.id) }
let(:project2) { create(:project, creator_id: user.id) }
- let!(:shared_runner) { create(:ci_shared_runner, tag_list: ['mysql', 'ruby'], active: true) }
- let!(:unused_specific_runner) { create(:ci_specific_runner) }
+ let!(:shared_runner) { create(:ci_runner, :shared) }
+ let!(:unused_specific_runner) { create(:ci_runner) }
let!(:specific_runner) do
- runner = create(:ci_specific_runner, tag_list: ['mysql', 'ruby'])
- create(:ci_runner_project, runner: runner, project: project)
- runner
+ create(:ci_runner).tap do |runner|
+ create(:ci_runner_project, runner: runner, project: project)
+ end
end
let!(:two_projects_runner) do
- runner = create(:ci_specific_runner)
- create(:ci_runner_project, runner: runner, project: project)
- create(:ci_runner_project, runner: runner, project: project2)
- runner
+ create(:ci_runner).tap do |runner|
+ create(:ci_runner_project, runner: runner, project: project)
+ create(:ci_runner_project, runner: runner, project: project2)
+ end
end
before do
@@ -352,14 +352,12 @@ describe API::API, api: true do
end
describe 'POST /projects/:id/runners' do
- let(:specific_runner2) do
- runner = create(:ci_specific_runner)
- create(:ci_runner_project, runner: runner, project: project2)
- runner
- end
-
context 'authorized user' do
it 'should enable specific runner' do
+ specific_runner2 = create(:ci_runner).tap do |runner|
+ create(:ci_runner_project, runner: runner, project: project2)
+ end
+
expect do
post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id
end.to change{ project.runners.count }.by(+1)