2009-10-10 00:11:58 +00:00
|
|
|
require 'test/test_helper'
|
|
|
|
|
|
|
|
class RoutesTest < ActionController::TestCase
|
|
|
|
tests ApplicationController
|
|
|
|
|
|
|
|
def test_path_and_url(name, prepend_path=nil)
|
|
|
|
@request.path = '/users/session'
|
|
|
|
prepend_path = "#{prepend_path}_" if prepend_path
|
2009-10-11 11:15:48 +00:00
|
|
|
|
|
|
|
# No params
|
2009-10-12 02:24:57 +00:00
|
|
|
assert_equal @controller.send(:"#{prepend_path}#{name}_path", :user),
|
2009-10-10 11:37:22 +00:00
|
|
|
send(:"#{prepend_path}user_#{name}_path")
|
2009-10-12 02:24:57 +00:00
|
|
|
assert_equal @controller.send(:"#{prepend_path}#{name}_url", :user),
|
2009-10-10 11:37:22 +00:00
|
|
|
send(:"#{prepend_path}user_#{name}_url")
|
2009-10-10 00:11:58 +00:00
|
|
|
|
2009-10-11 11:15:48 +00:00
|
|
|
# Default url params
|
2009-10-12 02:24:57 +00:00
|
|
|
assert_equal @controller.send(:"#{prepend_path}#{name}_path", :user, :param => 123),
|
2009-10-10 11:37:22 +00:00
|
|
|
send(:"#{prepend_path}user_#{name}_path", :param => 123)
|
2009-10-12 02:24:57 +00:00
|
|
|
assert_equal @controller.send(:"#{prepend_path}#{name}_url", :user, :param => 123),
|
2009-10-10 11:37:22 +00:00
|
|
|
send(:"#{prepend_path}user_#{name}_url", :param => 123)
|
2009-10-10 00:11:58 +00:00
|
|
|
|
2009-10-10 11:37:22 +00:00
|
|
|
@request.path = nil
|
2009-10-11 11:15:48 +00:00
|
|
|
# With an AR object
|
2009-10-10 11:37:22 +00: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-10 00:11:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
test 'should alias session to mapped user session' do
|
|
|
|
test_path_and_url :session
|
|
|
|
test_path_and_url :session, :new
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'should alias password to mapped user password' do
|
|
|
|
test_path_and_url :password
|
|
|
|
test_path_and_url :password, :new
|
2009-10-12 02:24:57 +00:00
|
|
|
test_path_and_url :password, :edit
|
2009-10-10 00:11:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'should alias confirmation to mapped user confirmation' do
|
|
|
|
test_path_and_url :confirmation
|
|
|
|
test_path_and_url :confirmation, :new
|
|
|
|
end
|
|
|
|
end
|