Adds assertions on response status and body.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9976 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
18f693f9f7
commit
54d55a360a
|
@ -625,53 +625,32 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
|
||||||
{:issue => {:subject => 'API update', :notes => 'A new note'}},
|
{:issue => {:subject => 'API update', :notes => 'A new note'}},
|
||||||
{:success_code => :ok})
|
{:success_code => :ok})
|
||||||
|
|
||||||
should "not create a new issue" do
|
|
||||||
assert_no_difference('Issue.count') do
|
|
||||||
put '/issues/6.json', @parameters, credentials('jsmith')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
should "create a new journal" do
|
|
||||||
assert_difference('Journal.count') do
|
|
||||||
put '/issues/6.json', @parameters, credentials('jsmith')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
should "add the note to the journal" do
|
|
||||||
put '/issues/6.json', @parameters, credentials('jsmith')
|
|
||||||
|
|
||||||
journal = Journal.last
|
|
||||||
assert_equal "A new note", journal.notes
|
|
||||||
end
|
|
||||||
|
|
||||||
should "update the issue" do
|
should "update the issue" do
|
||||||
put '/issues/6.json', @parameters, credentials('jsmith')
|
assert_no_difference('Issue.count') do
|
||||||
|
assert_difference('Journal.count') do
|
||||||
|
put '/issues/6.json', @parameters, credentials('jsmith')
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal '', response.body
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
issue = Issue.find(6)
|
issue = Issue.find(6)
|
||||||
assert_equal "API update", issue.subject
|
assert_equal "API update", issue.subject
|
||||||
|
journal = Journal.last
|
||||||
|
assert_equal "A new note", journal.notes
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "PUT /issues/6.json with failed update" do
|
context "PUT /issues/6.json with failed update" do
|
||||||
setup do
|
should "return errors" do
|
||||||
@parameters = {:issue => {:subject => ''}}
|
|
||||||
end
|
|
||||||
|
|
||||||
should "not create a new issue" do
|
|
||||||
assert_no_difference('Issue.count') do
|
assert_no_difference('Issue.count') do
|
||||||
put '/issues/6.json', @parameters, credentials('jsmith')
|
assert_no_difference('Journal.count') do
|
||||||
end
|
put '/issues/6.json', {:issue => {:subject => ''}}, credentials('jsmith')
|
||||||
end
|
|
||||||
|
|
||||||
should "not create a new journal" do
|
assert_response :unprocessable_entity
|
||||||
assert_no_difference('Journal.count') do
|
end
|
||||||
put '/issues/6.json', @parameters, credentials('jsmith')
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
should "have an errors attribute" do
|
|
||||||
put '/issues/6.json', @parameters, credentials('jsmith')
|
|
||||||
|
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
assert json['errors'].include?("Subject can't be blank")
|
assert json['errors'].include?("Subject can't be blank")
|
||||||
|
@ -685,8 +664,11 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
|
||||||
{:success_code => :ok})
|
{:success_code => :ok})
|
||||||
|
|
||||||
should "delete the issue" do
|
should "delete the issue" do
|
||||||
assert_difference('Issue.count',-1) do
|
assert_difference('Issue.count', -1) do
|
||||||
delete '/issues/6.xml', {}, credentials('jsmith')
|
delete '/issues/6.xml', {}, credentials('jsmith')
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal '', response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_nil Issue.find_by_id(6)
|
assert_nil Issue.find_by_id(6)
|
||||||
|
@ -700,8 +682,11 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
|
||||||
{:success_code => :ok})
|
{:success_code => :ok})
|
||||||
|
|
||||||
should "delete the issue" do
|
should "delete the issue" do
|
||||||
assert_difference('Issue.count',-1) do
|
assert_difference('Issue.count', -1) do
|
||||||
delete '/issues/6.json', {}, credentials('jsmith')
|
delete '/issues/6.json', {}, credentials('jsmith')
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal '', response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_nil Issue.find_by_id(6)
|
assert_nil Issue.find_by_id(6)
|
||||||
|
|
Loading…
Reference in New Issue