ticketmaster-github 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.8.1
@@ -16,14 +16,13 @@ module TicketMaster::Provider
16
16
  :body => object.body,
17
17
  :created_at => object.created_at,
18
18
  :author => object.user.login}
19
-
20
19
  else
21
20
  hash = object
22
21
  end
23
22
  super hash
24
23
  end
25
24
  end
26
-
25
+
27
26
  def author
28
27
  self.user.login
29
28
  end
@@ -53,6 +52,7 @@ module TicketMaster::Provider
53
52
  def self.find_all(project_id, ticket_id)
54
53
  TicketMaster::Provider::Github.api.issue_comments(project_id, ticket_id).collect do |comment|
55
54
  comment.merge!(:project_id => project_id, :ticket_id => ticket_id)
55
+ clean_body! comment
56
56
  self.new comment
57
57
  end
58
58
  end
@@ -60,8 +60,22 @@ module TicketMaster::Provider
60
60
  def self.create(project_id, ticket_id, comment)
61
61
  github_comment = TicketMaster::Provider::Github.api.add_comment(project_id, ticket_id, comment)
62
62
  github_comment.merge!(:project_id => project_id, :ticket_id => ticket_id)
63
+ flat_body github_comment
63
64
  self.new github_comment
64
65
  end
66
+
67
+ private
68
+
69
+ #See https://www.kanbanpad.com/projects/31edb8d134e7967c1f0d#!xt-4f994d17014289000707433f
70
+ def self.flat_body(comment_hashie)
71
+ comment_hashie.body = comment_hashie.body.body
72
+ comment_hashie
73
+ end
74
+
75
+ # See https://www.kanbanpad.com/projects/31edb8d134e7967c1f0d#!xt-4f994f2101428900070759fd
76
+ def self.clean_body!(comment)
77
+ comment.body = comment.body.sub(/\A---\s\sbody:\s/, '').gsub(/\s\z/, '')
78
+ end
65
79
 
66
80
  end
67
81
  end
@@ -121,10 +121,9 @@ module TicketMaster::Provider
121
121
  Ticket.new(project_id, TicketMaster::Provider::Github.api.close_issue(project_id, number))
122
122
  end
123
123
 
124
- def comment!(comment)
125
- Comment.create(project_id, number, comment)
124
+ def comment!(attributes)
125
+ Comment.create(project_id, number, attributes)
126
126
  end
127
-
128
127
  end
129
128
  end
130
129
  end
data/spec/comment_spec.rb CHANGED
@@ -16,14 +16,20 @@ describe "Ticketmaster::Provider::Github::Comment" do
16
16
  end
17
17
 
18
18
  it "should be able to load all comments" do
19
- @comments = @ticket.comments
20
- @comments.should be_an_instance_of(Array)
21
- @comments.first.should be_an_instance_of(@klass)
19
+ comments = @ticket.comments
20
+ comments.should be_an_instance_of(Array)
21
+ comments.first.should be_an_instance_of(@klass)
22
+ comments.first.body.should == "for testing"
22
23
  end
23
-
24
+
24
25
  it "should be able to create a new comment" do
25
- comment = @ticket.comment!(:body => 'new comment')
26
+ comment = @ticket.comment!(:body => 'for testing')
26
27
  comment.should be_an_instance_of(@klass)
28
+ comment.body.should == 'for testing'
29
+ end
30
+
31
+ #see bug 116 tm-github: Bug Ticket#comments returning comments with weird text in the body
32
+ it "should be able to load a ticket and clean comment body" do
33
+ comments = @ticket.comments.map(&:body).should == ["for testing", "test comment"]
27
34
  end
28
-
29
35
  end
@@ -12,5 +12,19 @@
12
12
  "avatar_url": "https://secure.gravatar.com/avatar/42bd18419413dfbd6e7ec4fefdec94ae?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
13
13
  "id": 1434902
14
14
  }
15
+ },
16
+ {
17
+ "url": "https://api.github.com/repos/ticketmaster-user/tmtest-repo/issues/comments/3951282",
18
+ "created_at": "2012-02-13T22:49:55Z",
19
+ "body": "--- \nbody: test comment\n",
20
+ "updated_at": "2012-02-13T22:49:55Z",
21
+ "id": 3951283,
22
+ "user": {
23
+ "url": "https://api.github.com/users/ticketmaster-user",
24
+ "gravatar_id": "42bd18419413dfbd6e7ec4fefdec94ae",
25
+ "login": "ticketmaster-user",
26
+ "avatar_url": "https://secure.gravatar.com/avatar/42bd18419413dfbd6e7ec4fefdec94ae?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
27
+ "id": 1434902
28
+ }
15
29
  }
16
30
  ]
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "url": "https://api.github.com/repos/ticketmaster-user/tmtest-repo/issues/comments/3951282",
3
3
  "created_at": "2012-02-13T22:49:55Z",
4
- "body": "for testing",
4
+ "body": {
5
+ "body": "for testing"
6
+ },
5
7
  "updated_at": "2012-02-13T22:49:55Z",
6
8
  "id": 3951282,
7
9
  "user": {
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ticketmaster-github"
8
- s.version = "0.8.0"
8
+ s.version = "0.8.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["HybridGroup"]
12
- s.date = "2012-04-12"
12
+ s.date = "2012-05-01"
13
13
  s.description = "This provides an interface with github through the ticketmaster gem."
14
14
  s.email = "hong.quach@abigfisch.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ticketmaster-github
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 0
10
- version: 0.8.0
9
+ - 1
10
+ version: 0.8.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - HybridGroup
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-12 00:00:00 Z
18
+ date: 2012-05-01 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: ticketmaster