loyal_devise 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +14 -9
  3. data/.yardopts +9 -0
  4. data/CHANGELOG.rdoc +60 -5
  5. data/CONTRIBUTING.md +4 -2
  6. data/Gemfile +7 -7
  7. data/Gemfile.lock +107 -101
  8. data/MIT-LICENSE +1 -1
  9. data/README.md +110 -48
  10. data/Rakefile +1 -0
  11. data/app/controllers/devise/confirmations_controller.rb +2 -4
  12. data/app/controllers/devise/omniauth_callbacks_controller.rb +0 -1
  13. data/app/controllers/devise/passwords_controller.rb +16 -5
  14. data/app/controllers/devise/registrations_controller.rb +13 -7
  15. data/app/controllers/devise/sessions_controller.rb +6 -6
  16. data/app/controllers/devise/unlocks_controller.rb +3 -4
  17. data/app/controllers/devise_controller.rb +12 -33
  18. data/app/helpers/devise_helper.rb +0 -1
  19. data/app/mailers/devise/mailer.rb +7 -8
  20. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  21. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  22. data/app/views/devise/registrations/edit.html.erb +5 -1
  23. data/config/locales/en.yml +48 -48
  24. data/devise.gemspec +6 -6
  25. data/devise.png +0 -0
  26. data/gemfiles/{Gemfile.rails-3.1.x → Gemfile.rails-3.2.x} +8 -12
  27. data/gemfiles/Gemfile.rails-3.2.x.lock +156 -0
  28. data/lib/devise.rb +34 -11
  29. data/lib/devise/controllers/helpers.rb +33 -7
  30. data/lib/devise/controllers/rememberable.rb +6 -3
  31. data/lib/devise/controllers/scoped_views.rb +1 -2
  32. data/lib/devise/controllers/url_helpers.rb +0 -1
  33. data/lib/devise/delegator.rb +0 -1
  34. data/lib/devise/failure_app.rb +8 -2
  35. data/lib/devise/hooks/activatable.rb +1 -2
  36. data/lib/devise/hooks/forgetable.rb +0 -1
  37. data/lib/devise/hooks/lockable.rb +1 -2
  38. data/lib/devise/hooks/rememberable.rb +1 -2
  39. data/lib/devise/hooks/timeoutable.rb +0 -1
  40. data/lib/devise/hooks/trackable.rb +0 -1
  41. data/lib/devise/mailers/helpers.rb +18 -14
  42. data/lib/devise/mapping.rb +6 -7
  43. data/lib/devise/models.rb +0 -1
  44. data/lib/devise/models/authenticatable.rb +50 -27
  45. data/lib/devise/models/confirmable.rb +37 -16
  46. data/lib/devise/models/database_authenticatable.rb +17 -3
  47. data/lib/devise/models/lockable.rb +1 -2
  48. data/lib/devise/models/omniauthable.rb +1 -2
  49. data/lib/devise/models/recoverable.rb +10 -6
  50. data/lib/devise/models/registerable.rb +0 -1
  51. data/lib/devise/models/rememberable.rb +1 -2
  52. data/lib/devise/models/timeoutable.rb +1 -2
  53. data/lib/devise/models/token_authenticatable.rb +0 -1
  54. data/lib/devise/models/trackable.rb +0 -1
  55. data/lib/devise/models/validatable.rb +0 -1
  56. data/lib/devise/modules.rb +1 -2
  57. data/lib/devise/omniauth.rb +0 -1
  58. data/lib/devise/omniauth/config.rb +0 -1
  59. data/lib/devise/omniauth/url_helpers.rb +0 -1
  60. data/lib/devise/orm/active_record.rb +1 -2
  61. data/lib/devise/orm/mongoid.rb +1 -2
  62. data/lib/devise/{param_filter.rb → parameter_filter.rb} +10 -12
  63. data/lib/devise/parameter_sanitizer.rb +59 -0
  64. data/lib/devise/rails.rb +0 -1
  65. data/lib/devise/rails/routes.rb +22 -18
  66. data/lib/devise/rails/warden_compat.rb +0 -30
  67. data/lib/devise/strategies/authenticatable.rb +8 -6
  68. data/lib/devise/strategies/base.rb +1 -2
  69. data/lib/devise/strategies/database_authenticatable.rb +1 -2
  70. data/lib/devise/strategies/rememberable.rb +1 -2
  71. data/lib/devise/strategies/token_authenticatable.rb +38 -4
  72. data/lib/devise/test_helpers.rb +0 -1
  73. data/lib/devise/time_inflector.rb +1 -2
  74. data/lib/devise/version.rb +1 -2
  75. data/lib/generators/active_record/devise_generator.rb +1 -5
  76. data/lib/generators/active_record/templates/migration.rb +0 -1
  77. data/lib/generators/active_record/templates/migration_existing.rb +0 -1
  78. data/lib/generators/devise/devise_generator.rb +0 -1
  79. data/lib/generators/devise/install_generator.rb +0 -1
  80. data/lib/generators/devise/orm_helpers.rb +1 -2
  81. data/lib/generators/devise/views_generator.rb +8 -3
  82. data/lib/generators/mongoid/devise_generator.rb +1 -2
  83. data/lib/generators/templates/README +1 -1
  84. data/lib/generators/templates/devise.rb +10 -5
  85. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  86. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +1 -0
  87. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -1
  88. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +1 -0
  89. data/loyal_devise.gemspec +27 -0
  90. data/test/controllers/custom_strategy_test.rb +0 -1
  91. data/test/controllers/helpers_test.rb +0 -1
  92. data/test/controllers/internal_helpers_test.rb +13 -4
  93. data/test/controllers/passwords_controller_test.rb +32 -0
  94. data/test/controllers/sessions_controller_test.rb +28 -1
  95. data/test/controllers/url_helpers_test.rb +0 -1
  96. data/test/delegator_test.rb +0 -1
  97. data/test/devise_test.rb +12 -2
  98. data/test/failure_app_test.rb +3 -4
  99. data/test/generators/active_record_generator_test.rb +1 -4
  100. data/test/generators/devise_generator_test.rb +0 -1
  101. data/test/generators/install_generator_test.rb +0 -1
  102. data/test/generators/mongoid_generator_test.rb +0 -1
  103. data/test/generators/views_generator_test.rb +16 -2
  104. data/test/helpers/devise_helper_test.rb +1 -2
  105. data/test/integration/authenticatable_test.rb +92 -27
  106. data/test/integration/confirmable_test.rb +7 -7
  107. data/test/integration/database_authenticatable_test.rb +8 -7
  108. data/test/integration/http_authenticatable_test.rb +19 -2
  109. data/test/integration/lockable_test.rb +1 -2
  110. data/test/integration/omniauthable_test.rb +2 -3
  111. data/test/integration/recoverable_test.rb +40 -12
  112. data/test/integration/registerable_test.rb +17 -14
  113. data/test/integration/rememberable_test.rb +16 -10
  114. data/test/integration/timeoutable_test.rb +11 -2
  115. data/test/integration/token_authenticatable_test.rb +45 -2
  116. data/test/integration/trackable_test.rb +1 -2
  117. data/test/mailers/confirmation_instructions_test.rb +11 -3
  118. data/test/mailers/reset_password_instructions_test.rb +11 -3
  119. data/test/mailers/unlock_instructions_test.rb +11 -2
  120. data/test/mapping_test.rb +0 -1
  121. data/test/models/authenticatable_test.rb +6 -1
  122. data/test/models/confirmable_test.rb +53 -2
  123. data/test/models/database_authenticatable_test.rb +57 -21
  124. data/test/models/lockable_test.rb +1 -2
  125. data/test/models/omniauthable_test.rb +0 -1
  126. data/test/models/recoverable_test.rb +21 -5
  127. data/test/models/registerable_test.rb +0 -1
  128. data/test/models/rememberable_test.rb +4 -4
  129. data/test/models/serializable_test.rb +8 -8
  130. data/test/models/timeoutable_test.rb +0 -1
  131. data/test/models/token_authenticatable_test.rb +0 -1
  132. data/test/models/trackable_test.rb +0 -1
  133. data/test/models/validatable_test.rb +16 -6
  134. data/test/models_test.rb +7 -24
  135. data/test/omniauth/config_test.rb +1 -2
  136. data/test/omniauth/url_helpers_test.rb +4 -2
  137. data/test/orm/active_record.rb +1 -1
  138. data/test/orm/mongoid.rb +2 -4
  139. data/test/parameter_sanitizer_test.rb +51 -0
  140. data/test/rails_app/Rakefile +0 -4
  141. data/test/rails_app/app/active_record/admin.rb +0 -1
  142. data/test/rails_app/app/active_record/shim.rb +1 -2
  143. data/test/rails_app/app/active_record/user.rb +0 -1
  144. data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -2
  145. data/test/rails_app/app/controllers/admins_controller.rb +0 -1
  146. data/test/rails_app/app/controllers/application_controller.rb +1 -1
  147. data/test/rails_app/app/controllers/home_controller.rb +0 -1
  148. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -2
  149. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -2
  150. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -2
  151. data/test/rails_app/app/controllers/users_controller.rb +8 -1
  152. data/test/rails_app/app/helpers/application_helper.rb +0 -1
  153. data/test/rails_app/app/mailers/users/mailer.rb +4 -1
  154. data/test/rails_app/app/mongoid/admin.rb +4 -3
  155. data/test/rails_app/app/mongoid/shim.rb +3 -5
  156. data/test/rails_app/app/mongoid/user.rb +2 -3
  157. data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
  158. data/test/rails_app/bin/bundle +3 -0
  159. data/test/rails_app/bin/rails +4 -0
  160. data/test/rails_app/bin/rake +4 -0
  161. data/test/rails_app/config/application.rb +1 -3
  162. data/test/rails_app/config/boot.rb +3 -4
  163. data/test/rails_app/config/environment.rb +2 -3
  164. data/test/rails_app/config/environments/development.rb +23 -8
  165. data/test/rails_app/config/environments/production.rb +68 -18
  166. data/test/rails_app/config/environments/test.rb +18 -16
  167. data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -1
  168. data/test/rails_app/config/initializers/devise.rb +0 -1
  169. data/test/rails_app/config/initializers/inflections.rb +0 -1
  170. data/test/rails_app/config/initializers/secret_token.rb +8 -3
  171. data/test/rails_app/config/initializers/session_store.rb +1 -0
  172. data/test/rails_app/config/routes.rb +20 -17
  173. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -1
  174. data/test/rails_app/db/schema.rb +0 -1
  175. data/test/rails_app/lib/shared_admin.rb +0 -1
  176. data/test/rails_app/lib/shared_user.rb +0 -2
  177. data/test/routes_test.rb +22 -21
  178. data/test/support/assertions.rb +0 -1
  179. data/test/support/helpers.rb +1 -2
  180. data/test/support/integration.rb +0 -1
  181. data/test/support/webrat/integrations/rails.rb +0 -1
  182. data/test/test_helper.rb +8 -2
  183. data/test/test_helpers_test.rb +0 -1
  184. data/test/test_models.rb +26 -0
  185. metadata +65 -27
  186. data/gemfiles/Gemfile.rails-3.1.x.lock +0 -167
  187. data/test/indifferent_hash.rb +0 -34
  188. data/test/rails_app/script/rails +0 -10
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'test_helper'
3
2
 
4
3
  class TimeoutableTest < ActiveSupport::TestCase
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'test_helper'
3
2
 
4
3
  class TokenAuthenticatableTest < ActiveSupport::TestCase
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'test_helper'
3
2
 
4
3
  class TrackableTest < ActiveSupport::TestCase
@@ -1,4 +1,4 @@
1
- # -*- encoding : utf-8 -*-
1
+ # encoding: UTF-8
2
2
  require 'test_helper'
3
3
 
4
4
  class ValidatableTest < ActiveSupport::TestCase
@@ -56,10 +56,15 @@ class ValidatableTest < ActiveSupport::TestCase
56
56
  test 'should require confirmation to be set when creating a new record' do
57
57
  user = new_user(:password => 'new_password', :password_confirmation => 'blabla')
58
58
  assert user.invalid?
59
- assert_equal 'doesn\'t match confirmation', user.errors[:password].join
59
+
60
+ if Devise.rails4?
61
+ assert_equal 'doesn\'t match Password', user.errors[:password_confirmation].join
62
+ else
63
+ assert_equal 'doesn\'t match confirmation', user.errors[:password].join
64
+ end
60
65
  end
61
66
 
62
- test 'should require password when updating/reseting password' do
67
+ test 'should require password when updating/resetting password' do
63
68
  user = create_user
64
69
 
65
70
  user.password = ''
@@ -69,11 +74,16 @@ class ValidatableTest < ActiveSupport::TestCase
69
74
  assert_equal 'can\'t be blank', user.errors[:password].join
70
75
  end
71
76
 
72
- test 'should require confirmation when updating/reseting password' do
77
+ test 'should require confirmation when updating/resetting password' do
73
78
  user = create_user
74
79
  user.password_confirmation = 'another_password'
75
80
  assert user.invalid?
76
- assert_equal 'doesn\'t match confirmation', user.errors[:password].join
81
+
82
+ if Devise.rails4?
83
+ assert_equal 'doesn\'t match Password', user.errors[:password_confirmation].join
84
+ else
85
+ assert_equal 'doesn\'t match confirmation', user.errors[:password].join
86
+ end
77
87
  end
78
88
 
79
89
  test 'should require a password with minimum of 6 characters' do
@@ -98,7 +108,7 @@ class ValidatableTest < ActiveSupport::TestCase
98
108
  assert_not (user.errors[:password].join =~ /is too long/)
99
109
  end
100
110
 
101
- test 'should complain about length even if possword is not required' do
111
+ test 'should complain about length even if password is not required' do
102
112
  user = new_user(:password => 'x'*129, :password_confirmation => 'x'*129)
103
113
  user.stubs(:password_required?).returns(false)
104
114
  assert user.invalid?
@@ -1,27 +1,5 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'test_helper'
3
-
4
- class Configurable < User
5
- devise :database_authenticatable, :confirmable, :rememberable, :timeoutable, :lockable,
6
- :stretches => 15, :pepper => 'abcdef', :allow_unconfirmed_access_for => 5.days,
7
- :remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
8
- end
9
-
10
- class WithValidation < Admin
11
- devise :database_authenticatable, :validatable, :password_length => 2..6
12
- end
13
-
14
- class UserWithValidation < User
15
- validates_presence_of :username
16
- end
17
-
18
- class Several < Admin
19
- devise :validatable
20
- devise :lockable
21
- end
22
-
23
- class Inheritable < Admin
24
- end
2
+ require 'test_models'
25
3
 
26
4
  class ActiveRecordTest < ActiveSupport::TestCase
27
5
  def include_module?(klass, mod)
@@ -105,7 +83,12 @@ class ActiveRecordTest < ActiveSupport::TestCase
105
83
  end
106
84
 
107
85
  test 'set null fields on migrations' do
108
- Admin.create!
86
+ # Ignore email sending since no email exists.
87
+ klass = Class.new(Admin) do
88
+ def send_devise_notification(*); end
89
+ end
90
+
91
+ klass.create!
109
92
  end
110
93
  end
111
94
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'test_helper'
3
2
 
4
3
  class OmniAuthConfigTest < ActiveSupport::TestCase
@@ -55,4 +54,4 @@ class OmniAuthConfigTest < ActiveSupport::TestCase
55
54
  config_class = config.strategy_class
56
55
  assert_equal MyStrategy, config_class
57
56
  end
58
- end
57
+ end
@@ -1,7 +1,9 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'test_helper'
3
2
 
4
3
  class OmniAuthRoutesTest < ActionController::TestCase
4
+ ExpectedUrlGeneratiorError = Devise.rails4? ?
5
+ ActionController::UrlGenerationError : ActionController::RoutingError
6
+
5
7
  tests ApplicationController
6
8
 
7
9
  def assert_path(action, provider, with_param=true)
@@ -31,7 +33,7 @@ class OmniAuthRoutesTest < ActionController::TestCase
31
33
  test 'should generate authorization path' do
32
34
  assert_match "/users/auth/facebook", @controller.omniauth_authorize_path(:user, :facebook)
33
35
 
34
- assert_raise ActionController::RoutingError do
36
+ assert_raise ExpectedUrlGeneratiorError do
35
37
  @controller.omniauth_authorize_path(:user, :github)
36
38
  end
37
39
  end
@@ -1,6 +1,6 @@
1
- # -*- encoding : utf-8 -*-
2
1
  ActiveRecord::Migration.verbose = false
3
2
  ActiveRecord::Base.logger = Logger.new(nil)
3
+ ActiveRecord::Base.include_root_in_json = true
4
4
 
5
5
  ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__))
6
6
 
@@ -1,15 +1,13 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'mongoid/version'
3
2
 
4
3
  Mongoid.configure do |config|
5
- config.master = Mongo::Connection.new('127.0.0.1', 27017).db("devise-test-suite")
4
+ config.connect_to("devise-test-suite")
6
5
  config.use_utc = true
7
6
  config.include_root_in_json = true
8
7
  end
9
8
 
10
9
  class ActiveSupport::TestCase
11
10
  setup do
12
- User.delete_all
13
- Admin.delete_all
11
+ Mongoid.purge!
14
12
  end
15
13
  end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+ require 'devise/parameter_sanitizer'
3
+
4
+ class BaseSanitizerTest < ActiveSupport::TestCase
5
+ def sanitizer
6
+ Devise::BaseSanitizer.new(User, :user, { user: { "email" => "jose" } })
7
+ end
8
+
9
+ test 'returns chosen params' do
10
+ assert_equal({ "email" => "jose" }, sanitizer.for(:sign_in))
11
+ end
12
+ end
13
+
14
+ if defined?(ActionController::StrongParameters)
15
+ require 'active_model/forbidden_attributes_protection'
16
+
17
+ class ParameterSanitizerTest < ActiveSupport::TestCase
18
+ def sanitizer(params)
19
+ params = ActionController::Parameters.new(params)
20
+ Devise::ParameterSanitizer.new(User, :user, params)
21
+ end
22
+
23
+ test 'filters some parameters on sign in by default' do
24
+ sanitizer = sanitizer(user: { "email" => "jose", "password" => "invalid" })
25
+ assert_equal({ "email" => "jose" }, sanitizer.for(:sign_in))
26
+ end
27
+
28
+ test 'filters some parameters on sign up by default' do
29
+ sanitizer = sanitizer(user: { "email" => "jose", "role" => "invalid" })
30
+ assert_equal({ "email" => "jose" }, sanitizer.for(:sign_up))
31
+ end
32
+
33
+ test 'filters some parameters on account update by default' do
34
+ sanitizer = sanitizer(user: { "email" => "jose", "role" => "invalid" })
35
+ assert_equal({ "email" => "jose" }, sanitizer.for(:account_update))
36
+ end
37
+
38
+ test 'allows custom hooks' do
39
+ sanitizer = sanitizer(user: { "email" => "jose", "password" => "invalid" })
40
+ sanitizer.for(:sign_in) { |user| user.permit(:email, :password) }
41
+ assert_equal({ "email" => "jose", "password" => "invalid" }, sanitizer.for(:sign_in))
42
+ end
43
+
44
+ test 'raises on unknown hooks' do
45
+ sanitizer = sanitizer(user: { "email" => "jose", "password" => "invalid" })
46
+ assert_raise NotImplementedError do
47
+ sanitizer.for(:unknown)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -3,8 +3,4 @@
3
3
 
4
4
  require File.expand_path('../config/application', __FILE__)
5
5
 
6
- require 'rake'
7
- require 'rake/testtask'
8
- require 'rake/rdoctask'
9
-
10
6
  Rails.application.load_tasks
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'shared_admin'
3
2
 
4
3
  class Admin < ActiveRecord::Base
@@ -1,3 +1,2 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Shim
3
- end
2
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'shared_user'
3
2
 
4
3
  class User < ActiveRecord::Base
@@ -1,7 +1,6 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Admins::SessionsController < Devise::SessionsController
3
2
  def new
4
3
  flash[:special] = "Welcome to #{controller_path.inspect} controller!"
5
4
  super
6
5
  end
7
- end
6
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class AdminsController < ApplicationController
3
2
  before_filter :authenticate_admin!
4
3
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # Filters added to this controller apply to all controllers in the application.
3
2
  # Likewise, all the methods added will be available for all controllers.
4
3
 
@@ -6,4 +5,5 @@ class ApplicationController < ActionController::Base
6
5
  protect_from_forgery
7
6
  before_filter :current_user, :unless => :devise_controller?
8
7
  before_filter :authenticate_user!, :if => :devise_controller?
8
+ respond_to *Mime::SET.map(&:to_sym)
9
9
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class HomeController < ApplicationController
3
2
  def index
4
3
  end
@@ -1,3 +1,2 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Publisher::RegistrationsController < ApplicationController
3
- end
2
+ end
@@ -1,3 +1,2 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Publisher::SessionsController < ApplicationController
3
- end
2
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
3
2
  def facebook
4
3
  data = env["omniauth.auth"]
@@ -12,4 +11,4 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
12
11
  sign_in user
13
12
  render :text => ""
14
13
  end
15
- end
14
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class UsersController < ApplicationController
3
2
  prepend_before_filter :current_user, :only => :exhibit
4
3
  before_filter :authenticate_user!, :except => [:accept, :exhibit]
@@ -9,6 +8,14 @@ class UsersController < ApplicationController
9
8
  respond_with(current_user)
10
9
  end
11
10
 
11
+ def edit_form
12
+ user_session['last_request_at'] = 31.minutes.ago.utc
13
+ end
14
+
15
+ def update_form
16
+ render :text => 'Update'
17
+ end
18
+
12
19
  def accept
13
20
  @current_user = current_user
14
21
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # Methods added to this helper will be available to all templates in the application.
3
2
  module ApplicationHelper
4
3
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Users::Mailer < Devise::Mailer
3
2
  default :from => 'custom@example.com'
4
3
  end
@@ -7,3 +6,7 @@ class Users::ReplyToMailer < Devise::Mailer
7
6
  default :from => 'custom@example.com'
8
7
  default :reply_to => 'custom_reply_to@example.com'
9
8
  end
9
+
10
+ class Users::FromProcMailer < Devise::Mailer
11
+ default :from => proc { 'custom@example.com' }
12
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'shared_admin'
3
2
 
4
3
  class Admin
@@ -7,8 +6,8 @@ class Admin
7
6
  include SharedAdmin
8
7
 
9
8
  ## Database authenticatable
10
- field :email, :type => String, :null => true
11
- field :encrypted_password, :type => String, :null => true
9
+ field :email, :type => String
10
+ field :encrypted_password, :type => String
12
11
 
13
12
  ## Recoverable
14
13
  field :reset_password_token, :type => String
@@ -25,4 +24,6 @@ class Admin
25
24
 
26
25
  ## Lockable
27
26
  field :locked_at, :type => Time
27
+
28
+ field :active, :type => Boolean, :default => false
28
29
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Shim
3
2
  extend ::ActiveSupport::Concern
4
3
 
@@ -8,13 +7,12 @@ module Shim
8
7
  end
9
8
 
10
9
  module ClassMethods
11
- def last(options={})
12
- options.delete(:order) if options[:order] == "id"
13
- super(options)
10
+ def order(attribute)
11
+ asc(attribute)
14
12
  end
15
13
 
16
14
  def find_by_email(email)
17
- first(:conditions => { :email => email })
15
+ find_by(:email => email)
18
16
  end
19
17
  end
20
18
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'shared_user'
3
2
 
4
3
  class User
@@ -10,8 +9,8 @@ class User
10
9
  field :facebook_token, :type => String
11
10
 
12
11
  ## Database authenticatable
13
- field :email, :type => String, :null => false, :default => ""
14
- field :encrypted_password, :type => String, :null => false, :default => ""
12
+ field :email, :type => String, :default => ""
13
+ field :encrypted_password, :type => String, :default => ""
15
14
 
16
15
  ## Recoverable
17
16
  field :reset_password_token, :type => String
@@ -0,0 +1 @@
1
+ <%= button_to 'Update', update_form_user_path(current_user), method: 'put' %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -1,9 +1,7 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require File.expand_path('../boot', __FILE__)
3
2
 
4
3
  require "action_controller/railtie"
5
4
  require "action_mailer/railtie"
6
- require "active_resource/railtie"
7
5
  require "rails/test_unit/railtie"
8
6
 
9
7
  Bundler.require :default, DEVISE_ORM
@@ -18,7 +16,7 @@ require "devise"
18
16
  module RailsApp
19
17
  class Application < Rails::Application
20
18
  # Add additional load paths for your own custom dirs
21
- config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers views).include?($1) }
19
+ config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers mailers views).include?($1) }
22
20
  config.autoload_paths += [ "#{config.root}/app/#{DEVISE_ORM}" ]
23
21
 
24
22
  # Configure generators values. Many other options are available, be sure to check the documentation.