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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
1b481342
Commit
1b481342
authored
Sep 02, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spec
parent
eab938d5
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
30 deletions
+67
-30
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+0
-4
spec/factories/ci/pipelines.rb
spec/factories/ci/pipelines.rb
+0
-4
spec/factories/ci/runners.rb
spec/factories/ci/runners.rb
+1
-4
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-1
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+23
-1
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+9
-7
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+31
-7
spec/support/cycle_analytics_helpers.rb
spec/support/cycle_analytics_helpers.rb
+2
-2
No files found.
spec/factories/ci/builds.rb
View file @
1b481342
...
...
@@ -231,9 +231,5 @@ FactoryGirl.define do
trait
:protected
do
protected
true
end
trait
:unprotected
do
protected
false
end
end
end
spec/factories/ci/pipelines.rb
View file @
1b481342
...
...
@@ -64,10 +64,6 @@ FactoryGirl.define do
trait
:protected
do
protected
true
end
trait
:unprotected
do
protected
false
end
end
end
end
spec/factories/ci/runners.rb
View file @
1b481342
...
...
@@ -5,6 +5,7 @@ FactoryGirl.define do
platform
"darwin"
is_shared
false
active
true
access_level
:not_protected
trait
:online
do
contacted_at
Time
.
now
...
...
@@ -25,9 +26,5 @@ FactoryGirl.define do
trait
:ref_protected
do
access_level
:ref_protected
end
trait
:not_protected
do
access_level
:not_protected
end
end
end
spec/models/ci/build_spec.rb
View file @
1b481342
...
...
@@ -53,7 +53,7 @@ describe Ci::Build do
end
context
'when protected is false'
do
let!
(
:job
)
{
create
(
:ci_build
,
:unprotected
)
}
let!
(
:job
)
{
create
(
:ci_build
)
}
it
{
is_expected
.
not_to
include
(
job
)
}
end
...
...
spec/models/ci/runner_spec.rb
View file @
1b481342
...
...
@@ -255,7 +255,29 @@ describe Ci::Runner do
end
end
context
'when runner is protected'
do
context
'when access_level of runner is not_protected'
do
before
do
runner
.
not_protected!
end
context
'when build is protected'
do
before
do
build
.
protected
=
true
end
it
{
is_expected
.
to
be_truthy
}
end
context
'when build is unprotected'
do
before
do
build
.
protected
=
false
end
it
{
is_expected
.
to
be_truthy
}
end
end
context
'when access_level of runner is ref_protected'
do
before
do
runner
.
ref_protected!
end
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
1b481342
...
...
@@ -391,14 +391,16 @@ describe Ci::CreatePipelineService do
end
context
'when user is master'
do
let
(
:pipeline
)
{
execute_service
}
before
do
project
.
add_master
(
user
)
end
it
'creates a pipeline'
do
expect
(
execute_service
).
to
be_persisted
it
'creates a protected pipeline'
do
expect
(
pipeline
).
to
be_persisted
expect
(
pipeline
).
to
be_protected
expect
(
Ci
::
Pipeline
.
count
).
to
eq
(
1
)
expect
(
Ci
::
Pipeline
.
last
).
to
be_protected
end
end
...
...
@@ -469,12 +471,12 @@ describe Ci::CreatePipelineService do
let
(
:user
)
{}
let
(
:trigger
)
{
create
(
:ci_trigger
,
owner:
nil
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
,
trigger:
trigger
)
}
let
(
:pipeline
)
{
execute_service
(
trigger_request:
trigger_request
)
}
it
'creates a pipeline'
do
expect
(
execute_service
(
trigger_request:
trigger_request
))
.
to
be_persis
ted
it
'creates a
n unprotected
pipeline'
do
expect
(
pipeline
).
to
be_persisted
expect
(
pipeline
).
not_to
be_protec
ted
expect
(
Ci
::
Pipeline
.
count
).
to
eq
(
1
)
expect
(
Ci
::
Pipeline
.
last
).
not_to
be_protected
end
end
end
...
...
spec/services/ci/register_job_service_spec.rb
View file @
1b481342
...
...
@@ -219,18 +219,30 @@ module Ci
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:not_protected
,
:specific
)
}
context
'when a job is protected'
do
let!
(
:p
ending_build
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
let!
(
:p
rotected_job
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
it
'picks the protected job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
p
ending_build
)
expect
(
execute
(
specific_runner
)).
to
eq
(
p
rotected_job
)
end
end
context
'when a job is unprotected'
do
let!
(
:
pending_build
)
{
create
(
:ci_build
,
:unprotecte
d
,
pipeline:
pipeline
)
}
let!
(
:
unprotected_job
)
{
create
(
:ci_buil
d
,
pipeline:
pipeline
)
}
it
'picks the unprotected job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_build
)
expect
(
execute
(
specific_runner
)).
to
eq
(
unprotected_job
)
end
end
context
'when protected attribute of a job is nil'
do
let!
(
:legacy_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
before
do
legacy_job
.
update_attribute
(
:protected
,
nil
)
end
it
'picks the legacy job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
legacy_job
)
end
end
end
...
...
@@ -239,20 +251,32 @@ module Ci
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:ref_protected
,
:specific
)
}
context
'when a job is protected'
do
let!
(
:p
ending_build
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
let!
(
:p
rotected_job
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
it
'picks the protected job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
p
ending_build
)
expect
(
execute
(
specific_runner
)).
to
eq
(
p
rotected_job
)
end
end
context
'when a job is unprotected'
do
let!
(
:unprotected_job
)
{
create
(
:ci_build
,
:unprotected
,
pipeline:
pipeline
)
}
let!
(
:unprotected_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
'does not pick the unprotected job'
do
expect
(
execute
(
specific_runner
)).
to
be_nil
end
end
context
'when protected attribute of a job is nil'
do
let!
(
:legacy_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
before
do
legacy_job
.
update_attribute
(
:protected
,
nil
)
end
it
'does not pick the legacy job'
do
expect
(
execute
(
specific_runner
)).
to
be_nil
end
end
end
def
execute
(
runner
)
...
...
spec/support/cycle_analytics_helpers.rb
View file @
1b481342
...
...
@@ -81,7 +81,7 @@ module CycleAnalyticsHelpers
ref:
'master'
,
source: :push
,
project:
project
,
protected:
tru
e
)
protected:
fals
e
)
end
def
new_dummy_job
(
environment
)
...
...
@@ -95,7 +95,7 @@ module CycleAnalyticsHelpers
tag:
false
,
name:
'dummy'
,
pipeline:
dummy_pipeline
,
protected:
tru
e
)
protected:
fals
e
)
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