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
e9862a99
Commit
e9862a99
authored
Jul 20, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use struct instead of hash
parent
c9c715cd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
19 deletions
+20
-19
app/services/ci/create_trigger_request_service.rb
app/services/ci/create_trigger_request_service.rb
+3
-2
lib/api/triggers.rb
lib/api/triggers.rb
+1
-1
lib/api/v3/triggers.rb
lib/api/v3/triggers.rb
+2
-2
lib/ci/api/triggers.rb
lib/ci/api/triggers.rb
+2
-2
spec/services/ci/create_trigger_request_service_spec.rb
spec/services/ci/create_trigger_request_service_spec.rb
+12
-12
No files found.
app/services/ci/create_trigger_request_service.rb
View file @
e9862a99
module
Ci
module
Ci
module
CreateTriggerRequestService
module
CreateTriggerRequestService
Result
=
Struct
.
new
(
:trigger_request
,
:pipeline
)
def
self
.
execute
(
project
,
trigger
,
ref
,
variables
=
nil
)
def
self
.
execute
(
project
,
trigger
,
ref
,
variables
=
nil
)
trigger_request
=
trigger
.
trigger_requests
.
create
(
variables:
variables
)
trigger_request
=
trigger
.
trigger_requests
.
create
(
variables:
variables
)
pipeline
=
Ci
::
CreatePipelineService
.
new
(
project
,
trigger
.
owner
,
ref:
ref
)
pipeline
=
Ci
::
CreatePipelineService
.
new
(
project
,
trigger
.
owner
,
ref:
ref
)
.
execute
(
:trigger
,
ignore_skip_ci:
true
,
trigger_request:
trigger_request
)
.
execute
(
:trigger
,
ignore_skip_ci:
true
,
trigger_request:
trigger_request
)
{
trigger_request:
trigger_request
,
Result
.
new
(
trigger_request
,
pipeline
)
pipeline:
pipeline
}
end
end
end
end
end
end
lib/api/triggers.rb
View file @
e9862a99
...
@@ -28,7 +28,7 @@ module API
...
@@ -28,7 +28,7 @@ module API
# create request and trigger builds
# create request and trigger builds
result
=
Ci
::
CreateTriggerRequestService
.
execute
(
project
,
trigger
,
params
[
:ref
].
to_s
,
variables
)
result
=
Ci
::
CreateTriggerRequestService
.
execute
(
project
,
trigger
,
params
[
:ref
].
to_s
,
variables
)
pipeline
=
result
[
:pipeline
]
pipeline
=
result
.
pipeline
if
pipeline
.
persisted?
if
pipeline
.
persisted?
present
pipeline
,
with:
Entities
::
Pipeline
present
pipeline
,
with:
Entities
::
Pipeline
...
...
lib/api/v3/triggers.rb
View file @
e9862a99
...
@@ -29,10 +29,10 @@ module API
...
@@ -29,10 +29,10 @@ module API
# create request and trigger builds
# create request and trigger builds
result
=
Ci
::
CreateTriggerRequestService
.
execute
(
project
,
trigger
,
params
[
:ref
].
to_s
,
variables
)
result
=
Ci
::
CreateTriggerRequestService
.
execute
(
project
,
trigger
,
params
[
:ref
].
to_s
,
variables
)
pipeline
=
result
[
:pipeline
]
pipeline
=
result
.
pipeline
if
pipeline
.
persisted?
if
pipeline
.
persisted?
present
result
[
:trigger_request
]
,
with:
::
API
::
V3
::
Entities
::
TriggerRequest
present
result
.
trigger_request
,
with:
::
API
::
V3
::
Entities
::
TriggerRequest
else
else
render_validation_error!
(
pipeline
)
render_validation_error!
(
pipeline
)
end
end
...
...
lib/ci/api/triggers.rb
View file @
e9862a99
...
@@ -25,10 +25,10 @@ module Ci
...
@@ -25,10 +25,10 @@ module Ci
# create request and trigger builds
# create request and trigger builds
result
=
Ci
::
CreateTriggerRequestService
.
execute
(
project
,
trigger
,
params
[
:ref
],
variables
)
result
=
Ci
::
CreateTriggerRequestService
.
execute
(
project
,
trigger
,
params
[
:ref
],
variables
)
pipeline
=
result
[
:pipeline
]
pipeline
=
result
.
pipeline
if
pipeline
.
persisted?
if
pipeline
.
persisted?
present
result
[
:trigger_request
]
,
with:
Entities
::
TriggerRequest
present
result
.
trigger_request
,
with:
Entities
::
TriggerRequest
else
else
render_validation_error!
(
pipeline
)
render_validation_error!
(
pipeline
)
end
end
...
...
spec/services/ci/create_trigger_request_service_spec.rb
View file @
e9862a99
...
@@ -17,26 +17,26 @@ describe Ci::CreateTriggerRequestService, services: true do
...
@@ -17,26 +17,26 @@ describe Ci::CreateTriggerRequestService, services: true do
subject
{
service
.
execute
(
project
,
trigger
,
'master'
)
}
subject
{
service
.
execute
(
project
,
trigger
,
'master'
)
}
context
'without owner'
do
context
'without owner'
do
it
{
expect
(
subject
[
:trigger_request
]
).
to
be_kind_of
(
Ci
::
TriggerRequest
)
}
it
{
expect
(
subject
.
trigger_request
).
to
be_kind_of
(
Ci
::
TriggerRequest
)
}
it
{
expect
(
subject
[
:trigger_request
]
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
it
{
expect
(
subject
.
trigger_request
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
it
{
expect
(
subject
[
:pipeline
]
).
to
be_kind_of
(
Ci
::
Pipeline
)
}
it
{
expect
(
subject
.
pipeline
).
to
be_kind_of
(
Ci
::
Pipeline
)
}
it
{
expect
(
subject
[
:pipeline
]
).
to
be_trigger
}
it
{
expect
(
subject
.
pipeline
).
to
be_trigger
}
end
end
context
'with owner'
do
context
'with owner'
do
it
{
expect
(
subject
[
:trigger_request
]
).
to
be_kind_of
(
Ci
::
TriggerRequest
)
}
it
{
expect
(
subject
.
trigger_request
).
to
be_kind_of
(
Ci
::
TriggerRequest
)
}
it
{
expect
(
subject
[
:trigger_request
]
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
it
{
expect
(
subject
.
trigger_request
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
it
{
expect
(
subject
[
:trigger_request
]
.
builds
.
first
.
user
).
to
eq
(
owner
)
}
it
{
expect
(
subject
.
trigger_request
.
builds
.
first
.
user
).
to
eq
(
owner
)
}
it
{
expect
(
subject
[
:pipeline
]
).
to
be_kind_of
(
Ci
::
Pipeline
)
}
it
{
expect
(
subject
.
pipeline
).
to
be_kind_of
(
Ci
::
Pipeline
)
}
it
{
expect
(
subject
[
:pipeline
]
).
to
be_trigger
}
it
{
expect
(
subject
.
pipeline
).
to
be_trigger
}
it
{
expect
(
subject
[
:pipeline
]
.
user
).
to
eq
(
owner
)
}
it
{
expect
(
subject
.
pipeline
.
user
).
to
eq
(
owner
)
}
end
end
end
end
context
'no commit for ref'
do
context
'no commit for ref'
do
subject
{
service
.
execute
(
project
,
trigger
,
'other-branch'
)
}
subject
{
service
.
execute
(
project
,
trigger
,
'other-branch'
)
}
it
{
expect
(
subject
[
:pipeline
]
).
not_to
be_persisted
}
it
{
expect
(
subject
.
pipeline
).
not_to
be_persisted
}
end
end
context
'no builds created'
do
context
'no builds created'
do
...
@@ -46,7 +46,7 @@ describe Ci::CreateTriggerRequestService, services: true do
...
@@ -46,7 +46,7 @@ describe Ci::CreateTriggerRequestService, services: true do
stub_ci_pipeline_yaml_file
(
'script: { only: [develop], script: hello World }'
)
stub_ci_pipeline_yaml_file
(
'script: { only: [develop], script: hello World }'
)
end
end
it
{
expect
(
subject
[
:pipeline
]
).
not_to
be_persisted
}
it
{
expect
(
subject
.
pipeline
).
not_to
be_persisted
}
end
end
end
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