graffititracker_devise 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. data/CHANGELOG.rdoc +410 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +272 -0
  4. data/Rakefile +53 -0
  5. data/TODO +2 -0
  6. data/app/controllers/confirmations_controller.rb +33 -0
  7. data/app/controllers/passwords_controller.rb +41 -0
  8. data/app/controllers/registrations_controller.rb +53 -0
  9. data/app/controllers/sessions_controller.rb +42 -0
  10. data/app/controllers/unlocks_controller.rb +41 -0
  11. data/app/models/devise_mailer.rb +68 -0
  12. data/app/views/confirmations/new.html.erb +12 -0
  13. data/app/views/devise_mailer/confirmation_instructions.html.erb +5 -0
  14. data/app/views/devise_mailer/reset_password_instructions.html.erb +8 -0
  15. data/app/views/devise_mailer/unlock_instructions.html.erb +7 -0
  16. data/app/views/passwords/edit.html.erb +16 -0
  17. data/app/views/passwords/new.html.erb +12 -0
  18. data/app/views/registrations/edit.html.erb +25 -0
  19. data/app/views/registrations/new.html.erb +17 -0
  20. data/app/views/sessions/new.html.erb +17 -0
  21. data/app/views/shared/_devise_links.erb +19 -0
  22. data/app/views/unlocks/new.html.erb +12 -0
  23. data/generators/devise/USAGE +5 -0
  24. data/generators/devise/devise_generator.rb +15 -0
  25. data/generators/devise/lib/route_devise.rb +32 -0
  26. data/generators/devise/templates/migration.rb +23 -0
  27. data/generators/devise/templates/model.rb +9 -0
  28. data/generators/devise_install/USAGE +3 -0
  29. data/generators/devise_install/devise_install_generator.rb +15 -0
  30. data/generators/devise_install/templates/README +23 -0
  31. data/generators/devise_install/templates/devise.rb +105 -0
  32. data/generators/devise_views/USAGE +3 -0
  33. data/generators/devise_views/devise_views_generator.rb +21 -0
  34. data/lib/devise.rb +277 -0
  35. data/lib/devise/controllers/helpers.rb +226 -0
  36. data/lib/devise/controllers/internal_helpers.rb +129 -0
  37. data/lib/devise/controllers/url_helpers.rb +41 -0
  38. data/lib/devise/encryptors/authlogic_sha512.rb +21 -0
  39. data/lib/devise/encryptors/base.rb +20 -0
  40. data/lib/devise/encryptors/bcrypt.rb +21 -0
  41. data/lib/devise/encryptors/clearance_sha1.rb +19 -0
  42. data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
  43. data/lib/devise/encryptors/sha1.rb +27 -0
  44. data/lib/devise/encryptors/sha512.rb +27 -0
  45. data/lib/devise/failure_app.rb +72 -0
  46. data/lib/devise/hooks/activatable.rb +15 -0
  47. data/lib/devise/hooks/rememberable.rb +33 -0
  48. data/lib/devise/hooks/timeoutable.rb +18 -0
  49. data/lib/devise/hooks/trackable.rb +18 -0
  50. data/lib/devise/locales/en.yml +35 -0
  51. data/lib/devise/mapping.rb +130 -0
  52. data/lib/devise/models.rb +117 -0
  53. data/lib/devise/models/activatable.rb +16 -0
  54. data/lib/devise/models/confirmable.rb +167 -0
  55. data/lib/devise/models/database_authenticatable.rb +144 -0
  56. data/lib/devise/models/http_authenticatable.rb +23 -0
  57. data/lib/devise/models/lockable.rb +150 -0
  58. data/lib/devise/models/recoverable.rb +80 -0
  59. data/lib/devise/models/registerable.rb +8 -0
  60. data/lib/devise/models/rememberable.rb +92 -0
  61. data/lib/devise/models/timeoutable.rb +28 -0
  62. data/lib/devise/models/token_authenticatable.rb +89 -0
  63. data/lib/devise/models/trackable.rb +16 -0
  64. data/lib/devise/models/validatable.rb +39 -0
  65. data/lib/devise/orm/active_record.rb +41 -0
  66. data/lib/devise/orm/data_mapper.rb +83 -0
  67. data/lib/devise/orm/mongo_mapper.rb +52 -0
  68. data/lib/devise/rails.rb +14 -0
  69. data/lib/devise/rails/routes.rb +133 -0
  70. data/lib/devise/rails/warden_compat.rb +63 -0
  71. data/lib/devise/schema.rb +73 -0
  72. data/lib/devise/strategies/base.rb +16 -0
  73. data/lib/devise/strategies/database_authenticatable.rb +36 -0
  74. data/lib/devise/strategies/http_authenticatable.rb +59 -0
  75. data/lib/devise/strategies/rememberable.rb +37 -0
  76. data/lib/devise/strategies/token_authenticatable.rb +37 -0
  77. data/lib/devise/test_helpers.rb +90 -0
  78. data/lib/devise/version.rb +3 -0
  79. data/rails/init.rb +2 -0
  80. data/test/controllers/helpers_test.rb +184 -0
  81. data/test/controllers/internal_helpers_test.rb +55 -0
  82. data/test/controllers/url_helpers_test.rb +47 -0
  83. data/test/devise_test.rb +74 -0
  84. data/test/encryptors_test.rb +31 -0
  85. data/test/failure_app_test.rb +44 -0
  86. data/test/integration/authenticatable_test.rb +340 -0
  87. data/test/integration/confirmable_test.rb +97 -0
  88. data/test/integration/http_authenticatable_test.rb +52 -0
  89. data/test/integration/lockable_test.rb +102 -0
  90. data/test/integration/rack_middleware_test.rb +47 -0
  91. data/test/integration/recoverable_test.rb +141 -0
  92. data/test/integration/registerable_test.rb +144 -0
  93. data/test/integration/rememberable_test.rb +82 -0
  94. data/test/integration/timeoutable_test.rb +68 -0
  95. data/test/integration/token_authenticatable_test.rb +55 -0
  96. data/test/integration/trackable_test.rb +64 -0
  97. data/test/mailers/confirmation_instructions_test.rb +86 -0
  98. data/test/mailers/reset_password_instructions_test.rb +68 -0
  99. data/test/mailers/unlock_instructions_test.rb +62 -0
  100. data/test/mapping_test.rb +158 -0
  101. data/test/models/authenticatable_test.rb +180 -0
  102. data/test/models/confirmable_test.rb +228 -0
  103. data/test/models/lockable_test.rb +202 -0
  104. data/test/models/recoverable_test.rb +138 -0
  105. data/test/models/rememberable_test.rb +135 -0
  106. data/test/models/timeoutable_test.rb +28 -0
  107. data/test/models/token_authenticatable_test.rb +51 -0
  108. data/test/models/trackable_test.rb +5 -0
  109. data/test/models/validatable_test.rb +106 -0
  110. data/test/models_test.rb +70 -0
  111. data/test/orm/active_record.rb +31 -0
  112. data/test/orm/mongo_mapper.rb +20 -0
  113. data/test/rails_app/app/active_record/admin.rb +7 -0
  114. data/test/rails_app/app/active_record/user.rb +7 -0
  115. data/test/rails_app/app/controllers/admins_controller.rb +6 -0
  116. data/test/rails_app/app/controllers/application_controller.rb +12 -0
  117. data/test/rails_app/app/controllers/home_controller.rb +4 -0
  118. data/test/rails_app/app/controllers/users_controller.rb +16 -0
  119. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  120. data/test/rails_app/app/mongo_mapper/admin.rb +13 -0
  121. data/test/rails_app/app/mongo_mapper/user.rb +14 -0
  122. data/test/rails_app/config/boot.rb +110 -0
  123. data/test/rails_app/config/environment.rb +42 -0
  124. data/test/rails_app/config/environments/development.rb +17 -0
  125. data/test/rails_app/config/environments/production.rb +28 -0
  126. data/test/rails_app/config/environments/test.rb +28 -0
  127. data/test/rails_app/config/initializers/devise.rb +82 -0
  128. data/test/rails_app/config/initializers/inflections.rb +2 -0
  129. data/test/rails_app/config/initializers/new_rails_defaults.rb +24 -0
  130. data/test/rails_app/config/initializers/session_store.rb +15 -0
  131. data/test/rails_app/config/routes.rb +25 -0
  132. data/test/routes_test.rb +131 -0
  133. data/test/support/assertions_helper.rb +37 -0
  134. data/test/support/integration_tests_helper.rb +71 -0
  135. data/test/support/test_silencer.rb +5 -0
  136. data/test/support/tests_helper.rb +39 -0
  137. data/test/test_helper.rb +21 -0
  138. data/test/test_helpers_test.rb +57 -0
  139. metadata +279 -0
@@ -0,0 +1,37 @@
1
+ require 'devise/strategies/base'
2
+
3
+ module Devise
4
+ module Strategies
5
+ # Remember the user through the remember token. This strategy is responsible
6
+ # to verify whether there is a cookie with the remember token, and to
7
+ # recreate the user from this cookie if it exists. Must be called *before*
8
+ # authenticatable.
9
+ class Rememberable < Devise::Strategies::Base
10
+
11
+ # A valid strategy for rememberable needs a remember token in the cookies.
12
+ def valid?
13
+ remember_me_cookie.present? && mapping.to.respond_to?(:serialize_from_cookie)
14
+ end
15
+
16
+ # To authenticate a user we deserialize the cookie and attempt finding
17
+ # the record in the database. If the attempt fails, we pass to another
18
+ # strategy handle the authentication.
19
+ def authenticate!
20
+ if resource = mapping.to.serialize_from_cookie(remember_me_cookie)
21
+ success!(resource)
22
+ else
23
+ pass
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ # Accessor for remember cookie
30
+ def remember_me_cookie
31
+ @remember_me_cookie ||= request.cookies["remember_#{mapping.name}_token"]
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ Warden::Strategies.add(:rememberable, Devise::Strategies::Rememberable)
@@ -0,0 +1,37 @@
1
+ require 'devise/strategies/base'
2
+
3
+ module Devise
4
+ module Strategies
5
+ # Strategy for signing in a user, based on a authenticatable token.
6
+ # Redirects to sign_in page if it's not authenticated.
7
+ class TokenAuthenticatable < Base
8
+ def valid?
9
+ mapping.to.respond_to?(:authenticate_with_token) && authentication_token(scope).present?
10
+ end
11
+
12
+ # Authenticate a user based on authenticatable token params, returning to warden
13
+ # success and the authenticated user if everything is okay. Otherwise redirect
14
+ # to sign in page.
15
+ def authenticate!
16
+ if resource = mapping.to.authenticate_with_token(params[scope] || params)
17
+ success!(resource)
18
+ else
19
+ fail!(:invalid_token)
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ # Detect authentication token in params: scoped or not.
26
+ def authentication_token(scope)
27
+ if params[scope]
28
+ params[scope][mapping.to.token_authentication_key]
29
+ else
30
+ params[mapping.to.token_authentication_key]
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ Warden::Strategies.add(:token_authenticatable, Devise::Strategies::TokenAuthenticatable)
@@ -0,0 +1,90 @@
1
+ module Devise
2
+ module TestHelpers
3
+ def self.included(base)
4
+ base.class_eval do
5
+ setup :setup_controller_for_warden, :warden if respond_to?(:setup)
6
+ end
7
+ end
8
+
9
+ # This is a Warden::Proxy customized for functional tests. It's meant to
10
+ # some of Warden::Manager responsibilities, as retrieving configuration
11
+ # options and calling the FailureApp.
12
+ class TestWarden < Warden::Proxy #:nodoc:
13
+ attr_reader :controller
14
+
15
+ def initialize(controller)
16
+ @controller = controller
17
+ manager = Warden::Manager.new(nil) do |config|
18
+ Devise.configure_warden(config)
19
+ end
20
+ super(controller.request.env, manager)
21
+ end
22
+
23
+ def authenticate!(*args)
24
+ catch_with_redirect { super }
25
+ end
26
+
27
+ def user(*args)
28
+ catch_with_redirect { super }
29
+ end
30
+
31
+ def catch_with_redirect(&block)
32
+ result = catch(:warden, &block)
33
+
34
+ if result.is_a?(Hash) && !custom_failure? && !@controller.send(:performed?)
35
+ result[:action] ||= :unauthenticated
36
+
37
+ env = @controller.request.env
38
+ env["PATH_INFO"] = "/#{result[:action]}"
39
+ env["warden.options"] = result
40
+ Warden::Manager._before_failure.each{ |hook| hook.call(env, result) }
41
+
42
+ status, headers, body = Devise::FailureApp.call(env).to_a
43
+ @controller.send :redirect_to, headers["Location"]
44
+ else
45
+ result
46
+ end
47
+ end
48
+ end
49
+
50
+ # We need to setup the environment variables and the response in the controller.
51
+ def setup_controller_for_warden #:nodoc:
52
+ @request.env['action_controller.rescue.request'] = @request
53
+ @request.env['action_controller.rescue.response'] = @response
54
+ @request.env['rack.session'] = session
55
+ @controller.response = @response
56
+ end
57
+
58
+ # Quick access to Warden::Proxy.
59
+ def warden #:nodoc:
60
+ @warden ||= (@request.env['warden'] = TestWarden.new(@controller))
61
+ end
62
+
63
+ # sign_in a given resource by storing its keys in the session.
64
+ #
65
+ # Examples:
66
+ #
67
+ # sign_in :user, @user # sign_in(scope, resource)
68
+ # sign_in @user # sign_in(resource)
69
+ #
70
+ def sign_in(resource_or_scope, resource=nil)
71
+ scope ||= Devise::Mapping.find_scope!(resource_or_scope)
72
+ resource ||= resource_or_scope
73
+ warden.session_serializer.store(resource, scope)
74
+ end
75
+
76
+ # Sign out a given resource or scope by calling logout on Warden.
77
+ #
78
+ # Examples:
79
+ #
80
+ # sign_out :user # sign_out(scope)
81
+ # sign_out @user # sign_out(resource)
82
+ #
83
+ def sign_out(resource_or_scope)
84
+ scope = Devise::Mapping.find_scope!(resource_or_scope)
85
+ @controller.instance_variable_set(:"@current_#{scope}", nil)
86
+ warden.logout(scope)
87
+ end
88
+
89
+ end
90
+ end
@@ -0,0 +1,3 @@
1
+ module Devise
2
+ VERSION = "1.0.11".freeze
3
+ end
@@ -0,0 +1,2 @@
1
+ # We need to load devise here to ensure routes extensions are loaded.
2
+ require 'devise'
@@ -0,0 +1,184 @@
1
+ require 'test/test_helper'
2
+ require 'ostruct'
3
+
4
+ class MockController < ApplicationController
5
+ attr_accessor :env
6
+
7
+ def request
8
+ self
9
+ end
10
+
11
+ def path
12
+ ''
13
+ end
14
+ end
15
+
16
+ class ControllerAuthenticableTest < ActionController::TestCase
17
+ tests MockController
18
+
19
+ def setup
20
+ @controller = MockController.new
21
+ @mock_warden = OpenStruct.new
22
+ @controller.env = { 'warden' => @mock_warden }
23
+ @controller.session = {}
24
+ end
25
+
26
+ test 'setup warden' do
27
+ assert_not_nil @controller.warden
28
+ end
29
+
30
+ test 'provide access to warden instance' do
31
+ assert_equal @controller.warden, @controller.env['warden']
32
+ end
33
+
34
+ test 'proxy signed_in? to authenticated' do
35
+ @mock_warden.expects(:authenticate?).with(:scope => :my_scope)
36
+ @controller.signed_in?(:my_scope)
37
+ end
38
+
39
+ test 'proxy anybody_signed_in? to signed_in?' do
40
+ Devise.mappings.keys.each { |scope| # :user, :admin, :manager
41
+ @controller.expects(:signed_in?).with(scope)
42
+ }
43
+ @controller.anybody_signed_in?
44
+ end
45
+
46
+ test 'proxy current_admin to authenticate with admin scope' do
47
+ @mock_warden.expects(:authenticate).with(:scope => :admin)
48
+ @controller.current_admin
49
+ end
50
+
51
+ test 'proxy current_user to authenticate with user scope' do
52
+ @mock_warden.expects(:authenticate).with(:scope => :user)
53
+ @controller.current_user
54
+ end
55
+
56
+ test 'proxy user_authenticate! to authenticate with user scope' do
57
+ @mock_warden.expects(:authenticate!).with(:scope => :user)
58
+ @controller.authenticate_user!
59
+ end
60
+
61
+ test 'proxy admin_authenticate! to authenticate with admin scope' do
62
+ @mock_warden.expects(:authenticate!).with(:scope => :admin)
63
+ @controller.authenticate_admin!
64
+ end
65
+
66
+ test 'proxy user_signed_in? to authenticate? with user scope' do
67
+ @mock_warden.expects(:authenticate?).with(:scope => :user)
68
+ @controller.user_signed_in?
69
+ end
70
+
71
+ test 'proxy admin_signed_in? to authenticate? with admin scope' do
72
+ @mock_warden.expects(:authenticate?).with(:scope => :admin)
73
+ @controller.admin_signed_in?
74
+ end
75
+
76
+ test 'proxy user_session to session scope in warden' do
77
+ @mock_warden.expects(:authenticate).with(:scope => :user).returns(true)
78
+ @mock_warden.expects(:session).with(:user).returns({})
79
+ @controller.user_session
80
+ end
81
+
82
+ test 'proxy admin_session to session scope in warden' do
83
+ @mock_warden.expects(:authenticate).with(:scope => :admin).returns(true)
84
+ @mock_warden.expects(:session).with(:admin).returns({})
85
+ @controller.admin_session
86
+ end
87
+
88
+ test 'sign in proxy to set_user on warden' do
89
+ user = User.new
90
+ @mock_warden.expects(:set_user).with(user, :scope => :user).returns(true)
91
+ @controller.sign_in(:user, user)
92
+ end
93
+
94
+ test 'sign in accepts a resource as argument' do
95
+ user = User.new
96
+ @mock_warden.expects(:set_user).with(user, :scope => :user).returns(true)
97
+ @controller.sign_in(user)
98
+ end
99
+
100
+ test 'sign out proxy to logout on warden' do
101
+ @mock_warden.expects(:user).with(:user).returns(true)
102
+ @mock_warden.expects(:logout).with(:user).returns(true)
103
+ @controller.sign_out(:user)
104
+ end
105
+
106
+ test 'sign out accepts a resource as argument' do
107
+ @mock_warden.expects(:user).with(:user).returns(true)
108
+ @mock_warden.expects(:logout).with(:user).returns(true)
109
+ @controller.sign_out(User.new)
110
+ end
111
+
112
+ test 'stored location for returns the location for a given scope' do
113
+ assert_nil @controller.stored_location_for(:user)
114
+ @controller.session[:"user.return_to"] = "/foo.bar"
115
+ assert_equal "/foo.bar", @controller.stored_location_for(:user)
116
+ end
117
+
118
+ test 'stored location for accepts a resource as argument' do
119
+ assert_nil @controller.stored_location_for(:user)
120
+ @controller.session[:"user.return_to"] = "/foo.bar"
121
+ assert_equal "/foo.bar", @controller.stored_location_for(User.new)
122
+ end
123
+
124
+ test 'stored location cleans information after reading' do
125
+ @controller.session[:"user.return_to"] = "/foo.bar"
126
+ assert_equal "/foo.bar", @controller.stored_location_for(:user)
127
+ assert_nil @controller.session[:"user.return_to"]
128
+ end
129
+
130
+ test 'after sign in path defaults to root path if none by was specified for the given scope' do
131
+ assert_equal root_path, @controller.after_sign_in_path_for(:user)
132
+ end
133
+
134
+ test 'after sign in path defaults to the scoped root path' do
135
+ assert_equal admin_root_path, @controller.after_sign_in_path_for(:admin)
136
+ end
137
+
138
+ test 'after sign out path defaults to the root path' do
139
+ assert_equal root_path, @controller.after_sign_out_path_for(:admin)
140
+ assert_equal root_path, @controller.after_sign_out_path_for(:user)
141
+ end
142
+
143
+ test 'sign in and redirect uses the stored location' do
144
+ user = User.new
145
+ @controller.session[:"user.return_to"] = "/foo.bar"
146
+ @mock_warden.expects(:set_user).with(user, :scope => :user).returns(true)
147
+ @controller.expects(:redirect_to).with("/foo.bar")
148
+ @controller.sign_in_and_redirect(user)
149
+ end
150
+
151
+ test 'sign in and redirect uses the configured after sign in path' do
152
+ admin = Admin.new
153
+ @mock_warden.expects(:set_user).with(admin, :scope => :admin).returns(true)
154
+ @controller.expects(:redirect_to).with(admin_root_path)
155
+ @controller.sign_in_and_redirect(admin)
156
+ end
157
+
158
+ test 'only redirect if skip is given' do
159
+ admin = Admin.new
160
+ @controller.expects(:redirect_to).with(admin_root_path)
161
+ @controller.sign_in_and_redirect(:admin, admin, true)
162
+ end
163
+
164
+ test 'sign out and redirect uses the configured after sign out path' do
165
+ @mock_warden.expects(:user).with(:admin).returns(true)
166
+ @mock_warden.expects(:logout).with(:admin).returns(true)
167
+ @controller.expects(:redirect_to).with(admin_root_path)
168
+ @controller.instance_eval "def after_sign_out_path_for(resource); admin_root_path; end"
169
+ @controller.sign_out_and_redirect(:admin)
170
+ end
171
+
172
+ test 'is not a devise controller' do
173
+ assert_not @controller.devise_controller?
174
+ end
175
+
176
+ test 'default url options are retrieved from devise' do
177
+ begin
178
+ Devise.default_url_options {{ :locale => I18n.locale }}
179
+ assert_equal({ :locale => :en }, @controller.send(:default_url_options))
180
+ ensure
181
+ Devise.default_url_options {{ }}
182
+ end
183
+ end
184
+ end
@@ -0,0 +1,55 @@
1
+ require 'test/test_helper'
2
+
3
+ class MyController < ApplicationController
4
+ include Devise::Controllers::InternalHelpers
5
+ end
6
+
7
+ class HelpersTest < ActionController::TestCase
8
+ tests MyController
9
+
10
+ test 'get resource name from request path' do
11
+ @request.path = '/users/session'
12
+ assert_equal :user, @controller.resource_name
13
+ end
14
+
15
+ test 'get resource name from specific request path' do
16
+ @request.path = '/admin_area/session'
17
+ assert_equal :admin, @controller.resource_name
18
+ end
19
+
20
+ test 'get resource class from request path' do
21
+ @request.path = '/users/session'
22
+ assert_equal User, @controller.resource_class
23
+ end
24
+
25
+ test 'get resource instance variable from request path' do
26
+ @request.path = '/admin_area/session'
27
+ @controller.instance_variable_set(:@admin, admin = Admin.new)
28
+ assert_equal admin, @controller.resource
29
+ end
30
+
31
+ test 'set resource instance variable from request path' do
32
+ @request.path = '/admin_area/session'
33
+
34
+ admin = @controller.send(:resource_class).new
35
+ @controller.send(:resource=, admin)
36
+
37
+ assert_equal admin, @controller.send(:resource)
38
+ assert_equal admin, @controller.instance_variable_get(:@admin)
39
+ end
40
+
41
+ test 'resources methods are not controller actions' do
42
+ assert @controller.class.action_methods.empty?
43
+ end
44
+
45
+ test 'require no authentication tests current mapping' do
46
+ @controller.expects(:resource_name).returns(:user).twice
47
+ @mock_warden.expects(:authenticated?).with(:user).returns(true)
48
+ @controller.expects(:redirect_to).with(root_path)
49
+ @controller.send :require_no_authentication
50
+ end
51
+
52
+ test 'is a devise controller' do
53
+ assert @controller.devise_controller?
54
+ end
55
+ end
@@ -0,0 +1,47 @@
1
+ require 'test/test_helper'
2
+
3
+ class RoutesTest < ActionController::TestCase
4
+ tests ApplicationController
5
+
6
+ def test_path_and_url(name, prepend_path=nil)
7
+ @request.path = '/users/session'
8
+ prepend_path = "#{prepend_path}_" if prepend_path
9
+
10
+ # Resource param
11
+ assert_equal @controller.send(:"#{prepend_path}#{name}_path", :user),
12
+ send(:"#{prepend_path}user_#{name}_path")
13
+ assert_equal @controller.send(:"#{prepend_path}#{name}_url", :user),
14
+ send(:"#{prepend_path}user_#{name}_url")
15
+
16
+ # Default url params
17
+ assert_equal @controller.send(:"#{prepend_path}#{name}_path", :user, :param => 123),
18
+ send(:"#{prepend_path}user_#{name}_path", :param => 123)
19
+ assert_equal @controller.send(:"#{prepend_path}#{name}_url", :user, :param => 123),
20
+ send(:"#{prepend_path}user_#{name}_url", :param => 123)
21
+
22
+ @request.path = nil
23
+ # With an AR object
24
+ assert_equal @controller.send(:"#{prepend_path}#{name}_path", User.new),
25
+ send(:"#{prepend_path}user_#{name}_path")
26
+ assert_equal @controller.send(:"#{prepend_path}#{name}_url", User.new),
27
+ send(:"#{prepend_path}user_#{name}_url")
28
+ end
29
+
30
+
31
+ test 'should alias session to mapped user session' do
32
+ test_path_and_url :session
33
+ test_path_and_url :session, :new
34
+ test_path_and_url :session, :destroy
35
+ end
36
+
37
+ test 'should alias password to mapped user password' do
38
+ test_path_and_url :password
39
+ test_path_and_url :password, :new
40
+ test_path_and_url :password, :edit
41
+ end
42
+
43
+ test 'should alias confirmation to mapped user confirmation' do
44
+ test_path_and_url :confirmation
45
+ test_path_and_url :confirmation, :new
46
+ end
47
+ end