##// END OF EJS Templates
remove trailing white-spaces from test/test_helper.rb....
Toshi MARUYAMA -
r6826:5409e5dfca88
parent child
Show More
@@ -47,7 +47,7 class ActiveSupport::TestCase
47 47 self.use_instantiated_fixtures = false
48 48
49 49 # Add more helper methods to be used by all tests here...
50
50
51 51 def log_user(login, password)
52 52 User.anonymous
53 53 get "/login"
@@ -57,7 +57,7 class ActiveSupport::TestCase
57 57 post "/login", :username => login, :password => password
58 58 assert_equal login, User.find(session[:user_id]).login
59 59 end
60
60
61 61 def uploaded_test_file(name, mime)
62 62 ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime, true)
63 63 end
@@ -127,7 +127,7 class ActiveSupport::TestCase
127 127 def assert_error_tag(options={})
128 128 assert_tag({:attributes => { :id => 'errorExplanation' }}.merge(options))
129 129 end
130
130
131 131 def assert_include(expected, s)
132 132 assert s.include?(expected), "\"#{expected}\" not found in \"#{s}\""
133 133 end
@@ -176,7 +176,7 class ActiveSupport::TestCase
176 176 :old_value => @old_value.id,
177 177 :value => @new_value.id,
178 178 :prop_key => prop_key)
179
179
180 180 assert_match @new_value.name, show_detail(@detail, true)
181 181 end
182 182
@@ -185,7 +185,7 class ActiveSupport::TestCase
185 185 :old_value => @old_value.id,
186 186 :value => @new_value.id,
187 187 :prop_key => prop_key)
188
188
189 189 assert_match @old_value.name, show_detail(@detail, true)
190 190 end
191 191 end
@@ -229,7 +229,7 class ActiveSupport::TestCase
229 229 def self.should_allow_http_basic_auth_with_username_and_password(http_method, url, parameters={}, options={})
230 230 success_code = options[:success_code] || :success
231 231 failure_code = options[:failure_code] || :unauthorized
232
232
233 233 context "should allow http basic auth using a username and password for #{http_method} #{url}" do
234 234 context "with a valid HTTP authentication" do
235 235 setup do
@@ -237,7 +237,7 class ActiveSupport::TestCase
237 237 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password')
238 238 send(http_method, url, parameters, {:authorization => @authorization})
239 239 end
240
240
241 241 should_respond_with success_code
242 242 should_respond_with_content_type_based_on_url(url)
243 243 should "login as the user" do
@@ -251,14 +251,14 class ActiveSupport::TestCase
251 251 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'wrong_password')
252 252 send(http_method, url, parameters, {:authorization => @authorization})
253 253 end
254
254
255 255 should_respond_with failure_code
256 256 should_respond_with_content_type_based_on_url(url)
257 257 should "not login as the user" do
258 258 assert_equal User.anonymous, User.current
259 259 end
260 260 end
261
261
262 262 context "without credentials" do
263 263 setup do
264 264 send(http_method, url, parameters, {:authorization => ''})
@@ -294,7 +294,7 class ActiveSupport::TestCase
294 294 @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'X')
295 295 send(http_method, url, parameters, {:authorization => @authorization})
296 296 end
297
297
298 298 should_respond_with success_code
299 299 should_respond_with_content_type_based_on_url(url)
300 300 should_be_a_valid_response_string_based_on_url(url)
@@ -319,7 +319,7 class ActiveSupport::TestCase
319 319 end
320 320 end
321 321 end
322
322
323 323 # Test that a request allows full key authentication
324 324 #
325 325 # @param [Symbol] http_method the HTTP method for request (:get, :post, :put, :delete)
@@ -345,7 +345,7 class ActiveSupport::TestCase
345 345 end
346 346 send(http_method, request_url, parameters)
347 347 end
348
348
349 349 should_respond_with success_code
350 350 should_respond_with_content_type_based_on_url(url)
351 351 should_be_a_valid_response_string_based_on_url(url)
@@ -366,7 +366,7 class ActiveSupport::TestCase
366 366 end
367 367 send(http_method, request_url, parameters)
368 368 end
369
369
370 370 should_respond_with failure_code
371 371 should_respond_with_content_type_based_on_url(url)
372 372 should "not login as the user" do
@@ -374,14 +374,14 class ActiveSupport::TestCase
374 374 end
375 375 end
376 376 end
377
377
378 378 context "should allow key based auth using X-Redmine-API-Key header for #{http_method} #{url}" do
379 379 setup do
380 380 @user = User.generate_with_protected!(:admin => true)
381 381 @token = Token.generate!(:user => @user, :action => 'api')
382 382 send(http_method, url, parameters, {'X-Redmine-API-Key' => @token.value.to_s})
383 383 end
384
384
385 385 should_respond_with success_code
386 386 should_respond_with_content_type_based_on_url(url)
387 387 should_be_a_valid_response_string_based_on_url(url)
@@ -406,7 +406,7 class ActiveSupport::TestCase
406 406 else
407 407 raise "Unknown content type for should_respond_with_content_type_based_on_url: #{url}"
408 408 end
409
409
410 410 end
411 411
412 412 # Uses the url to assert which format the response should be in
@@ -424,9 +424,9 class ActiveSupport::TestCase
424 424 else
425 425 raise "Unknown content type for should_be_a_valid_response_based_on_url: #{url}"
426 426 end
427
427
428 428 end
429
429
430 430 # Checks that the response is a valid JSON string
431 431 def self.should_be_a_valid_json_string
432 432 should "be a valid JSON string (or empty)" do
@@ -440,7 +440,7 class ActiveSupport::TestCase
440 440 assert REXML::Document.new(response.body)
441 441 end
442 442 end
443
443
444 444 end
445 445
446 446 # Simple module to "namespace" all of the API tests
General Comments 0
You need to be logged in to leave comments. Login now