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
255162e1
Commit
255162e1
authored
Jul 26, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Little refactor, add specs, and a CHANGELOG entry
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
189e3b57
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
9 deletions
+31
-9
CHANGELOG
CHANGELOG
+1
-0
app/models/project_services/hipchat_service.rb
app/models/project_services/hipchat_service.rb
+6
-3
spec/models/project_services/hipchat_service_spec.rb
spec/models/project_services/hipchat_service_spec.rb
+24
-6
No files found.
CHANGELOG
View file @
255162e1
...
@@ -9,6 +9,7 @@ v 8.11.0 (unreleased)
...
@@ -9,6 +9,7 @@ v 8.11.0 (unreleased)
- Add green outline to New Branch button. !5447 (winniehell)
- Add green outline to New Branch button. !5447 (winniehell)
- Retrieve rendered HTML from cache in one request
- Retrieve rendered HTML from cache in one request
- Nokogiri's various parsing methods are now instrumented
- Nokogiri's various parsing methods are now instrumented
- Add build event color in HipChat messages (David Eisner)
- Make fork counter always clickable. !5463 (winniehell)
- Make fork counter always clickable. !5463 (winniehell)
- Remove `search_id` of labels dropdown filter to fix 'Missleading URI for labels in Merge Requests and Issues view'. !5368 (Scott Le)
- Remove `search_id` of labels dropdown filter to fix 'Missleading URI for labels in Merge Requests and Issues view'. !5368 (Scott Le)
- Load project invited groups and members eagerly in `ProjectTeam#fetch_members`
- Load project invited groups and members eagerly in `ProjectTeam#fetch_members`
...
...
app/models/project_services/hipchat_service.rb
View file @
255162e1
...
@@ -67,7 +67,7 @@ class HipchatService < Service
...
@@ -67,7 +67,7 @@ class HipchatService < Service
@gate
||=
HipChat
::
Client
.
new
(
token
,
options
)
@gate
||=
HipChat
::
Client
.
new
(
token
,
options
)
end
end
def
message_options
(
data
)
def
message_options
(
data
=
nil
)
{
notify:
notify
.
present?
&&
notify
==
'1'
,
color:
build_status_color
(
data
)
||
color
||
'yellow'
}
{
notify:
notify
.
present?
&&
notify
==
'1'
,
color:
build_status_color
(
data
)
||
color
||
'yellow'
}
end
end
...
@@ -241,11 +241,14 @@ class HipchatService < Service
...
@@ -241,11 +241,14 @@ class HipchatService < Service
end
end
def
build_status_color
(
data
)
def
build_status_color
(
data
)
if
data
[
:commit
][
:status
]
==
'success'
return
unless
data
&&
data
[
:object_kind
]
==
'build'
case
data
[
:commit
][
:status
]
when
'success'
'green'
'green'
else
else
'red'
'red'
end
if
data
[
:object_kind
]
==
'build'
end
end
end
def
project_name
def
project_name
...
...
spec/models/project_services/hipchat_service_spec.rb
View file @
255162e1
...
@@ -340,18 +340,36 @@ describe HipchatService, models: true do
...
@@ -340,18 +340,36 @@ describe HipchatService, models: true do
end
end
context
"#message_options"
do
context
"#message_options"
do
it
"
should be
set to the defaults"
do
it
"
is
set to the defaults"
do
expect
(
hipchat
.
send
(
:message_options
)).
to
eq
({
notify:
false
,
color:
'yellow'
})
expect
(
hipchat
.
__send__
(
:message_options
)).
to
eq
({
notify:
false
,
color:
'yellow'
})
end
end
it
"s
hould set notfi
y to true"
do
it
"s
ets notif
y to true"
do
allow
(
hipchat
).
to
receive
(
:notify
).
and_return
(
'1'
)
allow
(
hipchat
).
to
receive
(
:notify
).
and_return
(
'1'
)
expect
(
hipchat
.
send
(
:message_options
)).
to
eq
({
notify:
true
,
color:
'yellow'
})
expect
(
hipchat
.
__send__
(
:message_options
)).
to
eq
({
notify:
true
,
color:
'yellow'
})
end
end
it
"s
hould set
the color"
do
it
"s
ets
the color"
do
allow
(
hipchat
).
to
receive
(
:color
).
and_return
(
'red'
)
allow
(
hipchat
).
to
receive
(
:color
).
and_return
(
'red'
)
expect
(
hipchat
.
send
(
:message_options
)).
to
eq
({
notify:
false
,
color:
'red'
})
expect
(
hipchat
.
__send__
(
:message_options
)).
to
eq
({
notify:
false
,
color:
'red'
})
end
context
'with a successful build'
do
it
'uses the green color'
do
build_data
=
{
object_kind:
'build'
,
commit:
{
status:
'success'
}
}
expect
(
hipchat
.
__send__
(
:message_options
,
build_data
)).
to
eq
({
notify:
false
,
color:
'green'
})
end
end
context
'with a failed build'
do
it
'uses the red color'
do
build_data
=
{
object_kind:
'build'
,
commit:
{
status:
'failed'
}
}
expect
(
hipchat
.
__send__
(
:message_options
,
build_data
)).
to
eq
({
notify:
false
,
color:
'red'
})
end
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