##// END OF EJS Templates
remove trailing white-spaces from test/integration/api_test/versions_test.rb....
Toshi MARUYAMA -
r6570:4c7ae6da3999
parent child
Show More
@@ -5,12 +5,12
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.
@@ -28,7 +28,7 class ApiTest::VersionsTest < ActionController::IntegrationTest
28 context "GET" do
28 context "GET" do
29 should "return project versions" do
29 should "return project versions" do
30 get '/projects/1/versions.xml'
30 get '/projects/1/versions.xml'
31
31
32 assert_response :success
32 assert_response :success
33 assert_equal 'application/xml', @response.content_type
33 assert_equal 'application/xml', @response.content_type
34 assert_tag :tag => 'versions',
34 assert_tag :tag => 'versions',
@@ -46,21 +46,21 class ApiTest::VersionsTest < ActionController::IntegrationTest
46 }
46 }
47 end
47 end
48 end
48 end
49
49
50 context "POST" do
50 context "POST" do
51 should "create the version" do
51 should "create the version" do
52 assert_difference 'Version.count' do
52 assert_difference 'Version.count' do
53 post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, :authorization => credentials('jsmith')
53 post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, :authorization => credentials('jsmith')
54 end
54 end
55
55
56 version = Version.first(:order => 'id DESC')
56 version = Version.first(:order => 'id DESC')
57 assert_equal 'API test', version.name
57 assert_equal 'API test', version.name
58
58
59 assert_response :created
59 assert_response :created
60 assert_equal 'application/xml', @response.content_type
60 assert_equal 'application/xml', @response.content_type
61 assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
61 assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
62 end
62 end
63
63
64 context "with failure" do
64 context "with failure" do
65 should "return the errors" do
65 should "return the errors" do
66 assert_no_difference('Version.count') do
66 assert_no_difference('Version.count') do
@@ -73,15 +73,15 class ApiTest::VersionsTest < ActionController::IntegrationTest
73 end
73 end
74 end
74 end
75 end
75 end
76
76
77 context "/versions/:id" do
77 context "/versions/:id" do
78 context "GET" do
78 context "GET" do
79 should "return the version" do
79 should "return the version" do
80 get '/versions/2.xml'
80 get '/versions/2.xml'
81
81
82 assert_response :success
82 assert_response :success
83 assert_equal 'application/xml', @response.content_type
83 assert_equal 'application/xml', @response.content_type
84 assert_tag 'version',
84 assert_tag 'version',
85 :child => {
85 :child => {
86 :tag => 'id',
86 :tag => 'id',
87 :content => '2',
87 :content => '2',
@@ -92,28 +92,28 class ApiTest::VersionsTest < ActionController::IntegrationTest
92 }
92 }
93 end
93 end
94 end
94 end
95
95
96 context "PUT" do
96 context "PUT" do
97 should "update the version" do
97 should "update the version" do
98 put '/versions/2.xml', {:version => {:name => 'API update'}}, :authorization => credentials('jsmith')
98 put '/versions/2.xml', {:version => {:name => 'API update'}}, :authorization => credentials('jsmith')
99
99
100 assert_response :ok
100 assert_response :ok
101 assert_equal 'API update', Version.find(2).name
101 assert_equal 'API update', Version.find(2).name
102 end
102 end
103 end
103 end
104
104
105 context "DELETE" do
105 context "DELETE" do
106 should "destroy the version" do
106 should "destroy the version" do
107 assert_difference 'Version.count', -1 do
107 assert_difference 'Version.count', -1 do
108 delete '/versions/3.xml', {}, :authorization => credentials('jsmith')
108 delete '/versions/3.xml', {}, :authorization => credentials('jsmith')
109 end
109 end
110
110
111 assert_response :ok
111 assert_response :ok
112 assert_nil Version.find_by_id(3)
112 assert_nil Version.find_by_id(3)
113 end
113 end
114 end
114 end
115 end
115 end
116
116
117 def credentials(user, password=nil)
117 def credentials(user, password=nil)
118 ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)
118 ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)
119 end
119 end
General Comments 0
You need to be logged in to leave comments. Login now