ticketmaster-basecamp 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,57 @@
1
+ module TicketMaster::Provider
2
+ module Basecamp
3
+ # Project class for ticketmaster-basecamp
4
+ #
5
+ # Remaps
6
+ #
7
+ # description => announcement
8
+ # created_at => created_on
9
+ # updated_at => last_changed_on
10
+ class Project < TicketMaster::Provider::Base::Project
11
+ API = Kernel::Basecamp::Project
12
+
13
+ def description
14
+ announcement
15
+ end
16
+
17
+ def description=(desc)
18
+ announcement = desc
19
+ end
20
+
21
+ def created_at
22
+ created_on
23
+ end
24
+
25
+ def created_at=(created)
26
+ created_on = created
27
+ end
28
+
29
+ def updated_at
30
+ last_changed_on
31
+ end
32
+
33
+ def updated_at=(updated)
34
+ last_changed_on = updated
35
+ end
36
+
37
+ def ticket!(*options)
38
+ options[0].merge!(:project_id => id) if options.first.is_a?(Hash)
39
+ self.class.parent::Ticket.create(*options)
40
+ end
41
+
42
+ # copy from this.copy(that) copies that into this
43
+ def copy(project)
44
+ project.tickets.each do |ticket|
45
+ copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description)
46
+ ticket.comments.each do |comment|
47
+ copy_ticket.comment!(:body => comment.body)
48
+ sleep 1
49
+ end
50
+ end
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+
57
+
@@ -0,0 +1,115 @@
1
+ module TicketMaster::Provider
2
+ module Basecamp
3
+ # Ticket class for ticketmaster-basecamp
4
+ #
5
+ #
6
+ # * status => completed (either completed or incomplete)
7
+ # * priority => position
8
+ # * title => TodoList#name - TodoItem#content (up to 100 characters)
9
+ # * resolution => completed (either completed or '')
10
+ # * updated_at => completed_on
11
+ # * description => content
12
+ # * assignee => responsible_party_name (read-only)
13
+ # * requestor => creator_name (read-only)
14
+ # * project_id
15
+ class Ticket < TicketMaster::Provider::Base::Ticket
16
+ attr_accessor :list
17
+ def self.find_by_id(project_id, id)
18
+ self.search(project_id, {'id' => id}).first
19
+ end
20
+
21
+ def self.find_by_attributes(project_id, attributes = {})
22
+ self.search(project_id, attributes)
23
+ end
24
+
25
+ def self.search(project_id, options = {}, limit = 1000)
26
+ tickets = Kernel::Basecamp::TodoList.find(:all, :params => {:project_id => project_id}).collect do |list|
27
+ list.todo_items.collect { |item|
28
+ item.attributes['list'] = list
29
+ item
30
+ }
31
+ end.flatten.collect { |ticket| self.new(ticket, ticket.attributes.delete('list')) }
32
+ search_by_attribute(tickets, options, limit)
33
+ end
34
+
35
+ # It expects a single hash
36
+ def self.create(*options)
37
+ if options.first.is_a?(Hash)
38
+ list_id = options[0].delete(:todo_list_id) || options[0].delete('todo_list_id')
39
+ project_id = options[0].delete(:project_id) || options[0].delete('project_id')
40
+ if list_id.nil? and project_id
41
+ list_id = Kernel::Basecamp::TodoList.create(:project_id => project_id, :name => 'New List').id
42
+ end
43
+ options[0][:todo_list_id] = list_id
44
+ end
45
+ something = Kernel::Basecamp::TodoItem.new(*options)
46
+ something.save
47
+ self.new something
48
+ end
49
+
50
+ def initialize(ticket, list = nil)
51
+ @system_data ||= {}
52
+ @cache ||= {}
53
+ @list = list
54
+ case ticket
55
+ when Hash
56
+ super(ticket.to_hash)
57
+ else
58
+ @system_data[:client] = ticket
59
+ self.prefix_options ||= @system_data[:client].prefix_options if @system_data[:client].prefix_options
60
+ super(ticket.attributes)
61
+ end
62
+ end
63
+
64
+ def status
65
+ self.completed ? 'completed' : 'incomplete'
66
+ end
67
+
68
+ def priority
69
+ self.position
70
+ end
71
+
72
+ def priority=(pri)
73
+ self.position = pri
74
+ end
75
+
76
+ def title
77
+ "#{@list.name} - #{content[0..100]}"
78
+ end
79
+
80
+ def title=(titl)
81
+ self.content = titl
82
+ end
83
+
84
+ def updated_at
85
+ self.completed_on
86
+ end
87
+
88
+ def updated_at=(comp)
89
+ self.completed_on = comp
90
+ end
91
+
92
+ def description
93
+ self.content
94
+ end
95
+
96
+ def description=(desc)
97
+ self.content = desc
98
+ end
99
+
100
+ def assignee
101
+ self.responsible_party_name
102
+ end
103
+
104
+ def requestor
105
+ self.creator_name
106
+ end
107
+
108
+ def comment!(*options)
109
+ options[0].merge!(:todo_item_id => id) if options.first.is_a?(Hash)
110
+ self.class.parent::Comment.create(*options)
111
+ end
112
+
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,5 @@
1
+ require File.dirname(__FILE__) + '/basecamp/basecamp.rb'
2
+
3
+ %w{ basecamp ticket project comment }.each do |f|
4
+ require File.dirname(__FILE__) + '/provider/' + f + '.rb';
5
+ end
@@ -0,0 +1,67 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticketmaster::Provider::Basecamp::Comment" do
4
+ before(:all) do
5
+ headers = {'Authorization' => 'Basic MDAwMDAwOkJhc2VjYW1wIGxhbW8='}
6
+ wheaders = headers.merge('Content-Type' => 'application/xml')
7
+ ActiveResource::HttpMock.respond_to do |mock|
8
+ mock.get '/projects/5220065.xml', headers, fixture_for('projects/5220065'), 200
9
+ mock.get '/projects/5220065/todo_lists.xml', headers, fixture_for('todo_lists'), 200
10
+ mock.get '/todo_lists/9973518/todo_items.xml', headers, fixture_for('todo_lists/9973518_items'), 200
11
+ mock.get '/todo_lists/9972756/todo_items.xml', headers, fixture_for('todo_lists/9972756_items'), 200
12
+ mock.get '/todo_items/62509330/comments.xml', headers, fixture_for('comments'), 200
13
+ mock.get '/comments/74197051.xml', headers, fixture_for('comments/74197051'), 200
14
+ mock.get '/comments/74197096.xml', headers, fixture_for('comments/74197096'), 200
15
+ mock.post '/todo_items/62509330/comments.xml', wheaders, '', 201
16
+ end
17
+ @project_id = 5220065
18
+ @ticket_id = 62509330
19
+ end
20
+
21
+ before(:each) do
22
+ @ticketmaster = TicketMaster.new(:basecamp, :domain => 'ticketmaster.basecamphq.com', :token => '000000')
23
+ @project = @ticketmaster.project(@project_id)
24
+ @ticket = @project.ticket(@ticket_id)
25
+ @klass = TicketMaster::Provider::Basecamp::Comment
26
+ end
27
+
28
+ it "should be able to load all comments" do
29
+ @comments = @ticket.comments
30
+ @comments.should be_an_instance_of(Array)
31
+ @comments.first.should be_an_instance_of(@klass)
32
+ end
33
+
34
+ it "should be able to load all comments based on 'id's" do # lighthouse comments don't have ids, so we're faking them
35
+ @comments = @ticket.comments([74197051, 74197096])
36
+ @comments.should be_an_instance_of(Array)
37
+ @comments.first.id.should == 74197051
38
+ @comments.last.id.should == 74197096
39
+ @comments[1].should be_an_instance_of(@klass)
40
+ end
41
+
42
+ it "should be able to load all comments based on attributes" do
43
+ @comments = @ticket.comments(:commentable_id => @ticket.id)
44
+ @comments.should be_an_instance_of(Array)
45
+ @comments.first.should be_an_instance_of(@klass)
46
+ end
47
+
48
+ it "should be able to load a comment based on id" do
49
+ @comment = @ticket.comment(74197051)
50
+ @comment.should be_an_instance_of(@klass)
51
+ @comment.id.should == 74197051
52
+ end
53
+
54
+ it "should be able to load a comment based on attributes" do
55
+ @comment = @ticket.comment(:commentable_id => @ticket.id)
56
+ @comment.should be_an_instance_of(@klass)
57
+ end
58
+
59
+ it "should return the class" do
60
+ @ticket.comment.should == @klass
61
+ end
62
+
63
+ it "should be able to create a comment" do # which as mentioned before is technically a ticket update
64
+ @comment = @ticket.comment!(:body => 'hello there boys and girls')
65
+ @comment.should be_an_instance_of(@klass)
66
+ end
67
+ end
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <comment>
3
+ <attachments-count type="integer">0</attachments-count>
4
+ <author-id type="integer">5654019</author-id>
5
+ <body>&lt;div&gt;Hello There&lt;br /&gt;&lt;/div&gt;</body>
6
+ <commentable-id type="integer">62509330</commentable-id>
7
+ <commentable-type>TodoItem</commentable-type>
8
+ <created-at type="datetime">2010-07-23T23:13:39Z</created-at>
9
+ <emailed-from nil="true"></emailed-from>
10
+ <id type="integer">74197051</id>
11
+ <author-name>Kia Kroas</author-name>
12
+ <attachments type="array"/>
13
+ </comment>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <comment>
3
+ <attachments-count type="integer">0</attachments-count>
4
+ <author-id type="integer">5654019</author-id>
5
+ <body>&lt;div&gt;Something's off.&lt;br /&gt;&lt;/div&gt;</body>
6
+ <commentable-id type="integer">62509330</commentable-id>
7
+ <commentable-type>TodoItem</commentable-type>
8
+ <created-at type="datetime">2010-07-23T23:14:24Z</created-at>
9
+ <emailed-from nil="true"></emailed-from>
10
+ <id type="integer">74197096</id>
11
+ <author-name>Kia Kroas</author-name>
12
+ <attachments type="array"/>
13
+ </comment>
@@ -0,0 +1,47 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <comments type="array" count="4">
3
+ <comment>
4
+ <attachments-count type="integer">0</attachments-count>
5
+ <author-id type="integer">5654019</author-id>
6
+ <body>&lt;div&gt;Hello There&lt;br /&gt;&lt;/div&gt;</body>
7
+ <commentable-id type="integer">62509330</commentable-id>
8
+ <commentable-type>TodoItem</commentable-type>
9
+ <created-at type="datetime">2010-07-23T23:13:39Z</created-at>
10
+ <emailed-from nil="true"></emailed-from>
11
+ <id type="integer">74197051</id>
12
+ <author-name>Kia Kroas</author-name>
13
+ </comment>
14
+ <comment>
15
+ <attachments-count type="integer">0</attachments-count>
16
+ <author-id type="integer">5654019</author-id>
17
+ <body>&lt;div&gt;Hm, why is the title different?&lt;br /&gt;&lt;/div&gt;</body>
18
+ <commentable-id type="integer">62509330</commentable-id>
19
+ <commentable-type>TodoItem</commentable-type>
20
+ <created-at type="datetime">2010-07-23T23:14:06Z</created-at>
21
+ <emailed-from nil="true"></emailed-from>
22
+ <id type="integer">74197080</id>
23
+ <author-name>Kia Kroas</author-name>
24
+ </comment>
25
+ <comment>
26
+ <attachments-count type="integer">0</attachments-count>
27
+ <author-id type="integer">5654019</author-id>
28
+ <body>&lt;div&gt;This doesn't seem right.&lt;br /&gt;&lt;/div&gt;</body>
29
+ <commentable-id type="integer">62509330</commentable-id>
30
+ <commentable-type>TodoItem</commentable-type>
31
+ <created-at type="datetime">2010-07-23T23:14:16Z</created-at>
32
+ <emailed-from nil="true"></emailed-from>
33
+ <id type="integer">74197085</id>
34
+ <author-name>Kia Kroas</author-name>
35
+ </comment>
36
+ <comment>
37
+ <attachments-count type="integer">0</attachments-count>
38
+ <author-id type="integer">5654019</author-id>
39
+ <body>&lt;div&gt;Something's off.&lt;br /&gt;&lt;/div&gt;</body>
40
+ <commentable-id type="integer">62509330</commentable-id>
41
+ <commentable-type>TodoItem</commentable-type>
42
+ <created-at type="datetime">2010-07-23T23:14:24Z</created-at>
43
+ <emailed-from nil="true"></emailed-from>
44
+ <id type="integer">74197096</id>
45
+ <author-name>Kia Kroas</author-name>
46
+ </comment>
47
+ </comments>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project>
3
+ <announcement>Announcement.</announcement>
4
+ <created-on type="date">2010-07-20</created-on>
5
+ <id type="integer">5220065</id>
6
+ <last-changed-on type="datetime">2010-07-23T06:31:39Z</last-changed-on>
7
+ <name>Ticketmaster-basecamp</name>
8
+ <show-announcement type="boolean">false</show-announcement>
9
+ <show-writeboards type="boolean">true</show-writeboards>
10
+ <start-page>log</start-page>
11
+ <status>active</status>
12
+ <company>
13
+ <id type="integer">1971191</id>
14
+ <name>Kia Kroas</name>
15
+ </company>
16
+ </project>
File without changes
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projects type="array">
3
+ <project>
4
+ <announcement>Announcement.</announcement>
5
+ <created-on type="date">2010-07-20</created-on>
6
+ <id type="integer">5220065</id>
7
+ <last-changed-on type="datetime">2010-07-23T06:31:39Z</last-changed-on>
8
+ <name>Ticketmaster-basecamp</name>
9
+ <show-announcement type="boolean">false</show-announcement>
10
+ <show-writeboards type="boolean">true</show-writeboards>
11
+ <start-page>log</start-page>
12
+ <status>active</status>
13
+ <company>
14
+ <id type="integer">1971191</id>
15
+ <name>Kia Kroas</name>
16
+ </company>
17
+ </project>
18
+ </projects>
@@ -0,0 +1,87 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <todo-items type="array">
3
+ <todo-item>
4
+ <comments-count type="integer">0</comments-count>
5
+ <completed type="boolean">false</completed>
6
+ <content>oeoeuoeuoeuou</content>
7
+ <created-at type="datetime">2010-07-20T23:36:49Z</created-at>
8
+ <creator-id type="integer">5654019</creator-id>
9
+ <due-at type="datetime" nil="true"></due-at>
10
+ <id type="integer">62504112</id>
11
+ <position type="integer">1</position>
12
+ <todo-list-id type="integer">9972756</todo-list-id>
13
+ <created-on type="datetime" deprecated="true">2010-07-20T23:36:49Z</created-on>
14
+ <creator-name>Kia Kroas</creator-name>
15
+ </todo-item>
16
+ <todo-item>
17
+ <comments-count type="integer">0</comments-count>
18
+ <completed type="boolean">false</completed>
19
+ <content>uoeuoeuoeu</content>
20
+ <created-at type="datetime">2010-07-20T23:36:55Z</created-at>
21
+ <creator-id type="integer">5654019</creator-id>
22
+ <due-at type="datetime" nil="true"></due-at>
23
+ <id type="integer">62504115</id>
24
+ <position type="integer">2</position>
25
+ <responsible-party-id type="integer">1971191</responsible-party-id>
26
+ <responsible-party-type>Company</responsible-party-type>
27
+ <todo-list-id type="integer">9972756</todo-list-id>
28
+ <responsible-party-name>Kia Kroas</responsible-party-name>
29
+ <created-on type="datetime" deprecated="true">2010-07-20T23:36:55Z</created-on>
30
+ <creator-name>Kia Kroas</creator-name>
31
+ </todo-item>
32
+ <todo-item>
33
+ <comments-count type="integer">3</comments-count>
34
+ <completed type="boolean">false</completed>
35
+ <content>eouoeuoeuoe</content>
36
+ <created-at type="datetime">2010-07-20T23:37:02Z</created-at>
37
+ <creator-id type="integer">5654019</creator-id>
38
+ <due-at type="datetime">2010-07-22T07:00:00Z</due-at>
39
+ <id type="integer">62504122</id>
40
+ <position type="integer">3</position>
41
+ <responsible-party-id type="integer">1971191</responsible-party-id>
42
+ <responsible-party-type>Company</responsible-party-type>
43
+ <todo-list-id type="integer">9972756</todo-list-id>
44
+ <responsible-party-name>Kia Kroas</responsible-party-name>
45
+ <created-on type="datetime" deprecated="true">2010-07-20T23:37:02Z</created-on>
46
+ <creator-name>Kia Kroas</creator-name>
47
+ </todo-item>
48
+ <todo-item>
49
+ <comments-count type="integer">0</comments-count>
50
+ <completed type="boolean">false</completed>
51
+ <content>TEHUNTHeuntah tnstn uhant uhaenothusaeuhts</content>
52
+ <created-at type="datetime">2010-07-21T00:10:42Z</created-at>
53
+ <creator-id type="integer">5654019</creator-id>
54
+ <due-at type="datetime" nil="true"></due-at>
55
+ <id type="integer">62505807</id>
56
+ <position type="integer">4</position>
57
+ <todo-list-id type="integer">9972756</todo-list-id>
58
+ <created-on type="datetime" deprecated="true">2010-07-21T00:10:42Z</created-on>
59
+ <creator-name>Kia Kroas</creator-name>
60
+ </todo-item>
61
+ <todo-item>
62
+ <comments-count type="integer">0</comments-count>
63
+ <completed type="boolean">false</completed>
64
+ <content>ent</content>
65
+ <created-at type="datetime">2010-07-21T00:10:42Z</created-at>
66
+ <creator-id type="integer">5654019</creator-id>
67
+ <due-at type="datetime" nil="true"></due-at>
68
+ <id type="integer">62505809</id>
69
+ <position type="integer">5</position>
70
+ <todo-list-id type="integer">9972756</todo-list-id>
71
+ <created-on type="datetime" deprecated="true">2010-07-21T00:10:42Z</created-on>
72
+ <creator-name>Kia Kroas</creator-name>
73
+ </todo-item>
74
+ <todo-item>
75
+ <comments-count type="integer">0</comments-count>
76
+ <completed type="boolean">false</completed>
77
+ <content>uoeuoeuoeu</content>
78
+ <created-at type="datetime">2010-07-20T23:36:51Z</created-at>
79
+ <creator-id type="integer">5654019</creator-id>
80
+ <due-at type="datetime" nil="true"></due-at>
81
+ <id type="integer">62504114</id>
82
+ <position type="integer">6</position>
83
+ <todo-list-id type="integer">9972756</todo-list-id>
84
+ <created-on type="datetime" deprecated="true">2010-07-20T23:36:51Z</created-on>
85
+ <creator-name>Kia Kroas</creator-name>
86
+ </todo-item>
87
+ </todo-items>
@@ -0,0 +1,92 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <todo-items type="array">
3
+ <todo-item>
4
+ <comments-count type="integer">0</comments-count>
5
+ <completed type="boolean">false</completed>
6
+ <content>hudnthdau</content>
7
+ <created-at type="datetime">2010-07-21T01:14:34Z</created-at>
8
+ <creator-id type="integer">5654019</creator-id>
9
+ <due-at type="datetime" nil="true"></due-at>
10
+ <id type="integer">62509330</id>
11
+ <position type="integer">1</position>
12
+ <todo-list-id type="integer">9973518</todo-list-id>
13
+ <created-on type="datetime" deprecated="true">2010-07-21T01:14:34Z</created-on>
14
+ <creator-name>Kia Kroas</creator-name>
15
+ </todo-item>
16
+ <todo-item>
17
+ <comments-count type="integer">0</comments-count>
18
+ <completed type="boolean">false</completed>
19
+ <content>euaoua</content>
20
+ <created-at type="datetime">2010-07-21T01:14:37Z</created-at>
21
+ <creator-id type="integer">5654019</creator-id>
22
+ <due-at type="datetime" nil="true"></due-at>
23
+ <id type="integer">62509332</id>
24
+ <position type="integer">2</position>
25
+ <responsible-party-id type="integer">5654019</responsible-party-id>
26
+ <responsible-party-type>Person</responsible-party-type>
27
+ <todo-list-id type="integer">9973518</todo-list-id>
28
+ <responsible-party-name>Kia Kroas</responsible-party-name>
29
+ <created-on type="datetime" deprecated="true">2010-07-21T01:14:37Z</created-on>
30
+ <creator-name>Kia Kroas</creator-name>
31
+ </todo-item>
32
+ <todo-item>
33
+ <comments-count type="integer">0</comments-count>
34
+ <completed type="boolean">false</completed>
35
+ <content>theunoaheu</content>
36
+ <created-at type="datetime">2010-07-21T22:24:39Z</created-at>
37
+ <creator-id type="integer">5654019</creator-id>
38
+ <due-at type="datetime" nil="true"></due-at>
39
+ <id type="integer">62606582</id>
40
+ <position type="integer">3</position>
41
+ <todo-list-id type="integer">9973518</todo-list-id>
42
+ <created-on type="datetime" deprecated="true">2010-07-21T22:24:39Z</created-on>
43
+ <creator-name>Kia Kroas</creator-name>
44
+ </todo-item>
45
+ <todo-item>
46
+ <comments-count type="integer">0</comments-count>
47
+ <completed type="boolean">false</completed>
48
+ <content>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd </content>
49
+ <created-at type="datetime">2010-07-21T22:47:07Z</created-at>
50
+ <creator-id type="integer">5654019</creator-id>
51
+ <due-at type="datetime" nil="true"></due-at>
52
+ <id type="integer">62608438</id>
53
+ <position type="integer">4</position>
54
+ <todo-list-id type="integer">9973518</todo-list-id>
55
+ <created-on type="datetime" deprecated="true">2010-07-21T22:47:07Z</created-on>
56
+ <creator-name>Kia Kroas</creator-name>
57
+ </todo-item>
58
+ <todo-item>
59
+ <comments-count type="integer">0</comments-count>
60
+ <completed type="boolean">false</completed>
61
+ <content>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd </content>
62
+ <created-at type="datetime">2010-07-21T22:47:07Z</created-at>
63
+ <creator-id type="integer">5654019</creator-id>
64
+ <due-at type="datetime" nil="true"></due-at>
65
+ <id type="integer">62608439</id>
66
+ <position type="integer">4</position>
67
+ <todo-list-id type="integer">9973518</todo-list-id>
68
+ <created-on type="datetime" deprecated="true">2010-07-21T22:47:07Z</created-on>
69
+ <creator-name>Kia Kroas</creator-name>
70
+ </todo-item>
71
+ <todo-item>
72
+ <comments-count type="integer">0</comments-count>
73
+ <completed type="boolean">false</completed>
74
+ <content>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In magna felis, lobortis at semper nec, fringilla vitae ipsum. Proin viverra turpis sem, in egestas odio. Maecenas convallis blandit lobortis. Suspendisse nisi lacus, imperdiet a tristique at, iaculis at enim. Pellentesque dui quam, vulputate et hendrerit ac, eleifend et neque. Maecenas interdum mattis ipsum ac posuere. Maecenas pretium semper diam nec ornare. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Quisque non nunc dui. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eget tellus nec mauris sodales dapibus nec at elit. Ut lorem tortor, porta vel ullamcorper eu, commodo vel enim. Ut ac gravida lectus.
75
+
76
+ Duis non erat at nunc fringilla ullamcorper vitae vitae diam. Ut nec sem sit amet lacus congue malesuada. Aenean posuere congue tellus ac lobortis. Nullam ut nulla felis. Nam at sem ipsum, sit amet pretium risus. Phasellus sed nulla id lectus aliquet mattis. Morbi sit amet felis et turpis varius pulvinar ut ac diam. Morbi vel est ante. Suspendisse quis turpis est. In magna est, pharetra vitae aliquet vulputate, mattis et arcu. Nullam eu urna tellus, a venenatis eros. Sed quis egestas arcu. Praesent id massa tortor, id cursus sapien. Quisque placerat adipiscing mollis. Morbi enim lectus, pulvinar et pretium sit amet, tincidunt vitae dolor. Phasellus at quam sem, sed rutrum leo.
77
+
78
+ Duis ac lorem a augue condimentum lobortis. Vestibulum dui dui, tincidunt quis interdum non, pellentesque eget purus. Donec eget ipsum ut erat eleifend malesuada. Pellentesque fringilla diam sed magna mattis sollicitudin. Aliquam erat volutpat. Nulla vitae leo a tellus vehicula vestibulum. Quisque id elit sed sem ullamcorper gravida at eu urna. Sed molestie ipsum in metus auctor imperdiet. Cras pellentesque, tortor condimentum sodales aliquet, massa lorem bibendum est, eget varius odio purus nec lorem. Donec eu enim metus, vel semper velit. Curabitur quis elit justo. Proin eu magna sit amet nibh sollicitudin euismod quis quis ante. Donec pellentesque pharetra tincidunt. Mauris blandit egestas metus in tincidunt. Nam sit amet risus lorem. Duis justo lacus, dapibus eu aliquam dignissim, molestie sed nulla. Nam ut tristique diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam augue felis, condimentum vitae cursus eget, euismod eu nisl. In molestie felis tortor, ut lobortis nisl.
79
+
80
+ Suspendisse sed orci id ligula ultricies posuere. Aliquam cursus venenatis libero id vehicula. Donec tincidunt risus sit amet tortor scelerisque fermentum. Vivamus eu nulla mi, eu ornare nisi. Aliquam id diam congue risus bibendum interdum quis in lorem. Nam id ante ut nisl fermentum hendrerit ac sit amet felis. Curabitur tincidunt, elit volutpat aliquet cursus, est sem commodo sapien, sed aliquam enim metus vel metus. Morbi hendrerit, enim vitae lacinia molestie, ligula dolor ultricies enim, eu luctus leo lorem ac enim. Etiam congue, lorem sit amet fringilla euismod, sem diam dapibus nulla, ut fermentum massa lacus eget sem. Sed tempus condimentum pretium. Sed ut quam turpis. Donec ut lacus at felis luctus lobortis sit amet ut velit. Integer pretium nulla sit amet lorem dignissim ut elementum magna auctor. Ut consequat ornare auctor. Pellentesque eu orci eget erat dictum vulputate non a massa. Cras a nulla tellus. Praesent sagittis libero et mauris porta eget suscipit diam scelerisque. Morbi libero velit, mollis in adipiscing sed, lobortis at sem. Vivamus eget nibh ac neque consectetur fermentum vel eu turpis.
81
+
82
+ Cras eget volutpat risus. Praesent nisl lacus, cursus ac ultrices in, interdum eu orci. Aenean tincidunt adipiscing libero, in tincidunt nulla consectetur vitae. Duis non orci in lacus lacinia aliquet. Fusce sed libero vitae turpis placerat fermentum et a mauris. Etiam sit amet mi erat. Pellentesque volutpat, felis quis hendrerit ornare, dui nibh porttitor augue, vel pulvinar nisl enim sit amet eros. Donec eget leo quis felis lobortis interdum. Fusce eu mi ac urna pellentesque bibendum. Nulla pharetra congue ante, vel porttitor ligula rhoncus vel. Cras lacinia euismod porta. Praesent tempor sem vitae ipsum tristique eleifend. Nullam scelerisque nisi ut mauris sollicitudin auctor. Nunc tellus velit, congue vitae commodo nec, vestibulum sed mi. Proin convallis viverra quam, eu placerat est commodo quis. Duis in mauris nibh. Nulla est risus, rutrum tempor consequat id, consectetur sed tortor. Maecenas consequat elit tortor, eu tempus turpis. Sed sit amet consectetur est. </content>
83
+ <created-at type="datetime">2010-07-21T22:47:22Z</created-at>
84
+ <creator-id type="integer">5654019</creator-id>
85
+ <due-at type="datetime" nil="true"></due-at>
86
+ <id type="integer">62608455</id>
87
+ <position type="integer">6</position>
88
+ <todo-list-id type="integer">9973518</todo-list-id>
89
+ <created-on type="datetime" deprecated="true">2010-07-21T22:47:22Z</created-on>
90
+ <creator-name>Kia Kroas</creator-name>
91
+ </todo-item>
92
+ </todo-items>
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <todo-lists type="array">
3
+ <todo-list>
4
+ <completed-count type="integer">0</completed-count>
5
+ <description></description>
6
+ <id type="integer">9973518</id>
7
+ <milestone-id type="integer" nil="true"></milestone-id>
8
+ <name>Stuff and stuff</name>
9
+ <position type="integer">1</position>
10
+ <private type="boolean">false</private>
11
+ <project-id type="integer">5220065</project-id>
12
+ <tracked type="boolean">false</tracked>
13
+ <uncompleted-count type="integer">6</uncompleted-count>
14
+ <complete>false</complete>
15
+ </todo-list>
16
+ <todo-list>
17
+ <completed-count type="integer">0</completed-count>
18
+ <description>etauhnotehunoteh tnheontu honetuh osneh noe hosneuh toneuh</description>
19
+ <id type="integer">9972756</id>
20
+ <milestone-id type="integer" nil="true"></milestone-id>
21
+ <name>Cheese</name>
22
+ <position type="integer">2</position>
23
+ <private type="boolean">false</private>
24
+ <project-id type="integer">5220065</project-id>
25
+ <tracked type="boolean">false</tracked>
26
+ <uncompleted-count type="integer">6</uncompleted-count>
27
+ <complete>false</complete>
28
+ </todo-list>
29
+ </todo-lists>
@@ -0,0 +1,70 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticketmaster::Provider::Basecamp::Project" do
4
+ before(:all) do
5
+ headers = {'Authorization' => 'Basic MDAwMDAwOkJhc2VjYW1wIGxhbW8='}
6
+ wheaders = headers.merge('Content-Type' => 'application/xml')
7
+ @project_id = 5220065
8
+ ActiveResource::HttpMock.respond_to do |mock|
9
+ mock.get '/projects.xml', headers, fixture_for('projects'), 200
10
+ mock.get '/projects/5220065.xml', headers, fixture_for('projects/5220065'), 200
11
+ mock.get '/projects/create.xml', headers, fixture_for('projects/create'), 200
12
+ mock.delete '/projects/5220065.xml', headers, '', 200
13
+ mock.put '/projects/5220065.xml', wheaders, '', 200
14
+ mock.post '/projects.xml', wheaders, '', 201, 'Location' => '/projects/create.xml'
15
+ end
16
+ end
17
+
18
+ before(:each) do
19
+ @ticketmaster = TicketMaster.new(:basecamp, :token => '000000', :domain => 'ticketmaster.basecamphq.com')
20
+ @klass = TicketMaster::Provider::Basecamp::Project
21
+ end
22
+
23
+ it "should be able to load all projects" do
24
+ @ticketmaster.projects.should be_an_instance_of(Array)
25
+ @ticketmaster.projects.first.should be_an_instance_of(@klass)
26
+ end
27
+
28
+ it "should be able to load projects from an array of ids" do
29
+ @projects = @ticketmaster.projects([@project_id])
30
+ @projects.should be_an_instance_of(Array)
31
+ @projects.first.should be_an_instance_of(@klass)
32
+ @projects.first.id.should == @project_id
33
+ end
34
+
35
+ it "should be able to load all projects from attributes" do
36
+ @projects = @ticketmaster.projects(:id => @project_id)
37
+ @projects.should be_an_instance_of(Array)
38
+ @projects.first.should be_an_instance_of(@klass)
39
+ @projects.first.id.should == @project_id
40
+ end
41
+
42
+ it "should be able to find a project" do
43
+ @ticketmaster.project.should == @klass
44
+ @ticketmaster.project.find(@project_id).should be_an_instance_of(@klass)
45
+ end
46
+
47
+ it "should be able to find a project by id" do
48
+ @ticketmaster.project(@project_id).should be_an_instance_of(@klass)
49
+ @ticketmaster.project(@project_id).id.should == @project_id
50
+ end
51
+
52
+ it "should be able to find a project by attributes" do
53
+ @ticketmaster.project(:id => @project_id).id.should == @project_id
54
+ @ticketmaster.project(:id => @project_id).should be_an_instance_of(@klass)
55
+ end
56
+
57
+ it "should be able to update and save a project" do
58
+ @project = @ticketmaster.project(@project_id)
59
+ @project.save.should == nil
60
+ @project.update!(:name => 'some new name').should == true
61
+ @project.name = 'this is a change'
62
+ @project.save.should == true
63
+ end
64
+
65
+ it "should be able to create a project" do
66
+ @project = @ticketmaster.project.create(:name => 'Project #1')
67
+ @project.should be_an_instance_of(@klass)
68
+ end
69
+
70
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color