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
257d15a6
Commit
257d15a6
authored
Oct 19, 2016
by
Airat Shigapov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return truncation for notification descriptions, fix minor bugs with rendering
parent
7b90680c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
12 deletions
+17
-12
app/models/project_services/hipchat_service.rb
app/models/project_services/hipchat_service.rb
+11
-6
spec/models/project_services/hipchat_service_spec.rb
spec/models/project_services/hipchat_service_spec.rb
+6
-6
No files found.
app/models/project_services/hipchat_service.rb
View file @
257d15a6
...
@@ -2,6 +2,11 @@ class HipchatService < Service
...
@@ -2,6 +2,11 @@ class HipchatService < Service
include
ActionView
::
Helpers
::
SanitizeHelper
include
ActionView
::
Helpers
::
SanitizeHelper
MAX_COMMITS
=
3
MAX_COMMITS
=
3
HIPCHAT_ALLOWED_TAGS
=
%w[
a b i strong em br img pre code
table th tr td caption colgroup col thead tbody tfoot
ul ol li dl dt dd
]
prop_accessor
:token
,
:room
,
:server
,
:notify
,
:color
,
:api_version
prop_accessor
:token
,
:room
,
:server
,
:notify
,
:color
,
:api_version
boolean_accessor
:notify_only_broken_builds
boolean_accessor
:notify_only_broken_builds
...
@@ -139,10 +144,10 @@ class HipchatService < Service
...
@@ -139,10 +144,10 @@ class HipchatService < Service
context
.
merge!
(
options
)
context
.
merge!
(
options
)
html
=
Banzai
.
render
(
text
,
context
)
html
=
Banzai
.
post_process
(
Banzai
.
render
(
text
,
context
)
,
context
)
html
=
Banzai
.
post_process
(
html
,
context
)
sanitized_html
=
sanitize
(
html
,
tags:
HIPCHAT_ALLOWED_TAGS
,
attributes:
%w[href title alt]
)
sanitize
html
,
attributes:
%w(href title alt
)
sanitize
d_html
.
truncate
(
200
,
separator:
' '
,
omission:
'...'
)
end
end
def
create_issue_message
(
data
)
def
create_issue_message
(
data
)
...
@@ -159,7 +164,7 @@ class HipchatService < Service
...
@@ -159,7 +164,7 @@ class HipchatService < Service
issue_link
=
"<a href=
\"
#{
issue_url
}
\"
>issue #
#{
issue_iid
}
</a>"
issue_link
=
"<a href=
\"
#{
issue_url
}
\"
>issue #
#{
issue_iid
}
</a>"
message
=
"
#{
user_name
}
#{
state
}
#{
issue_link
}
in
#{
project_link
}
: <b>
#{
title
}
</b>"
message
=
"
#{
user_name
}
#{
state
}
#{
issue_link
}
in
#{
project_link
}
: <b>
#{
title
}
</b>"
message
<<
markdown
(
description
)
message
<<
"<pre>
#{
markdown
(
description
)
}
</pre>"
message
message
end
end
...
@@ -179,7 +184,7 @@ class HipchatService < Service
...
@@ -179,7 +184,7 @@ class HipchatService < Service
message
=
"
#{
user_name
}
#{
state
}
#{
merge_request_link
}
in "
\
message
=
"
#{
user_name
}
#{
state
}
#{
merge_request_link
}
in "
\
"
#{
project_link
}
: <b>
#{
title
}
</b>"
"
#{
project_link
}
: <b>
#{
title
}
</b>"
message
<<
markdown
(
description
)
message
<<
"<pre>
#{
markdown
(
description
)
}
</pre>"
message
message
end
end
...
@@ -230,7 +235,7 @@ class HipchatService < Service
...
@@ -230,7 +235,7 @@ class HipchatService < Service
message
=
"
#{
user_name
}
commented on
#{
subject_html
}
in
#{
project_link
}
: "
message
=
"
#{
user_name
}
commented on
#{
subject_html
}
in
#{
project_link
}
: "
message
<<
title
message
<<
title
message
<<
markdown
(
note
,
ref:
commit_id
)
message
<<
"<pre>
#{
markdown
(
note
,
ref:
commit_id
)
}
</pre>"
message
message
end
end
...
...
spec/models/project_services/hipchat_service_spec.rb
View file @
257d15a6
...
@@ -135,7 +135,7 @@ describe HipchatService, models: true do
...
@@ -135,7 +135,7 @@ describe HipchatService, models: true do
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>issue #
#{
obj_attr
[
"iid"
]
}
</a> in "
\
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>issue #
#{
obj_attr
[
"iid"
]
}
</a> in "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<b>Awesome issue</b>"
\
"<b>Awesome issue</b>"
\
"<p
><strong>please</strong> fix</p
>"
)
"<p
re><strong>please</strong> fix</pre
>"
)
end
end
end
end
...
@@ -159,7 +159,7 @@ describe HipchatService, models: true do
...
@@ -159,7 +159,7 @@ describe HipchatService, models: true do
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>merge request !
#{
obj_attr
[
"iid"
]
}
</a> in "
\
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>merge request !
#{
obj_attr
[
"iid"
]
}
</a> in "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<b>Awesome merge request</b>"
\
"<b>Awesome merge request</b>"
\
"<p
><strong>please</strong> fix</p
>"
)
"<p
re><strong>please</strong> fix</pre
>"
)
end
end
end
end
...
@@ -190,7 +190,7 @@ describe HipchatService, models: true do
...
@@ -190,7 +190,7 @@ describe HipchatService, models: true do
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>commit
#{
commit_id
}
</a> in "
\
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>commit
#{
commit_id
}
</a> in "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"
#{
title
}
"
\
"
#{
title
}
"
\
"<p
>a comment on a commit</p
>"
)
"<p
re>a comment on a commit</pre
>"
)
end
end
end
end
...
@@ -222,7 +222,7 @@ describe HipchatService, models: true do
...
@@ -222,7 +222,7 @@ describe HipchatService, models: true do
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>merge request !
#{
merge_id
}
</a> in "
\
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>merge request !
#{
merge_id
}
</a> in "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<b>
#{
title
}
</b>"
\
"<b>
#{
title
}
</b>"
\
"<p
>merge request <strong>note</strong></p
>"
)
"<p
re>merge request <strong>note</strong></pre
>"
)
end
end
end
end
...
@@ -247,7 +247,7 @@ describe HipchatService, models: true do
...
@@ -247,7 +247,7 @@ describe HipchatService, models: true do
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>issue #
#{
issue_id
}
</a> in "
\
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>issue #
#{
issue_id
}
</a> in "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<b>
#{
title
}
</b>"
\
"<b>
#{
title
}
</b>"
\
"<p
>issue <strong>note</strong></p
>"
)
"<p
re>issue <strong>note</strong></pre
>"
)
end
end
end
end
...
@@ -275,7 +275,7 @@ describe HipchatService, models: true do
...
@@ -275,7 +275,7 @@ describe HipchatService, models: true do
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>snippet #
#{
snippet_id
}
</a> in "
\
"<a href=
\"
#{
obj_attr
[
:url
]
}
\"
>snippet #
#{
snippet_id
}
</a> in "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<a href=
\"
#{
project
.
web_url
}
\"
>
#{
project_name
}
</a>: "
\
"<b>
#{
title
}
</b>"
\
"<b>
#{
title
}
</b>"
\
"<p
>snippet note</p
>"
)
"<p
re>snippet note</pre
>"
)
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