##// END OF EJS Templates
code layout clean up test/integration/api_test/users_test.rb...
Toshi MARUYAMA -
r8202:260bc487aa17
parent child
Show More
@@ -71,13 +71,22 class ApiTest::UsersTest < ActionController::IntegrationTest
71 71 context "POST /users" do
72 72 context "with valid parameters" do
73 73 setup do
74 @parameters = {:user => {:login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', :mail => 'foo@example.net', :password => 'secret', :mail_notification => 'only_assigned'}}
74 @parameters = {
75 :user => {
76 :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
77 :mail => 'foo@example.net', :password => 'secret',
78 :mail_notification => 'only_assigned'
79 }
80 }
75 81 end
76 82
77 83 context ".xml" do
78 84 should_allow_api_authentication(:post,
79 85 '/users.xml',
80 {:user => {:login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', :mail => 'foo@example.net', :password => 'secret'}},
86 {:user => {
87 :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
88 :mail => 'foo@example.net', :password => 'secret'
89 }},
81 90 {:success_code => :created})
82 91
83 92 should "create a user with the attributes" do
@@ -103,7 +112,10 class ApiTest::UsersTest < ActionController::IntegrationTest
103 112 context ".json" do
104 113 should_allow_api_authentication(:post,
105 114 '/users.json',
106 {:user => {:login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', :mail => 'foo@example.net'}},
115 {:user => {
116 :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
117 :mail => 'foo@example.net'
118 }},
107 119 {:success_code => :created})
108 120
109 121 should "create a user with the attributes" do
@@ -141,7 +153,10 class ApiTest::UsersTest < ActionController::IntegrationTest
141 153
142 154 assert_response :unprocessable_entity
143 155 assert_equal 'application/xml', @response.content_type
144 assert_tag 'errors', :child => {:tag => 'error', :content => "First name can't be blank"}
156 assert_tag 'errors', :child => {
157 :tag => 'error',
158 :content => "First name can't be blank"
159 }
145 160 end
146 161 end
147 162
@@ -165,13 +180,21 class ApiTest::UsersTest < ActionController::IntegrationTest
165 180 context "PUT /users/2" do
166 181 context "with valid parameters" do
167 182 setup do
168 @parameters = {:user => {:login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', :mail => 'jsmith@somenet.foo'}}
183 @parameters = {
184 :user => {
185 :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed',
186 :mail => 'jsmith@somenet.foo'
187 }
188 }
169 189 end
170 190
171 191 context ".xml" do
172 192 should_allow_api_authentication(:put,
173 193 '/users/2.xml',
174 {:user => {:login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', :mail => 'jsmith@somenet.foo'}},
194 {:user => {
195 :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed',
196 :mail => 'jsmith@somenet.foo'
197 }},
175 198 {:success_code => :ok})
176 199
177 200 should "update user with the attributes" do
@@ -193,7 +216,10 class ApiTest::UsersTest < ActionController::IntegrationTest
193 216 context ".json" do
194 217 should_allow_api_authentication(:put,
195 218 '/users/2.json',
196 {:user => {:login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', :mail => 'jsmith@somenet.foo'}},
219 {:user => {
220 :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed',
221 :mail => 'jsmith@somenet.foo'
222 }},
197 223 {:success_code => :ok})
198 224
199 225 should "update user with the attributes" do
@@ -215,7 +241,12 class ApiTest::UsersTest < ActionController::IntegrationTest
215 241
216 242 context "with invalid parameters" do
217 243 setup do
218 @parameters = {:user => {:login => 'jsmith', :firstname => '', :lastname => 'Lastname', :mail => 'foo'}}
244 @parameters = {
245 :user => {
246 :login => 'jsmith', :firstname => '', :lastname => 'Lastname',
247 :mail => 'foo'
248 }
249 }
219 250 end
220 251
221 252 context ".xml" do
@@ -226,7 +257,10 class ApiTest::UsersTest < ActionController::IntegrationTest
226 257
227 258 assert_response :unprocessable_entity
228 259 assert_equal 'application/xml', @response.content_type
229 assert_tag 'errors', :child => {:tag => 'error', :content => "First name can't be blank"}
260 assert_tag 'errors', :child => {
261 :tag => 'error',
262 :content => "First name can't be blank"
263 }
230 264 end
231 265 end
232 266
General Comments 0
You need to be logged in to leave comments. Login now