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
782c8f9a
Commit
782c8f9a
authored
Oct 05, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix triggers spec
parent
d2d2df07
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
26 deletions
+15
-26
app/services/ci/create_trigger_request_service.rb
app/services/ci/create_trigger_request_service.rb
+7
-3
spec/services/ci/create_trigger_request_service_spec.rb
spec/services/ci/create_trigger_request_service_spec.rb
+8
-23
No files found.
app/services/ci/create_trigger_request_service.rb
View file @
782c8f9a
module
Ci
class
CreateTriggerRequestService
def
execute
(
project
,
trigger
,
ref
,
variables
=
nil
)
commit
=
project
.
gl_project
.
commi
t
(
ref
)
return
unless
commi
t
target
=
project
.
gl_project
.
repository
.
rev_parse_targe
t
(
ref
)
return
unless
targe
t
ci_commit
=
project
.
gl_project
.
ensure_ci_commit
(
commit
.
sha
)
# check if ref is tag
sha
=
target
.
oid
tag
=
target
.
is_a?
(
Rugged
::
Tag
)
||
target
.
is_a?
(
Rugged
::
Tag
::
Annotation
)
ci_commit
=
project
.
gl_project
.
ensure_ci_commit
(
sha
)
trigger_request
=
trigger
.
trigger_requests
.
create!
(
variables:
variables
)
...
...
spec/services/ci/create_trigger_request_service_spec.rb
View file @
782c8f9a
...
...
@@ -3,19 +3,19 @@ require 'spec_helper'
describe
Ci
::
CreateTriggerRequestService
do
let
(
:service
)
{
Ci
::
CreateTriggerRequestService
.
new
}
let
(
:project
)
{
FactoryGirl
.
create
:ci_project
}
let
(
:gl_project
)
{
FactoryGirl
.
create
:
empty_
project
,
gitlab_ci_project:
project
}
let
(
:gl_project
)
{
FactoryGirl
.
create
:project
,
gitlab_ci_project:
project
}
let
(
:trigger
)
{
FactoryGirl
.
create
:ci_trigger
,
project:
project
}
before
do
stub_ci_commit_to_return_yaml_file
end
describe
:execute
do
context
'valid params'
do
subject
{
service
.
execute
(
project
,
trigger
,
'master'
)
}
before
do
@commit
=
FactoryGirl
.
create
:ci_commit
,
gl_project:
gl_project
end
it
{
expect
(
subject
).
to
be_kind_of
(
Ci
::
TriggerRequest
)
}
it
{
expect
(
subject
.
commit
).
to
eq
(
@c
ommit
)
}
it
{
expect
(
subject
.
commit
).
to
be_kind_of
(
Ci
::
C
ommit
)
}
end
context
'no commit for ref'
do
...
...
@@ -28,26 +28,11 @@ describe Ci::CreateTriggerRequestService do
subject
{
service
.
execute
(
project
,
trigger
,
'master'
)
}
before
do
FactoryGirl
.
create
:ci_commit_without_jobs
,
gl_project:
gl_project
stub_ci_commit_yaml_file
(
'{}'
)
FactoryGirl
.
create
:ci_commit
,
gl_project:
gl_project
end
it
{
expect
(
subject
).
to
be_nil
}
end
context
'for multiple commits'
do
subject
{
service
.
execute
(
project
,
trigger
,
'master'
)
}
before
do
@commit1
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
2
.
hour
.
ago
,
gl_project:
gl_project
@commit2
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
1
.
hour
.
ago
,
gl_project:
gl_project
@commit3
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
3
.
hour
.
ago
,
gl_project:
gl_project
end
context
'retries latest one'
do
it
{
expect
(
subject
).
to
be_kind_of
(
Ci
::
TriggerRequest
)
}
it
{
expect
(
subject
).
to
be_persisted
}
it
{
expect
(
subject
.
commit
).
to
eq
(
@commit2
)
}
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