tsenart-pivotal-tracker 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/Gemfile +16 -0
  2. data/Gemfile.lock +48 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +77 -0
  5. data/Rakefile +50 -0
  6. data/VERSION +1 -0
  7. data/lib/pivotal-tracker/activity.rb +46 -0
  8. data/lib/pivotal-tracker/attachment.rb +16 -0
  9. data/lib/pivotal-tracker/client.rb +41 -0
  10. data/lib/pivotal-tracker/extensions.rb +11 -0
  11. data/lib/pivotal-tracker/iteration.rb +34 -0
  12. data/lib/pivotal-tracker/membership.rb +20 -0
  13. data/lib/pivotal-tracker/note.rb +58 -0
  14. data/lib/pivotal-tracker/project.rb +58 -0
  15. data/lib/pivotal-tracker/proxy.rb +66 -0
  16. data/lib/pivotal-tracker/story.rb +148 -0
  17. data/lib/pivotal-tracker/task.rb +53 -0
  18. data/lib/pivotal-tracker/validation.rb +68 -0
  19. data/lib/pivotal-tracker.rb +40 -0
  20. data/lib/pivotal_tracker.rb +2 -0
  21. data/pivotal-tracker.gemspec +121 -0
  22. data/spec/fixtures/activity.xml +177 -0
  23. data/spec/fixtures/created_note.xml +14 -0
  24. data/spec/fixtures/created_story.xml +14 -0
  25. data/spec/fixtures/iterations_all.xml +237 -0
  26. data/spec/fixtures/iterations_backlog.xml +163 -0
  27. data/spec/fixtures/iterations_current.xml +47 -0
  28. data/spec/fixtures/iterations_done.xml +33 -0
  29. data/spec/fixtures/memberships.xml +42 -0
  30. data/spec/fixtures/notes.xml +33 -0
  31. data/spec/fixtures/project.xml +51 -0
  32. data/spec/fixtures/project_activity.xml +177 -0
  33. data/spec/fixtures/projects.xml +103 -0
  34. data/spec/fixtures/stale_fish.yml +100 -0
  35. data/spec/fixtures/stories.xml +293 -0
  36. data/spec/fixtures/tasks.xml +24 -0
  37. data/spec/spec.opts +1 -0
  38. data/spec/spec_helper.rb +31 -0
  39. data/spec/support/stale_fish_fixtures.rb +67 -0
  40. data/spec/unit/pivotal-tracker/activity_spec.rb +32 -0
  41. data/spec/unit/pivotal-tracker/attachment_spec.rb +62 -0
  42. data/spec/unit/pivotal-tracker/client_spec.rb +87 -0
  43. data/spec/unit/pivotal-tracker/iteration_spec.rb +52 -0
  44. data/spec/unit/pivotal-tracker/membership_spec.rb +20 -0
  45. data/spec/unit/pivotal-tracker/note_spec.rb +61 -0
  46. data/spec/unit/pivotal-tracker/project_spec.rb +55 -0
  47. data/spec/unit/pivotal-tracker/story_spec.rb +185 -0
  48. data/spec/unit/pivotal-tracker/task_spec.rb +21 -0
  49. metadata +236 -0
@@ -0,0 +1,293 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <stories type="array" count="14" limit="20" total="14">
3
+ <story>
4
+ <id type="integer">4460116</id>
5
+ <project_id type="integer">102622</project_id>
6
+ <story_type>feature</story_type>
7
+ <url>http://www.pivotaltracker.com/story/show/4460116</url>
8
+ <estimate type="integer">0</estimate>
9
+ <current_state>accepted</current_state>
10
+ <description>This is a story that's finished.</description>
11
+ <name>Old, accepted story</name>
12
+ <requested_by>Jon Mischo</requested_by>
13
+ <created_at type="datetime">2010/07/27 21:58:28 UTC</created_at>
14
+ <updated_at type="datetime">2010/07/27 22:21:17 UTC</updated_at>
15
+ <accepted_at type="datetime">2010/07/18 17:00:00 UTC</accepted_at>
16
+ </story>
17
+ <story>
18
+ <id type="integer">4459994</id>
19
+ <project_id type="integer">102622</project_id>
20
+ <story_type>feature</story_type>
21
+ <url>http://www.pivotaltracker.com/story/show/4459994</url>
22
+ <estimate type="integer">2</estimate>
23
+ <current_state>unstarted</current_state>
24
+ <description>Generic description</description>
25
+ <name>Tasks Test</name>
26
+ <requested_by>Jon Mischo</requested_by>
27
+ <created_at type="datetime">2010/07/27 21:51:01 UTC</created_at>
28
+ <updated_at type="datetime">2010/07/27 22:20:46 UTC</updated_at>
29
+ <tasks type="array">
30
+ <task>
31
+ <id type="integer">468113</id>
32
+ <description>Task number 1</description>
33
+ <position>1</position>
34
+ <complete>false</complete>
35
+ <created_at type="datetime">2010/07/27 21:51:28 UTC</created_at>
36
+ </task>
37
+ <task>
38
+ <id type="integer">468114</id>
39
+ <description>Number 2 Task</description>
40
+ <position>2</position>
41
+ <complete>false</complete>
42
+ <created_at type="datetime">2010/07/27 21:51:32 UTC</created_at>
43
+ </task>
44
+ <task>
45
+ <id type="integer">468117</id>
46
+ <description>3rd task is a charm</description>
47
+ <position>3</position>
48
+ <complete>true</complete>
49
+ <created_at type="datetime">2010/07/27 21:51:42 UTC</created_at>
50
+ </task>
51
+ </tasks>
52
+ </story>
53
+ <story>
54
+ <id type="integer">4460038</id>
55
+ <project_id type="integer">102622</project_id>
56
+ <story_type>feature</story_type>
57
+ <url>http://www.pivotaltracker.com/story/show/4460038</url>
58
+ <estimate type="integer">1</estimate>
59
+ <current_state>unstarted</current_state>
60
+ <description>This is a story that has comments.</description>
61
+ <name>This is for comments</name>
62
+ <requested_by>Jon Mischo</requested_by>
63
+ <created_at type="datetime">2010/07/27 21:53:16 UTC</created_at>
64
+ <updated_at type="datetime">2010/07/27 22:20:48 UTC</updated_at>
65
+ <notes type="array">
66
+ <note>
67
+ <id type="integer">2111593</id>
68
+ <text>This is a comment...whee!</text>
69
+ <author>Jon</author>
70
+ <noted_at type="datetime">2010/07/27 22:15:48 UTC</noted_at>
71
+ </note>
72
+ <note>
73
+ <id type="integer">2128955</id>
74
+ <text>Test note</text>
75
+ <author>Test Suite Access</author>
76
+ <noted_at type="datetime">2010/07/29 18:15:09 UTC</noted_at>
77
+ </note>
78
+ <note>
79
+ <id type="integer">2128959</id>
80
+ <text>Test note</text>
81
+ <author>Test Suite Access</author>
82
+ <noted_at type="datetime">2010/07/29 18:16:12 UTC</noted_at>
83
+ </note>
84
+ <note>
85
+ <id type="integer">2129077</id>
86
+ <text>Test note</text>
87
+ <author>Test Suite Access</author>
88
+ <noted_at type="datetime">2010/07/29 18:22:26 UTC</noted_at>
89
+ </note>
90
+ <note>
91
+ <id type="integer">2129374</id>
92
+ <text>Test note</text>
93
+ <author>Test Suite Access</author>
94
+ <noted_at type="datetime">2010/07/29 18:55:44 UTC</noted_at>
95
+ </note>
96
+ </notes>
97
+ </story>
98
+ <story>
99
+ <id type="integer">4460598</id>
100
+ <project_id type="integer">102622</project_id>
101
+ <story_type>feature</story_type>
102
+ <url>http://www.pivotaltracker.com/story/show/4460598</url>
103
+ <estimate type="integer">3</estimate>
104
+ <current_state>unstarted</current_state>
105
+ <description>This story has attachments.</description>
106
+ <name>Story with attachments</name>
107
+ <requested_by>Jon Mischo</requested_by>
108
+ <created_at type="datetime">2010/07/27 22:33:13 UTC</created_at>
109
+ <updated_at type="datetime">2010/07/27 22:33:28 UTC</updated_at>
110
+ <attachments type="array">
111
+ <attachment>
112
+ <id type="integer">491576</id>
113
+ <filename>LICENSE</filename>
114
+ <description></description>
115
+ <uploaded_by>Jon</uploaded_by>
116
+ <uploaded_at type="datetime">2010/07/27 22:34:23 UTC</uploaded_at>
117
+ <url>http://www.pivotaltracker.com/resource/download/491576</url>
118
+ </attachment>
119
+ <attachment>
120
+ <id type="integer">493019</id>
121
+ <filename>README.rdoc</filename>
122
+ <description>README file from api gem</description>
123
+ <uploaded_by>Jon</uploaded_by>
124
+ <uploaded_at type="datetime">2010/07/28 15:16:18 UTC</uploaded_at>
125
+ <url>http://www.pivotaltracker.com/resource/download/493019</url>
126
+ </attachment>
127
+ </attachments>
128
+ </story>
129
+ <story>
130
+ <id type="integer">4473735</id>
131
+ <project_id type="integer">102622</project_id>
132
+ <story_type>feature</story_type>
133
+ <url>http://www.pivotaltracker.com/story/show/4473735</url>
134
+ <estimate type="integer">1</estimate>
135
+ <current_state>unstarted</current_state>
136
+ <description></description>
137
+ <name>Attachment upload test story</name>
138
+ <requested_by>Jon</requested_by>
139
+ <created_at type="datetime">2010/07/28 18:17:33 UTC</created_at>
140
+ <updated_at type="datetime">2010/07/28 18:17:44 UTC</updated_at>
141
+ <attachments type="array">
142
+ <attachment>
143
+ <id type="integer">495851</id>
144
+ <filename>LICENSE</filename>
145
+ <description></description>
146
+ <uploaded_by>Test Suite Access</uploaded_by>
147
+ <uploaded_at type="datetime">2010/07/29 19:07:19 UTC</uploaded_at>
148
+ <url>http://www.pivotaltracker.com/resource/download/495851</url>
149
+ </attachment>
150
+ <attachment>
151
+ <id type="integer">495856</id>
152
+ <filename>LICENSE</filename>
153
+ <description></description>
154
+ <uploaded_by>Test Suite Access</uploaded_by>
155
+ <uploaded_at type="datetime">2010/07/29 19:09:27 UTC</uploaded_at>
156
+ <url>http://www.pivotaltracker.com/resource/download/495856</url>
157
+ </attachment>
158
+ <attachment>
159
+ <id type="integer">495858</id>
160
+ <filename>LICENSE</filename>
161
+ <description></description>
162
+ <uploaded_by>Test Suite Access</uploaded_by>
163
+ <uploaded_at type="datetime">2010/07/29 19:11:44 UTC</uploaded_at>
164
+ <url>http://www.pivotaltracker.com/resource/download/495858</url>
165
+ </attachment>
166
+ <attachment>
167
+ <id type="integer">495863</id>
168
+ <filename>LICENSE</filename>
169
+ <description></description>
170
+ <uploaded_by>Test Suite Access</uploaded_by>
171
+ <uploaded_at type="datetime">2010/07/29 19:13:06 UTC</uploaded_at>
172
+ <url>http://www.pivotaltracker.com/resource/download/495863</url>
173
+ </attachment>
174
+ </attachments>
175
+ </story>
176
+ <story>
177
+ <id type="integer">4490874</id>
178
+ <project_id type="integer">102622</project_id>
179
+ <story_type>feature</story_type>
180
+ <url>http://www.pivotaltracker.com/story/show/4490874</url>
181
+ <estimate type="integer">0</estimate>
182
+ <current_state>unstarted</current_state>
183
+ <description></description>
184
+ <name>Movable Story</name>
185
+ <requested_by>Test Suite Access</requested_by>
186
+ <created_at type="datetime">2010/07/29 18:12:31 UTC</created_at>
187
+ <updated_at type="datetime">2010/07/29 19:13:12 UTC</updated_at>
188
+ </story>
189
+ <story>
190
+ <id type="integer">4492080</id>
191
+ <project_id type="integer">102622</project_id>
192
+ <story_type>feature</story_type>
193
+ <url>http://www.pivotaltracker.com/story/show/4492080</url>
194
+ <estimate type="integer">-1</estimate>
195
+ <current_state>unscheduled</current_state>
196
+ <description></description>
197
+ <name>Create stuff</name>
198
+ <requested_by>Test Suite Access</requested_by>
199
+ <created_at type="datetime">2010/07/29 19:13:04 UTC</created_at>
200
+ <updated_at type="datetime">2010/07/29 19:13:04 UTC</updated_at>
201
+ </story>
202
+ <story>
203
+ <id type="integer">4492078</id>
204
+ <project_id type="integer">102622</project_id>
205
+ <story_type>feature</story_type>
206
+ <url>http://www.pivotaltracker.com/story/show/4492078</url>
207
+ <estimate type="integer">-1</estimate>
208
+ <current_state>unscheduled</current_state>
209
+ <description></description>
210
+ <name>Create stuff</name>
211
+ <requested_by>Test Suite Access</requested_by>
212
+ <created_at type="datetime">2010/07/29 19:13:01 UTC</created_at>
213
+ <updated_at type="datetime">2010/07/29 19:13:01 UTC</updated_at>
214
+ </story>
215
+ <story>
216
+ <id type="integer">4492060</id>
217
+ <project_id type="integer">102622</project_id>
218
+ <story_type>feature</story_type>
219
+ <url>http://www.pivotaltracker.com/story/show/4492060</url>
220
+ <estimate type="integer">-1</estimate>
221
+ <current_state>unscheduled</current_state>
222
+ <description></description>
223
+ <name>Create stuff</name>
224
+ <requested_by>Test Suite Access</requested_by>
225
+ <created_at type="datetime">2010/07/29 19:11:43 UTC</created_at>
226
+ <updated_at type="datetime">2010/07/29 19:11:43 UTC</updated_at>
227
+ </story>
228
+ <story>
229
+ <id type="integer">4492059</id>
230
+ <project_id type="integer">102622</project_id>
231
+ <story_type>feature</story_type>
232
+ <url>http://www.pivotaltracker.com/story/show/4492059</url>
233
+ <estimate type="integer">-1</estimate>
234
+ <current_state>unscheduled</current_state>
235
+ <description></description>
236
+ <name>Create stuff</name>
237
+ <requested_by>Test Suite Access</requested_by>
238
+ <created_at type="datetime">2010/07/29 19:11:38 UTC</created_at>
239
+ <updated_at type="datetime">2010/07/29 19:11:38 UTC</updated_at>
240
+ </story>
241
+ <story>
242
+ <id type="integer">4491973</id>
243
+ <project_id type="integer">102622</project_id>
244
+ <story_type>feature</story_type>
245
+ <url>http://www.pivotaltracker.com/story/show/4491973</url>
246
+ <estimate type="integer">-1</estimate>
247
+ <current_state>unscheduled</current_state>
248
+ <description></description>
249
+ <name>Create stuff</name>
250
+ <requested_by>Test Suite Access</requested_by>
251
+ <created_at type="datetime">2010/07/29 19:09:26 UTC</created_at>
252
+ <updated_at type="datetime">2010/07/29 19:09:26 UTC</updated_at>
253
+ </story>
254
+ <story>
255
+ <id type="integer">4491971</id>
256
+ <project_id type="integer">102622</project_id>
257
+ <story_type>feature</story_type>
258
+ <url>http://www.pivotaltracker.com/story/show/4491971</url>
259
+ <estimate type="integer">-1</estimate>
260
+ <current_state>unscheduled</current_state>
261
+ <description></description>
262
+ <name>Create stuff</name>
263
+ <requested_by>Test Suite Access</requested_by>
264
+ <created_at type="datetime">2010/07/29 19:09:24 UTC</created_at>
265
+ <updated_at type="datetime">2010/07/29 19:09:24 UTC</updated_at>
266
+ </story>
267
+ <story>
268
+ <id type="integer">4491741</id>
269
+ <project_id type="integer">102622</project_id>
270
+ <story_type>feature</story_type>
271
+ <url>http://www.pivotaltracker.com/story/show/4491741</url>
272
+ <estimate type="integer">-1</estimate>
273
+ <current_state>unscheduled</current_state>
274
+ <description></description>
275
+ <name>Create Stuff</name>
276
+ <requested_by>Test Suite Access</requested_by>
277
+ <created_at type="datetime">2010/07/29 18:56:02 UTC</created_at>
278
+ <updated_at type="datetime">2010/07/29 18:56:02 UTC</updated_at>
279
+ </story>
280
+ <story>
281
+ <id type="integer">4490944</id>
282
+ <project_id type="integer">102622</project_id>
283
+ <story_type>feature</story_type>
284
+ <url>http://www.pivotaltracker.com/story/show/4490944</url>
285
+ <estimate type="integer">-1</estimate>
286
+ <current_state>unscheduled</current_state>
287
+ <description></description>
288
+ <name>Create Stuff</name>
289
+ <requested_by>Test Suite Access</requested_by>
290
+ <created_at type="datetime">2010/07/29 18:17:23 UTC</created_at>
291
+ <updated_at type="datetime">2010/07/29 18:17:23 UTC</updated_at>
292
+ </story>
293
+ </stories>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <tasks type="array">
3
+ <task>
4
+ <id type="integer">468113</id>
5
+ <description>Task number 1</description>
6
+ <position>1</position>
7
+ <complete>false</complete>
8
+ <created_at type="datetime">2010/07/27 21:51:28 UTC</created_at>
9
+ </task>
10
+ <task>
11
+ <id type="integer">468114</id>
12
+ <description>Number 2 Task</description>
13
+ <position>2</position>
14
+ <complete>false</complete>
15
+ <created_at type="datetime">2010/07/27 21:51:32 UTC</created_at>
16
+ </task>
17
+ <task>
18
+ <id type="integer">468117</id>
19
+ <description>3rd task is a charm</description>
20
+ <position>3</position>
21
+ <complete>true</complete>
22
+ <created_at type="datetime">2010/07/27 21:51:42 UTC</created_at>
23
+ </task>
24
+ </tasks>
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'stale_fish'
4
+
5
+ Bundler.require(:default, :runtime, :test)
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+
9
+ require 'pivotal-tracker'
10
+ require 'spec'
11
+ require 'spec/autorun'
12
+
13
+ PROJECT_ID = ENV['PROJECT_ID'] || "102622"
14
+ TOKEN = '8358666c5a593a3c82cda728c8a62b63'
15
+
16
+ PivotalTracker::Client.token = TOKEN
17
+
18
+ # Requires supporting files with custom matchers and macros, etc,
19
+ # in ./support/ and its subdirectories.
20
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
21
+
22
+ StaleFish.setup(File.join(File.dirname(__FILE__), 'fixtures', 'stale_fish.yml'))
23
+
24
+ Spec::Runner.configure do |config|
25
+ # config.include(Rack::Test::Methods)
26
+
27
+ config.before :suite do
28
+ StaleFish.update_stale
29
+ end
30
+
31
+ end
@@ -0,0 +1,67 @@
1
+ module StaleFishFixtures
2
+ class << self
3
+
4
+ def update_projects_fixture
5
+ connection["/projects"].get
6
+ end
7
+
8
+ def update_project_fixture
9
+ connection["/projects/102622"].get
10
+ end
11
+
12
+ def update_stories_fixture
13
+ connection["/projects/102622/stories?limit=20"].get
14
+ end
15
+
16
+ def update_memberships_fixture
17
+ connection["/projects/102622/memberships"].get
18
+ end
19
+
20
+ def update_tasks_fixture
21
+ connection["/projects/102622/stories/4459994/tasks"].get
22
+ end
23
+
24
+ def update_activity_fixture
25
+ connection["/activities"].get
26
+ end
27
+
28
+ def update_project_activity_fixture
29
+ connection["/projects/102622/activities"].get
30
+ end
31
+
32
+ def update_iterations_all_fixture
33
+ connection["/projects/102622/iterations"].get
34
+ end
35
+
36
+ def update_iterations_current_fixture
37
+ connection["/projects/102622/iterations/current"].get
38
+ end
39
+
40
+ def update_iterations_backlog_fixture
41
+ connection["/projects/102622/iterations/backlog"].get
42
+ end
43
+
44
+ def update_iterations_done_fixture
45
+ connection["/projects/102622/iterations/done"].get
46
+ end
47
+
48
+ def create_new_story
49
+ connection["/projects/102622/stories"].post("<story><name>Create stuff</name></story>", :content_type => 'application/xml')
50
+ end
51
+
52
+ def update_notes_fixture
53
+ connection["/projects/102622/stories/4460038/notes"].get
54
+ end
55
+
56
+ # def upload_attachment_fixture
57
+ # connection["/projects/102622/stories/4473735/attachments"].post(:Filedata => File.new(File.dirname(__FILE__) + '/../../LICENSE'))
58
+ # end
59
+
60
+ protected
61
+
62
+ def connection
63
+ @connection ||= RestClient::Resource.new('http://www.pivotaltracker.com/services/v3', :headers => {'X-TrackerToken' => TOKEN, 'Content-Type' => 'application/xml'})
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe PivotalTracker::Activity do
4
+
5
+ context "without a specified project" do
6
+ it "should return an array of activities" do
7
+ PivotalTracker::Activity.all.should be_a(Array)
8
+ PivotalTracker::Activity.all.first.should be_a(PivotalTracker::Activity)
9
+ end
10
+ end
11
+
12
+ context "with a specified project" do
13
+ before do
14
+ @project = PivotalTracker::Project.find(PROJECT_ID)
15
+ end
16
+
17
+ it "should return an array of activities" do
18
+ @project.activities.all.should be_a(Array)
19
+ @project.activities.all.first.should be_a(PivotalTracker::Activity)
20
+ end
21
+ end
22
+
23
+ context "with a specified occurred since date filter" do
24
+ it "should correctly url encode the occurred since date filter in the API call" do
25
+ PivotalTracker::Client.stub!(:connection).and_return connection = double("Client Connection")
26
+ connection.should_receive(:[]).with("/activities?limit=100&occurred_since_date=2010/07/29%2019:13:00%20UTC")
27
+ .and_return double("Connection", :get => '<blah></blah>')
28
+ PivotalTracker::Activity.all nil, :limit => 100, :occurred_since_date => DateTime.parse("2010/7/29 19:13:00 UTC")
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe PivotalTracker::Attachment do
4
+
5
+ before do
6
+ PivotalTracker::Client.token = TOKEN
7
+ @project = PivotalTracker::Project.find(102622)
8
+ @story = @project.stories.find(4460598)
9
+ end
10
+
11
+ context "always" do
12
+ it "should return an integer id" do
13
+ @story.attachments.first.id.should be_a(Integer)
14
+ end
15
+
16
+ it "should return a string for url" do
17
+ @story.attachments.first.url.should be_a(String)
18
+ end
19
+
20
+ it "should return a string for filename" do
21
+ @story.attachments.first.filename.should be_a(String)
22
+ end
23
+
24
+ it "should return a string for uploaded_by" do
25
+ @story.attachments.first.uploaded_by.should be_a(String)
26
+ end
27
+
28
+ it "should return a datetime for uploaded_at" do
29
+ @story.attachments.first.uploaded_at.should be_a(DateTime)
30
+ end
31
+ end
32
+
33
+ context "without description" do
34
+ it "should have a blank string for the description" do
35
+ @story.attachments.first.description.should be_a(String)
36
+ @story.attachments.first.description.should be_blank
37
+ end
38
+ end
39
+
40
+ context "with description" do
41
+ it "should have a non-blank string for the description" do
42
+ @story.attachments.first.description.should be_a(String)
43
+ @story.attachments.last.description.should_not be_blank
44
+ end
45
+ end
46
+
47
+ context "uploading" do
48
+
49
+ before do
50
+ @target_story = @project.stories.find(4473735)
51
+ @orig_net_lock = FakeWeb.allow_net_connect?
52
+ end
53
+
54
+ it "should return an attachment object with a pending status" do
55
+ FakeWeb.allow_net_connect = true
56
+ resource = @target_story.upload_attachment(File.dirname(__FILE__) + '/../../../LICENSE')
57
+ FakeWeb.allow_net_connect = @orig_net_lock
58
+ resource.should be_a(PivotalTracker::Attachment)
59
+ resource.status.should == 'Pending'
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,87 @@
1
+ require "spec_helper"
2
+ require 'ruby-debug'
3
+
4
+ describe PivotalTracker::Client do
5
+
6
+ describe ".connection" do
7
+
8
+ context "with no existing token" do
9
+
10
+ before do
11
+ PivotalTracker::Client.token = nil
12
+ end
13
+
14
+ it "raises a NoToken exception" do
15
+ lambda { PivotalTracker::Client.connection }.should raise_error(PivotalTracker::Client::NoToken)
16
+ end
17
+
18
+ describe "after setting a new token" do
19
+
20
+ before do
21
+ PivotalTracker::Client.token = "anewtoken"
22
+ end
23
+
24
+ it "called to RestClient::Resource using the new token" do
25
+ RestClient::Resource.should_receive(:new).with("http://www.pivotaltracker.com/services/v3", :headers => {'X-TrackerToken' => "anewtoken", 'Content-Type' => 'application/xml'})
26
+
27
+ PivotalTracker::Client.connection
28
+ end
29
+
30
+ it "returned the connection for the new token" do
31
+ @resource = Object.new
32
+
33
+ RestClient::Resource.should_receive(:new).
34
+ with("http://www.pivotaltracker.com/services/v3", :headers => {'X-TrackerToken' => "anewtoken", 'Content-Type' => 'application/xml'}).
35
+ and_return(@resource)
36
+
37
+ PivotalTracker::Client.connection.should == @resource
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ context "with an existing token" do
45
+
46
+ before do
47
+ PivotalTracker::Client.token = "abc123"
48
+ end
49
+
50
+ it "returned a RestClient::Resource using the token" do
51
+ @resource = Object.new
52
+
53
+ RestClient::Resource.should_receive(:new).
54
+ with("http://www.pivotaltracker.com/services/v3", :headers => {'X-TrackerToken' => "abc123", 'Content-Type' => 'application/xml'}).
55
+ and_return(@resource)
56
+
57
+ PivotalTracker::Client.connection.should == @resource
58
+ end
59
+
60
+ describe "after setting a new token" do
61
+
62
+ before do
63
+ PivotalTracker::Client.token = "anewtoken"
64
+ end
65
+
66
+ it "called to RestClient::Resource using the new token" do
67
+ RestClient::Resource.should_receive(:new).with("http://www.pivotaltracker.com/services/v3", :headers => {'X-TrackerToken' => "anewtoken", 'Content-Type' => 'application/xml'})
68
+
69
+ PivotalTracker::Client.connection
70
+ end
71
+
72
+ it "returned the connection for the new token" do
73
+ @resource = Object.new
74
+
75
+ RestClient::Resource.should_receive(:new).
76
+ with("http://www.pivotaltracker.com/services/v3", :headers => {'X-TrackerToken' => "anewtoken", 'Content-Type' => 'application/xml'}).
77
+ and_return(@resource)
78
+
79
+ PivotalTracker::Client.connection.should == @resource
80
+ end
81
+
82
+ end
83
+
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe PivotalTracker::Iteration do
4
+ before do
5
+ @project = PivotalTracker::Project.find(PROJECT_ID)
6
+ end
7
+
8
+ describe ".all" do
9
+ before do
10
+ @iterations = PivotalTracker::Iteration.all(@project)
11
+ end
12
+
13
+ it "should return an array of Iterations for the given Project" do
14
+ @iterations.should be_a(Array)
15
+ @iterations.first.should be_a(PivotalTracker::Iteration)
16
+ end
17
+ end
18
+
19
+ describe ".current" do
20
+ before do
21
+ @iteration = PivotalTracker::Iteration.current(@project)
22
+ end
23
+
24
+ it "should return a single Iteration" do
25
+ @iteration.should be_a(PivotalTracker::Iteration)
26
+ end
27
+ end
28
+
29
+ describe ".backlog" do
30
+ before do
31
+ @iterations = PivotalTracker::Iteration.backlog(@project)
32
+ end
33
+
34
+ it "should return an array of Iterations for the given Project" do
35
+ @iterations.should be_a(Array)
36
+ @iterations.first.should be_a(PivotalTracker::Iteration)
37
+ end
38
+ end
39
+
40
+ describe ".done" do
41
+ before do
42
+ @iterations = PivotalTracker::Iteration.done(@project)
43
+ end
44
+
45
+ it "should return an array of Iterations for the given Project" do
46
+ @iterations.should be_a(Array)
47
+ @iterations.first.should be_a(PivotalTracker::Iteration)
48
+ end
49
+ end
50
+
51
+ end
52
+
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe PivotalTracker::Project do
4
+ before do
5
+ @project = PivotalTracker::Project.find(102622)
6
+ end
7
+
8
+ context ".all" do
9
+ it "should return an array of memberships" do
10
+ @project.memberships.all.should be_a(Array)
11
+ @project.memberships.all.first.should be_a(PivotalTracker::Membership)
12
+ end
13
+ end
14
+
15
+ context ".find" do
16
+ it "should return the given membership" do
17
+ @project.memberships.find(331832).should be_a(PivotalTracker::Membership)
18
+ end
19
+ end
20
+ end