##// END OF EJS Templates
remove trailing white-spaces from test/integration/api_test/versions_test.rb....
Toshi MARUYAMA -
r6570:4c7ae6da3999
parent child
Show More
@@ -1,120 +1,120
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../../test_helper', __FILE__)
19 19
20 20 class ApiTest::VersionsTest < ActionController::IntegrationTest
21 21 fixtures :all
22 22
23 23 def setup
24 24 Setting.rest_api_enabled = '1'
25 25 end
26 26
27 27 context "/projects/:project_id/versions" do
28 28 context "GET" do
29 29 should "return project versions" do
30 30 get '/projects/1/versions.xml'
31
31
32 32 assert_response :success
33 33 assert_equal 'application/xml', @response.content_type
34 34 assert_tag :tag => 'versions',
35 35 :attributes => {:type => 'array'},
36 36 :child => {
37 37 :tag => 'version',
38 38 :child => {
39 39 :tag => 'id',
40 40 :content => '2',
41 41 :sibling => {
42 42 :tag => 'name',
43 43 :content => '1.0'
44 44 }
45 45 }
46 46 }
47 47 end
48 48 end
49
49
50 50 context "POST" do
51 51 should "create the version" do
52 52 assert_difference 'Version.count' do
53 53 post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, :authorization => credentials('jsmith')
54 54 end
55
55
56 56 version = Version.first(:order => 'id DESC')
57 57 assert_equal 'API test', version.name
58
58
59 59 assert_response :created
60 60 assert_equal 'application/xml', @response.content_type
61 61 assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
62 62 end
63
63
64 64 context "with failure" do
65 65 should "return the errors" do
66 66 assert_no_difference('Version.count') do
67 67 post '/projects/1/versions.xml', {:version => {:name => ''}}, :authorization => credentials('jsmith')
68 68 end
69 69
70 70 assert_response :unprocessable_entity
71 71 assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"}
72 72 end
73 73 end
74 74 end
75 75 end
76
76
77 77 context "/versions/:id" do
78 78 context "GET" do
79 79 should "return the version" do
80 80 get '/versions/2.xml'
81
81
82 82 assert_response :success
83 83 assert_equal 'application/xml', @response.content_type
84 assert_tag 'version',
84 assert_tag 'version',
85 85 :child => {
86 86 :tag => 'id',
87 87 :content => '2',
88 88 :sibling => {
89 89 :tag => 'name',
90 90 :content => '1.0'
91 91 }
92 92 }
93 93 end
94 94 end
95
95
96 96 context "PUT" do
97 97 should "update the version" do
98 98 put '/versions/2.xml', {:version => {:name => 'API update'}}, :authorization => credentials('jsmith')
99
99
100 100 assert_response :ok
101 101 assert_equal 'API update', Version.find(2).name
102 102 end
103 103 end
104
104
105 105 context "DELETE" do
106 106 should "destroy the version" do
107 107 assert_difference 'Version.count', -1 do
108 108 delete '/versions/3.xml', {}, :authorization => credentials('jsmith')
109 109 end
110
110
111 111 assert_response :ok
112 112 assert_nil Version.find_by_id(3)
113 113 end
114 114 end
115 115 end
116
116
117 117 def credentials(user, password=nil)
118 118 ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)
119 119 end
120 120 end
General Comments 0
You need to be logged in to leave comments. Login now