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
iv
gitlab-ce
Commits
f42078f7
Commit
f42078f7
authored
Oct 05, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rest of tests
parent
0367dbf0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
136 deletions
+67
-136
app/services/ci/create_trigger_request_service.rb
app/services/ci/create_trigger_request_service.rb
+5
-8
app/services/ci/web_hook_service.rb
app/services/ci/web_hook_service.rb
+1
-0
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+1
-0
spec/features/ci/commits_spec.rb
spec/features/ci/commits_spec.rb
+6
-2
spec/models/ci/project_services/hip_chat_message_spec.rb
spec/models/ci/project_services/hip_chat_message_spec.rb
+25
-58
spec/models/ci/project_services/slack_message_spec.rb
spec/models/ci/project_services/slack_message_spec.rb
+29
-68
No files found.
app/services/ci/create_trigger_request_service.rb
View file @
f42078f7
module
Ci
class
CreateTriggerRequestService
def
execute
(
project
,
trigger
,
ref
,
variables
=
nil
)
return
unless
project
.
gl_project
return
unless
project
.
gl_project
.
repository
commit
=
project
.
gl_project
.
commit
(
ref
)
return
unless
commit
# check if ref is tag
ta
rget
=
project
.
gl_project
.
repository
.
rev_parse_target
(
ref
)
sha
=
target
.
oid
tag
=
target
.
is_a?
(
Rugged
::
Tag
)
||
target
.
is_a?
(
Rugged
::
Tag
::
Annotation
)
ta
g
=
project
.
gl_project
.
repository
.
find_tag
(
ref
).
present?
ci_commit
=
project
.
gl_project
.
ensure_ci_commit
(
commit
.
sha
)
ci_commit
=
project
.
gl_project
.
ensure_ci_commit
(
sha
)
trigger_request
=
trigger
.
trigger_requests
.
create!
(
variables:
variables
)
...
...
@@ -17,8 +16,6 @@ module Ci
if
ci_commit
.
create_builds
(
ref
,
tag
,
nil
,
trigger_request
)
trigger_request
end
rescue
Rugged
::
OdbError
nil
end
end
end
app/services/ci/web_hook_service.rb
View file @
f42078f7
...
...
@@ -27,6 +27,7 @@ module Ci
project_name:
project
.
name
,
gitlab_url:
project
.
gitlab_url
,
ref:
build
.
ref
,
before_sha:
build
.
before_sha
,
sha:
build
.
sha
,
})
end
...
...
spec/factories/ci/builds.rb
View file @
f42078f7
...
...
@@ -31,6 +31,7 @@ FactoryGirl.define do
tag
false
started_at
'Di 29. Okt 09:51:28 CET 2013'
finished_at
'Di 29. Okt 09:53:28 CET 2013'
commands
'ls -a'
options
do
{
image:
"ruby:2.1"
,
...
...
spec/features/ci/commits_spec.rb
View file @
f42078f7
...
...
@@ -11,6 +11,10 @@ describe "Commits" do
@commit
.
project
.
gl_project
.
team
<<
[
@user
,
:master
]
end
before
do
stub_ci_commit_to_return_yaml_file
end
describe
"GET /:project/commits/:sha"
do
before
do
visit
ci_commit_path
(
@commit
)
...
...
@@ -38,9 +42,9 @@ describe "Commits" do
end
it
"shows warning"
do
@commit_no_yaml
=
FactoryGirl
.
create
:ci_empty_commit
stub_ci_commit_yaml_file
(
nil
)
visit
ci_commit_path
(
@commit
_no_yaml
)
visit
ci_commit_path
(
@commit
)
expect
(
page
).
to
have_content
".gitlab-ci.yml not found in this commit"
end
...
...
spec/models/ci/project_services/hip_chat_message_spec.rb
View file @
f42078f7
...
...
@@ -3,70 +3,37 @@ require 'spec_helper'
describe
Ci
::
HipChatMessage
do
subject
{
Ci
::
HipChatMessage
.
new
(
build
)
}
context
"One build"
do
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_commit_with_one_job
)
}
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_commit_with_two_jobs
)
}
let
(
:build
)
do
commit
.
create_builds
(
'master'
,
false
,
nil
)
commit
.
builds
.
first
end
context
'when build succeeds'
do
it
'returns a successful message'
do
build
.
update
(
status:
"success"
)
expect
(
subject
.
status_color
).
to
eq
'green'
expect
(
subject
.
notify?
).
to
be_falsey
expect
(
subject
.
to_s
).
to
match
(
/Build '[^']+' #\d+/
)
expect
(
subject
.
to_s
).
to
match
(
/Successful in \d+ second\(s\)\./
)
end
end
context
'when build fails'
do
it
'returns a failure message'
do
build
.
update
(
status:
"failed"
)
expect
(
subject
.
status_color
).
to
eq
'red'
expect
(
subject
.
notify?
).
to
be_truthy
expect
(
subject
.
to_s
).
to
match
(
/Build '[^']+' #\d+/
)
expect
(
subject
.
to_s
).
to
match
(
/Failed in \d+ second\(s\)\./
)
end
end
let
(
:build
)
do
commit
.
builds
.
first
end
context
"Several builds"
do
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_commit_with_two_jobs
)
}
let
(
:build
)
do
commit
.
builds
.
first
end
context
'when all matrix builds succeed'
do
it
'returns a successful message'
do
commit
.
create_builds
(
'master'
,
false
,
nil
)
commit
.
builds
.
update_all
(
status:
"success"
)
commit
.
reload
context
'when all matrix builds succeed'
do
it
'returns a successful message'
do
commit
.
create_builds
(
'master'
,
false
,
nil
)
commit
.
builds
.
update_all
(
status:
"success"
)
commit
.
reload
expect
(
subject
.
status_color
).
to
eq
'green'
expect
(
subject
.
notify?
).
to
be_falsey
expect
(
subject
.
to_s
).
to
match
(
/Commit #\d+/
)
expect
(
subject
.
to_s
).
to
match
(
/Successful in \d+ second\(s\)\./
)
end
expect
(
subject
.
status_color
).
to
eq
'green'
expect
(
subject
.
notify?
).
to
be_falsey
expect
(
subject
.
to_s
).
to
match
(
/Commit #\d+/
)
expect
(
subject
.
to_s
).
to
match
(
/Successful in \d+ second\(s\)\./
)
end
end
context
'when at least one matrix build fails'
do
it
'returns a failure message'
do
commit
.
create_builds
(
'master'
,
false
,
nil
)
first_build
=
commit
.
builds
.
first
second_build
=
commit
.
builds
.
last
first_build
.
update
(
status:
"success"
)
second_build
.
update
(
status:
"failed"
)
expect
(
subject
.
status_color
).
to
eq
'red'
expect
(
subject
.
notify?
).
to
be_truthy
expect
(
subject
.
to_s
).
to
match
(
/Commit #\d+/
)
expect
(
subject
.
to_s
).
to
match
(
/Failed in \d+ second\(s\)\./
)
end
context
'when at least one matrix build fails'
do
it
'returns a failure message'
do
commit
.
create_builds
(
'master'
,
false
,
nil
)
first_build
=
commit
.
builds
.
first
second_build
=
commit
.
builds
.
last
first_build
.
update
(
status:
"success"
)
second_build
.
update
(
status:
"failed"
)
expect
(
subject
.
status_color
).
to
eq
'red'
expect
(
subject
.
notify?
).
to
be_truthy
expect
(
subject
.
to_s
).
to
match
(
/Commit #\d+/
)
expect
(
subject
.
to_s
).
to
match
(
/Failed in \d+ second\(s\)\./
)
end
end
end
spec/models/ci/project_services/slack_message_spec.rb
View file @
f42078f7
...
...
@@ -3,80 +3,41 @@ require 'spec_helper'
describe
Ci
::
SlackMessage
do
subject
{
Ci
::
SlackMessage
.
new
(
commit
)
}
context
"One build"
do
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_commit_with_one_job
)
}
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_commit_with_two_jobs
)
}
let
(
:build
)
do
commit
.
create_builds
(
'master'
,
false
,
nil
)
commit
.
builds
.
first
end
context
'when build succeeded'
do
let
(
:color
)
{
'good'
}
it
'returns a message with succeeded build'
do
build
.
update
(
status:
"success"
)
expect
(
subject
.
color
).
to
eq
(
color
)
expect
(
subject
.
fallback
).
to
include
(
'Build'
)
expect
(
subject
.
fallback
).
to
include
(
"
\#
#{
build
.
id
}
"
)
expect
(
subject
.
fallback
).
to
include
(
'succeeded'
)
expect
(
subject
.
attachments
.
first
[
:fields
]).
to
be_empty
end
end
context
'when build failed'
do
let
(
:color
)
{
'danger'
}
it
'returns a message with failed build'
do
build
.
update
(
status:
"failed"
)
context
'when all matrix builds succeeded'
do
let
(
:color
)
{
'good'
}
expect
(
subject
.
color
).
to
eq
(
color
)
expect
(
subject
.
fallback
).
to
include
(
'Build'
)
expect
(
subject
.
fallback
).
to
include
(
"
\#
#{
build
.
id
}
"
)
expect
(
subject
.
fallback
).
to
include
(
'failed'
)
expect
(
subject
.
attachments
.
first
[
:fields
]).
to
be_empty
end
it
'returns a message with success'
do
commit
.
create_builds
(
'master'
,
false
,
nil
)
commit
.
builds
.
update_all
(
status:
"success"
)
commit
.
reload
expect
(
subject
.
color
).
to
eq
(
color
)
expect
(
subject
.
fallback
).
to
include
(
'Commit'
)
expect
(
subject
.
fallback
).
to
include
(
"
\#
#{
commit
.
id
}
"
)
expect
(
subject
.
fallback
).
to
include
(
'succeeded'
)
expect
(
subject
.
attachments
.
first
[
:fields
]).
to
be_empty
end
end
context
"Several builds"
do
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_commit_with_two_jobs
)
}
context
'when all matrix builds succeeded'
do
let
(
:color
)
{
'good'
}
it
'returns a message with success'
do
commit
.
create_builds
(
'master'
,
false
,
nil
)
commit
.
builds
.
update_all
(
status:
"success"
)
commit
.
reload
expect
(
subject
.
color
).
to
eq
(
color
)
expect
(
subject
.
fallback
).
to
include
(
'Commit'
)
expect
(
subject
.
fallback
).
to
include
(
"
\#
#{
commit
.
id
}
"
)
expect
(
subject
.
fallback
).
to
include
(
'succeeded'
)
expect
(
subject
.
attachments
.
first
[
:fields
]).
to
be_empty
end
end
context
'when one of matrix builds failed'
do
let
(
:color
)
{
'danger'
}
context
'when one of matrix builds failed'
do
let
(
:color
)
{
'danger'
}
it
'returns a message with information about failed build'
do
commit
.
create_builds
(
'master'
,
false
,
nil
)
first_build
=
commit
.
builds
.
first
second_build
=
commit
.
builds
.
last
first_build
.
update
(
status:
"success"
)
second_build
.
update
(
status:
"failed"
)
expect
(
subject
.
color
).
to
eq
(
color
)
expect
(
subject
.
fallback
).
to
include
(
'Commit'
)
expect
(
subject
.
fallback
).
to
include
(
"
\#
#{
commit
.
id
}
"
)
expect
(
subject
.
fallback
).
to
include
(
'failed'
)
expect
(
subject
.
attachments
.
first
[
:fields
].
size
).
to
eq
(
1
)
expect
(
subject
.
attachments
.
first
[
:fields
].
first
[
:title
]).
to
eq
(
second_build
.
name
)
expect
(
subject
.
attachments
.
first
[
:fields
].
first
[
:value
]).
to
include
(
"
\#
#{
second_build
.
id
}
"
)
end
it
'returns a message with information about failed build'
do
commit
.
create_builds
(
'master'
,
false
,
nil
)
first_build
=
commit
.
builds
.
first
second_build
=
commit
.
builds
.
last
first_build
.
update
(
status:
"success"
)
second_build
.
update
(
status:
"failed"
)
expect
(
subject
.
color
).
to
eq
(
color
)
expect
(
subject
.
fallback
).
to
include
(
'Commit'
)
expect
(
subject
.
fallback
).
to
include
(
"
\#
#{
commit
.
id
}
"
)
expect
(
subject
.
fallback
).
to
include
(
'failed'
)
expect
(
subject
.
attachments
.
first
[
:fields
].
size
).
to
eq
(
1
)
expect
(
subject
.
attachments
.
first
[
:fields
].
first
[
:title
]).
to
eq
(
second_build
.
name
)
expect
(
subject
.
attachments
.
first
[
:fields
].
first
[
:value
]).
to
include
(
"
\#
#{
second_build
.
id
}
"
)
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