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
bbe967ab
Commit
bbe967ab
authored
Aug 22, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the rest of specs
parent
eda34b1a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
5 deletions
+74
-5
lib/gitlab/ci/stage/seed.rb
lib/gitlab/ci/stage/seed.rb
+7
-5
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+8
-0
spec/lib/gitlab/ci/stage/seed_spec.rb
spec/lib/gitlab/ci/stage/seed_spec.rb
+11
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+10
-0
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+38
-0
No files found.
lib/gitlab/ci/stage/seed.rb
View file @
bbe967ab
...
@@ -29,14 +29,10 @@ module Gitlab
...
@@ -29,14 +29,10 @@ module Gitlab
ref:
pipeline
.
ref
,
ref:
pipeline
.
ref
,
tag:
pipeline
.
tag
,
tag:
pipeline
.
tag
,
trigger_request:
trigger
,
trigger_request:
trigger
,
protected:
protected
?)
protected:
protected
_ref
?
)
end
end
end
end
def
protected?
@protected
||=
project
.
protected_for?
(
pipeline
.
ref
)
end
def
create!
def
create!
pipeline
.
stages
.
create!
(
stage
).
tap
do
|
stage
|
pipeline
.
stages
.
create!
(
stage
).
tap
do
|
stage
|
builds_attributes
=
builds
.
map
do
|
attributes
|
builds_attributes
=
builds
.
map
do
|
attributes
|
...
@@ -48,6 +44,12 @@ module Gitlab
...
@@ -48,6 +44,12 @@ module Gitlab
end
end
end
end
end
end
private
def
protected_ref?
@protected_ref
||=
project
.
protected_for?
(
pipeline
.
ref
)
end
end
end
end
end
end
end
...
...
spec/factories/ci/builds.rb
View file @
bbe967ab
...
@@ -226,5 +226,13 @@ FactoryGirl.define do
...
@@ -226,5 +226,13 @@ FactoryGirl.define do
status
'created'
status
'created'
self
.
when
'manual'
self
.
when
'manual'
end
end
trait
(
:protected
)
do
protected
true
end
trait
(
:unprotected
)
do
protected
false
end
end
end
end
end
spec/lib/gitlab/ci/stage/seed_spec.rb
View file @
bbe967ab
...
@@ -26,6 +26,17 @@ describe Gitlab::Ci::Stage::Seed do
...
@@ -26,6 +26,17 @@ describe Gitlab::Ci::Stage::Seed do
expect
(
subject
.
builds
).
to
all
(
include
(
project:
pipeline
.
project
))
expect
(
subject
.
builds
).
to
all
(
include
(
project:
pipeline
.
project
))
expect
(
subject
.
builds
)
expect
(
subject
.
builds
)
.
to
all
(
include
(
trigger_request:
pipeline
.
trigger_requests
.
first
))
.
to
all
(
include
(
trigger_request:
pipeline
.
trigger_requests
.
first
))
expect
(
subject
.
builds
).
to
all
(
include
(
protected:
true
))
end
context
'when a ref is unprotected'
do
before
do
allow_any_instance_of
(
Project
).
to
receive
(
:protected_for?
).
and_return
(
false
)
end
it
'returns unprotected builds'
do
expect
(
subject
.
builds
).
to
all
(
include
(
protected:
false
))
end
end
end
end
end
...
...
spec/models/ci/build_spec.rb
View file @
bbe967ab
...
@@ -43,6 +43,16 @@ describe Ci::Build do
...
@@ -43,6 +43,16 @@ describe Ci::Build do
it
{
is_expected
.
not_to
include
(
manual_but_created
)
}
it
{
is_expected
.
not_to
include
(
manual_but_created
)
}
end
end
describe
'.protected_'
do
let!
(
:protected_job
)
{
create
(
:ci_build
,
:protected
)
}
let!
(
:unprotected_job
)
{
create
(
:ci_build
,
:unprotected
)
}
subject
{
described_class
.
protected_
}
it
{
is_expected
.
to
include
(
protected_job
)
}
it
{
is_expected
.
not_to
include
(
unprotected_job
)
}
end
describe
'#actionize'
do
describe
'#actionize'
do
context
'when build is a created'
do
context
'when build is a created'
do
before
do
before
do
...
...
spec/services/ci/register_job_service_spec.rb
View file @
bbe967ab
...
@@ -215,6 +215,44 @@ module Ci
...
@@ -215,6 +215,44 @@ module Ci
end
end
end
end
context
'when a runner is unprotected'
do
context
'when a job is protected'
do
let!
(
:pending_build
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
it
'picks the protected job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_build
)
end
end
context
'when a job is unprotected'
do
let!
(
:pending_build
)
{
create
(
:ci_build
,
:unprotected
,
pipeline:
pipeline
)
}
it
'picks the unprotected job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_build
)
end
end
end
context
'when a runner is protected'
do
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:protected
,
:specific
)
}
context
'when a job is protected'
do
let!
(
:pending_build
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
it
'picks the protected job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_build
)
end
end
context
'when a job is unprotected'
do
let!
(
:unprotected_job
)
{
create
(
:ci_build
,
:unprotected
,
pipeline:
pipeline
)
}
it
'does not pick the unprotected job'
do
expect
(
execute
(
specific_runner
)).
to
be_nil
end
end
end
def
execute
(
runner
)
def
execute
(
runner
)
described_class
.
new
(
runner
).
execute
.
build
described_class
.
new
(
runner
).
execute
.
build
end
end
...
...
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