taskmapper-jira 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source :rubygems
2
2
 
3
3
  gem 'taskmapper', "~> 0.8"
4
- gem 'jira4r-jh', "~> 0.4"
4
+ gem 'jira4r-jh-ruby1.9', "~> 0.4"
5
5
 
6
6
  group :test, :development do
7
7
  gem "rspec", "~> 2.8"
data/Gemfile.lock CHANGED
@@ -1,40 +1,38 @@
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.6)
5
+ activesupport (= 3.2.6)
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.6)
8
+ activemodel (= 3.2.6)
9
+ activesupport (= 3.2.6)
10
+ activesupport (3.2.6)
11
11
  i18n (~> 0.6)
12
12
  multi_json (~> 1.0)
13
13
  builder (3.0.0)
14
14
  diff-lcs (1.1.3)
15
15
  hashie (1.2.0)
16
- httpclient (2.2.3)
17
16
  i18n (0.6.0)
18
- jira4r-jh (0.4.0)
19
- soap4r
20
- soap4r
21
- multi_json (1.1.0)
17
+ jira4r-jh-ruby1.9 (0.4.0)
18
+ soap4r-ruby1.9
19
+ soap4r-ruby1.9
20
+ multi_json (1.3.6)
22
21
  rake (0.9.2.2)
23
22
  rcov (1.0.0)
24
- rspec (2.8.0)
25
- rspec-core (~> 2.8.0)
26
- rspec-expectations (~> 2.8.0)
27
- rspec-mocks (~> 2.8.0)
28
- rspec-core (2.8.0)
29
- rspec-expectations (2.8.0)
30
- diff-lcs (~> 1.1.2)
31
- rspec-mocks (2.8.0)
32
- simplecov (0.6.1)
23
+ rspec (2.10.0)
24
+ rspec-core (~> 2.10.0)
25
+ rspec-expectations (~> 2.10.0)
26
+ rspec-mocks (~> 2.10.0)
27
+ rspec-core (2.10.1)
28
+ rspec-expectations (2.10.0)
29
+ diff-lcs (~> 1.1.3)
30
+ rspec-mocks (2.10.1)
31
+ simplecov (0.6.4)
33
32
  multi_json (~> 1.0)
34
33
  simplecov-html (~> 0.5.3)
35
34
  simplecov-html (0.5.3)
36
- soap4r (1.5.8)
37
- httpclient (>= 2.1.1)
35
+ soap4r-ruby1.9 (2.0.5)
38
36
  taskmapper (0.8.0)
39
37
  activeresource (~> 3.0)
40
38
  activesupport (~> 3.0)
@@ -44,7 +42,7 @@ PLATFORMS
44
42
  ruby
45
43
 
46
44
  DEPENDENCIES
47
- jira4r-jh (~> 0.4)
45
+ jira4r-jh-ruby1.9 (~> 0.4)
48
46
  rake (~> 0.9.2)
49
47
  rcov (~> 1.0)
50
48
  rspec (~> 2.8)
data/Rakefile CHANGED
@@ -1,10 +1,8 @@
1
- require 'bundler/setup'
2
- Bundler::GemHelper.install_tasks
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
- task :default => :spec
4
+ RSpec::Core::RakeTask.new
5
5
 
6
- desc "run specs"
7
- task :spec do
8
- sh "bundle exec rspec --color spec/"
9
- end
6
+ task :default => :spec
7
+ task :test => :spec
10
8
 
data/lib/jira/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class TaskMapper
2
2
  module Jira
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -28,12 +28,6 @@ module TaskMapper::Provider
28
28
  end
29
29
  end
30
30
 
31
- def self.find(ticket_id, *options)
32
- if options.first.empty?
33
- self.find_all(ticket_id)
34
- end
35
- end
36
-
37
31
  def self.find_all(ticket_id)
38
32
  begin
39
33
  $jira.getComments("#{ticket_id}").map { |comment| self.new comment }
@@ -41,6 +35,14 @@ module TaskMapper::Provider
41
35
  []
42
36
  end
43
37
  end
38
+
39
+ def self.find_by_attributes(project_id, ticket_id, attributes = {})
40
+ search_by_attribute(self.find_all(ticket_id), attributes)
41
+ end
42
+
43
+ def self.find_by_id(project_id, ticket_id, id)
44
+ self.find_all(ticket_id).find { |comment| comment.id == id }
45
+ end
44
46
  end
45
47
  end
46
48
  end
data/lib/provider/jira.rb CHANGED
@@ -37,10 +37,6 @@ module TaskMapper::Provider
37
37
  end
38
38
  end
39
39
 
40
- def projects(*options)
41
- Project.find(options)
42
- end
43
-
44
40
  def valid?
45
41
  @valid_auth
46
42
  end
@@ -38,18 +38,6 @@ module TaskMapper::Provider
38
38
  end
39
39
  end
40
40
 
41
- def self.find(*options)
42
- if options[0].first.is_a? Array
43
- self.find_all.select do |project|
44
- project if options.first.any? { |id| project.id == id }
45
- end
46
- elsif options[0].first.is_a? Hash
47
- find_by_attributes(options[0].first)
48
- else
49
- self.find_all
50
- end
51
- end
52
-
53
41
  def self.find_by_attributes(attributes = {})
54
42
  search_by_attribute(self.find_all, attributes)
55
43
  end
@@ -45,7 +45,7 @@ module TaskMapper::Provider
45
45
  end
46
46
 
47
47
  def self.find_by_id(project_id, id)
48
- self.find_all(project_id).select { |ticket| ticket.id == id }.first
48
+ self.find_all(project_id).find { |ticket| ticket.id == id }
49
49
  end
50
50
 
51
51
  def self.find_all(project_id)
@@ -54,10 +54,6 @@ module TaskMapper::Provider
54
54
  end
55
55
  end
56
56
 
57
- def comments(*options)
58
- Comment.find(self.id, options)
59
- end
60
-
61
57
  def comment(*options)
62
58
  nil
63
59
  end
data/spec/comment_spec.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe TaskMapper::Provider::Jira::Comment do
4
- before(:each) do
5
- @url = "some_url"
6
- @fj = FakeJiraTool.new
7
- @project_jira = Struct.new(:id, :name, :description).new(1, 'project', 'project description')
8
- @ticket = Struct.new(:id,
4
+ let(:url) { 'http://jira.atlassian.com' }
5
+ let(:fake_jira) { FakeJiraTool.new }
6
+ let(:project_from_jira) { Struct.new(:id, :name, :description).new(1, 'project', 'project description') }
7
+ let(:ticket_from_jira) do
8
+ Struct.new(:id,
9
9
  :status,
10
10
  :priority,
11
11
  :summary,
@@ -13,27 +13,37 @@ describe TaskMapper::Provider::Jira::Comment do
13
13
  :created,
14
14
  :updated,
15
15
  :description, :assignee, :reporter).new(1,'open','high', 'ticket 1', 'none', Time.now, Time.now, 'description', 'myself', 'yourself')
16
- @comment = Struct.new(:id, :author, :body, :created, :updated, :ticket_id, :project_id).new(1,
17
- 'myself',
18
- 'body',
19
- Time.now,
20
- Time.now,
21
- 1,
22
- 1)
23
- Jira4R::JiraTool.stub!(:new).with(2, @url).and_return(@fj)
24
- @fj.stub!(:getProjectsNoSchemes).and_return([@project_jira, @project_jira])
25
- @fj.stub!(:getProjectById).and_return(@project_jira)
26
- @fj.stub!(:getIssuesFromJqlSearch).and_return([@ticket])
27
- @fj.stub!(:getComments).and_return([@comment])
28
- @tm = TaskMapper.new(:jira, :username => 'testuser', :password => 'testuser', :url => @url)
29
- @ticket = @tm.projects.first.tickets.first
30
- @klass = TaskMapper::Provider::Jira::Comment
31
16
  end
32
-
33
- it "should be able to load all comments" do
34
- @ticket.comments.should be_an_instance_of(Array)
35
- @ticket.comments.first.should be_an_instance_of(@klass)
17
+ let(:comment_from_jira) do
18
+ Struct.new(:id, :author, :body, :created, :updated, :ticket_id, :project_id).new(1,'myself','body',Time.now,Time.now,1,1)
19
+ end
20
+ let(:tm) { TaskMapper.new :jira, :username => 'soaptester', :password => 'soaptester', :url => url }
21
+ let(:ticket) { tm.project(1).ticket(1) }
22
+ let(:comment_class) { TaskMapper::Provider::Jira::Comment }
23
+ let(:comment_id) { 1 }
24
+ before(:each) do
25
+ Jira4R::JiraTool.stub!(:new).with(2, url).and_return(fake_jira)
26
+ fake_jira.stub!(:getProjectsNoSchemes).and_return([project_from_jira, project_from_jira])
27
+ fake_jira.stub!(:getProjectById).and_return(project_from_jira)
28
+ fake_jira.stub!(:getIssuesFromJqlSearch).and_return([ticket_from_jira])
29
+ fake_jira.stub!(:getComments).and_return([comment_from_jira])
36
30
  end
37
31
 
38
- it "should be able to create a comment"
32
+ describe "Retrieving comments" do
33
+ context "when #comments" do
34
+ subject { ticket.comments }
35
+ it { should be_an_instance_of Array }
36
+
37
+ context "when #comments.first" do
38
+ subject { ticket.comments.first }
39
+ it { should be_an_instance_of comment_class }
40
+ end
41
+ end
42
+
43
+ context "when #comments with id's" do
44
+ subject { ticket.comments [comment_id] }
45
+ it { should be_an_instance_of Array }
46
+ end
47
+
48
+ end
39
49
  end
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0"?>
2
+ <soap:Envelope
3
+ xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
4
+ soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
5
+ <projects>
6
+ <project>
7
+ <id>10</id>
8
+ <name>Project Test</name>
9
+ </project>
10
+ </projects>
11
+ </soap:Envelope>
data/spec/project_spec.rb CHANGED
@@ -1,46 +1,51 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe TaskMapper::Provider::Jira::Project do
4
+
5
+ let(:backend_url) { 'http://jira.atlassian.com' }
6
+ let(:tm) { TaskMapper.new(:jira, :username => 'soaptester', :password => 'soaptester', :url => backend_url) }
7
+ let(:fake_jira) { FakeJiraTool.new }
8
+ let(:returned_project) { Struct.new(:id, :name, :description).new(1, 'project', 'project description') }
9
+ let(:project_class) { TaskMapper::Provider::Jira::Project }
10
+ let(:project_id) { 1 }
4
11
  before(:each) do
5
- @url = "some_url"
6
- @fj = FakeJiraTool.new
7
- @project = Struct.new(:id, :name, :description).new(1,
8
- 'project',
9
- 'project description')
10
- Jira4R::JiraTool.stub!(:new).with(2, @url).and_return(@fj)
11
- @fj.stub!(:getProjectsNoSchemes).and_return([@project, @project])
12
- @fj.stub!(:getProjectByKey).and_return(@project)
13
- @tm = TaskMapper.new(:jira, :username => 'testuser', :password => 'testuser', :url => @url)
14
- @klass = TaskMapper::Provider::Jira::Project
12
+ Jira4R::JiraTool.stub!(:new).with(2, backend_url).and_return(fake_jira)
13
+ fake_jira.stub!(:getProjectsNoSchemes).and_return([returned_project, returned_project])
14
+ fake_jira.stub!(:getProjectByKey).and_return(returned_project)
15
15
  end
16
16
 
17
- it "should be able to load all projects" do
18
- @tm.projects.should be_an_instance_of(Array)
19
- @tm.projects.first.should be_an_instance_of(@klass)
20
- end
17
+ describe "Retrieving projects" do
18
+ context "when #projects" do
19
+ subject { tm.projects }
20
+ pending { should be_an_instance_of Array }
21
+ end
21
22
 
22
- it "should be able to load all projects based on an array of id's" do
23
- @tm.projects([1]).should be_an_instance_of(Array)
24
- @tm.projects.first.should be_an_instance_of(@klass)
25
- @tm.projects.first.id.should == 1
26
- end
23
+ context "when #projects with array of id's" do
24
+ subject { tm.projects [project_id] }
25
+ it { should be_an_instance_of Array }
26
+ end
27
27
 
28
- it "should be load all projects based on attributes" do
29
- projects = @tm.projects(:id => 1)
30
- projects.should be_an_instance_of(Array)
31
- projects.first.should be_an_instance_of(@klass)
32
- projects.first.id.should == 1
33
- end
28
+ context "when #projects with attributes" do
29
+ subject { tm.projects :id => project_id }
30
+ it { should be_an_instance_of Array }
31
+ end
34
32
 
35
- it "should be able to load a single project based on id" do
36
- project = @tm.project(1)
37
- project.should be_an_instance_of(@klass)
38
- project.name.should == 'project'
39
- end
33
+ describe "Retrieving a single project" do
34
+ context "when #project with id" do
35
+ subject { tm.project project_id }
36
+ it { should be_an_instance_of project_class }
37
+
38
+ context "when #project.name" do
39
+ subject { tm.project(project_id).name }
40
+ it { should_not be_nil }
41
+ it { should be_eql('project') }
42
+ end
43
+ end
40
44
 
41
- it "should be able to load a single project by attributes" do
42
- project = @tm.project(:id => 1)
43
- project.should be_an_instance_of(@klass)
44
- project.name.should == 'project'
45
+ context "when #project with attribute" do
46
+ subject { tm.project :id => project_id }
47
+ it { should be_an_instance_of project_class }
48
+ end
49
+ end
45
50
  end
46
51
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
2
2
  require 'taskmapper'
3
3
  require 'taskmapper-jira'
4
+ require 'rspec'
4
5
  require 'rspec/expectations'
5
6
 
6
7
  class FakeJiraTool
@@ -18,6 +19,6 @@ class FakeJiraTool
18
19
  end
19
20
 
20
21
  RSpec.configure do |config|
21
- config.mock_framework = :rspec
22
+ config.color_enabled = true
22
23
  end
23
24
 
data/spec/ticket_spec.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe TaskMapper::Provider::Jira::Ticket do
4
- before(:each) do
5
- @url = "some_url"
6
- @fj = FakeJiraTool.new
7
- @project_jira = Struct.new(:id, :name, :description).new(1, 'project', 'project description')
8
- @ticket = Struct.new(:id,
4
+ let(:url) { 'http://jira.atlassian.com' }
5
+ let(:fake_jira) { FakeJiraTool.new }
6
+ let(:project_from_jira) { Struct.new(:id, :name, :description).new(1, 'project', 'project description') }
7
+ let(:ticket_from_jira) do
8
+ Struct.new(:id,
9
9
  :status,
10
10
  :priority,
11
11
  :summary,
@@ -13,37 +13,51 @@ describe TaskMapper::Provider::Jira::Ticket do
13
13
  :created,
14
14
  :updated,
15
15
  :description, :assignee, :reporter).new(1,'open','high', 'ticket 1', 'none', Time.now, Time.now, 'description', 'myself', 'yourself')
16
- Jira4R::JiraTool.stub!(:new).with(2, @url).and_return(@fj)
17
- @fj.stub!(:getProjectsNoSchemes).and_return([@project_jira, @project_jira])
18
- @fj.stub!(:getProjectById).and_return(@project_jira)
19
- @fj.stub!(:getIssuesFromJqlSearch).and_return([@ticket])
20
- @tm = TaskMapper.new(:jira, :username => 'testuser', :password => 'testuser', :url => @url)
21
- @project_tm = @tm.projects.first
22
- @klass = TaskMapper::Provider::Jira::Ticket
23
16
  end
24
-
25
- it "should be able to load all tickets" do
26
- @project_tm.tickets.should be_an_instance_of(Array)
27
- @project_tm.tickets.first.should be_an_instance_of(@klass)
17
+ let(:tm) { TaskMapper.new(:jira, :username => 'testuser', :password => 'testuser', :url => url) }
18
+ let(:ticket_class) { TaskMapper::Provider::Jira::Ticket }
19
+ let(:project_from_tm) { tm.project 1 }
20
+ let(:ticket_id) { 1 }
21
+
22
+ before(:each) do
23
+ Jira4R::JiraTool.stub!(:new).with(2, url).and_return(fake_jira)
24
+ fake_jira.stub!(:getProjectsNoSchemes).and_return([project_from_jira, project_from_jira])
25
+ fake_jira.stub!(:getProjectById).and_return(project_from_jira)
26
+ fake_jira.stub!(:getIssuesFromJqlSearch).and_return([ticket_from_jira])
28
27
  end
29
28
 
30
- it "should be able to load all tickets based on array of id's" do
31
- tickets = @project_tm.tickets([1])
32
- tickets.should be_an_instance_of(Array)
33
- tickets.first.should be_an_instance_of(@klass)
34
- tickets.first.id.should == 1
35
- end
29
+ describe "Retrieving tickets" do
30
+ context "when #tickets" do
31
+ subject { project_from_tm.tickets }
32
+ it { should be_an_instance_of Array }
36
33
 
37
- it "should be able to load a single ticket based on id" do
38
- ticket = @project_tm.ticket(1)
39
- ticket.should be_an_instance_of(@klass)
40
- ticket.id.should == 1
41
- end
34
+ context "when #tickets.first" do
35
+ subject { project_from_tm.tickets.first }
36
+ it { should be_an_instance_of ticket_class }
37
+ end
38
+ end
39
+
40
+ context "when #tickets with array of id's" do
41
+ subject { project_from_tm.tickets [ticket_id] }
42
+ it { should be_an_instance_of Array }
43
+ end
44
+
45
+ context "when #tickets with attributes" do
46
+ subject { project_from_tm.tickets :id => ticket_id }
47
+ it { should be_an_instance_of Array }
48
+ end
49
+
50
+ describe "Retrieve a single ticket" do
51
+ context "when #ticket with id" do
52
+ subject { project_from_tm.ticket ticket_id }
53
+ it { should be_an_instance_of ticket_class }
54
+ end
42
55
 
43
- it "should be able to load a single ticket based on attributes" do
44
- ticket = @project_tm.ticket(:id => 1)
45
- ticket.should be_an_instance_of(@klass)
46
- ticket.id.should == 1
56
+ context "when #ticket with attribute" do
57
+ subject { project_from_tm.ticket :id => ticket_id }
58
+ it { should be_an_instance_of ticket_class }
59
+ end
60
+ end
47
61
  end
48
62
 
49
63
  end
metadata CHANGED
@@ -1,35 +1,25 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: taskmapper-jira
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 0
10
- version: 0.3.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Charles Lowell
14
9
  - Rafael George
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-05-11 00:00:00 Z
13
+ date: 2012-07-19 00:00:00.000000000 Z
20
14
  dependencies: []
21
-
22
15
  description: Interact with Atlassian JIRA ticketing system from Ruby
23
- email:
16
+ email:
24
17
  - cowboyd@thefrontside.net
25
18
  - rafael@hybridgroup.com
26
19
  executables: []
27
-
28
20
  extensions: []
29
-
30
21
  extra_rdoc_files: []
31
-
32
- files:
22
+ files:
33
23
  - .gitignore
34
24
  - .rbenv-gemsets
35
25
  - .rvmrc
@@ -44,6 +34,7 @@ files:
44
34
  - lib/provider/ticket.rb
45
35
  - lib/taskmapper-jira.rb
46
36
  - spec/comment_spec.rb
37
+ - spec/fixtures/projects.xml
47
38
  - spec/project_spec.rb
48
39
  - spec/spec_helper.rb
49
40
  - spec/taskmapper-jira_spec.rb
@@ -51,39 +42,34 @@ files:
51
42
  - taskmapper-jira.gemspec
52
43
  homepage: http://github.com/hybridgroup/taskmapper-jira
53
44
  licenses: []
54
-
55
45
  post_install_message:
56
46
  rdoc_options: []
57
-
58
- require_paths:
47
+ require_paths:
59
48
  - lib
60
- required_ruby_version: !ruby/object:Gem::Requirement
49
+ required_ruby_version: !ruby/object:Gem::Requirement
61
50
  none: false
62
- requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- hash: 3
66
- segments:
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ segments:
67
56
  - 0
68
- version: "0"
69
- required_rubygems_version: !ruby/object:Gem::Requirement
57
+ hash: 320469779
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
59
  none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- hash: 3
75
- segments:
76
- - 0
77
- version: "0"
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
78
64
  requirements: []
79
-
80
65
  rubyforge_project:
81
- rubygems_version: 1.8.15
66
+ rubygems_version: 1.8.24
82
67
  signing_key:
83
68
  specification_version: 3
84
69
  summary: taskmapper binding for JIRA
85
- test_files:
70
+ test_files:
86
71
  - spec/comment_spec.rb
72
+ - spec/fixtures/projects.xml
87
73
  - spec/project_spec.rb
88
74
  - spec/spec_helper.rb
89
75
  - spec/taskmapper-jira_spec.rb