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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
618dc4cd
Commit
618dc4cd
authored
Apr 26, 2015
by
Jeroen van Baarsen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9206 from dsander/hipchat-options
Add notify and color options to HipchatService
parents
f0c4c51f
3c3b43b0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
3 deletions
+27
-3
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+2
-1
app/models/project_services/hipchat_service.rb
app/models/project_services/hipchat_service.rb
+8
-2
spec/models/project_services/hipchat_service_spec.rb
spec/models/project_services/hipchat_service_spec.rb
+16
-0
No files found.
CHANGELOG
View file @
618dc4cd
...
...
@@ -23,6 +23,7 @@ v 7.11.0 (unreleased)
- Improve new project command options (Ben Bodenmiller)
- Prevent sending empty messages to HipChat (Chulki Lee)
- Improve UI for mobile phones on dashboard and project pages
- Add room notification and message color option for HipChat
v 7.10.0
- Ignore submodules that are defined in .gitmodules but are checked in as directories.
...
...
app/controllers/projects/services_controller.rb
View file @
618dc4cd
...
...
@@ -6,7 +6,8 @@ class Projects::ServicesController < Projects::ApplicationController
:description
,
:issues_url
,
:new_issue_url
,
:restrict_to_branch
,
:channel
,
:colorize_messages
,
:channels
,
:push_events
,
:issues_events
,
:merge_requests_events
,
:tag_push_events
,
:note_events
,
:send_from_committer_email
,
:disable_diffs
,
:external_wiki_url
]
:note_events
,
:send_from_committer_email
,
:disable_diffs
,
:external_wiki_url
,
:notify
,
:color
]
# Authorize
before_action
:authorize_admin_project!
before_action
:service
,
only:
[
:edit
,
:update
,
:test
]
...
...
app/models/project_services/hipchat_service.rb
View file @
618dc4cd
...
...
@@ -20,7 +20,7 @@
class
HipchatService
<
Service
MAX_COMMITS
=
3
prop_accessor
:token
,
:room
,
:server
prop_accessor
:token
,
:room
,
:server
,
:notify
,
:color
validates
:token
,
presence:
true
,
if: :activated?
def
title
...
...
@@ -39,6 +39,8 @@ class HipchatService < Service
[
{
type:
'text'
,
name:
'token'
,
placeholder:
'Room token'
},
{
type:
'text'
,
name:
'room'
,
placeholder:
'Room name or ID'
},
{
type:
'checkbox'
,
name:
'notify'
},
{
type:
'select'
,
name:
'color'
,
choices:
[
'yellow'
,
'red'
,
'green'
,
'purple'
,
'gray'
,
'random'
]
},
{
type:
'text'
,
name:
'server'
,
placeholder:
'Leave blank for default. https://hipchat.example.com'
}
]
...
...
@@ -52,7 +54,7 @@ class HipchatService < Service
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
message
=
create_message
(
data
)
return
unless
message
.
present?
gate
[
room
].
send
(
'GitLab'
,
message
)
gate
[
room
].
send
(
'GitLab'
,
message
,
message_options
)
end
private
...
...
@@ -63,6 +65,10 @@ class HipchatService < Service
@gate
||=
HipChat
::
Client
.
new
(
token
,
options
)
end
def
message_options
{
notify:
notify
.
present?
&&
notify
==
'1'
,
color:
color
||
'yellow'
}
end
def
create_message
(
data
)
object_kind
=
data
[
:object_kind
]
...
...
spec/models/project_services/hipchat_service_spec.rb
View file @
618dc4cd
...
...
@@ -213,5 +213,21 @@ describe HipchatService do
"<pre>snippet note</pre>"
)
end
end
context
"#message_options"
do
it
"should be set to the defaults"
do
expect
(
hipchat
.
send
(
:message_options
)).
to
eq
({
notify:
false
,
color:
'yellow'
})
end
it
"should set notfiy to true"
do
hipchat
.
stub
(
notify:
'1'
)
expect
(
hipchat
.
send
(
:message_options
)).
to
eq
({
notify:
true
,
color:
'yellow'
})
end
it
"should set the color"
do
hipchat
.
stub
(
color:
'red'
)
expect
(
hipchat
.
send
(
:message_options
)).
to
eq
({
notify:
false
,
color:
'red'
})
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