2010-03-26 06:27:19 -04:00
|
|
|
require 'test_helper'
|
2009-10-09 20:11:58 -04:00
|
|
|
|
|
|
|
class RoutesTest < ActionController::TestCase
|
|
|
|
tests ApplicationController
|
|
|
|
|
2010-03-26 06:27:19 -04:00
|
|
|
def assert_path_and_url(name, prepend_path=nil)
|
2009-10-09 20:11:58 -04:00
|
|
|
@request.path = '/users/session'
|
|
|
|
prepend_path = "#{prepend_path}_" if prepend_path
|
2009-10-11 07:15:48 -04:00
|
|
|
|
2009-10-16 12:44:51 -04:00
|
|
|
# Resource param
|
2009-10-11 22:24:57 -04:00
|
|
|
assert_equal @controller.send(:"#{prepend_path}#{name}_path", :user),
|
2009-10-10 07:37:22 -04:00
|
|
|
send(:"#{prepend_path}user_#{name}_path")
|
2009-10-11 22:24:57 -04:00
|
|
|
assert_equal @controller.send(:"#{prepend_path}#{name}_url", :user),
|
2009-10-10 07:37:22 -04:00
|
|
|
send(:"#{prepend_path}user_#{name}_url")
|
2009-10-09 20:11:58 -04:00
|
|
|
|
2009-10-11 07:15:48 -04:00
|
|
|
# Default url params
|
2009-10-11 22:24:57 -04:00
|
|
|
assert_equal @controller.send(:"#{prepend_path}#{name}_path", :user, :param => 123),
|
2009-10-10 07:37:22 -04:00
|
|
|
send(:"#{prepend_path}user_#{name}_path", :param => 123)
|
2009-10-11 22:24:57 -04:00
|
|
|
assert_equal @controller.send(:"#{prepend_path}#{name}_url", :user, :param => 123),
|
2009-10-10 07:37:22 -04:00
|
|
|
send(:"#{prepend_path}user_#{name}_url", :param => 123)
|
2009-10-09 20:11:58 -04:00
|
|
|
|
2009-10-10 07:37:22 -04:00
|
|
|
@request.path = nil
|
2010-07-16 07:42:13 -04:00
|
|
|
# With an object
|
2009-10-10 07:37:22 -04:00
|
|
|
assert_equal @controller.send(:"#{prepend_path}#{name}_path", User.new),
|
|
|
|
send(:"#{prepend_path}user_#{name}_path")
|
|
|
|
assert_equal @controller.send(:"#{prepend_path}#{name}_url", User.new),
|
|
|
|
send(:"#{prepend_path}user_#{name}_url")
|
2009-10-09 20:11:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
test 'should alias session to mapped user session' do
|
2010-03-26 06:27:19 -04:00
|
|
|
assert_path_and_url :session
|
|
|
|
assert_path_and_url :session, :new
|
|
|
|
assert_path_and_url :session, :destroy
|
2009-10-09 20:11:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'should alias password to mapped user password' do
|
2010-03-26 06:27:19 -04:00
|
|
|
assert_path_and_url :password
|
|
|
|
assert_path_and_url :password, :new
|
|
|
|
assert_path_and_url :password, :edit
|
2009-10-09 20:11:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'should alias confirmation to mapped user confirmation' do
|
2010-03-26 06:27:19 -04:00
|
|
|
assert_path_and_url :confirmation
|
|
|
|
assert_path_and_url :confirmation, :new
|
2009-10-09 20:11:58 -04:00
|
|
|
end
|
2010-07-04 05:53:12 -04:00
|
|
|
|
|
|
|
test 'should alias unlock to mapped user unlock' do
|
|
|
|
assert_path_and_url :unlock
|
|
|
|
assert_path_and_url :unlock, :new
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'should alias registration to mapped user registration' do
|
|
|
|
assert_path_and_url :registration
|
|
|
|
assert_path_and_url :registration, :new
|
|
|
|
assert_path_and_url :registration, :edit
|
2010-07-15 16:00:20 -04:00
|
|
|
assert_path_and_url :registration, :cancel
|
2010-07-04 05:53:12 -04:00
|
|
|
end
|
2009-10-09 20:11:58 -04:00
|
|
|
end
|