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
dca9bd9e
Commit
dca9bd9e
authored
Jul 28, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand pipeline_trigger_service_spec by godfat request
parent
2ea6915e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
16 deletions
+28
-16
spec/services/ci/pipeline_trigger_service_spec.rb
spec/services/ci/pipeline_trigger_service_spec.rb
+28
-16
No files found.
spec/services/ci/pipeline_trigger_service_spec.rb
View file @
dca9bd9e
...
...
@@ -12,43 +12,57 @@ describe Ci::PipelineTriggerService, services: true do
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
,
owner:
user
)
}
let
(
:result
)
{
described_class
.
new
(
project
,
user
,
params
).
execute
}
let
(
:params
)
do
{
token:
token
,
ref:
ref
,
variables:
variables
}
end
before
do
project
.
add_developer
(
user
)
end
context
'when params have an existsed trigger token'
do
let
(
:token
)
{
trigger
.
token
}
context
'when trigger belongs to a different project'
do
let
(
:params
)
{
{
token:
trigger
.
token
,
ref:
'master'
,
variables:
nil
}
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
create
(
:empty_project
),
owner:
user
)
}
it
'does nothing'
do
expect
{
result
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
end
end
context
'when params have an existsed trigger token'
do
context
'when params have an existsed ref'
do
let
(
:ref
)
{
'master'
}
let
(
:variables
)
{}
let
(
:params
)
{
{
token:
trigger
.
token
,
ref:
'master'
,
variables:
nil
}
}
it
'triggers a pipeline'
do
expect
{
result
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
1
)
expect
(
result
[
:pipeline
].
ref
).
to
eq
(
ref
)
expect
(
result
[
:pipeline
].
ref
).
to
eq
(
'master'
)
expect
(
result
[
:pipeline
].
project
).
to
eq
(
project
)
expect
(
result
[
:pipeline
].
user
).
to
eq
(
trigger
.
owner
)
expect
(
result
[
:status
]).
to
eq
(
:success
)
end
context
'when commit message has [ci skip]'
do
before
do
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:git_commit_message
)
{
'[ci skip]'
}
end
it
'ignores [ci skip] and create as general'
do
expect
{
result
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
1
)
expect
(
result
[
:status
]).
to
eq
(
:success
)
end
end
context
'when params have a variable'
do
let
(
:params
)
{
{
token:
trigger
.
token
,
ref:
'master'
,
variables:
variables
}
}
let
(
:variables
)
{
{
'AAA'
=>
'AAA123'
}
}
it
'has a variable'
do
expect
{
result
}.
to
change
{
Ci
::
PipelineVariable
.
count
}.
by
(
1
)
expect
(
result
[
:pipeline
].
variables
.
first
.
key
).
to
eq
(
variables
.
keys
.
first
)
expect
(
result
[
:pipeline
].
variables
.
first
.
value
).
to
eq
(
variables
.
values
.
first
)
.
and
change
{
Ci
::
TriggerRequest
.
count
}.
by
(
1
)
expect
(
result
[
:pipeline
].
variables
.
map
{
|
v
|
{
v
.
key
=>
v
.
value
}
}.
first
).
to
eq
(
variables
)
expect
(
result
[
:pipeline
].
trigger_requests
.
last
.
variables
).
to
be_nil
end
end
end
context
'when params have a non-existsed ref'
do
let
(
:ref
)
{
'invalid-ref'
}
let
(
:variables
)
{}
let
(
:params
)
{
{
token:
trigger
.
token
,
ref:
'invalid-ref'
,
variables:
nil
}
}
it
'does not trigger a pipeline'
do
expect
{
result
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
...
...
@@ -58,9 +72,7 @@ describe Ci::PipelineTriggerService, services: true do
end
context
'when params have a non-existsed trigger token'
do
let
(
:token
)
{
'invalid-token'
}
let
(
:ref
)
{}
let
(
:variables
)
{}
let
(
:params
)
{
{
token:
'invalid-token'
,
ref:
nil
,
variables:
nil
}
}
it
'does not trigger a pipeline'
do
expect
{
result
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
...
...
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