comparison test/integration/api_test/issues_test.rb @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents 8661b858af72
children 433d4f72a19b
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2010 Jean-Philippe Lang 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
8 # 8 #
9 # This program is distributed in the hope that it will be useful, 9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details. 12 # GNU General Public License for more details.
13 # 13 #
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 require File.expand_path('../../../test_helper', __FILE__) 18 require File.expand_path('../../../test_helper', __FILE__)
38 :custom_fields_projects, 38 :custom_fields_projects,
39 :custom_fields_trackers, 39 :custom_fields_trackers,
40 :time_entries, 40 :time_entries,
41 :journals, 41 :journals,
42 :journal_details, 42 :journal_details,
43 :queries 43 :queries,
44 :attachments
44 45
45 def setup 46 def setup
46 Setting.rest_api_enabled = '1' 47 Setting.rest_api_enabled = '1'
47 end 48 end
48 49
49 context "/index.xml" do 50 context "/issues" do
50 # Use a private project to make sure auth is really working and not just 51 # Use a private project to make sure auth is really working and not just
51 # only showing public issues. 52 # only showing public issues.
52 should_allow_api_authentication(:get, "/projects/private-child/issues.xml") 53 should_allow_api_authentication(:get, "/projects/private-child/issues.xml")
53 54
54 should "contain metadata" do 55 should "contain metadata" do
55 get '/issues.xml' 56 get '/issues.xml'
56 57
57 assert_tag :tag => 'issues', 58 assert_tag :tag => 'issues',
58 :attributes => { 59 :attributes => {
59 :type => 'array', 60 :type => 'array',
60 :total_count => assigns(:issue_count), 61 :total_count => assigns(:issue_count),
61 :limit => 25, 62 :limit => 25,
62 :offset => 0 63 :offset => 0
63 } 64 }
64 end 65 end
65 66
66 context "with offset and limit" do 67 context "with offset and limit" do
67 should "use the params" do 68 should "use the params" do
68 get '/issues.xml?offset=2&limit=3' 69 get '/issues.xml?offset=2&limit=3'
69 70
70 assert_equal 3, assigns(:limit) 71 assert_equal 3, assigns(:limit)
71 assert_equal 2, assigns(:offset) 72 assert_equal 2, assigns(:offset)
72 assert_tag :tag => 'issues', :children => {:count => 3, :only => {:tag => 'issue'}} 73 assert_tag :tag => 'issues', :children => {:count => 3, :only => {:tag => 'issue'}}
73 end 74 end
74 end 75 end
75 76
76 context "with nometa param" do 77 context "with nometa param" do
77 should "not contain metadata" do 78 should "not contain metadata" do
78 get '/issues.xml?nometa=1' 79 get '/issues.xml?nometa=1'
79 80
80 assert_tag :tag => 'issues', 81 assert_tag :tag => 'issues',
81 :attributes => { 82 :attributes => {
82 :type => 'array', 83 :type => 'array',
83 :total_count => nil, 84 :total_count => nil,
84 :limit => nil, 85 :limit => nil,
88 end 89 end
89 90
90 context "with nometa header" do 91 context "with nometa header" do
91 should "not contain metadata" do 92 should "not contain metadata" do
92 get '/issues.xml', {}, {'X-Redmine-Nometa' => '1'} 93 get '/issues.xml', {}, {'X-Redmine-Nometa' => '1'}
93 94
94 assert_tag :tag => 'issues', 95 assert_tag :tag => 'issues',
95 :attributes => { 96 :attributes => {
96 :type => 'array', 97 :type => 'array',
97 :total_count => nil, 98 :total_count => nil,
98 :limit => nil, 99 :limit => nil,
99 :offset => nil 100 :offset => nil
100 } 101 }
101 end 102 end
102 end 103 end
104
105 context "with relations" do
106 should "display relations" do
107 get '/issues.xml?include=relations'
108
109 assert_response :success
110 assert_equal 'application/xml', @response.content_type
111 assert_tag 'relations',
112 :parent => {:tag => 'issue', :child => {:tag => 'id', :content => '3'}},
113 :children => {:count => 1},
114 :child => {
115 :tag => 'relation',
116 :attributes => {:id => '2', :issue_id => '2', :issue_to_id => '3', :relation_type => 'relates'}
117 }
118 assert_tag 'relations',
119 :parent => {:tag => 'issue', :child => {:tag => 'id', :content => '1'}},
120 :children => {:count => 0}
121 end
122 end
123
124 context "with invalid query params" do
125 should "return errors" do
126 get '/issues.xml', {:f => ['start_date'], :op => {:start_date => '='}}
127
128 assert_response :unprocessable_entity
129 assert_equal 'application/xml', @response.content_type
130 assert_tag 'errors', :child => {:tag => 'error', :content => "Start date can't be blank"}
131 end
132 end
133
134 context "with custom field filter" do
135 should "show only issues with the custom field value" do
136 get '/issues.xml', { :set_filter => 1, :f => ['cf_1'], :op => {:cf_1 => '='}, :v => {:cf_1 => ['MySQL']}}
137
138 expected_ids = Issue.visible.all(
139 :include => :custom_values,
140 :conditions => {:custom_values => {:custom_field_id => 1, :value => 'MySQL'}}).map(&:id)
141
142 assert_select 'issues > issue > id', :count => expected_ids.count do |ids|
143 ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) }
144 end
145 end
146 end
147
148 context "with custom field filter (shorthand method)" do
149 should "show only issues with the custom field value" do
150 get '/issues.xml', { :cf_1 => 'MySQL' }
151
152 expected_ids = Issue.visible.all(
153 :include => :custom_values,
154 :conditions => {:custom_values => {:custom_field_id => 1, :value => 'MySQL'}}).map(&:id)
155
156 assert_select 'issues > issue > id', :count => expected_ids.count do |ids|
157 ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) }
158 end
159 end
160 end
103 end 161 end
104 162
105 context "/index.json" do 163 context "/index.json" do
106 should_allow_api_authentication(:get, "/projects/private-child/issues.json") 164 should_allow_api_authentication(:get, "/projects/private-child/issues.json")
107 end 165 end
108 166
109 context "/index.xml with filter" do 167 context "/index.xml with filter" do
110 should_allow_api_authentication(:get, "/projects/private-child/issues.xml?status_id=5")
111
112 should "show only issues with the status_id" do 168 should "show only issues with the status_id" do
113 get '/issues.xml?status_id=5' 169 get '/issues.xml?status_id=5'
114 assert_tag :tag => 'issues', 170
115 :children => { :count => Issue.visible.count(:conditions => {:status_id => 5}), 171 expected_ids = Issue.visible.all(:conditions => {:status_id => 5}).map(&:id)
116 :only => { :tag => 'issue' } } 172
173 assert_select 'issues > issue > id', :count => expected_ids.count do |ids|
174 ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) }
175 end
117 end 176 end
118 end 177 end
119 178
120 context "/index.json with filter" do 179 context "/index.json with filter" do
121 should_allow_api_authentication(:get, "/projects/private-child/issues.json?status_id=5")
122
123 should "show only issues with the status_id" do 180 should "show only issues with the status_id" do
124 get '/issues.json?status_id=5' 181 get '/issues.json?status_id=5'
125 182
126 json = ActiveSupport::JSON.decode(response.body) 183 json = ActiveSupport::JSON.decode(response.body)
127 status_ids_used = json['issues'].collect {|j| j['status']['id'] } 184 status_ids_used = json['issues'].collect {|j| j['status']['id'] }
137 end 194 end
138 195
139 context "/issues/6.json" do 196 context "/issues/6.json" do
140 should_allow_api_authentication(:get, "/issues/6.json") 197 should_allow_api_authentication(:get, "/issues/6.json")
141 end 198 end
142 199
143 context "GET /issues/:id" do 200 context "GET /issues/:id" do
144 context "with journals" do 201 context "with journals" do
145 context ".xml" do 202 context ".xml" do
146 should "display journals" do 203 should "display journals" do
147 get '/issues/1.xml?include=journals' 204 get '/issues/1.xml?include=journals'
148 205
149 assert_tag :tag => 'issue', 206 assert_tag :tag => 'issue',
150 :child => { 207 :child => {
151 :tag => 'journals', 208 :tag => 'journals',
152 :attributes => { :type => 'array' }, 209 :attributes => { :type => 'array' },
153 :child => { 210 :child => {
172 } 229 }
173 } 230 }
174 end 231 end
175 end 232 end
176 end 233 end
177 234
178 context "with custom fields" do 235 context "with custom fields" do
179 context ".xml" do 236 context ".xml" do
180 should "display custom fields" do 237 should "display custom fields" do
181 get '/issues/3.xml' 238 get '/issues/3.xml'
182 239
183 assert_tag :tag => 'issue', 240 assert_tag :tag => 'issue',
184 :child => { 241 :child => {
185 :tag => 'custom_fields', 242 :tag => 'custom_fields',
186 :attributes => { :type => 'array' }, 243 :attributes => { :type => 'array' },
187 :child => { 244 :child => {
188 :tag => 'custom_field', 245 :tag => 'custom_field',
191 :tag => 'value', 248 :tag => 'value',
192 :content => 'MySQL' 249 :content => 'MySQL'
193 } 250 }
194 } 251 }
195 } 252 }
196 253
197 assert_nothing_raised do 254 assert_nothing_raised do
198 Hash.from_xml(response.body).to_xml 255 Hash.from_xml(response.body).to_xml
199 end 256 end
200 end 257 end
201 end 258 end
202 end 259 end
203 260
261 context "with attachments" do
262 context ".xml" do
263 should "display attachments" do
264 get '/issues/3.xml?include=attachments'
265
266 assert_tag :tag => 'issue',
267 :child => {
268 :tag => 'attachments',
269 :children => {:count => 5},
270 :child => {
271 :tag => 'attachment',
272 :child => {
273 :tag => 'filename',
274 :content => 'source.rb',
275 :sibling => {
276 :tag => 'content_url',
277 :content => 'http://www.example.com/attachments/download/4/source.rb'
278 }
279 }
280 }
281 }
282 end
283 end
284 end
285
204 context "with subtasks" do 286 context "with subtasks" do
205 setup do 287 setup do
206 @c1 = Issue.generate!(:status_id => 1, :subject => "child c1", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1) 288 @c1 = Issue.generate!(:status_id => 1, :subject => "child c1", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1)
207 @c2 = Issue.generate!(:status_id => 1, :subject => "child c2", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1) 289 @c2 = Issue.generate!(:status_id => 1, :subject => "child c2", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1)
208 @c3 = Issue.generate!(:status_id => 1, :subject => "child c3", :tracker_id => 1, :project_id => 1, :parent_issue_id => @c1.id) 290 @c3 = Issue.generate!(:status_id => 1, :subject => "child c3", :tracker_id => 1, :project_id => 1, :parent_issue_id => @c1.id)
209 end 291 end
210 292
211 context ".xml" do 293 context ".xml" do
212 should "display children" do 294 should "display children" do
213 get '/issues/1.xml?include=children' 295 get '/issues/1.xml?include=children'
214 296
215 assert_tag :tag => 'issue', 297 assert_tag :tag => 'issue',
216 :child => { 298 :child => {
217 :tag => 'children', 299 :tag => 'children',
218 :children => {:count => 2}, 300 :children => {:count => 2},
219 :child => { 301 :child => {
220 :tag => 'issue', 302 :tag => 'issue',
232 } 314 }
233 } 315 }
234 } 316 }
235 } 317 }
236 end 318 end
237 319
238 context ".json" do 320 context ".json" do
239 should "display children" do 321 should "display children" do
240 get '/issues/1.json?include=children' 322 get '/issues/1.json?include=children'
241 323
242 json = ActiveSupport::JSON.decode(response.body) 324 json = ActiveSupport::JSON.decode(response.body)
243 assert_equal([ 325 assert_equal([
244 { 326 {
245 'id' => @c1.id, 'subject' => 'child c1', 'tracker' => {'id' => 1, 'name' => 'Bug'}, 327 'id' => @c1.id, 'subject' => 'child c1', 'tracker' => {'id' => 1, 'name' => 'Bug'},
246 'children' => [{ 'id' => @c3.id, 'subject' => 'child c3', 'tracker' => {'id' => 1, 'name' => 'Bug'} }] 328 'children' => [{ 'id' => @c3.id, 'subject' => 'child c3', 'tracker' => {'id' => 1, 'name' => 'Bug'} }]
262 344
263 should "create an issue with the attributes" do 345 should "create an issue with the attributes" do
264 assert_difference('Issue.count') do 346 assert_difference('Issue.count') do
265 post '/issues.xml', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, :authorization => credentials('jsmith') 347 post '/issues.xml', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, :authorization => credentials('jsmith')
266 end 348 end
267 349
268 issue = Issue.first(:order => 'id DESC') 350 issue = Issue.first(:order => 'id DESC')
269 assert_equal 1, issue.project_id 351 assert_equal 1, issue.project_id
270 assert_equal 2, issue.tracker_id 352 assert_equal 2, issue.tracker_id
271 assert_equal 3, issue.status_id 353 assert_equal 3, issue.status_id
272 assert_equal 'API test', issue.subject 354 assert_equal 'API test', issue.subject
273 355
274 assert_response :created 356 assert_response :created
275 assert_equal 'application/xml', @response.content_type 357 assert_equal 'application/xml', @response.content_type
276 assert_tag 'issue', :child => {:tag => 'id', :content => issue.id.to_s} 358 assert_tag 'issue', :child => {:tag => 'id', :content => issue.id.to_s}
277 end 359 end
278 end 360 end
279 361
280 context "POST /issues.xml with failure" do 362 context "POST /issues.xml with failure" do
281 should_allow_api_authentication(:post,
282 '/issues.xml',
283 {:issue => {:project_id => 1}},
284 {:success_code => :unprocessable_entity})
285
286 should "have an errors tag" do 363 should "have an errors tag" do
287 assert_no_difference('Issue.count') do 364 assert_no_difference('Issue.count') do
288 post '/issues.xml', {:issue => {:project_id => 1}}, :authorization => credentials('jsmith') 365 post '/issues.xml', {:issue => {:project_id => 1}}, :authorization => credentials('jsmith')
289 end 366 end
290 367
300 377
301 should "create an issue with the attributes" do 378 should "create an issue with the attributes" do
302 assert_difference('Issue.count') do 379 assert_difference('Issue.count') do
303 post '/issues.json', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, :authorization => credentials('jsmith') 380 post '/issues.json', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, :authorization => credentials('jsmith')
304 end 381 end
305 382
306 issue = Issue.first(:order => 'id DESC') 383 issue = Issue.first(:order => 'id DESC')
307 assert_equal 1, issue.project_id 384 assert_equal 1, issue.project_id
308 assert_equal 2, issue.tracker_id 385 assert_equal 2, issue.tracker_id
309 assert_equal 3, issue.status_id 386 assert_equal 3, issue.status_id
310 assert_equal 'API test', issue.subject 387 assert_equal 'API test', issue.subject
311 end 388 end
312 389
313 end 390 end
314 391
315 context "POST /issues.json with failure" do 392 context "POST /issues.json with failure" do
316 should_allow_api_authentication(:post,
317 '/issues.json',
318 {:issue => {:project_id => 1}},
319 {:success_code => :unprocessable_entity})
320
321 should "have an errors element" do 393 should "have an errors element" do
322 assert_no_difference('Issue.count') do 394 assert_no_difference('Issue.count') do
323 post '/issues.json', {:issue => {:project_id => 1}}, :authorization => credentials('jsmith') 395 post '/issues.json', {:issue => {:project_id => 1}}, :authorization => credentials('jsmith')
324 end 396 end
325 397
332 context "PUT /issues/6.xml" do 404 context "PUT /issues/6.xml" do
333 setup do 405 setup do
334 @parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}} 406 @parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}}
335 @headers = { :authorization => credentials('jsmith') } 407 @headers = { :authorization => credentials('jsmith') }
336 end 408 end
337 409
338 should_allow_api_authentication(:put, 410 should_allow_api_authentication(:put,
339 '/issues/6.xml', 411 '/issues/6.xml',
340 {:issue => {:subject => 'API update', :notes => 'A new note'}}, 412 {:issue => {:subject => 'API update', :notes => 'A new note'}},
341 {:success_code => :ok}) 413 {:success_code => :ok})
342 414
352 end 424 end
353 end 425 end
354 426
355 should "add the note to the journal" do 427 should "add the note to the journal" do
356 put '/issues/6.xml', @parameters, @headers 428 put '/issues/6.xml', @parameters, @headers
357 429
358 journal = Journal.last 430 journal = Journal.last
359 assert_equal "A new note", journal.notes 431 assert_equal "A new note", journal.notes
360 end 432 end
361 433
362 should "update the issue" do 434 should "update the issue" do
363 put '/issues/6.xml', @parameters, @headers 435 put '/issues/6.xml', @parameters, @headers
364 436
365 issue = Issue.find(6) 437 issue = Issue.find(6)
366 assert_equal "API update", issue.subject 438 assert_equal "API update", issue.subject
367 end 439 end
368 440
369 end 441 end
370 442
371 context "PUT /issues/3.xml with custom fields" do 443 context "PUT /issues/3.xml with custom fields" do
372 setup do 444 setup do
373 @parameters = {:issue => {:custom_fields => [{'id' => '1', 'value' => 'PostgreSQL' }, {'id' => '2', 'value' => '150'}]}} 445 @parameters = {:issue => {:custom_fields => [{'id' => '1', 'value' => 'PostgreSQL' }, {'id' => '2', 'value' => '150'}]}}
374 @headers = { :authorization => credentials('jsmith') } 446 @headers = { :authorization => credentials('jsmith') }
375 end 447 end
376 448
377 should "update custom fields" do 449 should "update custom fields" do
378 assert_no_difference('Issue.count') do 450 assert_no_difference('Issue.count') do
379 put '/issues/3.xml', @parameters, @headers 451 put '/issues/3.xml', @parameters, @headers
380 end 452 end
381 453
382 issue = Issue.find(3) 454 issue = Issue.find(3)
383 assert_equal '150', issue.custom_value_for(2).value 455 assert_equal '150', issue.custom_value_for(2).value
384 assert_equal 'PostgreSQL', issue.custom_value_for(1).value 456 assert_equal 'PostgreSQL', issue.custom_value_for(1).value
385 end 457 end
386 end 458 end
387 459
388 context "PUT /issues/6.xml with failed update" do 460 context "PUT /issues/6.xml with failed update" do
389 setup do 461 setup do
390 @parameters = {:issue => {:subject => ''}} 462 @parameters = {:issue => {:subject => ''}}
391 @headers = { :authorization => credentials('jsmith') } 463 @headers = { :authorization => credentials('jsmith') }
392 end 464 end
393 465
394 should_allow_api_authentication(:put,
395 '/issues/6.xml',
396 {:issue => {:subject => ''}}, # Missing subject should fail
397 {:success_code => :unprocessable_entity})
398
399 should "not create a new issue" do 466 should "not create a new issue" do
400 assert_no_difference('Issue.count') do 467 assert_no_difference('Issue.count') do
401 put '/issues/6.xml', @parameters, @headers 468 put '/issues/6.xml', @parameters, @headers
402 end 469 end
403 end 470 end
418 context "PUT /issues/6.json" do 485 context "PUT /issues/6.json" do
419 setup do 486 setup do
420 @parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}} 487 @parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}}
421 @headers = { :authorization => credentials('jsmith') } 488 @headers = { :authorization => credentials('jsmith') }
422 end 489 end
423 490
424 should_allow_api_authentication(:put, 491 should_allow_api_authentication(:put,
425 '/issues/6.json', 492 '/issues/6.json',
426 {:issue => {:subject => 'API update', :notes => 'A new note'}}, 493 {:issue => {:subject => 'API update', :notes => 'A new note'}},
427 {:success_code => :ok}) 494 {:success_code => :ok})
428 495
438 end 505 end
439 end 506 end
440 507
441 should "add the note to the journal" do 508 should "add the note to the journal" do
442 put '/issues/6.json', @parameters, @headers 509 put '/issues/6.json', @parameters, @headers
443 510
444 journal = Journal.last 511 journal = Journal.last
445 assert_equal "A new note", journal.notes 512 assert_equal "A new note", journal.notes
446 end 513 end
447 514
448 should "update the issue" do 515 should "update the issue" do
449 put '/issues/6.json', @parameters, @headers 516 put '/issues/6.json', @parameters, @headers
450 517
451 issue = Issue.find(6) 518 issue = Issue.find(6)
452 assert_equal "API update", issue.subject 519 assert_equal "API update", issue.subject
453 end 520 end
454 521
455 end 522 end
456 523
457 context "PUT /issues/6.json with failed update" do 524 context "PUT /issues/6.json with failed update" do
458 setup do 525 setup do
459 @parameters = {:issue => {:subject => ''}} 526 @parameters = {:issue => {:subject => ''}}
460 @headers = { :authorization => credentials('jsmith') } 527 @headers = { :authorization => credentials('jsmith') }
461 end 528 end
462
463 should_allow_api_authentication(:put,
464 '/issues/6.json',
465 {:issue => {:subject => ''}}, # Missing subject should fail
466 {:success_code => :unprocessable_entity})
467 529
468 should "not create a new issue" do 530 should "not create a new issue" do
469 assert_no_difference('Issue.count') do 531 assert_no_difference('Issue.count') do
470 put '/issues/6.json', @parameters, @headers 532 put '/issues/6.json', @parameters, @headers
471 end 533 end
493 555
494 should "delete the issue" do 556 should "delete the issue" do
495 assert_difference('Issue.count',-1) do 557 assert_difference('Issue.count',-1) do
496 delete '/issues/6.xml', {}, :authorization => credentials('jsmith') 558 delete '/issues/6.xml', {}, :authorization => credentials('jsmith')
497 end 559 end
498 560
499 assert_nil Issue.find_by_id(6) 561 assert_nil Issue.find_by_id(6)
500 end 562 end
501 end 563 end
502 564
503 context "DELETE /issues/1.json" do 565 context "DELETE /issues/1.json" do
508 570
509 should "delete the issue" do 571 should "delete the issue" do
510 assert_difference('Issue.count',-1) do 572 assert_difference('Issue.count',-1) do
511 delete '/issues/6.json', {}, :authorization => credentials('jsmith') 573 delete '/issues/6.json', {}, :authorization => credentials('jsmith')
512 end 574 end
513 575
514 assert_nil Issue.find_by_id(6) 576 assert_nil Issue.find_by_id(6)
515 end 577 end
516 end 578 end
517 579
518 def credentials(user, password=nil) 580 def credentials(user, password=nil)