taskmapper-kanbanpad 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,15 +1,14 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
-
6
- gem "taskmapper", "~> 0.8"
7
- # Add dependencies to develop your gem here.
8
- # Include everything needed to run rake, tests, features, etc.
9
- group :development do
10
- gem "rspec", "~> 2.8"
11
- gem "bundler", "~> 1.1"
12
- gem "jeweler", "~> 1.6"
13
- gem "simplecov", "~> 0.5", :platforms => :ruby_19
14
- gem "rcov", "~> 1.0", :platforms => :ruby_18
15
- end
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "taskmapper", "~> 0.8"
7
+ # Add dependencies to develop your gem here.
8
+ # Include everything needed to run rake, tests, features, etc.
9
+ group :development do
10
+ gem "rspec", "~> 2.8"
11
+ gem "jeweler", "~> 1.6"
12
+ gem "simplecov", "~> 0.5", :platforms => :ruby_19
13
+ gem "rcov", "~> 1.0", :platforms => :ruby_18
14
+ end
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activemodel (3.2.3)
5
- activesupport (= 3.2.3)
4
+ activemodel (3.2.5)
5
+ activesupport (= 3.2.5)
6
6
  builder (~> 3.0.0)
7
- activeresource (3.2.3)
8
- activemodel (= 3.2.3)
9
- activesupport (= 3.2.3)
10
- activesupport (3.2.3)
7
+ activeresource (3.2.5)
8
+ activemodel (= 3.2.5)
9
+ activesupport (= 3.2.5)
10
+ activesupport (3.2.5)
11
11
  i18n (~> 0.6)
12
12
  multi_json (~> 1.0)
13
13
  builder (3.0.0)
@@ -15,23 +15,27 @@ GEM
15
15
  git (1.2.5)
16
16
  hashie (1.2.0)
17
17
  i18n (0.6.0)
18
- jeweler (1.6.4)
18
+ jeweler (1.8.3)
19
19
  bundler (~> 1.0)
20
20
  git (>= 1.2.5)
21
21
  rake
22
- multi_json (1.0.4)
22
+ rdoc
23
+ json (1.7.3)
24
+ multi_json (1.3.6)
23
25
  rake (0.9.2.2)
24
26
  rcov (1.0.0)
25
- rspec (2.8.0)
26
- rspec-core (~> 2.8.0)
27
- rspec-expectations (~> 2.8.0)
28
- rspec-mocks (~> 2.8.0)
29
- rspec-core (2.8.0)
30
- rspec-expectations (2.8.0)
31
- diff-lcs (~> 1.1.2)
32
- rspec-mocks (2.8.0)
33
- simplecov (0.5.4)
34
- multi_json (~> 1.0.3)
27
+ rdoc (3.12)
28
+ json (~> 1.4)
29
+ rspec (2.10.0)
30
+ rspec-core (~> 2.10.0)
31
+ rspec-expectations (~> 2.10.0)
32
+ rspec-mocks (~> 2.10.0)
33
+ rspec-core (2.10.1)
34
+ rspec-expectations (2.10.0)
35
+ diff-lcs (~> 1.1.3)
36
+ rspec-mocks (2.10.1)
37
+ simplecov (0.6.4)
38
+ multi_json (~> 1.0)
35
39
  simplecov-html (~> 0.5.3)
36
40
  simplecov-html (0.5.3)
37
41
  taskmapper (0.8.0)
@@ -43,7 +47,6 @@ PLATFORMS
43
47
  ruby
44
48
 
45
49
  DEPENDENCIES
46
- bundler (~> 1.1)
47
50
  jeweler (~> 1.6)
48
51
  rcov (~> 1.0)
49
52
  rspec (~> 2.8)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.8.0
@@ -0,0 +1,31 @@
1
+ module APIExtentions
2
+ def to_ticket_hash
3
+ {:id => id,
4
+ :title => title,
5
+ :created_at => created_at,
6
+ :updated_at => updated_at,
7
+ :wip => wip,
8
+ :step_id => step_id,
9
+ :project_slug => project_slug,
10
+ :finished => finished,
11
+ :backlog => backlog,
12
+ :assignee => assigned_to}
13
+ end
14
+
15
+ def update_with(ticket)
16
+ self.assigned_to = ticket.assignee == 'Nobody' ? '' : ticket.assignee
17
+ self.title = ticket.title
18
+ self.task_id = ticket.id
19
+ self.note = ticket.description
20
+ self
21
+ end
22
+
23
+ end
24
+
25
+ class KanbanpadAPI::Task
26
+ include APIExtentions
27
+ end
28
+
29
+ class KanbanpadAPI::TaskList
30
+ include APIExtentions
31
+ end
@@ -1,11 +1,11 @@
1
1
  module TaskMapper::Provider
2
2
  # This is the Kanbanpad Provider for taskmapper
3
-
3
+
4
4
  module Kanbanpad
5
5
  include TaskMapper::Provider::Base
6
6
  TICKET_API = KanbanpadAPI::Task
7
7
  PROJECT_API = KanbanpadAPI::Project
8
-
8
+
9
9
  # This is for cases when you want to instantiate using TaskMapper::Provider::Kanbanpad.new(auth)
10
10
  def self.new(auth = {})
11
11
  TaskMapper.new(:kanbanpad, auth)
@@ -40,6 +40,10 @@ module TaskMapper::Provider
40
40
  self[:slug]
41
41
  end
42
42
 
43
+ def ticket!(attributes)
44
+ Ticket.create(attributes.merge!(:project_id => id))
45
+ end
46
+
43
47
  def created_at
44
48
  begin
45
49
  Time.parse(self[:created_at])
@@ -7,24 +7,12 @@ module TaskMapper::Provider
7
7
  STEP_API = KanbanpadAPI::Step
8
8
  TASK_COMMENT_API = KanbanpadAPI::TaskCommentCreator
9
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
10
+ def initialize(*args)
11
+ case args.first
12
+ when Hash then super args.first
13
+ when KanbanpadAPI::Task then super args.first.to_ticket_hash
14
+ when KanbanpadAPI::TaskList then super args.first.to_ticket_hash
15
+ else raise ArgumentError.new
28
16
  end
29
17
  end
30
18
 
@@ -62,28 +50,26 @@ module TaskMapper::Provider
62
50
  end
63
51
  end
64
52
 
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
53
+ def save
54
+ new? ? to_issue.save : update
73
55
  end
74
56
 
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)
57
+ def new?
58
+ project_id.nil? && step_id.nil?
59
+ end
60
+
61
+ def self.create(attributes)
62
+ ticket = self.new(attributes)
63
+ ticket if ticket.save
78
64
  end
79
65
 
80
66
  def self.find_by_attributes(project_id, attributes = {})
81
- self.search_by_attribute(self.search(project_id), attributes)
67
+ search_by_attribute(search(project_id), attributes)
82
68
  end
83
69
 
84
70
  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
71
+ API.find(:all, :params => {:project_id => project_id, :backlog => 'yes', :finished => 'yes'}).collect do |task|
72
+ self.new task
87
73
  end
88
74
  end
89
75
 
@@ -122,6 +108,19 @@ module TaskMapper::Provider
122
108
  STEP_API.find(self.step_id, :params => {:project_id => self.project_id}).name
123
109
  end
124
110
 
111
+ def find_task
112
+ task = KanbanpadAPI::Task.find(id, :params => {:project_id => project_id, :step_id => step_id})
113
+ raise TaskMapper::Exception.new "Task with #{id} was not found" unless task
114
+ task
115
+ end
116
+
117
+ def update
118
+ find_task.update_with(self).save
119
+ end
120
+
121
+ def to_issue
122
+ KanbanpadAPI::TaskList.new(self)
123
+ end
125
124
  end
126
125
  end
127
126
  end
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/kanbanpad/kanbanpad-api'
2
2
 
3
- %w{ kanbanpad ticket project comment }.each do |f|
3
+ %w{ kanbanpad ticket project comment api-extensions }.each do |f|
4
4
  require File.dirname(__FILE__) + '/provider/' + f + '.rb';
5
5
  end
6
6
 
@@ -1,37 +1,45 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
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
4
+ let(:headers) { {'Authorization' => 'Basic YWJjQGcuY29tOmllODIzZDYzanM='} }
5
+ let(:wheaders) { headers.merge('Accept' => 'application/json') }
6
+ let(:pheaders) { headers.merge("Content-Type" => "application/json") }
7
+ let(:project_id) { 'be74b643b64e3dc79aa0' }
8
+ let(:comment_id) { '4d684e6f973c7d5648000009' }
9
+ let(:tm) { TaskMapper.new(:kanbanpad, :username => 'abc@g.com', :password => 'ie823d63js') }
10
+ let(:comment_class) { TaskMapper::Provider::Kanbanpad::Comment }
11
+
12
+ describe "Retrieving comments from a project" do
13
+ before(:each) do
14
+ ActiveResource::HttpMock.respond_to do |mock|
15
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
16
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/comments.json', wheaders, fixture_for('comments'), 200
17
+ end
13
18
  end
14
- @project_id = 'be74b643b64e3dc79aa0'
15
- @ticket_id = '4cd428c496f0734eef000007'
16
- @comment_id = '4d684e6f973c7d5648000009'
17
- end
19
+ let(:project) { tm.project project_id }
18
20
 
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
21
+ context "when calling #comments to a project" do
22
+ subject { project.comments }
23
+ it { should be_instance_of Array }
24
+ it { subject.first.should be_an_instance_of comment_class }
25
+ end
23
26
  end
24
27
 
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
28
+ describe "Creating comments to a project" do
29
+ before(:each) do
30
+ ActiveResource::HttpMock.respond_to do |mock|
31
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
32
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/comments.json', wheaders, fixture_for('comments'), 200
33
+ mock.post '/api/v1/projects/be74b643b64e3dc79aa0/comments.json', pheaders, '', 200
34
+ end
35
+ end
36
+ let(:project) { tm.project project_id }
36
37
 
38
+ context "when calling #comment! to a project instance" do
39
+ subject { project.comment! :body => 'New Project Comment' }
40
+ it { should be_an_instance_of comment_class }
41
+ it { subject.project_id.should_not be_nil }
42
+ it { subject.project_id.should be_a String }
43
+ end
44
+ end
37
45
  end
@@ -1,49 +1,44 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
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
4
+ let(:headers) { {'Authorization' => 'Basic YWJjQGcuY29tOmllODIzZDYzanM='} }
5
+ let(:wheaders) { headers.merge('Accept' => 'application/json') }
6
+ let(:project_id) { 'be74b643b64e3dc79aa0' }
7
+ let(:tm) { TaskMapper.new(:kanbanpad, :username => 'abc@g.com', :password => 'ie823d63js') }
8
+ let(:project_class) { TaskMapper::Provider::Kanbanpad::Project }
9
+
10
+ describe "Retrieving projects" do
11
+ before(:each) do
12
+ ActiveResource::HttpMock.respond_to do |mock|
13
+ mock.get '/api/v1/projects.json', wheaders, fixture_for('projects'), 200
14
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
15
+ end
16
+ end
17
+
18
+ context "when calling #projects on a TaskMapper instance" do
19
+ subject { tm.projects }
20
+ it { should be_an_instance_of Array }
21
+ it { subject.first.should be_an_instance_of project_class }
22
+ end
48
23
 
24
+ context "when calling #projects on a TaskMapper instance with an array of project's id" do
25
+ subject { tm.projects([project_id]) }
26
+ it { should be_an_instance_of Array }
27
+ it { subject.first.should be_an_instance_of project_class }
28
+ it { subject.first.slug.should be_eql project_id }
29
+ end
30
+
31
+ context "when calling #projects on a TaskMapper instance passing a hash of attributes" do
32
+ subject { tm.projects :slug => project_id }
33
+ it { should be_an_instance_of Array }
34
+ it { subject.first.should be_an_instance_of project_class }
35
+ it { subject.first.slug.should be_eql project_id }
36
+ end
37
+
38
+ context "when calling #project with a project slug" do
39
+ subject { tm.project project_id }
40
+ it { should be_an_instance_of project_class }
41
+ it { subject.slug.should be_eql project_id }
42
+ end
43
+ end
49
44
  end
@@ -1,55 +1,61 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
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
-
4
+ let(:headers) { {'Authorization' => 'Basic YWJjQGcuY29tOmllODIzZDYzanM='} }
5
+ let(:wheaders) { headers.merge('Accept' => 'application/json') }
6
+ let(:pheaders) { headers.merge("Content-Type" => "application/json") }
7
+ let(:project_id) { 'be74b643b64e3dc79aa0' }
8
+ let(:ticket_id) { '4cd428c496f0734eef000007' }
9
+ let(:comment_id) { '4d684e6f973c7d5648000009' }
10
+ let(:tm) { TaskMapper.new(:kanbanpad, :username => 'abc@g.com', :password => 'ie823d63js') }
11
+ let(:comment_class) { TaskMapper::Provider::Kanbanpad::Comment }
12
+
13
+ before(:all) do
9
14
  ActiveResource::HttpMock.respond_to do |mock|
10
15
  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
16
  mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks/4cd428c496f0734eef000007.json', wheaders, fixture_for('tasks/4cd428c496f0734eef000007'), 200
14
17
  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
18
  end
17
- @project_id = 'be74b643b64e3dc79aa0'
18
- @ticket_id = '4cd428c496f0734eef000007'
19
- @comment_id = '4d684e6f973c7d5648000009'
20
19
  end
20
+ let(:project) { tm.project project_id }
21
+ let(:ticket) { project.ticket ticket_id }
21
22
 
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
23
+ describe "Retrieving ticket comments" do
24
+ context "when calling #comments to a ticket instance" do
25
+ subject { ticket.comments }
26
+ it { should be_an_instance_of Array }
27
+ it { subject.first.should be_an_instance_of comment_class }
28
+ end
28
29
 
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
30
+ context "when calling #comments with an array of comments id's" do
31
+ subject { ticket.comments [comment_id] }
32
+ it { should be_an_instance_of Array }
33
+ it { subject.first.should be_an_instance_of comment_class }
34
+ it { subject.first.id.should be_eql comment_id }
35
+ end
34
36
 
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
37
+ context "when calling #comments with a hash attributes" do
38
+ subject { ticket.comments :id => comment_id }
39
+ it { should be_an_instance_of Array }
40
+ it { subject.first.should be_an_instance_of comment_class }
41
+ it { subject.first.id.should be_eql comment_id }
42
+ end
40
43
 
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
44
  end
46
45
 
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
46
+ describe "Comment creation to a ticket" do
47
+ before(:each) do
48
+ ActiveResource::HttpMock.respond_to do |mock|
49
+ mock.post '/api/v1/projects/be74b643b64e3dc79aa0/steps/4dc312f49bd0ff6c37000040/tasks/4cd428c496f0734eef000007/comments.json', pheaders, '', 200
50
+ end
51
+ end
52
+
53
+ context "when calling #comment! to a ticket instance" do
54
+ subject { ticket.comment! :body => 'New Ticket' }
55
+ it { should be_an_instance_of comment_class }
56
+ it { subject.ticket_id.should_not be_nil }
57
+ it { subject.ticket_id.should_not be_eql 0 }
58
+ end
53
59
  end
54
-
60
+
55
61
  end
@@ -1,11 +1,23 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "TaskMapper::Provider::Kanbanpad" do
4
-
5
- it "should be able to instantiate a new instance" do
6
- #@ticketmaster = TaskMapper.new(:kanbanpad, {:account => 'ticketmaster', :token => '000000'})
7
- #@ticketmaster.should be_an_instance_of(TaskMapper)
8
- #@ticketmaster.should be_a_kind_of(TaskMapper::Provider::Kanbanpad)
4
+ let(:headers) { {"Authorization"=>"Basic eWVzOm5v", "Accept"=>"application/json"} }
5
+
6
+ describe "Provider initializer" do
7
+ subject { TaskMapper.new :kanbanpad, :username => 'blah', :password => 'let' }
8
+ it { should_not be_nil }
9
+ end
10
+
11
+ describe "Provider credential validation" do
12
+ before(:each) do
13
+ ActiveResource::HttpMock.respond_to do |mock|
14
+ mock.get '/api/v1/projects.json', headers, fixture_for('projects'), 200
15
+ end
16
+ end
17
+
18
+ subject { TaskMapper.new(:kanbanpad, :username => 'yes', :password => 'no').valid? }
19
+ it { should be_true }
9
20
  end
21
+
10
22
 
11
23
  end
data/spec/tickets_spec.rb CHANGED
@@ -1,105 +1,106 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe TaskMapper::Provider::Kanbanpad::Ticket 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
- post_data = {:tasks => {:title => 'new ticket'}}
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/4cd428c496f0734eef000008.json', wheaders, fixture_for('tasks/4cd428c496f0734eef000008'), 200
15
- mock.get '/api/v1/projects/be74b643b64e3dc79aa0/steps/4dc312f49bd0ff6c37000040.json', wheaders, fixture_for('steps/4dc312f49bd0ff6c37000040'), 200
16
- mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks/4dc31c4c9bd0ff6c3700004e.json', wheaders, fixture_for('tasks/4dc31c4c9bd0ff6c3700004e'), 200
17
- mock.put '/api/v1/projects/be74b643b64e3dc79aa0/steps/4dc312f49bd0ff6c37000040/tasks/4cd428c496f0734eef000007.json', pheaders, fixture_for('tasks/4cd428c496f0734eef000007'), 200
18
- mock.post '/api/v1/projects/be74b643b64e3dc79aa0/tasks.json', pheaders, fixture_for('tasks/4cd428c496f0734eef000007'), 200
19
- mock.get '/api/v1/projects/be74b643b64e3dc79aa0/steps/4dc312f49bd0ff6c37000040/tasks/4cd428c496f0734eef000007.json', wheaders, fixture_for('tasks/4cd428c496f0734eef000007'), 200
20
- end
21
- @project_id = 'be74b643b64e3dc79aa0'
22
- @ticket_id = '4cd428c496f0734eef000007'
23
- @ticket_id_without_note = '4cd428c496f0734eef000008'
24
- @ticket_id_without_assignee = '4dc31c4c9bd0ff6c3700004e'
25
- end
26
-
27
- before(:each) do
28
- @taskmapper = TaskMapper.new(:kanbanpad, :username => 'abc@g.com', :password => 'ie823d63js')
29
- @project = @taskmapper.project(@project_id)
30
- @klass = TaskMapper::Provider::Kanbanpad::Ticket
31
- @comment_klass = TaskMapper::Provider::Kanbanpad::Comment
32
- end
4
+ let(:headers) { {'Authorization' => 'Basic YWJjQGcuY29tOmllODIzZDYzanM='} }
5
+ let(:wheaders) { headers.merge('Accept' => 'application/json') }
6
+ let(:pheaders) { headers.merge("Content-Type" => "application/json") }
7
+ let(:ticket_data) { {:tasks => {:title => 'new ticket'}} }
8
+ let(:project_id) { 'be74b643b64e3dc79aa0'}
9
+ let(:ticket_id) { '4cd428c496f0734eef000007'}
10
+ let(:ticket_id_without_note) { '4cd428c496f0734eef000008' }
11
+ let(:ticket_id_without_assignee) { '4dc31c4c9bd0ff6c3700004e' }
12
+ let(:tm) { TaskMapper.new(:kanbanpad, :username => 'abc@g.com', :password => 'ie823d63js') }
13
+ let(:ticket_class) { TaskMapper::Provider::Kanbanpad::Ticket }
14
+ let(:comment_class) { TaskMapper::Provider::Kanbanpad::Comment }
33
15
 
34
- it "should be able to load all tickets" do
35
- @project.tickets.should be_an_instance_of(Array)
36
- @project.tickets.first.should be_an_instance_of(@klass)
37
- end
16
+ describe "Retrieving tickets" do
17
+ before(:each) do
18
+ ActiveResource::HttpMock.respond_to do |mock|
19
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
20
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks.json?backlog=yes&finished=yes', headers, fixture_for('tasks'), 200
21
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks/4cd428c496f0734eef000007.json', headers, fixture_for('tasks/4cd428c496f0734eef000007'), 200
22
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks/4dc31c4c9bd0ff6c3700004e.json', headers, fixture_for('tasks/4dc31c4c9bd0ff6c3700004e'), 200
23
+ end
24
+ end
25
+ let(:project) { tm.project project_id }
38
26
 
39
- it "should be able to load all tickets based on an array of ids" do
40
- @tickets = @project.tickets([@ticket_id])
41
- @tickets.should be_an_instance_of(Array)
42
- @tickets.first.should be_an_instance_of(@klass)
43
- @tickets.first.id.should == '4cd428c496f0734eef000007'
44
- end
27
+ context "when calling #tickets on a project instance" do
28
+ subject { project.tickets }
29
+ it { should be_an_instance_of Array }
30
+ it { subject.first.should be_an_instance_of ticket_class }
31
+ end
45
32
 
46
- it "should retrieve a ticket without notes" do
47
- @ticket = @project.ticket(@ticket_id_without_note)
48
- @ticket.should be_an_instance_of(@klass)
49
- end
33
+ context "when calling #tickets with an array of ticket id's" do
34
+ subject { project.tickets([ticket_id]) }
35
+ it { should be_an_instance_of Array }
36
+ it { subject.first.should be_an_instance_of ticket_class }
37
+ it { subject.first.id.should be_eql ticket_id }
38
+ end
50
39
 
51
- it "should be able to load all tickets based on attributes" do
52
- @tickets = @project.tickets(:id => @ticket_id)
53
- @tickets.should be_an_instance_of(Array)
54
- @tickets.first.should be_an_instance_of(@klass)
55
- @tickets.first.id.should == '4cd428c496f0734eef000007'
56
- end
40
+ context "when calling #tickets with a hash attributes" do
41
+ subject { project.tickets :id => ticket_id }
42
+ it { should be_an_instance_of Array }
43
+ it { subject.first.should be_an_instance_of ticket_class }
44
+ it { subject.first.id.should be_eql ticket_id }
45
+ end
57
46
 
58
- it "should return the ticket class" do
59
- @project.ticket.should == @klass
60
- end
47
+ describe "Retrieve a single ticket" do
48
+ context "when calling #ticket with a ticket id" do
49
+ subject { project.ticket ticket_id }
50
+ it { should be_an_instance_of ticket_class }
51
+ it { subject.id.should be_eql ticket_id }
52
+ end
61
53
 
62
- it "should be able to load a single ticket" do
63
- @ticket = @project.ticket(@ticket_id)
64
- @ticket.should be_an_instance_of(@klass)
65
- @ticket.id.should == @ticket_id
66
- end
54
+ context "when calling #ticket with a hash attribute" do
55
+ subject { project.ticket :id => ticket_id }
56
+ it { should be_an_instance_of ticket_class }
57
+ it { subject.id.should be_eql ticket_id }
58
+ end
67
59
 
68
- it "should be able to load a single ticket based on attributes" do
69
- @ticket = @project.ticket(:id => @ticket_id)
70
- @ticket.should be_an_instance_of(@klass)
71
- @ticket.id.should == @ticket_id
72
- end
60
+ context "when retrieving a ticket without assignee" do
61
+ subject { project.ticket ticket_id_without_assignee }
62
+ it { subject.assignee.should be_eql 'Nobody' }
63
+ end
73
64
 
74
- it "should return nobody as assignee for an empty assignee from the api" do
75
- @ticket = @project.ticket(@ticket_id_without_assignee)
76
- @ticket.assignee.should == 'Nobody'
65
+ context "when retrieving a ticket" do
66
+ subject { project.ticket ticket_id }
67
+ it { subject.id.should be_eql '4cd428c496f0734eef000007' }
68
+ it { subject.status.should be_eql 'Finished' }
69
+ it { subject.priority.should be_eql 'Not Urgent' }
70
+ it { subject.resolution.should be_nil }
71
+ it { subject.title.should be_eql 'Fix UI detail' }
72
+ it { subject.created_at.should_not be_nil }
73
+ it { subject.updated_at.should_not be_nil }
74
+ it { subject.description.should be_nil }
75
+ it { subject.requestor.should be_nil }
76
+ it { subject.project_id.should be_eql 'be74b643b64e3dc79aa0' }
77
+ end
78
+ end
77
79
  end
78
80
 
79
- it "should be able to create a ticket for a given project" do
80
- @ticket = @project.ticket!(:title => 'New ticket', :assignee => ['jhon'], :description => 'Ticket description')
81
- @ticket.should be_an_instance_of(@klass)
82
- end
81
+ describe "Create and Update tickets" do
82
+ before(:each) do
83
+ ActiveResource::HttpMock.respond_to do |mock|
84
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
85
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks/4cd428c496f0734eef000007.json', wheaders, fixture_for('tasks/4cd428c496f0734eef000007'), 200
86
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/steps/4dc312f49bd0ff6c37000040/tasks/4cd428c496f0734eef000007.json', wheaders, fixture_for('tasks/4cd428c496f0734eef000007'), 200
87
+ mock.post '/api/v1/projects/be74b643b64e3dc79aa0/tasks.json', pheaders, '', 200
88
+ mock.put '/api/v1/projects/be74b643b64e3dc79aa0/steps/4dc312f49bd0ff6c37000040/tasks/4cd428c496f0734eef000007.json', pheaders, fixture_for('tasks/4cd428c496f0734eef000007'), 200
89
+ end
90
+ end
91
+ let(:project) { tm.project project_id }
83
92
 
84
- it "should be able to update a ticket" do
85
- pending
86
- @ticket = @project.ticket(@ticket_id)
87
- @ticket.title = "Hello World"
88
- @ticket.save.should be_true
89
- end
93
+ context "when calling #ticket! to a project instance" do
94
+ subject { project.ticket! :title => 'New Ticket', :assignee => ['john'], :description => 'Ticket description' }
95
+ it { should be_an_instance_of ticket_class }
96
+ end
90
97
 
91
- it "should contain all fields for tickets" do
92
- ticket = @project.ticket(@ticket_id)
93
- ticket.id.should == '4cd428c496f0734eef000007'
94
- ticket.status.should == 'Finished'
95
- ticket.priority.should == 'Not Urgent'
96
- ticket.resolution.should be_nil
97
- ticket.title.should == 'Fix UI detail'
98
- ticket.created_at.should_not be_nil
99
- ticket.updated_at.should_not be_nil
100
- ticket.description.should be_nil
101
- ticket.assignee.should == 'Rafael George'
102
- ticket.requestor.should be_nil
103
- ticket.project_id.should == 'be74b643b64e3dc79aa0'
98
+ context "when calling #save to a ticket instance and a field is change" do
99
+ it "should update the ticket instance in the backend" do
100
+ ticket = project.ticket ticket_id
101
+ ticket.title = 'Hello World'
102
+ ticket.save.should be_true
103
+ end
104
+ end
104
105
  end
105
106
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "taskmapper-kanbanpad"
8
- s.version = "0.7.0"
8
+ s.version = "0.8.0"
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-05-10"
12
+ s.date = "2012-06-18"
13
13
  s.description = "Allows taskmapper to interact with kanbanpad."
14
14
  s.email = "sonia@hybridgroup.com"
15
15
  s.extra_rdoc_files = [
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "Rakefile",
29
29
  "VERSION",
30
30
  "lib/kanbanpad/kanbanpad-api.rb",
31
+ "lib/provider/api-extensions.rb",
31
32
  "lib/provider/comment.rb",
32
33
  "lib/provider/kanbanpad.rb",
33
34
  "lib/provider/project.rb",
@@ -62,7 +63,7 @@ Gem::Specification.new do |s|
62
63
  ]
63
64
  s.homepage = "http://github.com/hybridgroup/taskmapper-kanbanpad"
64
65
  s.require_paths = ["lib"]
65
- s.rubygems_version = "1.8.17"
66
+ s.rubygems_version = "1.8.24"
66
67
  s.summary = "taskmapper Provider for Kanbanpad"
67
68
 
68
69
  if s.respond_to? :specification_version then
@@ -71,7 +72,6 @@ Gem::Specification.new do |s|
71
72
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
72
73
  s.add_runtime_dependency(%q<taskmapper>, ["~> 0.8"])
73
74
  s.add_development_dependency(%q<rspec>, ["~> 2.8"])
74
- s.add_development_dependency(%q<bundler>, ["~> 1.1"])
75
75
  s.add_development_dependency(%q<jeweler>, ["~> 1.6"])
76
76
  s.add_development_dependency(%q<simplecov>, ["~> 0.5"])
77
77
  s.add_development_dependency(%q<rcov>, ["~> 1.0"])
@@ -79,7 +79,6 @@ Gem::Specification.new do |s|
79
79
  else
80
80
  s.add_dependency(%q<taskmapper>, ["~> 0.8"])
81
81
  s.add_dependency(%q<rspec>, ["~> 2.8"])
82
- s.add_dependency(%q<bundler>, ["~> 1.1"])
83
82
  s.add_dependency(%q<jeweler>, ["~> 1.6"])
84
83
  s.add_dependency(%q<simplecov>, ["~> 0.5"])
85
84
  s.add_dependency(%q<rcov>, ["~> 1.0"])
@@ -88,7 +87,6 @@ Gem::Specification.new do |s|
88
87
  else
89
88
  s.add_dependency(%q<taskmapper>, ["~> 0.8"])
90
89
  s.add_dependency(%q<rspec>, ["~> 2.8"])
91
- s.add_dependency(%q<bundler>, ["~> 1.1"])
92
90
  s.add_dependency(%q<jeweler>, ["~> 1.6"])
93
91
  s.add_dependency(%q<simplecov>, ["~> 0.5"])
94
92
  s.add_dependency(%q<rcov>, ["~> 1.0"])
metadata CHANGED
@@ -1,104 +1,120 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: taskmapper-kanbanpad
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0
4
5
  prerelease:
5
- version: 0.7.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - HybridGroup
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-05-10 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-06-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: taskmapper
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
18
+ requirements:
20
19
  - - ~>
21
- - !ruby/object:Gem::Version
22
- version: "0.8"
20
+ - !ruby/object:Gem::Version
21
+ version: '0.8'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.8'
30
+ - !ruby/object:Gem::Dependency
27
31
  name: rspec
28
- requirement: &id002 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
29
33
  none: false
30
- requirements:
34
+ requirements:
31
35
  - - ~>
32
- - !ruby/object:Gem::Version
33
- version: "2.8"
36
+ - !ruby/object:Gem::Version
37
+ version: '2.8'
34
38
  type: :development
35
39
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: bundler
39
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
40
41
  none: false
41
- requirements:
42
+ requirements:
42
43
  - - ~>
43
- - !ruby/object:Gem::Version
44
- version: "1.1"
45
- type: :development
46
- prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
44
+ - !ruby/object:Gem::Version
45
+ version: '2.8'
46
+ - !ruby/object:Gem::Dependency
49
47
  name: jeweler
50
- requirement: &id004 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
51
49
  none: false
52
- requirements:
50
+ requirements:
53
51
  - - ~>
54
- - !ruby/object:Gem::Version
55
- version: "1.6"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.6'
56
54
  type: :development
57
55
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ - !ruby/object:Gem::Dependency
60
63
  name: simplecov
61
- requirement: &id005 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
62
65
  none: false
63
- requirements:
66
+ requirements:
64
67
  - - ~>
65
- - !ruby/object:Gem::Version
66
- version: "0.5"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.5'
67
70
  type: :development
68
71
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '0.5'
78
+ - !ruby/object:Gem::Dependency
71
79
  name: rcov
72
- requirement: &id006 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
73
81
  none: false
74
- requirements:
82
+ requirements:
75
83
  - - ~>
76
- - !ruby/object:Gem::Version
77
- version: "1.0"
84
+ - !ruby/object:Gem::Version
85
+ version: '1.0'
78
86
  type: :development
79
87
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.0'
94
+ - !ruby/object:Gem::Dependency
82
95
  name: rspec
83
- requirement: &id007 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
84
97
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
88
101
  version: 1.2.9
89
102
  type: :development
90
103
  prerelease: false
91
- version_requirements: *id007
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.2.9
92
110
  description: Allows taskmapper to interact with kanbanpad.
93
111
  email: sonia@hybridgroup.com
94
112
  executables: []
95
-
96
113
  extensions: []
97
-
98
- extra_rdoc_files:
114
+ extra_rdoc_files:
99
115
  - LICENSE
100
116
  - README.md
101
- files:
117
+ files:
102
118
  - .document
103
119
  - .rbenv-gemsets
104
120
  - .rbenv-version
@@ -110,6 +126,7 @@ files:
110
126
  - Rakefile
111
127
  - VERSION
112
128
  - lib/kanbanpad/kanbanpad-api.rb
129
+ - lib/provider/api-extensions.rb
113
130
  - lib/provider/comment.rb
114
131
  - lib/provider/kanbanpad.rb
115
132
  - lib/provider/project.rb
@@ -143,30 +160,29 @@ files:
143
160
  - taskmapper-kanbanpad.gemspec
144
161
  homepage: http://github.com/hybridgroup/taskmapper-kanbanpad
145
162
  licenses: []
146
-
147
163
  post_install_message:
148
164
  rdoc_options: []
149
-
150
- require_paths:
165
+ require_paths:
151
166
  - lib
152
- required_ruby_version: !ruby/object:Gem::Requirement
167
+ required_ruby_version: !ruby/object:Gem::Requirement
153
168
  none: false
154
- requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- version: "0"
158
- required_rubygems_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ! '>='
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ segments:
174
+ - 0
175
+ hash: 260360189
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
177
  none: false
160
- requirements:
161
- - - ">="
162
- - !ruby/object:Gem::Version
163
- version: "0"
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
164
182
  requirements: []
165
-
166
183
  rubyforge_project:
167
- rubygems_version: 1.8.17
184
+ rubygems_version: 1.8.24
168
185
  signing_key:
169
186
  specification_version: 3
170
187
  summary: taskmapper Provider for Kanbanpad
171
188
  test_files: []
172
-