devise 1.1.rc2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise might be problematic. Click here for more details.

Files changed (77) hide show
  1. data/CHANGELOG.rdoc +22 -2
  2. data/Gemfile +7 -13
  3. data/Gemfile.lock +118 -0
  4. data/README.rdoc +15 -13
  5. data/app/controllers/devise/unlocks_controller.rb +0 -7
  6. data/app/mailers/devise/mailer.rb +7 -4
  7. data/app/views/devise/confirmations/new.html.erb +1 -1
  8. data/app/views/devise/passwords/new.html.erb +1 -1
  9. data/app/views/devise/unlocks/new.html.erb +1 -1
  10. data/lib/devise.rb +27 -9
  11. data/lib/devise/controllers/helpers.rb +19 -5
  12. data/lib/devise/controllers/internal_helpers.rb +2 -8
  13. data/lib/devise/encryptors/base.rb +1 -1
  14. data/lib/devise/encryptors/bcrypt.rb +2 -2
  15. data/lib/devise/failure_app.rb +6 -2
  16. data/lib/devise/hooks/rememberable.rb +9 -1
  17. data/lib/devise/mapping.rb +15 -50
  18. data/lib/devise/models/authenticatable.rb +8 -0
  19. data/lib/devise/models/confirmable.rb +10 -6
  20. data/lib/devise/models/database_authenticatable.rb +9 -1
  21. data/lib/devise/models/recoverable.rb +6 -1
  22. data/lib/devise/models/rememberable.rb +36 -7
  23. data/lib/devise/models/token_authenticatable.rb +5 -5
  24. data/lib/devise/models/validatable.rb +1 -1
  25. data/lib/devise/path_checker.rb +7 -2
  26. data/lib/devise/rails.rb +6 -1
  27. data/lib/devise/rails/routes.rb +137 -50
  28. data/lib/devise/rails/warden_compat.rb +16 -2
  29. data/lib/devise/strategies/authenticatable.rb +12 -0
  30. data/lib/devise/strategies/base.rb +0 -18
  31. data/lib/devise/strategies/rememberable.rb +9 -1
  32. data/lib/devise/test_helpers.rb +2 -0
  33. data/lib/devise/version.rb +1 -1
  34. data/lib/generators/active_record/devise_generator.rb +28 -0
  35. data/lib/generators/{devise/devise → active_record}/templates/migration.rb +4 -0
  36. data/lib/generators/devise/devise_generator.rb +17 -0
  37. data/lib/generators/devise/{install/install_generator.rb → install_generator.rb} +1 -1
  38. data/lib/generators/devise/orm_helpers.rb +23 -0
  39. data/lib/generators/devise/{install/templates → templates}/README +0 -0
  40. data/lib/generators/devise/{install/templates → templates}/devise.rb +20 -13
  41. data/lib/generators/devise/{views/views_generator.rb → views_generator.rb} +2 -2
  42. data/lib/generators/mongoid/devise_generator.rb +17 -0
  43. data/test/controllers/helpers_test.rb +9 -0
  44. data/test/controllers/internal_helpers_test.rb +7 -16
  45. data/test/controllers/url_helpers_test.rb +11 -0
  46. data/test/encryptors_test.rb +1 -1
  47. data/test/failure_app_test.rb +18 -5
  48. data/test/integration/authenticatable_test.rb +76 -11
  49. data/test/integration/confirmable_test.rb +16 -9
  50. data/test/integration/lockable_test.rb +11 -13
  51. data/test/integration/registerable_test.rb +4 -4
  52. data/test/integration/rememberable_test.rb +54 -1
  53. data/test/mapping_test.rb +10 -45
  54. data/test/models/confirmable_test.rb +1 -1
  55. data/test/models/rememberable_test.rb +108 -0
  56. data/test/models/validatable_test.rb +2 -4
  57. data/test/models_test.rb +4 -4
  58. data/test/rails_app/app/active_record/admin.rb +1 -1
  59. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  60. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  61. data/test/rails_app/app/controllers/users_controller.rb +5 -1
  62. data/test/rails_app/app/mongoid/admin.rb +1 -1
  63. data/test/rails_app/config/application.rb +2 -2
  64. data/test/rails_app/config/environments/test.rb +2 -0
  65. data/test/rails_app/config/initializers/devise.rb +95 -34
  66. data/test/rails_app/config/routes.rb +32 -14
  67. data/test/routes_test.rb +34 -2
  68. data/test/support/integration.rb +22 -6
  69. data/test/test_helpers_test.rb +16 -2
  70. metadata +24 -27
  71. data/lib/devise/orm/data_mapper.rb +0 -97
  72. data/lib/generators/devise/devise/devise_generator.rb +0 -86
  73. data/lib/generators/devise_generator.rb +0 -2
  74. data/test/orm/data_mapper.rb +0 -10
  75. data/test/rails_app/app/data_mapper/admin.rb +0 -12
  76. data/test/rails_app/app/data_mapper/shim.rb +0 -2
  77. data/test/rails_app/app/data_mapper/user.rb +0 -23
@@ -1,25 +1,29 @@
1
1
  require 'test_helper'
2
2
 
3
- class MapRoutingTest < ActionController::TestCase
4
-
3
+ class DefaultRoutingTest < ActionController::TestCase
5
4
  test 'map new user session' do
6
5
  assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => 'users/sign_in', :method => :get})
6
+ assert_named_route "/users/sign_in", :new_user_session_path
7
7
  end
8
8
 
9
9
  test 'map create user session' do
10
10
  assert_recognizes({:controller => 'devise/sessions', :action => 'create'}, {:path => 'users/sign_in', :method => :post})
11
+ assert_named_route "/users/sign_in", :user_session_path
11
12
  end
12
13
 
13
14
  test 'map destroy user session' do
14
15
  assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => 'users/sign_out', :method => :get})
16
+ assert_named_route "/users/sign_out", :destroy_user_session_path
15
17
  end
16
18
 
17
19
  test 'map new user confirmation' do
18
20
  assert_recognizes({:controller => 'devise/confirmations', :action => 'new'}, 'users/confirmation/new')
21
+ assert_named_route "/users/confirmation/new", :new_user_confirmation_path
19
22
  end
20
23
 
21
24
  test 'map create user confirmation' do
22
25
  assert_recognizes({:controller => 'devise/confirmations', :action => 'create'}, {:path => 'users/confirmation', :method => :post})
26
+ assert_named_route "/users/confirmation", :user_confirmation_path
23
27
  end
24
28
 
25
29
  test 'map show user confirmation' do
@@ -28,14 +32,17 @@ class MapRoutingTest < ActionController::TestCase
28
32
 
29
33
  test 'map new user password' do
30
34
  assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'users/password/new')
35
+ assert_named_route "/users/password/new", :new_user_password_path
31
36
  end
32
37
 
33
38
  test 'map create user password' do
34
39
  assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => 'users/password', :method => :post})
40
+ assert_named_route "/users/password", :user_password_path
35
41
  end
36
42
 
37
43
  test 'map edit user password' do
38
44
  assert_recognizes({:controller => 'devise/passwords', :action => 'edit'}, 'users/password/edit')
45
+ assert_named_route "/users/password/edit", :edit_user_password_path
39
46
  end
40
47
 
41
48
  test 'map update user password' do
@@ -44,10 +51,12 @@ class MapRoutingTest < ActionController::TestCase
44
51
 
45
52
  test 'map new user unlock' do
46
53
  assert_recognizes({:controller => 'devise/unlocks', :action => 'new'}, 'users/unlock/new')
54
+ assert_named_route "/users/unlock/new", :new_user_unlock_path
47
55
  end
48
56
 
49
57
  test 'map create user unlock' do
50
58
  assert_recognizes({:controller => 'devise/unlocks', :action => 'create'}, {:path => 'users/unlock', :method => :post})
59
+ assert_named_route "/users/unlock", :user_unlock_path
51
60
  end
52
61
 
53
62
  test 'map show user unlock' do
@@ -56,14 +65,17 @@ class MapRoutingTest < ActionController::TestCase
56
65
 
57
66
  test 'map new user registration' do
58
67
  assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, 'users/sign_up')
68
+ assert_named_route "/users/sign_up", :new_user_registration_path
59
69
  end
60
70
 
61
71
  test 'map create user registration' do
62
72
  assert_recognizes({:controller => 'devise/registrations', :action => 'create'}, {:path => 'users', :method => :post})
73
+ assert_named_route "/users", :user_registration_path
63
74
  end
64
75
 
65
76
  test 'map edit user registration' do
66
77
  assert_recognizes({:controller => 'devise/registrations', :action => 'edit'}, {:path => 'users/edit', :method => :get})
78
+ assert_named_route "/users/edit", :edit_user_registration_path
67
79
  end
68
80
 
69
81
  test 'map update user registration' do
@@ -74,6 +86,14 @@ class MapRoutingTest < ActionController::TestCase
74
86
  assert_recognizes({:controller => 'devise/registrations', :action => 'destroy'}, {:path => 'users', :method => :delete})
75
87
  end
76
88
 
89
+ protected
90
+
91
+ def assert_named_route(result, name)
92
+ assert_equal result, @routes.url_helpers.send(name)
93
+ end
94
+ end
95
+
96
+ class CustomizedRoutingTest < ActionController::TestCase
77
97
  test 'map admin with :path option' do
78
98
  assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'admin_area/sign_up', :method => :get})
79
99
  end
@@ -112,3 +132,15 @@ class MapRoutingTest < ActionController::TestCase
112
132
  assert_recognizes({:controller => 'devise/registrations', :action => 'new', :locale => 'en'}, '/en/accounts/management/register')
113
133
  end
114
134
  end
135
+
136
+ class ScopedRoutingTest < ActionController::TestCase
137
+ test 'map publisher account' do
138
+ assert_recognizes({:controller => 'publisher/registrations', :action => 'new'}, {:path => '/publisher/accounts/sign_up', :method => :get})
139
+ assert_equal '/publisher/accounts/sign_up', @routes.url_helpers.new_publisher_account_registration_path
140
+ end
141
+
142
+ test 'map publisher account merges path names' do
143
+ assert_recognizes({:controller => 'publisher/sessions', :action => 'new'}, {:path => '/publisher/accounts/get_in', :method => :get})
144
+ assert_equal '/publisher/accounts/get_in', @routes.url_helpers.new_publisher_account_session_path
145
+ end
146
+ end
@@ -31,7 +31,7 @@ class ActionDispatch::IntegrationTest
31
31
 
32
32
  def sign_in_as_user(options={}, &block)
33
33
  user = create_user(options)
34
- get new_user_session_path unless options[:visit] == false
34
+ visit_with_option options[:visit], new_user_session_path
35
35
  fill_in 'email', :with => 'user@test.com'
36
36
  fill_in 'password', :with => options[:password] || '123456'
37
37
  check 'remember me' if options[:remember_me] == true
@@ -42,7 +42,7 @@ class ActionDispatch::IntegrationTest
42
42
 
43
43
  def sign_in_as_admin(options={}, &block)
44
44
  admin = create_admin(options)
45
- get new_admin_session_path unless options[:visit] == false
45
+ visit_with_option options[:visit], new_admin_session_path
46
46
  fill_in 'email', :with => 'admin@test.com'
47
47
  fill_in 'password', :with => '123456'
48
48
  yield if block_given?
@@ -57,16 +57,32 @@ class ActionDispatch::IntegrationTest
57
57
  assert [301, 302].include?(@integration_session.status),
58
58
  "Expected status to be 301 or 302, got #{@integration_session.status}"
59
59
 
60
- url = prepend_host(url)
61
- location = prepend_host(@integration_session.headers["Location"])
62
- assert_equal url, location
60
+ assert_url url, @integration_session.headers["Location"]
61
+ end
62
+
63
+ def assert_current_url(expected)
64
+ assert_url expected, current_url
65
+ end
66
+
67
+ def assert_url(expected, actual)
68
+ assert_equal prepend_host(expected), prepend_host(actual)
63
69
  end
64
70
 
65
71
  protected
66
72
 
73
+ def visit_with_option(given, default)
74
+ case given
75
+ when String
76
+ visit given
77
+ when FalseClass
78
+ # Do nothing
79
+ else
80
+ visit default
81
+ end
82
+ end
83
+
67
84
  def prepend_host(url)
68
85
  url = "http://#{request.host}#{url}" if url[0] == ?/
69
86
  url
70
87
  end
71
-
72
88
  end
@@ -10,14 +10,28 @@ class TestHelpersTest < ActionController::TestCase
10
10
  assert_equal "You need to sign in or sign up before continuing.", flash[:alert]
11
11
  end
12
12
 
13
- test "redirects if attempting to access a page with a unconfirmed account" do
13
+ test "redirects if attempting to access a page with an unconfirmed account" do
14
14
  swap Devise, :confirm_within => 0 do
15
- sign_in create_user
15
+ user = create_user
16
+ assert !user.active?
17
+
18
+ sign_in user
16
19
  get :index
17
20
  assert_redirected_to new_user_session_path
18
21
  end
19
22
  end
20
23
 
24
+ test "returns nil if accessing current_user with an unconfirmed account" do
25
+ swap Devise, :confirm_within => 0 do
26
+ user = create_user
27
+ assert !user.active?
28
+
29
+ sign_in user
30
+ get :accept, :id => user
31
+ assert_nil assigns(:current_user)
32
+ end
33
+ end
34
+
21
35
  test "does not redirect with valid user" do
22
36
  user = create_user
23
37
  user.confirm!
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise
3
3
  version: !ruby/object:Gem::Version
4
- hash: 977940499
5
- prerelease: true
4
+ hash: 19
5
+ prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - rc2
10
- version: 1.1.rc2
9
+ - 0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Jos\xC3\xA9 Valim"
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-06-23 00:00:00 +02:00
19
+ date: 2010-07-26 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -59,12 +59,14 @@ extensions: []
59
59
 
60
60
  extra_rdoc_files:
61
61
  - CHANGELOG.rdoc
62
+ - Gemfile.lock
62
63
  - MIT-LICENSE
63
64
  - README.rdoc
64
65
  - TODO
65
66
  files:
66
67
  - CHANGELOG.rdoc
67
68
  - Gemfile
69
+ - Gemfile.lock
68
70
  - MIT-LICENSE
69
71
  - README.rdoc
70
72
  - Rakefile
@@ -121,7 +123,6 @@ files:
121
123
  - lib/devise/models/validatable.rb
122
124
  - lib/devise/modules.rb
123
125
  - lib/devise/orm/active_record.rb
124
- - lib/devise/orm/data_mapper.rb
125
126
  - lib/devise/orm/mongoid.rb
126
127
  - lib/devise/path_checker.rb
127
128
  - lib/devise/rails.rb
@@ -135,15 +136,17 @@ files:
135
136
  - lib/devise/strategies/token_authenticatable.rb
136
137
  - lib/devise/test_helpers.rb
137
138
  - lib/devise/version.rb
138
- - lib/generators/devise/devise/devise_generator.rb
139
- - lib/generators/devise/devise/templates/migration.rb
140
- - lib/generators/devise/install/install_generator.rb
141
- - lib/generators/devise/install/templates/README
142
- - lib/generators/devise/install/templates/devise.rb
143
- - lib/generators/devise/views/views_generator.rb
144
- - lib/generators/devise_generator.rb
139
+ - lib/generators/active_record/devise_generator.rb
140
+ - lib/generators/active_record/templates/migration.rb
141
+ - lib/generators/devise/devise_generator.rb
142
+ - lib/generators/devise/install_generator.rb
143
+ - lib/generators/devise/orm_helpers.rb
144
+ - lib/generators/devise/templates/README
145
+ - lib/generators/devise/templates/devise.rb
146
+ - lib/generators/devise/views_generator.rb
145
147
  - lib/generators/devise_install_generator.rb
146
148
  - lib/generators/devise_views_generator.rb
149
+ - lib/generators/mongoid/devise_generator.rb
147
150
  - test/controllers/helpers_test.rb
148
151
  - test/controllers/internal_helpers_test.rb
149
152
  - test/controllers/url_helpers_test.rb
@@ -176,7 +179,6 @@ files:
176
179
  - test/models/validatable_test.rb
177
180
  - test/models_test.rb
178
181
  - test/orm/active_record.rb
179
- - test/orm/data_mapper.rb
180
182
  - test/orm/mongoid.rb
181
183
  - test/rails_app/app/active_record/admin.rb
182
184
  - test/rails_app/app/active_record/shim.rb
@@ -184,11 +186,10 @@ files:
184
186
  - test/rails_app/app/controllers/admins_controller.rb
185
187
  - test/rails_app/app/controllers/application_controller.rb
186
188
  - test/rails_app/app/controllers/home_controller.rb
189
+ - test/rails_app/app/controllers/publisher/registrations_controller.rb
190
+ - test/rails_app/app/controllers/publisher/sessions_controller.rb
187
191
  - test/rails_app/app/controllers/sessions_controller.rb
188
192
  - test/rails_app/app/controllers/users_controller.rb
189
- - test/rails_app/app/data_mapper/admin.rb
190
- - test/rails_app/app/data_mapper/shim.rb
191
- - test/rails_app/app/data_mapper/user.rb
192
193
  - test/rails_app/app/helpers/application_helper.rb
193
194
  - test/rails_app/app/mongoid/admin.rb
194
195
  - test/rails_app/app/mongoid/shim.rb
@@ -235,14 +236,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
235
236
  required_rubygems_version: !ruby/object:Gem::Requirement
236
237
  none: false
237
238
  requirements:
238
- - - ">"
239
+ - - ">="
239
240
  - !ruby/object:Gem::Version
240
- hash: 25
241
+ hash: 3
241
242
  segments:
242
- - 1
243
- - 3
244
- - 1
245
- version: 1.3.1
243
+ - 0
244
+ version: "0"
246
245
  requirements: []
247
246
 
248
247
  rubyforge_project:
@@ -283,7 +282,6 @@ test_files:
283
282
  - test/models/validatable_test.rb
284
283
  - test/models_test.rb
285
284
  - test/orm/active_record.rb
286
- - test/orm/data_mapper.rb
287
285
  - test/orm/mongoid.rb
288
286
  - test/rails_app/app/active_record/admin.rb
289
287
  - test/rails_app/app/active_record/shim.rb
@@ -291,11 +289,10 @@ test_files:
291
289
  - test/rails_app/app/controllers/admins_controller.rb
292
290
  - test/rails_app/app/controllers/application_controller.rb
293
291
  - test/rails_app/app/controllers/home_controller.rb
292
+ - test/rails_app/app/controllers/publisher/registrations_controller.rb
293
+ - test/rails_app/app/controllers/publisher/sessions_controller.rb
294
294
  - test/rails_app/app/controllers/sessions_controller.rb
295
295
  - test/rails_app/app/controllers/users_controller.rb
296
- - test/rails_app/app/data_mapper/admin.rb
297
- - test/rails_app/app/data_mapper/shim.rb
298
- - test/rails_app/app/data_mapper/user.rb
299
296
  - test/rails_app/app/helpers/application_helper.rb
300
297
  - test/rails_app/app/mongoid/admin.rb
301
298
  - test/rails_app/app/mongoid/shim.rb
@@ -1,97 +0,0 @@
1
- module Devise
2
- module Orm
3
- module DataMapper
4
- module Hook
5
- def devise_modules_hook!
6
- extend Schema
7
- include Compatibility
8
- yield
9
- return unless Devise.apply_schema
10
- devise_modules.each { |m| send(m) if respond_to?(m, true) }
11
- end
12
- end
13
-
14
- module Schema
15
- include Devise::Schema
16
-
17
- SCHEMA_OPTIONS = {
18
- :null => :required,
19
- :limit => :length
20
- }
21
-
22
- # Tell how to apply schema methods. This automatically maps :limit to
23
- # :length and :null to :required.
24
- def apply_devise_schema(name, type, options={})
25
- SCHEMA_OPTIONS.each do |old_key, new_key|
26
- next unless options.key?(old_key)
27
- options[new_key] = options.delete(old_key)
28
- end
29
-
30
- options.delete(:default) if options[:default].nil?
31
- property name, type, options
32
- end
33
- end
34
-
35
- module Compatibility
36
- extend ActiveSupport::Concern
37
-
38
- module ClassMethods
39
- # Hooks for confirmable
40
- def before_create(*args)
41
- wrap_hook(:before, :create, *args)
42
- end
43
-
44
- def after_create(*args)
45
- wrap_hook(:after, :create, *args)
46
- end
47
-
48
- def before_save(*args)
49
- wrap_hook(:before, :save, *args)
50
- end
51
-
52
- def wrap_hook(action, method, *args)
53
- options = args.extract_options!
54
-
55
- args.each do |callback|
56
- send action, method, callback
57
- class_eval <<-METHOD, __FILE__, __LINE__ + 1
58
- def #{callback}
59
- super if #{options[:if] || true}
60
- end
61
- METHOD
62
- end
63
- end
64
-
65
- # Add ActiveRecord like finder
66
- def find(*args)
67
- case args.first
68
- when :first, :all
69
- send(args.shift, *args)
70
- else
71
- get(*args)
72
- end
73
- end
74
- end
75
-
76
- def changed?
77
- dirty?
78
- end
79
-
80
- def save(options=nil)
81
- if options.is_a?(Hash) && options[:validate] == false
82
- save!
83
- else
84
- super()
85
- end
86
- end
87
-
88
- def update_attributes(*args)
89
- update(*args)
90
- end
91
- end
92
- end
93
- end
94
- end
95
-
96
- DataMapper::Model.append_extensions(Devise::Models)
97
- DataMapper::Model.append_extensions(Devise::Orm::DataMapper::Hook)
@@ -1,86 +0,0 @@
1
- require 'rails/generators/migration'
2
-
3
- module Devise
4
- module Generators
5
- class DeviseGenerator < Rails::Generators::NamedBase
6
- include Rails::Generators::Migration
7
-
8
- source_root File.expand_path("../templates", __FILE__)
9
- namespace "devise"
10
-
11
- desc "Generates a model with the given NAME (if one does not exist) with devise " <<
12
- "configuration plus a migration file and devise routes."
13
-
14
- def self.orm_has_migration?
15
- Rails::Generators.options[:rails][:orm] == :active_record
16
- end
17
-
18
- def self.next_migration_number(path)
19
- Time.now.utc.strftime("%Y%m%d%H%M%S")
20
- end
21
-
22
- class_option :orm
23
- class_option :migration, :type => :boolean, :default => orm_has_migration?
24
-
25
- def invoke_orm_model
26
- return unless behavior == :invoke
27
-
28
- if model_exists?
29
- say "* Model already exists. Adding Devise behavior."
30
- elsif options[:orm].present?
31
- invoke "model", [name], :migration => false, :orm => options[:orm]
32
-
33
- unless model_exists?
34
- abort "Tried to invoke the model generator for '#{options[:orm]}' but could not find it.\n" <<
35
- "Please create your model by hand before calling `rails g devise #{name}`."
36
- end
37
- else
38
- abort "Cannot create a devise model because config.generators.orm is blank.\n" <<
39
- "Please create your model by hand or configure your generators orm before calling `rails g devise #{name}`."
40
- end
41
- end
42
-
43
- def inject_devise_config_into_model
44
- devise_class_setup = <<-CONTENT
45
-
46
- # Include default devise modules. Others available are:
47
- # :token_authenticatable, :confirmable, :lockable and :timeoutable
48
- devise :database_authenticatable, :registerable,
49
- :recoverable, :rememberable, :trackable, :validatable
50
-
51
- CONTENT
52
-
53
- case options[:orm].to_s
54
- when "mongoid"
55
- inject_into_file model_path, devise_class_setup, :after => "include Mongoid::Document\n"
56
- when "data_mapper"
57
- inject_into_file model_path, devise_class_setup, :after => "include DataMapper::Resource\n"
58
- when "active_record"
59
- inject_into_class model_path, class_name, devise_class_setup + <<-CONTENT
60
- # Setup accessible (or protected) attributes for your model
61
- attr_accessible :email, :password, :password_confirmation
62
- CONTENT
63
- end
64
- end
65
-
66
- def copy_migration_template
67
- return unless options.migration?
68
- migration_template "migration.rb", "db/migrate/devise_create_#{table_name}"
69
- end
70
-
71
- def add_devise_routes
72
- route "devise_for :#{table_name}"
73
- end
74
-
75
- protected
76
-
77
- def model_exists?
78
- File.exists?(File.join(destination_root, model_path))
79
- end
80
-
81
- def model_path
82
- @model_path ||= File.join("app", "models", "#{file_path}.rb")
83
- end
84
- end
85
- end
86
- end