Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0eeb4bed
Commit
0eeb4bed
authored
Jun 02, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduced Ci::Runner.specific_for for getting specific runners:
for a particular project.
parent
4f7f3258
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
2 deletions
+59
-2
app/controllers/projects/runners_controller.rb
app/controllers/projects/runners_controller.rb
+1
-2
app/models/ci/runner.rb
app/models/ci/runner.rb
+4
-0
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+54
-0
No files found.
app/controllers/projects/runners_controller.rb
View file @
0eeb4bed
...
...
@@ -7,8 +7,7 @@ class Projects::RunnersController < Projects::ApplicationController
def
index
@runners
=
project
.
runners
.
ordered
@specific_runners
=
current_user
.
ci_authorized_runners
.
where
.
not
(
id:
project
.
runners
).
ordered
.
page
(
params
[
:page
]).
per
(
20
)
specific_for
(
project
).
ordered
.
page
(
params
[
:page
]).
per
(
20
)
@shared_runners
=
Ci
::
Runner
.
shared
.
active
@shared_runners_count
=
@shared_runners
.
count
(
:all
)
end
...
...
app/models/ci/runner.rb
View file @
0eeb4bed
...
...
@@ -26,6 +26,10 @@ module Ci
.
where
(
"ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true"
,
project_id:
project_id
)
end
scope
:specific_for
,
->
(
project
)
do
where
(
locked:
false
).
where
.
not
(
id:
project
.
runners
).
specific
end
validate
:tag_constraints
acts_as_taggable
...
...
spec/models/ci/runner_spec.rb
View file @
0eeb4bed
...
...
@@ -112,6 +112,60 @@ describe Ci::Runner, models: true do
end
end
describe
:specific_for
do
let
(
:runner
)
{
create
(
:ci_runner
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:another_project
)
{
create
(
:project
)
}
before
{
project
.
runners
<<
runner
}
context
'with shared runners'
do
before
{
runner
.
update
(
is_shared:
true
)
}
context
'should not give owned runner'
do
subject
{
Ci
::
Runner
.
specific_for
(
project
)
}
it
{
is_expected
.
to
be_empty
}
end
context
'should not give shared runner'
do
subject
{
Ci
::
Runner
.
specific_for
(
another_project
)
}
it
{
is_expected
.
to
be_empty
}
end
end
context
'with unlocked runner'
do
context
'should not give owned runner'
do
subject
{
Ci
::
Runner
.
specific_for
(
project
)
}
it
{
is_expected
.
to
be_empty
}
end
context
'should give a specific runner'
do
subject
{
Ci
::
Runner
.
specific_for
(
another_project
)
}
it
{
is_expected
.
to
contain_exactly
(
runner
)
}
end
end
context
'with locked runner'
do
before
{
runner
.
update
(
locked:
true
)
}
context
'should not give owned runner'
do
subject
{
Ci
::
Runner
.
specific_for
(
project
)
}
it
{
is_expected
.
to
be_empty
}
end
context
'should not give a locked runner'
do
subject
{
Ci
::
Runner
.
specific_for
(
another_project
)
}
it
{
is_expected
.
to
be_empty
}
end
end
end
describe
"belongs_to_one_project?"
do
it
"returns false if there are two projects runner assigned to"
do
runner
=
FactoryGirl
.
create
(
:ci_runner
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment