Skip to content
This repository has been archived by the owner on Jan 30, 2018. It is now read-only.

Commit

Permalink
Add compare url to task comment if params exists in payload [438394]
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Szwed committed Sep 1, 2011
1 parent d682532 commit 236cfa0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/models/comment.rb
Expand Up @@ -31,7 +31,8 @@ def self.from_github(payload)
url+="/tree/#{branch_name}"
end

text = ("Posted on Github: <a href=\"%s\">%s</a>\n\n" % [url, anchor])
compare = payload.has_key?('compare') ? (" <a href=\"%s\">(compare)</a>" % payload['compare']) : ''
text = ("Posted on Github: <a href=\"%s\">%s</a>%s\n\n" % [url, anchor, compare])

commits.each do |commit|
@author_name = commit['author']['name']
Expand Down
5 changes: 3 additions & 2 deletions spec/controllers/hooks_controller_spec.rb
Expand Up @@ -379,6 +379,7 @@ def post(payload = @payload_v2, hook = 'pivotal')
"after": "de8251ff97ee194a289832576287d6f8ad74e3d0",
"ref": "refs/heads/master",
"pusher": {"email":"frank@teambox.com","name":"frank"},
"compare": "https://github.com/teambox/teambox/compare/41a212e^...hju8251",
"repository": {
"url": "http://github.com/defunkt/github",
"name": "github",
Expand Down Expand Up @@ -519,7 +520,7 @@ def post(payload = @payload_v2, hook = 'pivotal')
second_comment.target.should == @other_task

expected_first = (<<-HTML).strip
Posted on Github: <a href=\"http://github.com/defunkt/github/tree/master\">github/refs/heads/master</a>
Posted on Github: <a href=\"http://github.com/defunkt/github/tree/master\">github/refs/heads/master</a> <a href=\"https://github.com/teambox/teambox/compare/41a212e^...hju8251\">(compare)</a>
Chris Wanstrath - <a href=\"http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59\">Check this file, task</a>\n
Mislav Marohnić - <a href=\"http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0\">Closing for task</a>
Expand All @@ -528,7 +529,7 @@ def post(payload = @payload_v2, hook = 'pivotal')
first_comment.body.strip.should == expected_first.strip

expected_second = (<<-HTML).strip
Posted on Github: <a href=\"http://github.com/defunkt/github/tree/master\">github/refs/heads/master</a>
Posted on Github: <a href=\"http://github.com/defunkt/github/tree/master\">github/refs/heads/master</a> <a href=\"https://github.com/teambox/teambox/compare/41a212e^...hju8251\">(compare)</a>
Mislav Marohnić - <a href=\"http://github.com/defunkt/github/commit/hju8251ff97ee194a289832576287d6f89ui7978h\">Commit for different task</a>
HTML
Expand Down

0 comments on commit 236cfa0

Please sign in to comment.