comparison test/integration/issues_api_test.rb @ 22:40f7cfd4df19

* Update to SVN trunk rev 4173
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Fri, 24 Sep 2010 14:06:04 +0100
parents 513646585e45
children
comparison
equal deleted inserted replaced
14:1d32c0a0efbf 22:40f7cfd4df19
196 196
197 context "PUT /issues/1.xml" do 197 context "PUT /issues/1.xml" do
198 setup do 198 setup do
199 @issue_count = Issue.count 199 @issue_count = Issue.count
200 @journal_count = Journal.count 200 @journal_count = Journal.count
201 @attributes = {:subject => 'API update'} 201 @attributes = {:subject => 'API update', :notes => 'A new note'}
202 202
203 put '/issues/1.xml', {:issue => @attributes}, :authorization => credentials('jsmith') 203 put '/issues/1.xml', {:issue => @attributes}, :authorization => credentials('jsmith')
204 end 204 end
205 205
206 should_respond_with :ok 206 should_respond_with :ok
210 assert_equal Issue.count, @issue_count 210 assert_equal Issue.count, @issue_count
211 end 211 end
212 212
213 should "create a new journal" do 213 should "create a new journal" do
214 assert_equal Journal.count, @journal_count + 1 214 assert_equal Journal.count, @journal_count + 1
215 end
216
217 should "add the note to the journal" do
218 journal = Journal.last
219 assert_equal "A new note", journal.notes
215 end 220 end
216 221
217 should "update the issue" do 222 should "update the issue" do
218 issue = Issue.find(1) 223 issue = Issue.find(1)
219 @attributes.each do |attribute, value| 224 @attributes.each do |attribute, value|
220 assert_equal value, issue.send(attribute) 225 assert_equal value, issue.send(attribute) unless attribute == :notes
221 end 226 end
222 end 227 end
223 228
224 end 229 end
225 230
250 255
251 context "PUT /issues/1.json" do 256 context "PUT /issues/1.json" do
252 setup do 257 setup do
253 @issue_count = Issue.count 258 @issue_count = Issue.count
254 @journal_count = Journal.count 259 @journal_count = Journal.count
255 @attributes = {:subject => 'API update'} 260 @attributes = {:subject => 'API update', :notes => 'A new note'}
256 261
257 put '/issues/1.json', {:issue => @attributes}, :authorization => credentials('jsmith') 262 put '/issues/1.json', {:issue => @attributes}, :authorization => credentials('jsmith')
258 end 263 end
259 264
260 should_respond_with :ok 265 should_respond_with :ok
264 assert_equal Issue.count, @issue_count 269 assert_equal Issue.count, @issue_count
265 end 270 end
266 271
267 should "create a new journal" do 272 should "create a new journal" do
268 assert_equal Journal.count, @journal_count + 1 273 assert_equal Journal.count, @journal_count + 1
274 end
275
276 should "add the note to the journal" do
277 journal = Journal.last
278 assert_equal "A new note", journal.notes
269 end 279 end
270 280
271 should "update the issue" do 281 should "update the issue" do
272 issue = Issue.find(1) 282 issue = Issue.find(1)
273 @attributes.each do |attribute, value| 283 @attributes.each do |attribute, value|
274 assert_equal value, issue.send(attribute) 284 assert_equal value, issue.send(attribute) unless attribute == :notes
275 end 285 end
276 end 286 end
277 287
278 end 288 end
279 289
280 context "PUT /issues/1.json with failed update" do 290 context "PUT /issues/1.json with failed update" do
281 setup do 291 setup do
282 @attributes = {:subject => ''} 292 @attributes = {:subject => ''}