taskmapper-bugherd 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@taskmapper-bugherd --create
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
data/Gemfile ADDED
@@ -0,0 +1,15 @@
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
+ gem "bugherd-api", "~> 0.0"
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "rspec", "~> 2.3"
12
+ gem "jeweler", "~> 1.6"
13
+ gem "simplecov", "~> 0.5", :platforms => :ruby_19
14
+ gem "rcov", "~> 1.0", :platforms => :ruby_18
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,54 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.0.9)
5
+ activesupport (= 3.0.9)
6
+ builder (~> 2.1.2)
7
+ i18n (~> 0.5.0)
8
+ activeresource (3.0.9)
9
+ activemodel (= 3.0.9)
10
+ activesupport (= 3.0.9)
11
+ activesupport (3.0.9)
12
+ bugherd-api (0.0.3)
13
+ activeresource
14
+ activesupport
15
+ builder (2.1.2)
16
+ diff-lcs (1.1.2)
17
+ git (1.2.5)
18
+ hashie (1.2.0)
19
+ i18n (0.5.0)
20
+ jeweler (1.6.4)
21
+ bundler (~> 1.0)
22
+ git (>= 1.2.5)
23
+ rake
24
+ multi_json (1.0.4)
25
+ rake (0.9.2.2)
26
+ rcov (1.0.0)
27
+ rspec (2.3.0)
28
+ rspec-core (~> 2.3.0)
29
+ rspec-expectations (~> 2.3.0)
30
+ rspec-mocks (~> 2.3.0)
31
+ rspec-core (2.3.1)
32
+ rspec-expectations (2.3.0)
33
+ diff-lcs (~> 1.1.2)
34
+ rspec-mocks (2.3.0)
35
+ simplecov (0.5.4)
36
+ multi_json (~> 1.0.3)
37
+ simplecov-html (~> 0.5.3)
38
+ simplecov-html (0.5.3)
39
+ taskmapper (0.8.0)
40
+ activeresource (~> 3.0)
41
+ activesupport (~> 3.0)
42
+ hashie (~> 1.2)
43
+
44
+ PLATFORMS
45
+ ruby
46
+ x86-mingw32
47
+
48
+ DEPENDENCIES
49
+ bugherd-api (~> 0.0)
50
+ jeweler (~> 1.6)
51
+ rcov (~> 1.0)
52
+ rspec (~> 2.3)
53
+ simplecov (~> 0.5)
54
+ taskmapper (~> 0.8)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Rafael George
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,44 @@
1
+ = taskmapper-bugherd
2
+
3
+ This is a provider for taskmapper[http://ticketrb.com]. It provides interoperability with Bugherd[http://www.bugherd.com] through the taskmapper gem.
4
+
5
+ == Usage and Examples
6
+
7
+ first we have to instance a new taskmapper instance:
8
+ bugherd = TaskMapper.new(:bugherd, :email => 'user@email.com', :password => 'password')
9
+
10
+ === Retreiving all projects
11
+ bugherd.projects
12
+
13
+ === Retrieving projects based on an array of id's
14
+ bugherd.projects([1,2,3])
15
+
16
+ === Retrieving projects based on attributes
17
+ bugherd.projects(:id => 1)
18
+
19
+ === Retrieving a single project
20
+ bugherd.project(1)
21
+
22
+ === Retrieving all tickets
23
+ project = bugherd.project(1)
24
+ project.tickets
25
+
26
+ === Retrieving tickets based on array of id's
27
+ project = bugherd.project(1)
28
+ project.tickets([1,2,3,4])
29
+
30
+ == Contributing to taskmapper-bugherd
31
+
32
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
33
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
34
+ * Fork the project
35
+ * Start a feature/bugfix branch
36
+ * Commit and push until you are happy with your contribution
37
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
38
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
39
+
40
+ == Copyright
41
+
42
+ Copyright (c) 2011 Rafael George. See LICENSE.txt for
43
+ further details.
44
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "taskmapper-bugherd"
18
+ gem.homepage = "http://github.com/cored/taskmapper-bugherd"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{TaskMapper provider for Bugherd}
21
+ gem.description = %Q{TaskMapper provider for Bugherd}
22
+ gem.email = "george.rafael@gmail.com"
23
+ gem.authors = ["Rafael George"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "taskmapper-bugherd #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,37 @@
1
+ module TaskMapper::Provider
2
+ # This is the Bugherd Provider for taskmapper
3
+ module Bugherd
4
+ include TaskMapper::Provider::Base
5
+ TICKET_API = Bugherd::Ticket # The class to access the api's tickets
6
+ PROJECT_API = BugherdAPI::Project # The class to access the api's projects
7
+
8
+ # This is for cases when you want to instantiate using TaskMapper::Provider::Bugherd.new(auth)
9
+ def self.new(auth = {})
10
+ TaskMapper.new(:bugherd, auth)
11
+ end
12
+
13
+ # Providers must define an authorize method. This is used to initialize and set authentication
14
+ # parameters to access the API
15
+ def authorize(auth = {})
16
+ @authentication ||= TaskMapper::Authenticator.new(auth)
17
+ auth = @authentication
18
+ if (auth.email.empty? || auth.password.empty?)
19
+ raise "You must provide email and password for authentication"
20
+ end
21
+ BugherdAPI.authenticate(auth.email, auth.password)
22
+ # Set authentication parameters for whatever you're using to access the API
23
+ end
24
+
25
+ # declare needed overloaded methods here
26
+ def valid?
27
+ begin
28
+ !BugherdAPI::User.find(:all).nil?
29
+ rescue
30
+ false
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+
37
+
@@ -0,0 +1,49 @@
1
+ module TaskMapper::Provider
2
+ module Bugherd
3
+ # The comment class for taskmapper-bugherd
4
+ #
5
+ # Do any mapping between TaskMapper and your system's comment model here
6
+ # versions of the ticket.
7
+ #
8
+ class Comment < TaskMapper::Provider::Base::Comment
9
+ API = BugherdAPI::Comment # The class to access the api's comments
10
+ # declare needed overloaded methods here
11
+ #
12
+
13
+ def initialize(*object)
14
+ if object.first
15
+ object = object.first
16
+ @system_data = {:client => object}
17
+ unless object.is_a? Hash
18
+ hash = {:id => object.id,
19
+ :created_at => object.created_at,
20
+ :body => object.text,
21
+ :user_id => object.user_id,
22
+ :ticket_id => object.prefix_options[:task_id],
23
+ :project_id => object.prefix_options[:project_id]}
24
+ else
25
+ hash = object
26
+ end
27
+ super hash
28
+ end
29
+ end
30
+
31
+ def author
32
+ author = BugherdAPI::User.find(:all).select do |user|
33
+ user.id == self[:user_id]
34
+ end.first
35
+ "#{author.name} #{author.surname}"
36
+ end
37
+
38
+ def self.search(project_id, ticket_id, options = {}, limit = 1000)
39
+ API.find(:all, :params => {:project_id => project_id, :task_id => ticket_id}).collect do |comment|
40
+ self.new comment
41
+ end
42
+ end
43
+
44
+ def self.find_by_id(project_id, ticket_id, id)
45
+ self.new API.find(id, :params => {:project_id => project_id, :task_id => ticket_id})
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,42 @@
1
+ module TaskMapper::Provider
2
+ module Bugherd
3
+ # Project class for taskmapper-bugherd
4
+ #
5
+ #
6
+ class Project < TaskMapper::Provider::Base::Project
7
+ API = BugherdAPI::Project # The class to access the api's projects
8
+ # declare needed overloaded methods here
9
+
10
+ def initialize(*object)
11
+ if object.first
12
+ object = object.first
13
+ @system_data = {:client => object}
14
+ unless object.is_a? Hash
15
+ hash = {:id => object.id,
16
+ :name => object.name,
17
+ :created_at => object.created_at,
18
+ :updated_at => object.updated_at}
19
+
20
+ else
21
+ hash = object
22
+ end
23
+ super hash
24
+ end
25
+ end
26
+
27
+ # copy from this.copy(that) copies that into this
28
+ def copy(project)
29
+ project.tickets.each do |ticket|
30
+ copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description)
31
+ ticket.comments.each do |comment|
32
+ copy_ticket.comment!(:body => comment.body)
33
+ sleep 1
34
+ end
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+
42
+
@@ -0,0 +1,58 @@
1
+ module TaskMapper::Provider
2
+ module Bugherd
3
+ # Ticket class for taskmapper-bugherd
4
+ #
5
+
6
+ class Ticket < TaskMapper::Provider::Base::Ticket
7
+ API = BugherdAPI::Task# The class to access the api's tickets
8
+ STATUS = %w{new todo active declined fixed closed}
9
+ PRIORITY = %w{- critical important normal minor}
10
+ # declare needed overloaded methods here
11
+
12
+ def initialize(*object)
13
+ if object.first
14
+ object = object.first
15
+ @system_data = {:client => object}
16
+ unless object.is_a? Hash
17
+ hash = {:id => object.id,
18
+ :status_id => object.status_id,
19
+ :priority_id => object.priority_id,
20
+ :assigned_to_id => object.assigned_to_id,
21
+ :created_at => object.created_at,
22
+ :updated_at => object.updated_at,
23
+ :description => object.description}
24
+ else
25
+ hash = object
26
+ end
27
+ super hash
28
+ end
29
+ end
30
+
31
+ def status
32
+ STATUS[self[:status_id]]
33
+ end
34
+
35
+ def priority
36
+ self[:priority_id].nil? ? "" : PRIORITY[self[:priority_id]]
37
+ end
38
+
39
+ def project_id
40
+ self.system_data[:client].prefix_options[:project_id]
41
+ end
42
+
43
+ def assignee
44
+ user = BugherdAPI::User.find(:all).select do |bugherd_user|
45
+ bugherd_user.id == self[:assigned_to_id]
46
+ end.first
47
+ "#{user.name} #{user.surname}"
48
+ end
49
+
50
+ def self.search(project_id, options = {}, limit= 1000)
51
+ API.find(:all, :params => {:project_id => project_id}).map do |task|
52
+ self.new task
53
+ end
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'bugherd-api'
3
+
4
+ %w{ bugherd ticket project comment }.each do |f|
5
+ require File.dirname(__FILE__) + '/provider/' + f + '.rb';
6
+ end
@@ -0,0 +1,53 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe TaskMapper::Provider::Bugherd::Comment do
4
+ before(:each) do
5
+ @tm = TaskMapper.new(:bugherd, :email => 'user@email.com',
6
+ :password => '0000')
7
+ @klass = TaskMapper::Provider::Bugherd::Comment
8
+ headers = {'Authorization' => 'Basic dXNlckBlbWFpbC5jb206MDAwMA==', 'Accept' => 'application/xml'}
9
+ ActiveResource::HttpMock.respond_to do |mock|
10
+ mock.get '/api_v1/projects/1458.xml', headers, fixture_for('projects/1458', 'xml'), 200
11
+ mock.get '/api_v1/projects/1458/tasks/4950.xml', headers, fixture_for('tasks/4950', 'xml'), 200
12
+ mock.get '/api_v1/projects/1458/tasks/4950/comments.xml', headers, fixture_for('comments', 'xml'), 200
13
+ mock.get '/api_v1/projects/1458/tasks/4950/comments/9760.xml', headers, fixture_for('comments/9760', 'xml'), 200
14
+ mock.get '/api_v1/users.xml', headers, fixture_for('users', 'xml'), 200
15
+ end
16
+ @project_id = 1458
17
+ @ticket_id = 4950
18
+ @project = @tm.project(@project_id)
19
+ @ticket = @project.ticket(@ticket_id)
20
+ end
21
+
22
+ it "should retrieve all comments" do
23
+ @ticket.comments.should be_an_instance_of(Array)
24
+ @ticket.comments.first.should be_an_instance_of(@klass)
25
+ end
26
+
27
+ it "should retrieve all comments based on an array of id's" do
28
+ comments = @ticket.comments([9760])
29
+ comments.should be_an_instance_of(Array)
30
+ comments.first.should be_an_instance_of(@klass)
31
+ end
32
+
33
+ it "should be able to retrieve a single comment based on id" do
34
+ comment = @ticket.comment(9760)
35
+ comment.should be_an_instance_of(@klass)
36
+ end
37
+
38
+ it "should be able to retrieve a single comment based on attributes" do
39
+ comment = @ticket.comment(:id => 9760)
40
+ comment.should be_an_instance_of(@klass)
41
+ end
42
+
43
+ it "should have all valid fields for a comment" do
44
+ comment = @ticket.comment(9760)
45
+ comment.author.should == 'Rafael George'
46
+ comment.body.should == "I'm working on this already"
47
+ comment.id.should == 9760
48
+ comment.ticket_id.should == 4950
49
+ comment.project_id.should == 1458
50
+ comment.updated_at.should be_nil
51
+ comment.created_at.should_not be_nil
52
+ end
53
+ end
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <comment>
3
+ <id type="integer">9760</id>
4
+ <text>I'm working on this already</text>
5
+ <user-id type="integer">1798</user-id>
6
+ <created-at type="datetime">2011-08-18T19:57:56Z</created-at>
7
+ <updated-at type="datetime">2011-08-18T19:57:56Z</updated-at>
8
+ </comment>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <comments type="array">
3
+ <comment>
4
+ <id type="integer">9760</id>
5
+ <created-at type="datetime">2011-08-18T19:57:56Z</created-at>
6
+ <text>I'm working on this already</text>
7
+ <user-id type="integer">1798</user-id>
8
+ </comment>
9
+ </comments>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project>
3
+ <id type="integer">1458</id>
4
+ <name>clutchapptest</name>
5
+ <devurl>http://clutchapptest.taskmapper.com</devurl>
6
+ <api-key>6f416a76-7ce1-463e-92d7-5f21f9b77dd9</api-key>
7
+ <created-at type="datetime">2011-08-17T20:07:07Z</created-at>
8
+ <updated-at type="datetime">2011-08-18T19:56:58Z</updated-at>
9
+ <is-active type="boolean">true</is-active>
10
+ </project>
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projects type="array">
3
+ <project>
4
+ <api-key>6f416a76-7ce1-463e-92d7-5f21f9b77dd9</api-key>
5
+ <created-at type="datetime">2011-08-17T20:07:07Z</created-at>
6
+ <devurl>http://clutchapptest.taskmapper.com</devurl>
7
+ <id type="integer">1458</id>
8
+ <name>clutchapptest</name>
9
+ <updated-at type="datetime">2012-02-27T21:50:39Z</updated-at>
10
+ <is-active type="boolean">true</is-active>
11
+ </project>
12
+ <project>
13
+ <api-key nil="true"></api-key>
14
+ <created-at type="datetime">2011-08-18T18:18:26Z</created-at>
15
+ <devurl>yeah.com</devurl>
16
+ <id type="integer">1487</id>
17
+ <name>testing</name>
18
+ <updated-at type="datetime">2012-02-27T21:50:28Z</updated-at>
19
+ <is-active type="boolean">true</is-active>
20
+ </project>
21
+ </projects>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <task>
3
+ <id type="integer">4950</id>
4
+ <description>Now this one should be green not red</description>
5
+ <status-id type="integer">2</status-id>
6
+ <priority-id type="integer" nil="true"></priority-id>
7
+ <assigned-to-id type="integer">1798</assigned-to-id>
8
+ <created-at type="datetime">2011-08-18T19:57:35Z</created-at>
9
+ <updated-at type="datetime">2011-08-18T19:57:40Z</updated-at>
10
+ </task>
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <tasks type="array">
3
+ <task>
4
+ <assigned-to-id type="integer">1798</assigned-to-id>
5
+ <created-at type="datetime">2011-08-18T19:56:58Z</created-at>
6
+ <description>This button should use another color</description>
7
+ <id type="integer">4949</id>
8
+ <local-task-id type="integer">1</local-task-id>
9
+ <priority-id type="integer" nil="true"></priority-id>
10
+ <status-id type="integer">2</status-id>
11
+ <updated-at type="datetime">2011-08-18T19:57:11Z</updated-at>
12
+ <url>/mail/#inbox</url>
13
+ </task>
14
+ <task>
15
+ <assigned-to-id type="integer">1798</assigned-to-id>
16
+ <created-at type="datetime">2011-08-18T19:57:35Z</created-at>
17
+ <description>Now this one should be green not red</description>
18
+ <id type="integer">4950</id>
19
+ <local-task-id type="integer">2</local-task-id>
20
+ <priority-id type="integer" nil="true"></priority-id>
21
+ <status-id type="integer">2</status-id>
22
+ <updated-at type="datetime">2011-08-18T19:57:40Z</updated-at>
23
+ <url>/mail/#inbox</url>
24
+ </task>
25
+ <task>
26
+ <assigned-to-id type="integer" nil="true"></assigned-to-id>
27
+ <created-at type="datetime">2011-08-19T19:26:15Z</created-at>
28
+ <description>Should return nil withou asignee
29
+ </description>
30
+ <id type="integer">5019</id>
31
+ <local-task-id type="integer">3</local-task-id>
32
+ <priority-id type="integer" nil="true"></priority-id>
33
+ <status-id type="integer">0</status-id>
34
+ <updated-at type="datetime">2011-08-19T19:26:15Z</updated-at>
35
+ <url>/mail/?ui=2&amp;shva=1#inbox</url>
36
+ </task>
37
+ </tasks>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <users type="array">
3
+ <user>
4
+ <id type="integer">1798</id>
5
+ <email>george.rafael@gmail.com</email>
6
+ <name>Rafael</name>
7
+ <surname>George</surname>
8
+ </user>
9
+ </users>
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe TaskMapper::Provider::Bugherd::Project do
4
+ before(:each) do
5
+ headers = {'Authorization' => 'Basic dXNlckBlbWFpbC5jb206MDAwMA==', 'Accept' => 'application/xml'}
6
+ @tm = TaskMapper.new(:bugherd, :email => 'user@email.com',
7
+ :password => '0000')
8
+ @klass = TaskMapper::Provider::Bugherd::Project
9
+ ActiveResource::HttpMock.respond_to do |mock|
10
+ mock.get '/api_v1/projects.xml', headers, fixture_for('projects', 'xml'), 200
11
+ mock.get '/api_v1/projects/1458.xml', headers, fixture_for('/projects/1458', 'xml'), 200
12
+ end
13
+ @project_id = 1458
14
+ end
15
+
16
+ context "Loading all projects" do
17
+ it "should be able to retrieve all projects" do
18
+ projects = @tm.projects
19
+ projects.should be_an_instance_of(Array)
20
+ projects.first.should be_an_instance_of(@klass)
21
+ end
22
+
23
+ it "should be able to retrieve all projects based on an array of id's" do
24
+ projects = @tm.projects([@project_id])
25
+ projects.should be_an_instance_of(Array)
26
+ projects.first.should be_an_instance_of(@klass)
27
+ end
28
+
29
+ it "should be able to retrieve all projects using attributes" do
30
+ projects = @tm.projects(:id => @project_id)
31
+ projects.should be_an_instance_of(Array)
32
+ projects.first.should be_an_instance_of(@klass)
33
+ end
34
+ end
35
+
36
+ context "Loading a single project" do
37
+ it "should be able to retrieve a single project based on id" do
38
+ project = @tm.project(@project_id)
39
+ project.should be_an_instance_of(@klass)
40
+ end
41
+
42
+ it "should be able to retrieve a single project based on attributes" do
43
+ project = @tm.project(:id => @project_id)
44
+ project.should be_an_instance_of(@klass)
45
+ end
46
+ end
47
+
48
+ context "Project creation and update" do
49
+ it "should be able to create a project"
50
+ it "should be able to update a project"
51
+ end
52
+
53
+ it "should contain all mandatory fields for projects" do
54
+ project = @tm.project(@project_id)
55
+ project.id.should == 1458
56
+ project.name.should == 'clutchapptest'
57
+ project.created_at.should_not be_nil
58
+ project.updated_at.should_not be_nil
59
+ end
60
+ end
@@ -0,0 +1,17 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'taskmapper'
4
+ require 'rspec'
5
+ require 'taskmapper-bugherd'
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+
13
+ end
14
+
15
+ def fixture_for(name, format = 'xml')
16
+ File.read(File.dirname(__FILE__) + "/fixtures/#{name}.#{format}")
17
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "TaskMapperBugherd" do
4
+ before(:each) do
5
+ headers = {'Authorization' => 'Basic Z2VvcmdlLnJhZmFlbEBnbWFpbC5jb206MTIzNDU2', 'Accept' => 'application/xml'}
6
+ ActiveResource::HttpMock.respond_to do |mock|
7
+ @tm = TaskMapper.new(:bugherd, :email => 'george.rafael@gmail.com', :password => '123456')
8
+ ActiveResource::HttpMock.respond_to do |mock|
9
+ mock.get '/api_v1/users.xml', headers, fixture_for('users', 'xml'), 200
10
+ end
11
+ end
12
+
13
+ context "Initialization and validation" do
14
+ it "should be able to initialize a taskmapper object" do
15
+ @tm.should be_an_instance_of(TaskMapper)
16
+ @tm.should be_a_kind_of(TaskMapper::Provider::Bugherd)
17
+ end
18
+
19
+ it "should validate the taskmapper instance" do
20
+ @tm.valid?.should be_true
21
+ end
22
+ end
23
+
24
+ context "Raise exceptions" do
25
+ it "should raise an exception without email or password" do
26
+ lambda { @tm = TaskMapper.new(:bugherd, :email => '', :password => '') }.should raise_error
27
+ end
28
+
29
+ it "should raise an exception with an user message" do
30
+ lambda { @tm = TaskMapper.new(:bugherd, :email => '', :password => '')}.should raise_error("You must provide email and password for authentication")
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe TaskMapper::Provider::Bugherd::Ticket do
4
+ before(:each) do
5
+ headers = {'Authorization' => 'Basic Z2VvcmdlLnJhZmFlbEBnbWFpbC5jb206MTIzNDU2', 'Accept' => 'application/xml'}
6
+ ActiveResource::HttpMock.respond_to do |mock|
7
+ mock.get '/api_v1/projects/1458.xml', headers, fixture_for('/projects/1458', 'xml'), 200
8
+ mock.get '/api_v1/projects/1458/tasks.xml', headers, fixture_for('tasks', 'xml'), 200
9
+ mock.get '/api_v1/projects/1458/tasks/4950.xml', headers, fixture_for('/tasks/4950', 'xml'), 200
10
+ mock.get '/api_v1/projects/1458/tasks/4950.xml', headers, fixture_for('/tasks/4950', 'xml'), 200
11
+ mock.get '/api_v1/users.xml', headers, fixture_for('users', 'xml'), 200
12
+ end
13
+ @tm = TaskMapper.new(:bugherd, :email => 'george.rafael@gmail.com', :password => '123456')
14
+ @project = @tm.project(1458)
15
+ @klass = TaskMapper::Provider::Bugherd::Ticket
16
+ end
17
+
18
+ context "Loading all tickets" do
19
+ it "should be able to load all tickets" do
20
+ tickets = @project.tickets
21
+ tickets.should be_an_instance_of(Array)
22
+ tickets.first.should be_an_instance_of(@klass)
23
+ end
24
+
25
+ it "should be able to load all tickets based on an array of id's" do
26
+ tickets = @project.tickets([4950])
27
+ tickets.should be_an_instance_of(Array)
28
+ tickets.first.should be_an_instance_of(@klass)
29
+ end
30
+
31
+ it "should be able to load all tickets based on attributes" do
32
+ tickets = @project.tickets(:id => 4950)
33
+ tickets.should be_an_instance_of(Array)
34
+ tickets.first.should be_an_instance_of(@klass)
35
+ end
36
+ end
37
+
38
+ context "Loading a single ticket" do
39
+ it "should be able to load a single ticket based on id" do
40
+ ticket = @project.ticket(4950)
41
+ ticket.should be_an_instance_of(@klass)
42
+ end
43
+
44
+ it "should be able to load a single ticket based on attributes" do
45
+ ticket = @project.ticket(:id => 4950)
46
+ ticket.should be_an_instance_of(@klass)
47
+ end
48
+ end
49
+
50
+ it "should contain all fields for tickets" do
51
+ ticket = @project.ticket(4950)
52
+ ticket.id.should == 4950
53
+ ticket.status.should == 'active'
54
+ ticket.priority.should == ''
55
+ ticket.title.should be_nil
56
+ ticket.resolution.should be_nil
57
+ ticket.created_at.should_not be_nil
58
+ ticket.updated_at.should_not be_nil
59
+ ticket.description.should == 'Now this one should be green not red'
60
+ ticket.assignee.should == 'Rafael George'
61
+ ticket.requestor.should be_nil
62
+ ticket.project_id.should == 1458
63
+ end
64
+ end
@@ -0,0 +1,82 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "taskmapper-bugherd"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Rafael George"]
12
+ s.date = "2012-05-14"
13
+ s.description = "TaskMapper provider for Bugherd"
14
+ s.email = "george.rafael@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".rvmrc",
23
+ ".travis.yml",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "lib/provider/bugherd.rb",
31
+ "lib/provider/comment.rb",
32
+ "lib/provider/project.rb",
33
+ "lib/provider/ticket.rb",
34
+ "lib/taskmapper-bugherd.rb",
35
+ "spec/comments_spec.rb",
36
+ "spec/fixtures/comments.xml",
37
+ "spec/fixtures/comments/9760.xml",
38
+ "spec/fixtures/projects.xml",
39
+ "spec/fixtures/projects/1458.xml",
40
+ "spec/fixtures/tasks.xml",
41
+ "spec/fixtures/tasks/4950.xml",
42
+ "spec/fixtures/users.xml",
43
+ "spec/projects_spec.rb",
44
+ "spec/spec_helper.rb",
45
+ "spec/taskmapper-bugherd_spec.rb",
46
+ "spec/tickets_spec.rb",
47
+ "taskmapper-bugherd.gemspec"
48
+ ]
49
+ s.homepage = "http://github.com/cored/taskmapper-bugherd"
50
+ s.licenses = ["MIT"]
51
+ s.require_paths = ["lib"]
52
+ s.rubygems_version = "1.8.15"
53
+ s.summary = "TaskMapper provider for Bugherd"
54
+
55
+ if s.respond_to? :specification_version then
56
+ s.specification_version = 3
57
+
58
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
+ s.add_runtime_dependency(%q<taskmapper>, ["~> 0.8"])
60
+ s.add_runtime_dependency(%q<bugherd-api>, ["~> 0.0"])
61
+ s.add_development_dependency(%q<rspec>, ["~> 2.3"])
62
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6"])
63
+ s.add_development_dependency(%q<simplecov>, ["~> 0.5"])
64
+ s.add_development_dependency(%q<rcov>, ["~> 1.0"])
65
+ else
66
+ s.add_dependency(%q<taskmapper>, ["~> 0.8"])
67
+ s.add_dependency(%q<bugherd-api>, ["~> 0.0"])
68
+ s.add_dependency(%q<rspec>, ["~> 2.3"])
69
+ s.add_dependency(%q<jeweler>, ["~> 1.6"])
70
+ s.add_dependency(%q<simplecov>, ["~> 0.5"])
71
+ s.add_dependency(%q<rcov>, ["~> 1.0"])
72
+ end
73
+ else
74
+ s.add_dependency(%q<taskmapper>, ["~> 0.8"])
75
+ s.add_dependency(%q<bugherd-api>, ["~> 0.0"])
76
+ s.add_dependency(%q<rspec>, ["~> 2.3"])
77
+ s.add_dependency(%q<jeweler>, ["~> 1.6"])
78
+ s.add_dependency(%q<simplecov>, ["~> 0.5"])
79
+ s.add_dependency(%q<rcov>, ["~> 1.0"])
80
+ end
81
+ end
82
+
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: taskmapper-bugherd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Rafael George
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-14 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: taskmapper
16
+ requirement: &85527650 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.8'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *85527650
25
+ - !ruby/object:Gem::Dependency
26
+ name: bugherd-api
27
+ requirement: &85527340 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '0.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *85527340
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &85527000 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.3'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *85527000
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &85526670 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *85526670
58
+ - !ruby/object:Gem::Dependency
59
+ name: simplecov
60
+ requirement: &85526390 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '0.5'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *85526390
69
+ - !ruby/object:Gem::Dependency
70
+ name: rcov
71
+ requirement: &85526040 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '1.0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *85526040
80
+ description: TaskMapper provider for Bugherd
81
+ email: george.rafael@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files:
85
+ - LICENSE.txt
86
+ - README.rdoc
87
+ files:
88
+ - .document
89
+ - .rspec
90
+ - .rvmrc
91
+ - .travis.yml
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.rdoc
96
+ - Rakefile
97
+ - VERSION
98
+ - lib/provider/bugherd.rb
99
+ - lib/provider/comment.rb
100
+ - lib/provider/project.rb
101
+ - lib/provider/ticket.rb
102
+ - lib/taskmapper-bugherd.rb
103
+ - spec/comments_spec.rb
104
+ - spec/fixtures/comments.xml
105
+ - spec/fixtures/comments/9760.xml
106
+ - spec/fixtures/projects.xml
107
+ - spec/fixtures/projects/1458.xml
108
+ - spec/fixtures/tasks.xml
109
+ - spec/fixtures/tasks/4950.xml
110
+ - spec/fixtures/users.xml
111
+ - spec/projects_spec.rb
112
+ - spec/spec_helper.rb
113
+ - spec/taskmapper-bugherd_spec.rb
114
+ - spec/tickets_spec.rb
115
+ - taskmapper-bugherd.gemspec
116
+ homepage: http://github.com/cored/taskmapper-bugherd
117
+ licenses:
118
+ - MIT
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ segments:
130
+ - 0
131
+ hash: -97308657
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 1.8.15
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: TaskMapper provider for Bugherd
144
+ test_files: []