Mercurial > hg > soundsoftware-site
diff test/integration/api_test/versions_test.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | cbb26bc654de |
children | 622f24f53b42 261b3d9a4903 |
line wrap: on
line diff
--- a/test/integration/api_test/versions_test.rb Wed Jun 27 14:54:18 2012 +0100 +++ b/test/integration/api_test/versions_test.rb Mon Jan 07 12:01:42 2013 +0000 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2011 Jean-Philippe Lang +# Copyright (C) 2006-2012 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -58,7 +58,7 @@ context "POST" do should "create the version" do assert_difference 'Version.count' do - post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, :authorization => credentials('jsmith') + post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, credentials('jsmith') end version = Version.first(:order => 'id DESC') @@ -71,7 +71,7 @@ should "create the version with due date" do assert_difference 'Version.count' do - post '/projects/1/versions.xml', {:version => {:name => 'API test', :due_date => '2012-01-24'}}, :authorization => credentials('jsmith') + post '/projects/1/versions.xml', {:version => {:name => 'API test', :due_date => '2012-01-24'}}, credentials('jsmith') end version = Version.first(:order => 'id DESC') @@ -86,7 +86,7 @@ context "with failure" do should "return the errors" do assert_no_difference('Version.count') do - post '/projects/1/versions.xml', {:version => {:name => ''}}, :authorization => credentials('jsmith') + post '/projects/1/versions.xml', {:version => {:name => ''}}, credentials('jsmith') end assert_response :unprocessable_entity @@ -103,23 +103,20 @@ assert_response :success assert_equal 'application/xml', @response.content_type - assert_tag 'version', - :child => { - :tag => 'id', - :content => '2', - :sibling => { - :tag => 'name', - :content => '1.0' - } - } + assert_select 'version' do + assert_select 'id', :text => '2' + assert_select 'name', :text => '1.0' + assert_select 'sharing', :text => 'none' + end end end context "PUT" do should "update the version" do - put '/versions/2.xml', {:version => {:name => 'API update'}}, :authorization => credentials('jsmith') + put '/versions/2.xml', {:version => {:name => 'API update'}}, credentials('jsmith') assert_response :ok + assert_equal '', @response.body assert_equal 'API update', Version.find(2).name end end @@ -127,16 +124,13 @@ context "DELETE" do should "destroy the version" do assert_difference 'Version.count', -1 do - delete '/versions/3.xml', {}, :authorization => credentials('jsmith') + delete '/versions/3.xml', {}, credentials('jsmith') end assert_response :ok + assert_equal '', @response.body assert_nil Version.find_by_id(3) end end end - - def credentials(user, password=nil) - ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user) - end end