ticketmaster-kanbanpad 0.1.7 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.2.7
@@ -101,5 +101,10 @@ module KanbanpadAPI
101
101
  class TaskComment < Base
102
102
  self.site += 'projects/:project_id/tasks/:task_id'
103
103
  self.element_name = 'comment'
104
+
105
+ def self.element_path(id, prefix_options = {}, query_options = nil)
106
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
107
+ "#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
108
+ end
104
109
  end
105
110
  end
@@ -11,12 +11,15 @@ module TicketMaster::Provider
11
11
  API = KanbanpadAPI::TaskComment
12
12
 
13
13
  def self.find_by_id(project_id, ticket_id, id)
14
- self.new KanbanpadAPI::TaskComment.find(id, :params => {:project_id => project_id, :task_id => ticket_id})
14
+ self.search(project_id, ticket_id).select { |ticket| ticket.id == id }.first
15
+ end
16
+
17
+ def self.find_by_attributes(project_id, ticket_id, attributes = {})
18
+ search_by_attribute(self.search(project_id, ticket_id), attributes)
15
19
  end
16
20
 
17
21
  def self.search(project_id, ticket_id, options = {}, limit = 1000)
18
- comments = KanbanpadAPI::TaskComment.find(:all, :params => {:project_id => project_id, :task_id => ticket_id}).collect { |comment| self.new comment }
19
- search_by_attribute(comments, options, limit)
22
+ comments = API.find(:all, :params => {:project_id => project_id, :task_id => ticket_id}).collect { |comment| self.new comment }
20
23
  end
21
24
 
22
25
  def updated_at
@@ -17,6 +17,10 @@ module TicketMaster::Provider
17
17
  self.assigned_to.first
18
18
  end
19
19
 
20
+ def project_id
21
+ self.project_slug
22
+ end
23
+
20
24
  def created_at
21
25
  if self[:created_at].blank?
22
26
  Time.parse('2010-03-25 3:06:34') #kanbanpad used to not track the created_at
@@ -29,12 +33,8 @@ module TicketMaster::Provider
29
33
  end
30
34
  end
31
35
 
32
- def self.find_by_id(project_id, id)
33
- self.search(project_id, {'id' => id}).first
34
- end
35
-
36
36
  def self.find_by_attributes(project_id, attributes = {})
37
- self.search(project_id, attributes)
37
+ self.search_by_attribute(self.search(project_id), attributes)
38
38
  end
39
39
 
40
40
  def self.search(project_id, options = {}, limit = 1000)
@@ -55,6 +55,12 @@ module TicketMaster::Provider
55
55
  end
56
56
  end
57
57
 
58
+ def self.create(*options)
59
+ ticket = API.new(options.first)
60
+ ticket.save
61
+ self.new ticket
62
+ end
63
+
58
64
  #TODO?
59
65
  def comment
60
66
  warn 'Kanbanpad does not allow find by id of comments. Perhaps you should leave feedback to request it?'
@@ -66,7 +72,7 @@ module TicketMaster::Provider
66
72
  warn 'Perhaps you should leave feedback to request it?'
67
73
  []
68
74
  end
69
-
75
+
70
76
  end
71
77
  end
72
78
  end
@@ -1,5 +1,44 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe "Ticketmaster::Provider::Yoursystem::Comment" do
4
- it "should have specs for comments"
3
+ describe "Ticketmaster::Provider::Kanbanpad::Comment" do
4
+ before(:all) do
5
+ headers = {'Authorization' => 'Basic YWJjQGcuY29tOmllODIzZDYzanM='}
6
+ wheaders = headers.merge('Accept' => 'application/json')
7
+ ActiveResource::HttpMock.respond_to do |mock|
8
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
9
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks.json', wheaders, fixture_for('tasks'), 200
10
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks.json?backlog=yes&finished=yes', wheaders, fixture_for('tasks'), 200
11
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks/4cd428c496f0734eef000007.json', wheaders, fixture_for('tasks/4cd428c496f0734eef000007'), 200
12
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks/4cd428c496f0734eef000007/comments.json', wheaders, fixture_for('comments'), 200
13
+ end
14
+ @project_id = 'be74b643b64e3dc79aa0'
15
+ @ticket_id = '4cd428c496f0734eef000007'
16
+ @comment_id = '4d684e6f973c7d5648000009'
17
+ end
18
+
19
+ before(:each) do
20
+ @ticketmaster = TicketMaster.new(:kanbanpad, :username => 'abc@g.com', :password => 'ie823d63js')
21
+ @project = @ticketmaster.project(@project_id)
22
+ @ticket = @project.ticket(@ticket_id)
23
+ @klass = TicketMaster::Provider::Kanbanpad::Comment
24
+ end
25
+
26
+ it "should be able to load all comments" do
27
+ @comments = @ticket.comments
28
+ @comments.should be_an_instance_of(Array)
29
+ @comments.first.should be_an_instance_of(@klass)
30
+ end
31
+
32
+ it "should be able to load all comments based on array of id's" do
33
+ @comments = @ticket.comments([@comment_id])
34
+ @comments.should be_an_instance_of(Array)
35
+ @comments.first.should be_an_instance_of(@klass)
36
+ end
37
+
38
+ it "should be able to load all comments based on attributes" do
39
+ @comments = @ticket.comments(:id => @comment_id)
40
+ @comments.should be_an_instance_of(Array)
41
+ @comments.first.should be_an_instance_of(@klass)
42
+ end
43
+
5
44
  end
@@ -0,0 +1 @@
1
+ [{"created_at":"2011-02-26T00:50:55Z","author":"Rafael George <george.rafael@gmail.com>","body":"testing comments","updated_at":"2011-02-26T00:50:55Z","id":"4d684e6f973c7d5648000009","user_id":"4d62b9acc26df8076000004c"},{"created_at":"2011-02-26T01:02:25Z","author":"Rafael George <george.rafael@gmail.com>","body":"another comment\n","updated_at":"2011-02-26T01:02:25Z","id":"4d685121e87f1467ab00001d","user_id":"4d62b9acc26df8076000004c"},{"created_at":"2011-02-26T01:02:31Z","author":"Rafael George <george.rafael@gmail.com>","body":"and another one","updated_at":"2011-02-26T01:02:31Z","id":"4d685127d1c632140800000c","user_id":"4d62b9acc26df8076000004c"}]
data/spec/tickets_spec.rb CHANGED
@@ -4,6 +4,7 @@ describe "Ticketmaster::Provider::Kanbanpad::Ticket" do
4
4
  before(:all) do
5
5
  headers = {'Authorization' => 'Basic YWJjQGcuY29tOmllODIzZDYzanM='}
6
6
  wheaders = headers.merge('Accept' => 'application/json')
7
+ post_data = {:tasks => {:title => 'new ticket'}}
7
8
  ActiveResource::HttpMock.respond_to do |mock|
8
9
  mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
9
10
  mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks.json', wheaders, fixture_for('tasks'), 200
@@ -55,4 +56,5 @@ describe "Ticketmaster::Provider::Kanbanpad::Ticket" do
55
56
  @ticket.should be_an_instance_of(@klass)
56
57
  @ticket.id.should == @ticket_id
57
58
  end
59
+
58
60
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ticketmaster-kanbanpad}
8
- s.version = "0.1.7"
8
+ s.version = "0.2.7"
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 = %q{2011-02-24}
12
+ s.date = %q{2011-02-25}
13
13
  s.description = %q{Allows ticketmaster to interact with kanbanpad.}
14
14
  s.email = %q{sonia@hybridgroup.com}
15
15
  s.extra_rdoc_files = [
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  "lib/ticketmaster-kanbanpad.rb",
30
30
  "rakefile",
31
31
  "spec/comments_spec.rb",
32
- "spec/fixtures/all.json",
32
+ "spec/fixtures/comments.json",
33
33
  "spec/fixtures/projects.json",
34
34
  "spec/fixtures/projects.xml",
35
35
  "spec/fixtures/projects/be74b643b64e3dc79aa0.json",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ticketmaster-kanbanpad
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 7
10
- version: 0.1.7
10
+ version: 0.2.7
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: 2011-02-24 00:00:00 -04:00
18
+ date: 2011-02-25 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -56,7 +56,7 @@ files:
56
56
  - lib/ticketmaster-kanbanpad.rb
57
57
  - rakefile
58
58
  - spec/comments_spec.rb
59
- - spec/fixtures/all.json
59
+ - spec/fixtures/comments.json
60
60
  - spec/fixtures/projects.json
61
61
  - spec/fixtures/projects.xml
62
62
  - spec/fixtures/projects/be74b643b64e3dc79aa0.json
@@ -1 +0,0 @@
1
- [{"assigned_to":[],"created_at":"2011-02-21T19:13:22Z","title":"Testing provider","updated_at":"2011-02-21T22:48:15Z","urgent":false,"id":"4d62b952faf6426596000061","step_id":null,"note":null,"wip":true,"project_slug":"ef74c392a173ea994328","finished":true,"backlog":false},{"assigned_to":[],"created_at":"2011-02-21T22:53:59Z","title":"Checking tasks creation","updated_at":"2011-02-21T22:57:56Z","urgent":false,"id":"4d62ed07c0847f51ea000009","step_id":null,"note":null,"wip":false,"project_slug":"ef74c392a173ea994328","finished":true,"backlog":false}]