##// END OF EJS Templates
Use raw request content in tests to make sure that XML/JSON payload is properly parsed....
Jean-Philippe Lang -
r13410:3fe8197d7323
parent child
Show More
@@ -328,10 +328,19 class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
328 328 end
329 329
330 330 test "POST /issues.xml should create an issue with the attributes" do
331
332 payload = <<-XML
333 <?xml version="1.0" encoding="UTF-8" ?>
334 <issue>
335 <project_id>1</project_id>
336 <tracker_id>2</tracker_id>
337 <status_id>3</status_id>
338 <subject>API test</subject>
339 </issue>
340 XML
341
331 342 assert_difference('Issue.count') do
332 post '/issues.xml',
333 {:issue => {:project_id => 1, :subject => 'API test',
334 :tracker_id => 2, :status_id => 3}}, credentials('jsmith')
343 post '/issues.xml', payload, {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith'))
335 344 end
336 345 issue = Issue.order('id DESC').first
337 346 assert_equal 1, issue.project_id
@@ -365,11 +374,20 class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
365 374 end
366 375
367 376 test "POST /issues.json should create an issue with the attributes" do
377
378 payload = <<-JSON
379 {
380 "issue": {
381 "project_id": "1",
382 "tracker_id": "2",
383 "status_id": "3",
384 "subject": "API test"
385 }
386 }
387 JSON
388
368 389 assert_difference('Issue.count') do
369 post '/issues.json',
370 {:issue => {:project_id => 1, :subject => 'API test',
371 :tracker_id => 2, :status_id => 3}},
372 credentials('jsmith')
390 post '/issues.json', payload, {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
373 391 end
374 392
375 393 issue = Issue.order('id DESC').first
General Comments 0
You need to be logged in to leave comments. Login now