ticketmaster-pivotal 0.4.9 → 0.5.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.
- data/VERSION +1 -1
- data/lib/pivotal/pivotal-api.rb +6 -6
- data/lib/provider/project.rb +1 -1
- data/lib/provider/ticket.rb +40 -7
- data/spec/comments_spec.rb +1 -0
- data/spec/fixtures/activities.xml +39 -0
- data/spec/tickets_spec.rb +24 -1
- data/ticketmaster-pivotal.gemspec +3 -2
- metadata +6 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/pivotal/pivotal-api.rb
CHANGED
@@ -47,27 +47,27 @@ module PivotalAPI
|
|
47
47
|
class Activity < Base
|
48
48
|
self.site += 'projects/:project_id/'
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
class Membership < Base
|
52
52
|
self.site += 'projects/:project_id/'
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
class Iteration < Base
|
56
56
|
self.site += 'projects/:project_id/'
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
class Story < Base
|
60
60
|
self.site += 'projects/:project_id/'
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
class Note < Base
|
64
64
|
self.site += 'projects/:project_id/stories/:story_id/'
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
class Task < Base
|
68
68
|
self.site += 'projects/:project_id/stories/:story_id/'
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
class AllActivity < Base
|
72
72
|
end
|
73
73
|
end
|
data/lib/provider/project.rb
CHANGED
data/lib/provider/ticket.rb
CHANGED
@@ -14,10 +14,21 @@ module TicketMaster::Provider
|
|
14
14
|
# * project_id (prefix_options[:project_id])
|
15
15
|
class Ticket < TicketMaster::Provider::Base::Ticket
|
16
16
|
@@allowed_states = ['new', 'open', 'resolved', 'hold', 'invalid']
|
17
|
+
|
17
18
|
attr_accessor :prefix_options
|
18
19
|
API = PivotalAPI::Story
|
19
|
-
|
20
|
-
|
20
|
+
|
21
|
+
def self.find_by_attributes(project_id, attributes = {})
|
22
|
+
date_to_search = attributes[:updated_at] || attributes[:created_at]
|
23
|
+
tickets = []
|
24
|
+
unless date_to_search.nil?
|
25
|
+
tickets = search_by_datefields(project_id, date_to_search)
|
26
|
+
else
|
27
|
+
tickets += API.find(:all, :params => {:project_id => project_id, :filter => filter(attributes)}).map { |xticket| self.new xticket }
|
28
|
+
end
|
29
|
+
tickets.flatten
|
30
|
+
end
|
31
|
+
|
21
32
|
# The saver
|
22
33
|
def save(*options)
|
23
34
|
pt_ticket = @system_data[:client]
|
@@ -26,23 +37,27 @@ module TicketMaster::Provider
|
|
26
37
|
end
|
27
38
|
pt_ticket.save
|
28
39
|
end
|
29
|
-
|
40
|
+
|
30
41
|
def destroy(*options)
|
31
42
|
@system_data[:client].destroy.is_a?(Net::HTTPOK)
|
32
43
|
end
|
33
|
-
|
44
|
+
|
34
45
|
def project_id
|
35
46
|
self.prefix_options[:project_id]
|
36
47
|
end
|
37
|
-
|
48
|
+
|
49
|
+
def requestor
|
50
|
+
self.requested_by
|
51
|
+
end
|
52
|
+
|
38
53
|
def title
|
39
54
|
self.name
|
40
55
|
end
|
41
|
-
|
56
|
+
|
42
57
|
def title=(title)
|
43
58
|
self.name=title
|
44
59
|
end
|
45
|
-
|
60
|
+
|
46
61
|
# The closer
|
47
62
|
def close(resolution = 'resolved')
|
48
63
|
resolution = 'resolved' unless @@allowed_states.include?(resolution)
|
@@ -50,6 +65,24 @@ module TicketMaster::Provider
|
|
50
65
|
ticket.state = resolution
|
51
66
|
ticket.save
|
52
67
|
end
|
68
|
+
|
69
|
+
private
|
70
|
+
def self.search_by_datefields(project_id, date_to_search)
|
71
|
+
date_to_search = date_to_search.strftime("%Y/%m/%d")
|
72
|
+
tickets = []
|
73
|
+
PivotalAPI::Activity.find(:all, :params => {:project_id => project_id, :occurred_since_date => date_to_search}).each do |activity|
|
74
|
+
tickets = activity.stories.map { |xstory| self.new xstory }
|
75
|
+
end
|
76
|
+
tickets
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.filter(attributes = {})
|
80
|
+
filter = ""
|
81
|
+
attributes.each_pair do |key, value|
|
82
|
+
filter << "#{key}:#{value} "
|
83
|
+
end
|
84
|
+
filter.strip!
|
85
|
+
end
|
53
86
|
end
|
54
87
|
end
|
55
88
|
end
|
data/spec/comments_spec.rb
CHANGED
@@ -7,6 +7,7 @@ describe "Ticketmaster::Provider::Pivotal::Comment" do
|
|
7
7
|
ActiveResource::HttpMock.respond_to do |mock|
|
8
8
|
mock.get '/services/v3/projects/93790.xml', headers, fixture_for('projects/93790'), 200
|
9
9
|
mock.get '/services/v3/projects/93790/stories.xml', headers, fixture_for('stories'), 200
|
10
|
+
mock.get '/services/v3/projects/93790/stories.xml?filter=', headers, fixture_for('stories'), 200
|
10
11
|
mock.get '/services/v3/projects/93790/stories/4056827.xml', headers, fixture_for('stories/4056827'), 200
|
11
12
|
mock.get '/services/v3/projects/93790/stories/4056827/notes.xml', headers, fixture_for('notes'), 200
|
12
13
|
mock.get '/services/v3/projects/93790/stories/4056827/notes/1946635.xml', headers, fixture_for('notes/1946635'), 200
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<activities type="array">
|
3
|
+
<activity>
|
4
|
+
<id type="integer">86811411</id>
|
5
|
+
<version type="integer">3</version>
|
6
|
+
<event_type>story_create</event_type>
|
7
|
+
<occurred_at type="datetime">2011/06/09 23:29:12 UTC</occurred_at>
|
8
|
+
<author>Clutch Test</author>
|
9
|
+
<project_id type="integer">136096</project_id>
|
10
|
+
<description>Clutch Test added "Let's see with another story"</description>
|
11
|
+
<stories type="array">
|
12
|
+
<story>
|
13
|
+
<id type="integer">14398445</id>
|
14
|
+
<url>http://www.pivotaltracker.com/services/v3/projects/136096/stories/14398445</url>
|
15
|
+
<name>Let's see with another story</name>
|
16
|
+
<story_type>feature</story_type>
|
17
|
+
<current_state>unscheduled</current_state>
|
18
|
+
</story>
|
19
|
+
</stories>
|
20
|
+
</activity>
|
21
|
+
<activity>
|
22
|
+
<id type="integer">86747595</id>
|
23
|
+
<version type="integer">2</version>
|
24
|
+
<event_type>story_create</event_type>
|
25
|
+
<occurred_at type="datetime">2011/06/09 20:06:46 UTC</occurred_at>
|
26
|
+
<author>Clutch Test</author>
|
27
|
+
<project_id type="integer">136096</project_id>
|
28
|
+
<description>Clutch Test added "Hello, This is clutch"</description>
|
29
|
+
<stories type="array">
|
30
|
+
<story>
|
31
|
+
<id type="integer">14389955</id>
|
32
|
+
<url>http://www.pivotaltracker.com/services/v3/projects/136096/stories/14389955</url>
|
33
|
+
<name>Hello, This is clutch</name>
|
34
|
+
<story_type>feature</story_type>
|
35
|
+
<current_state>unscheduled</current_state>
|
36
|
+
</story>
|
37
|
+
</stories>
|
38
|
+
</activity>
|
39
|
+
</activities>
|
data/spec/tickets_spec.rb
CHANGED
@@ -7,9 +7,13 @@ describe "Ticketmaster::Provider::Pivotal::Ticket" do
|
|
7
7
|
ActiveResource::HttpMock.respond_to do |mock|
|
8
8
|
mock.get '/services/v3/projects/93790.xml', headers, fixture_for('projects/93790'), 200
|
9
9
|
mock.get '/services/v3/projects/93790/stories.xml', headers, fixture_for('stories'), 200
|
10
|
+
mock.get '/services/v3/projects/93790/stories.xml?filter=', headers, fixture_for('stories'), 200
|
11
|
+
mock.get '/services/v3/projects/93790/activities.xml?occurred_since_date=2010%2F06%2F26', headers, fixture_for('activities'), 200
|
12
|
+
mock.get '/services/v3/projects/93790/stories.xml?filter=id%3A4056827', headers, fixture_for('stories'), 200
|
10
13
|
mock.get '/services/v3/projects/93790/stories/4056827.xml', headers, fixture_for('stories/4056827'), 200
|
11
14
|
mock.put '/services/v3/projects/93790/stories/4056827.xml', wheaders, '', 200
|
12
15
|
mock.post '/services/v3/projects/93790/stories.xml', wheaders, fixture_for('stories/4056827'), 200
|
16
|
+
|
13
17
|
end
|
14
18
|
@project_id = 93790
|
15
19
|
@ticket_id = 4056827
|
@@ -57,7 +61,7 @@ describe "Ticketmaster::Provider::Pivotal::Ticket" do
|
|
57
61
|
end
|
58
62
|
|
59
63
|
it "should be able to update and save a ticket" do
|
60
|
-
@ticket = @project.ticket(
|
64
|
+
@ticket = @project.ticket(@ticket_id)
|
61
65
|
#@ticket.save.should == nil
|
62
66
|
@ticket.description = 'hello'
|
63
67
|
@ticket.save.should == true
|
@@ -67,5 +71,24 @@ describe "Ticketmaster::Provider::Pivotal::Ticket" do
|
|
67
71
|
@ticket = @project.ticket!(:title => 'Ticket #12', :description => 'Body')
|
68
72
|
@ticket.should be_an_instance_of(@klass)
|
69
73
|
end
|
74
|
+
|
75
|
+
it "should be able to load all tickets based on attributes using updated_at field" do
|
76
|
+
@ticket = @project.ticket(@ticket_id)
|
77
|
+
tickets = @project.tickets(:updated_at => @ticket.updated_at)
|
78
|
+
tickets.should be_an_instance_of(Array)
|
79
|
+
tickets.first.should be_an_instance_of(@klass)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "shoule be able to load all tickets based on attributes using created_at field" do
|
83
|
+
@ticket = @project.ticket(@ticket_id)
|
84
|
+
tickets = @project.tickets(:created_at => @ticket.created_at)
|
85
|
+
tickets.should be_an_instance_of(Array)
|
86
|
+
tickets.first.should be_an_instance_of(@klass)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return requestor field" do
|
90
|
+
@ticket = @project.ticket(@ticket_id)
|
91
|
+
@ticket.requestor.should == 'Hong Quach'
|
92
|
+
end
|
70
93
|
|
71
94
|
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ticketmaster-pivotal}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.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 = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-16}
|
13
13
|
s.description = %q{This is a ticketmaster provider for interacting with Pivotal Tracker .}
|
14
14
|
s.email = %q{hong.quach@abigfisch.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/provider/ticket.rb",
|
30
30
|
"lib/ticketmaster-pivotal.rb",
|
31
31
|
"spec/comments_spec.rb",
|
32
|
+
"spec/fixtures/activities.xml",
|
32
33
|
"spec/fixtures/notes.xml",
|
33
34
|
"spec/fixtures/notes/1946635.xml",
|
34
35
|
"spec/fixtures/projects.xml",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ticketmaster-pivotal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- HybridGroup
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-16 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/provider/ticket.rb
|
105
105
|
- lib/ticketmaster-pivotal.rb
|
106
106
|
- spec/comments_spec.rb
|
107
|
+
- spec/fixtures/activities.xml
|
107
108
|
- spec/fixtures/notes.xml
|
108
109
|
- spec/fixtures/notes/1946635.xml
|
109
110
|
- spec/fixtures/projects.xml
|