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
Boxiang Sun
gitlab-ce
Commits
b59abf5b
Commit
b59abf5b
authored
Jul 28, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use let(:params) instead of def param
parent
34d2b8e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
spec/services/ci/pipeline_trigger_service_spec.rb
spec/services/ci/pipeline_trigger_service_spec.rb
+10
-9
No files found.
spec/services/ci/pipeline_trigger_service_spec.rb
View file @
b59abf5b
...
@@ -9,19 +9,23 @@ describe Ci::PipelineTriggerService, services: true do
...
@@ -9,19 +9,23 @@ describe Ci::PipelineTriggerService, services: true do
describe
'#execute'
do
describe
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
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
before
do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
end
end
let
(
:result
)
{
described_class
.
new
(
project
,
user
,
params
).
execute
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
,
owner:
user
)
}
context
'when params have an existsed trigger token'
do
context
'when params have an existsed trigger token'
do
let
(
:token
)
{
trigger
.
token
}
let
(
:token
)
{
trigger
.
token
}
context
'when params have an existsed ref'
do
context
'when params have an existsed ref'
do
let
(
:ref
)
{
'master'
}
let
(
:ref
)
{
'master'
}
let
(
:variables
)
{}
it
'triggers a pipeline'
do
it
'triggers a pipeline'
do
expect
{
result
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
1
)
expect
{
result
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
1
)
...
@@ -44,6 +48,7 @@ describe Ci::PipelineTriggerService, services: true do
...
@@ -44,6 +48,7 @@ describe Ci::PipelineTriggerService, services: true do
context
'when params have a non-existsed ref'
do
context
'when params have a non-existsed ref'
do
let
(
:ref
)
{
'invalid-ref'
}
let
(
:ref
)
{
'invalid-ref'
}
let
(
:variables
)
{}
it
'does not trigger a pipeline'
do
it
'does not trigger a pipeline'
do
expect
{
result
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
expect
{
result
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
...
@@ -54,6 +59,8 @@ describe Ci::PipelineTriggerService, services: true do
...
@@ -54,6 +59,8 @@ describe Ci::PipelineTriggerService, services: true do
context
'when params have a non-existsed trigger token'
do
context
'when params have a non-existsed trigger token'
do
let
(
:token
)
{
'invalid-token'
}
let
(
:token
)
{
'invalid-token'
}
let
(
:ref
)
{}
let
(
:variables
)
{}
it
'does not trigger a pipeline'
do
it
'does not trigger a pipeline'
do
expect
{
result
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
expect
{
result
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
...
@@ -61,10 +68,4 @@ describe Ci::PipelineTriggerService, services: true do
...
@@ -61,10 +68,4 @@ describe Ci::PipelineTriggerService, services: true do
end
end
end
end
end
end
def
params
{
token:
defined?
(
token
)
?
token
:
nil
,
ref:
defined?
(
ref
)
?
ref
:
nil
,
variables:
defined?
(
variables
)
?
variables
:
nil
}
end
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