taskmapper-kanbanpad 0.7.0

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.
Files changed (43) hide show
  1. data/.document +5 -0
  2. data/.rbenv-gemsets +1 -0
  3. data/.rbenv-version +1 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +15 -0
  6. data/Gemfile.lock +51 -0
  7. data/LICENSE +22 -0
  8. data/README.md +39 -0
  9. data/Rakefile +43 -0
  10. data/VERSION +1 -0
  11. data/lib/kanbanpad/kanbanpad-api.rb +126 -0
  12. data/lib/provider/comment.rb +69 -0
  13. data/lib/provider/kanbanpad.rb +34 -0
  14. data/lib/provider/project.rb +78 -0
  15. data/lib/provider/ticket.rb +127 -0
  16. data/lib/taskmapper-kanbanpad.rb +6 -0
  17. data/spec/fixtures/comments.json +1 -0
  18. data/spec/fixtures/comments/4ef2719bf17365000110df9e.json +1 -0
  19. data/spec/fixtures/projects.json +8 -0
  20. data/spec/fixtures/projects.xml +23 -0
  21. data/spec/fixtures/projects/be74b643b64e3dc79aa0.json +2 -0
  22. data/spec/fixtures/projects/be74b643b64e3dc79aa0.xml +13 -0
  23. data/spec/fixtures/projects/create.json +1 -0
  24. data/spec/fixtures/projects/create.xml +1 -0
  25. data/spec/fixtures/projects/test.rb +7 -0
  26. data/spec/fixtures/steps/4dc312f49bd0ff6c37000040.json +1 -0
  27. data/spec/fixtures/tasks.json +2 -0
  28. data/spec/fixtures/tasks.xml +25 -0
  29. data/spec/fixtures/tasks/4cd428c496f0734eef000007.json +3 -0
  30. data/spec/fixtures/tasks/4cd428c496f0734eef000007.xml +14 -0
  31. data/spec/fixtures/tasks/4cd428c496f0734eef000008.json +1 -0
  32. data/spec/fixtures/tasks/4cd428c496f0734eef000008.xml +13 -0
  33. data/spec/fixtures/tasks/4dc31c4c9bd0ff6c3700004e.json +1 -0
  34. data/spec/fixtures/tasks/create.xml +1 -0
  35. data/spec/project_comments_spec.rb +37 -0
  36. data/spec/projects_spec.rb +49 -0
  37. data/spec/spec.opts +3 -0
  38. data/spec/spec_helper.rb +14 -0
  39. data/spec/ticket_comments_spec.rb +55 -0
  40. data/spec/ticketmaster-kanbanpad_spec.rb +11 -0
  41. data/spec/tickets_spec.rb +105 -0
  42. data/taskmapper-kanbanpad.gemspec +98 -0
  43. metadata +172 -0
@@ -0,0 +1,127 @@
1
+ module TaskMapper::Provider
2
+ module Kanbanpad
3
+ # Ticket class for taskmapper-kanbanpad
4
+ #
5
+ class Ticket < TaskMapper::Provider::Base::Ticket
6
+ API = KanbanpadAPI::TaskList
7
+ STEP_API = KanbanpadAPI::Step
8
+ TASK_COMMENT_API = KanbanpadAPI::TaskCommentCreator
9
+
10
+ def initialize(*object)
11
+ if object.first
12
+ object = object.first
13
+ @system_data = {:client => object}
14
+ unless object.is_? Hash
15
+ hash = {:id => object.id,
16
+ :finished => object.finished,
17
+ :title => object.title,
18
+ :backlog => object.backlog,
19
+ :assigned_to => object.assigned_to,
20
+ :wip => object.wip,
21
+ :project_slug => object.project_slug,
22
+ :step_id => object.step_id,
23
+ :urgent => object.urgent}
24
+ else
25
+ hash = object
26
+ end
27
+ super hash
28
+ end
29
+ end
30
+
31
+ def priority
32
+ self.urgent ? "Urgent" : "Not Urgent"
33
+ end
34
+
35
+ def status
36
+ return "Finished" if self.finished
37
+ return "Backlog" if self.backlog
38
+ self.wip? ? "#{step_name} - In-Progress" : "#{step_name} - Queue"
39
+ end
40
+
41
+ def description
42
+ self.note
43
+ end
44
+
45
+ def assignee
46
+ self.assigned_to.blank? ? 'Nobody' : self.assigned_to.first
47
+ end
48
+
49
+ def project_id
50
+ self.project_slug
51
+ end
52
+
53
+ def created_at
54
+ if self[:created_at].blank?
55
+ Time.parse('2010-03-25 3:06:34') #kanbanpad used to not track the created_at
56
+ else
57
+ begin
58
+ Time.parse(self[:created_at])
59
+ rescue
60
+ self[:created_at]
61
+ end
62
+ end
63
+ end
64
+
65
+ def self.create(*options)
66
+ if options.first.is_a? Hash
67
+ options.first.merge!(:assigned_to => options.first.delete(:assignee),
68
+ :note => options.first[:description])
69
+ task = API.new(options.first)
70
+ task.save
71
+ ticket = self.new task
72
+ end
73
+ end
74
+
75
+ def save
76
+ task = KanbanpadAPI::TaskList.find(:all, :params => {:project_id => self.project_id}).select { |task| task.id == self.id }.first
77
+ task.update_attributes(:title => self.title, :project_id => self.project_id)
78
+ end
79
+
80
+ def self.find_by_attributes(project_id, attributes = {})
81
+ self.search_by_attribute(self.search(project_id), attributes)
82
+ end
83
+
84
+ def self.search(project_id, options = {}, limit = 1000)
85
+ tickets = API.find(:all, :params => {:project_id => project_id, :backlog => 'yes', :finished => 'yes'}).collect do |ticket|
86
+ self.new ticket
87
+ end
88
+ end
89
+
90
+ def updated_at
91
+ if self[:updated_at].blank?
92
+ Time.parse('2010-03-25 3:06:34') #kanbanpad used to not track the updated_at
93
+ else
94
+ begin
95
+ Time.parse(self[:updated_at])
96
+ rescue
97
+ self[:updated_at]
98
+ end
99
+ end
100
+ end
101
+
102
+ #TODO?
103
+ def comment
104
+ warn 'Kanbanpad does not allow find by id of comments. Perhaps you should leave feedback to request it?'
105
+ nil
106
+ end
107
+
108
+ def comment!(*options)
109
+ if options.first.is_a? Hash
110
+ options.first.merge!(:project_id => self.project_id,
111
+ :task_id => self.id,
112
+ :step_id => self.step_id)
113
+
114
+ task_comment = TASK_COMMENT_API.new(options.first)
115
+ task_comment.save
116
+ comment = Comment.new(task_comment.attributes.merge :ticket_id => id)
117
+ end
118
+ end
119
+
120
+ private
121
+ def step_name
122
+ STEP_API.find(self.step_id, :params => {:project_id => self.project_id}).name
123
+ end
124
+
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,6 @@
1
+ require File.dirname(__FILE__) + '/kanbanpad/kanbanpad-api'
2
+
3
+ %w{ kanbanpad ticket project comment }.each do |f|
4
+ require File.dirname(__FILE__) + '/provider/' + f + '.rb';
5
+ end
6
+
@@ -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"}]
@@ -0,0 +1 @@
1
+ {"created_at":"2012-02-20T23:30:33Z", "author":"Alexander Giraldo", "body":"Testing", "updated_at":"2012-02-20T23:30:33Z", "id":"4f42d79987b92f1c4f000004", "grav_id":"a0f8f657f4af926df53ee90ce8a31760", "user_id":"4f3eb3e287b92f239e000001", "author_email":"alexanderg@hybridgroup.com"}
@@ -0,0 +1,8 @@
1
+ [
2
+ {"email":"sonia@g.com", "id":"7e2cad4b3cbe5954950c","slug":"7e2cad4b3cbe5954950c","name":"project1",
3
+ "wip_limit":"10", "organization_id":"4cd428da96f0734eef000008", "collaborator_ids":"4cd428da96f0734eef000009",
4
+ "privacy":"0", "created_at":"2011-09-16T12:56:26Z","updated_at":"2011-10-13T16:18:20Z"},
5
+ {"email":"jhon@g.com", "id":"be74b643b64e3dc79aa0","slug":"be74b643b64e3dc79aa0","name":"project2",
6
+ "wip_limit":"10", "organization_id":"4cd428da96f0734eef000008", "collaborator_ids":"4cd428da96f0734eef000009",
7
+ "privacy":"0", "created_at":"2011-09-16T12:56:26Z","updated_at":"2011-10-13T16:18:20Z"}
8
+ ]
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projects type="array">
3
+ <project>
4
+ <email>sonia@g.com</email>
5
+ <id>7e2cad4b3cbe5954950c</id>
6
+ <slug>7e2cad4b3cbe5954950c</slug>
7
+ <name>project1</name>
8
+ <wip_limit>10</wip_limit>
9
+ <organization_id>4cd428da96f0734eef000008</organization_id>
10
+ <collaborator_ids>4cd428da96f0734eef000009</collaborator_ids>
11
+ <privacy>0</privacy>
12
+ </project>
13
+ <project>
14
+ <email>jhon@g.com</email>
15
+ <id>be74b643b64e3dc79aa0</id>
16
+ <slug>be74b643b64e3dc79aa0</slug>
17
+ <name>project2</name>
18
+ <wip_limit>10</wip_limit>
19
+ <organization_id>4cd428da96f0734eef000008</organization_id>
20
+ <collaborator_ids>4cd428da96f0734eef000009</collaborator_ids>
21
+ <privacy>0</privacy>
22
+ </project>
23
+ </projects>
@@ -0,0 +1,2 @@
1
+ {"email":"crist@g.com", "id":"be74b643b64e3dc79aa0","slug":"be74b643b64e3dc79aa0","name":"Untitled",
2
+ "wip_limit":"10", "privacy":"0", "created_at":"2011-09-16T12:56:26Z","updated_at":"2011-10-13T16:18:20Z"}
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project>
3
+ <email>cris@g.com</email>
4
+ <id>be74b643b64e3dc79aa0</id>
5
+ <slug>be74b643b64e3dc79aa0</slug>
6
+ <created-at type="datetime">2011-03-29T13:10:09Z</created-at>
7
+ <updated-at type="datetime">2011-07-25T17:01:25Z</updated-at>
8
+ <name>Untitled</name>
9
+ <wip_limit>10</wip_limit>
10
+ <organization_id></organization_id>
11
+ <collaborator_ids></collaborator_ids>
12
+ <privacy>0</privacy>
13
+ </project>
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'crack'
3
+ require 'json'
4
+
5
+ xml = Crack::XML.parse(File.read('create.xml'))
6
+ json = xml.to_json
7
+ puts json
@@ -0,0 +1 @@
1
+ {"name":"Planning","queue_name":null,"wip_name":null,"id":"4dc312f49bd0ff6c37000040","wip_limit":null,"all_limit":null}
@@ -0,0 +1,2 @@
1
+ [{"assigned_to":[],"backlog":false,"comments_total":0,"created_at":"2011-05-05T21:53:16Z","finished":false,"id":"4cd428c496f0734eef000007","note":"","project_slug":"1c36637a4508065059b3","step_id":"4dc312f49bd0ff6c37000040","task_id":2,"title":"Task","updated_at":"2011-07-15T19:44:04Z","urgent":false,"wip":false},{"assigned_to":[],"backlog":false,"comments_total":1,"created_at":"2011-05-07T02:46:03Z","finished":false,"id":"4dc4b26aa6db681276000013","project_slug":"1c36637a4508065059b3","step_id":"4dc312f49bd0ff6c37000040","task_id":3,"title":"VAMOS A VER SI ES VERDAD","updated_at":"2011-07-15T19:44:04Z","urgent":false,"wip":false},{"assigned_to":[],"backlog":false,"comments_total":0,"created_at":"2011-05-07T02:55:09Z","finished":false,"id":"4dc4b48da6db68138a00000b","project_slug":"1c36637a4508065059b3","step_id":"4dc312f49bd0ff6c37000040","task_id":4,"title":"ANOTHER TASK","updated_at":"2011-07-15T19:44:04Z","urgent":false,"wip":false},{"assigned_to":[],"backlog":false,"comments_total":0,"created_at":"2011-05-07T03:31:23Z","finished":false,"id":"4dc4bd0ba6db681276000017","project_slug":"1c36637a4508065059b3","step_id":"4dc312f49bd0ff6c37000040","task_id":6,"title":"newer task","updated_at":"2011-07-15T19:44:04Z","urgent":false,"wip":false},{"assigned_to":[],"backlog":false,"comments_total":2,"created_at":"2011-05-07T03:33:34Z","finished":false,"id":"4dc4bd8e88de2c119600000c","project_slug":"1c36637a4508065059b3","step_id":"4dc312f49bd0ff6c37000040","task_id":7,"title":"a more newer task","updated_at":"2011-07-15T19:44:04Z","urgent":false,"wip":false}]
2
+
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <tasks type="array">
3
+ <task>
4
+ <id>4cd428c496f0734eef000007</id>
5
+ <task_id>1</task_id>
6
+ <title>Configure app</title>
7
+ <assigned_to>jhon</assigned_to>
8
+ <note></note>
9
+ <wip type="boolean">false</wip>
10
+ <project_slug>7e2cad4b3cbe5954950c</project_slug>
11
+ <backlog>false</backlog>
12
+ <finished>false</finished>
13
+ </task>
14
+ <task>
15
+ <id>4cd428c496f0734eef000008</id>
16
+ <task_id>2</task_id>
17
+ <title>Fix issue</title>
18
+ <assigned_to>james</assigned_to>
19
+ <note></note>
20
+ <wip type="boolean">false</wip>
21
+ <project_slug>7e2cad4b3cbe5954950c</project_slug>
22
+ <backlog>false</backlog>
23
+ <finished>true</finished>
24
+ </task>
25
+ </tasks>
@@ -0,0 +1,3 @@
1
+ {"id":"4cd428c496f0734eef000007","title":"Fix UI detail","assigned_to":["Rafael George"],"task_id":2,"urgent":false,
2
+ "note":"Lorem ipsum dolor sit amet, consectetur adipiscing elit.","wip":"false","project_slug":"be74b643b64e3dc79aa0",
3
+ "project_id":"be74b643b64e3dc79aa0","backlog":"false","finished":"false", "step_id":"4dc312f49bd0ff6c37000040", "created_at":"2011-05-07T02:59:10Z","updated_at":"2011-12-17T00:45:07Z"}
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <task>
3
+ <id>4cd428c496f0734eef000007</id>
4
+ <task_id>1</task_id>
5
+ <title>Fix UI detail</title>
6
+ <urgent>false</urgent>
7
+ <assigned_to>jhon</assigned_to>
8
+ <note>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</note>
9
+ <wip type="boolean">false</wip>
10
+ <project_slug>be74b643b64e3dc79aa0</project_slug>
11
+ <project_id>be74b643b64e3dc79aa0</project_id>
12
+ <backlog>false</backlog>
13
+ <finished>false</finished>
14
+ </task>
@@ -0,0 +1 @@
1
+ {"assigned_to":[],"backlog":false,"comments_total":0,"created_at":"2011-05-05T21:53:16Z","finished":false,"id":"4cd428c496f0734eef000007","note":"","project_slug":"1c36637a4508065059b3","step_id":"4dc312f49bd0ff6c37000040","task_id":2,"title":"Task","updated_at":"2011-07-15T19:44:04Z","urgent":false,"wip":false}
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <task>
3
+ <id>4cd428c496f0734eef000008</id>
4
+ <title>Fix bug</title>
5
+ <assigned_to>chris</assigned_to>
6
+ <note></note>
7
+ <task_id>2</task_id>
8
+ <urgent>false</urgent>
9
+ <wip type="boolean">false</wip>
10
+ <project_slug>be74b643b64e3dc79aa0</project_slug>
11
+ <backlog>false</backlog>
12
+ <finished>true</finished>
13
+ </task>
@@ -0,0 +1 @@
1
+ {"assigned_to":[],"created_at":"2011-05-05T21:53:16Z","title":"Task","updated_at":"2011-05-06T18:30:39Z","urgent":false,"task_id":2,"id":"4dc31c4c9bd0ff6c3700004e","step_id":"4dc312f49bd0ff6c37000040","note":"","wip":false,"project_slug":"1c36637a4508065059b3","finished":false,"backlog":false, "step_id":"4dc312f49bd0ff6c37000044"}
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,37 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe TaskMapper::Provider::Kanbanpad::Comment do
4
+ before(:all) do
5
+ headers = {'Authorization' => 'Basic YWJjQGcuY29tOmllODIzZDYzanM='}
6
+ wheaders = headers.merge('Accept' => 'application/json')
7
+ pheaders = headers.merge("Content-Type" => "application/json")
8
+
9
+ ActiveResource::HttpMock.respond_to do |mock|
10
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
11
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/comments.json', wheaders, fixture_for('comments'), 200
12
+ mock.post '/api/v1/projects/be74b643b64e3dc79aa0/comments.json', pheaders, fixture_for('comments/4ef2719bf17365000110df9e'), 200
13
+ end
14
+ @project_id = 'be74b643b64e3dc79aa0'
15
+ @ticket_id = '4cd428c496f0734eef000007'
16
+ @comment_id = '4d684e6f973c7d5648000009'
17
+ end
18
+
19
+ before(:each) do
20
+ @taskmapper = TaskMapper.new(:kanbanpad, :username => 'abc@g.com', :password => 'ie823d63js')
21
+ @project = @taskmapper.project(@project_id)
22
+ @klass = TaskMapper::Provider::Kanbanpad::Comment
23
+ end
24
+
25
+ it "should be able to load all comments" do
26
+ comments = @project.comments
27
+ comments.should be_instance_of Array
28
+ comments.first.should be_instance_of TaskMapper::Provider::Kanbanpad::Comment
29
+ end
30
+
31
+ it "should be able to create a comment" do
32
+ comment = @project.comment!(:body => "New Project Comment")
33
+ comment.should be_an_instance_of(@klass)
34
+ comment.project_id.should be_a String
35
+ end
36
+
37
+ end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe TaskMapper::Provider::Kanbanpad::Project do
4
+ before(:all) do
5
+ headers = {'Authorization' => 'Basic YWJjQGcuY29tOmllODIzZDYzanM='}
6
+ wheaders = headers.merge('Accept' => 'application/json')
7
+ @project_id = 'be74b643b64e3dc79aa0'
8
+ ActiveResource::HttpMock.respond_to do |mock|
9
+ mock.get '/api/v1/projects.json', wheaders, fixture_for('projects'), 200
10
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
11
+ mock.get '/api/v1/projects/create.json', headers, fixture_for('projects/create'), 200
12
+ end
13
+ end
14
+
15
+ before(:each) do
16
+ @taskmapper = TaskMapper.new(:kanbanpad, :username => 'abc@g.com', :password => 'ie823d63js')
17
+ @klass = TaskMapper::Provider::Kanbanpad::Project
18
+ end
19
+
20
+ it "should be able to load all projects" do
21
+ @taskmapper.projects.should be_an_instance_of(Array)
22
+ @taskmapper.projects.first.should be_an_instance_of(@klass)
23
+ end
24
+
25
+ it "should be able to load projects from an array of ids" do
26
+ @projects = @taskmapper.projects([@project_id])
27
+ @projects.should be_an_instance_of(Array)
28
+ @projects.first.should be_an_instance_of(@klass)
29
+ @projects.first.slug.should == @project_id
30
+ end
31
+
32
+ it "should be able to load all projects from attributes" do
33
+ @projects = @taskmapper.projects(:slug => @project_id)
34
+ @projects.should be_an_instance_of(Array)
35
+ @projects.first.should be_an_instance_of(@klass)
36
+ @projects.first.slug.should == @project_id
37
+ end
38
+
39
+ it "should be able to find a project" do
40
+ @taskmapper.project.should == @klass
41
+ @taskmapper.project.find(@project_id).should be_an_instance_of(@klass)
42
+ end
43
+
44
+ it "should be able to find a project by slug" do
45
+ @taskmapper.project(@project_id).should be_an_instance_of(@klass)
46
+ @taskmapper.project(@project_id).slug.should == @project_id
47
+ end
48
+
49
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format progress
3
+ --backtrace
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'rubygems'
4
+ require 'taskmapper'
5
+ require 'taskmapper-kanbanpad'
6
+ require 'rspec'
7
+
8
+ RSpec.configure do |config|
9
+ config.color_enabled = true
10
+ end
11
+
12
+ def fixture_for(name)
13
+ File.read(File.dirname(__FILE__) + '/fixtures/' + name + '.json')
14
+ end
@@ -0,0 +1,55 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe TaskMapper::Provider::Kanbanpad::Comment do
4
+ before(:all) do
5
+ headers = {'Authorization' => 'Basic YWJjQGcuY29tOmllODIzZDYzanM='}
6
+ wheaders = headers.merge('Accept' => 'application/json')
7
+ pheaders = headers.merge("Content-Type" => "application/json")
8
+
9
+ ActiveResource::HttpMock.respond_to do |mock|
10
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
11
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks.json', wheaders, fixture_for('tasks'), 200
12
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks.json?backlog=yes&finished=yes', wheaders, fixture_for('tasks'), 200
13
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks/4cd428c496f0734eef000007.json', wheaders, fixture_for('tasks/4cd428c496f0734eef000007'), 200
14
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks/4cd428c496f0734eef000007/comments.json', wheaders, fixture_for('comments'), 200
15
+ mock.post '/api/v1/projects/be74b643b64e3dc79aa0/steps/4dc312f49bd0ff6c37000040/tasks/4cd428c496f0734eef000007/comments.json', pheaders, fixture_for('comments/4ef2719bf17365000110df9e'), 200
16
+ end
17
+ @project_id = 'be74b643b64e3dc79aa0'
18
+ @ticket_id = '4cd428c496f0734eef000007'
19
+ @comment_id = '4d684e6f973c7d5648000009'
20
+ end
21
+
22
+ before(:each) do
23
+ @taskmapper = TaskMapper.new(:kanbanpad, :username => 'abc@g.com', :password => 'ie823d63js')
24
+ @project = @taskmapper.project(@project_id)
25
+ @ticket = @project.ticket(@ticket_id)
26
+ @klass = TaskMapper::Provider::Kanbanpad::Comment
27
+ end
28
+
29
+ it "should be able to load all comments" do
30
+ @comments = @ticket.comments
31
+ @comments.should be_an_instance_of(Array)
32
+ @comments.first.should be_an_instance_of(@klass)
33
+ end
34
+
35
+ it "should be able to load all comments based on array of id's" do
36
+ @comments = @ticket.comments([@comment_id])
37
+ @comments.should be_an_instance_of(Array)
38
+ @comments.first.should be_an_instance_of(@klass)
39
+ end
40
+
41
+ it "should be able to load all comments based on attributes" do
42
+ @comments = @ticket.comments(:id => @comment_id)
43
+ @comments.should be_an_instance_of(Array)
44
+ @comments.first.should be_an_instance_of(@klass)
45
+ end
46
+
47
+ it "should be able to create a comment for a given task" do
48
+ comment = @ticket.comment!(:body => "New Ticket")
49
+ comment.should be_an_instance_of(@klass)
50
+
51
+ comment.ticket_id.should_not be_nil
52
+ comment.ticket_id.should_not == 0
53
+ end
54
+
55
+ end