mirror of
https://github.com/redmine/redmine.git
synced 2025-11-14 09:16:02 +01:00
Use raw request content in tests to make sure that XML/JSON payload is properly parsed.
git-svn-id: http://svn.redmine.org/redmine/trunk@13792 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -328,10 +328,19 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "POST /issues.xml should create an issue with the attributes" do
|
test "POST /issues.xml should create an issue with the attributes" do
|
||||||
|
|
||||||
|
payload = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<issue>
|
||||||
|
<project_id>1</project_id>
|
||||||
|
<tracker_id>2</tracker_id>
|
||||||
|
<status_id>3</status_id>
|
||||||
|
<subject>API test</subject>
|
||||||
|
</issue>
|
||||||
|
XML
|
||||||
|
|
||||||
assert_difference('Issue.count') do
|
assert_difference('Issue.count') do
|
||||||
post '/issues.xml',
|
post '/issues.xml', payload, {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith'))
|
||||||
{:issue => {:project_id => 1, :subject => 'API test',
|
|
||||||
:tracker_id => 2, :status_id => 3}}, credentials('jsmith')
|
|
||||||
end
|
end
|
||||||
issue = Issue.order('id DESC').first
|
issue = Issue.order('id DESC').first
|
||||||
assert_equal 1, issue.project_id
|
assert_equal 1, issue.project_id
|
||||||
@@ -365,11 +374,20 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "POST /issues.json should create an issue with the attributes" do
|
test "POST /issues.json should create an issue with the attributes" do
|
||||||
|
|
||||||
|
payload = <<-JSON
|
||||||
|
{
|
||||||
|
"issue": {
|
||||||
|
"project_id": "1",
|
||||||
|
"tracker_id": "2",
|
||||||
|
"status_id": "3",
|
||||||
|
"subject": "API test"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JSON
|
||||||
|
|
||||||
assert_difference('Issue.count') do
|
assert_difference('Issue.count') do
|
||||||
post '/issues.json',
|
post '/issues.json', payload, {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
|
||||||
{:issue => {:project_id => 1, :subject => 'API test',
|
|
||||||
:tracker_id => 2, :status_id => 3}},
|
|
||||||
credentials('jsmith')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
issue = Issue.order('id DESC').first
|
issue = Issue.order('id DESC').first
|
||||||
|
|||||||
Reference in New Issue
Block a user