devise 1.4.9 → 1.5.0.rc1

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 (70) hide show
  1. data/.travis.yml +1 -1
  2. data/CHANGELOG.rdoc +21 -0
  3. data/Gemfile +5 -3
  4. data/README.rdoc +25 -13
  5. data/app/controllers/devise/confirmations_controller.rb +2 -3
  6. data/app/controllers/devise/passwords_controller.rb +2 -3
  7. data/app/controllers/devise/registrations_controller.rb +2 -13
  8. data/app/controllers/devise/sessions_controller.rb +2 -2
  9. data/app/controllers/devise/unlocks_controller.rb +2 -3
  10. data/config/locales/en.yml +1 -1
  11. data/devise.gemspec +1 -1
  12. data/lib/devise.rb +6 -4
  13. data/lib/devise/controllers/helpers.rb +43 -27
  14. data/lib/devise/controllers/internal_helpers.rb +14 -8
  15. data/lib/devise/delegator.rb +16 -0
  16. data/lib/devise/encryptors/authlogic_sha512.rb +1 -1
  17. data/lib/devise/encryptors/clearance_sha1.rb +1 -1
  18. data/lib/devise/encryptors/restful_authentication_sha1.rb +1 -1
  19. data/lib/devise/encryptors/sha1.rb +1 -1
  20. data/lib/devise/encryptors/sha512.rb +1 -1
  21. data/lib/devise/failure_app.rb +2 -1
  22. data/lib/devise/hooks/timeoutable.rb +3 -1
  23. data/lib/devise/mailers/helpers.rb +0 -5
  24. data/lib/devise/mapping.rb +70 -44
  25. data/lib/devise/models/authenticatable.rb +14 -24
  26. data/lib/devise/models/confirmable.rb +3 -3
  27. data/lib/devise/models/database_authenticatable.rb +11 -1
  28. data/lib/devise/models/lockable.rb +7 -11
  29. data/lib/devise/models/recoverable.rb +3 -3
  30. data/lib/devise/models/trackable.rb +2 -2
  31. data/lib/devise/omniauth.rb +5 -4
  32. data/lib/devise/omniauth/config.rb +27 -5
  33. data/lib/devise/param_filter.rb +41 -0
  34. data/lib/devise/rails.rb +0 -11
  35. data/lib/devise/rails/routes.rb +10 -7
  36. data/lib/devise/strategies/authenticatable.rb +1 -11
  37. data/lib/devise/version.rb +1 -1
  38. data/lib/generators/active_record/templates/migration.rb +7 -1
  39. data/lib/generators/active_record/templates/migration_existing.rb +3 -3
  40. data/lib/generators/devise/views_generator.rb +30 -4
  41. data/lib/generators/templates/devise.rb +0 -1
  42. data/lib/generators/templates/markerb/confirmation_instructions.markerb +5 -0
  43. data/lib/generators/templates/markerb/reset_password_instructions.markerb +8 -0
  44. data/lib/generators/templates/markerb/unlock_instructions.markerb +7 -0
  45. data/test/controllers/helpers_test.rb +20 -11
  46. data/test/devise_test.rb +1 -1
  47. data/test/generators/active_record_generator_test.rb +16 -6
  48. data/test/generators/views_generator_test.rb +11 -4
  49. data/test/integration/authenticatable_test.rb +25 -3
  50. data/test/integration/confirmable_test.rb +27 -3
  51. data/test/integration/lockable_test.rb +17 -6
  52. data/test/integration/omniauthable_test.rb +6 -9
  53. data/test/integration/recoverable_test.rb +21 -2
  54. data/test/integration/registerable_test.rb +18 -1
  55. data/test/integration/timeoutable_test.rb +9 -0
  56. data/test/integration/trackable_test.rb +11 -0
  57. data/test/mailers/confirmation_instructions_test.rb +5 -0
  58. data/test/mailers/reset_password_instructions_test.rb +5 -0
  59. data/test/mailers/unlock_instructions_test.rb +5 -0
  60. data/test/models/database_authenticatable_test.rb +2 -19
  61. data/test/omniauth/config_test.rb +56 -0
  62. data/test/omniauth/my_other_strategy.rb +5 -0
  63. data/test/omniauth/omniauth-my_strategy.rb +5 -0
  64. data/test/omniauth/url_helpers_test.rb +4 -4
  65. data/test/rails_app/config/environments/development.rb +0 -1
  66. data/test/rails_app/config/initializers/devise.rb +2 -2
  67. data/test/rails_app/config/routes.rb +4 -4
  68. data/test/rails_app/lib/shared_admin.rb +1 -0
  69. data/test/support/helpers.rb +27 -0
  70. metadata +54 -77
@@ -22,26 +22,9 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
22
22
  assert_equal email.strip, user.email
23
23
  end
24
24
 
25
- test 'find_for_authentication and filter_auth_params should not modify the conditions hash' do
26
- FilterAuthUser = Class.new(User) do
27
- def self.filter_auth_params(conditions)
28
- if conditions.is_a?(Hash) && login = conditions.delete('login')
29
- key = login.include?('@') ? :email : :username
30
- conditions[key] = login
31
- end
32
- super(conditions)
33
- end
34
- end
35
-
36
- conditions = { 'login' => 'foo@bar.com' }
37
- FilterAuthUser.find_for_authentication(conditions)
38
-
39
- assert_equal({ 'login' => 'foo@bar.com' }, conditions)
40
- end
41
-
42
- test "filter_auth_params should not convert booleans and integer to strings" do
25
+ test "param filter should not convert booleans and integer to strings" do
43
26
  conditions = { 'login' => 'foo@bar.com', "bool1" => true, "bool2" => false, "fixnum" => 123, "will_be_converted" => (1..10) }
44
- conditions = User.__send__(:filter_auth_params, conditions)
27
+ conditions = Devise::ParamFilter.new([], []).filter(conditions)
45
28
  assert_equal( { 'login' => 'foo@bar.com', "bool1" => true, "bool2" => false, "fixnum" => 123, "will_be_converted" => "1..10" }, conditions)
46
29
  end
47
30
 
@@ -0,0 +1,56 @@
1
+ require 'test_helper'
2
+
3
+ class OmniAuthConfigTest < ActiveSupport::TestCase
4
+ setup do
5
+ $: << File.dirname(__FILE__)
6
+ end
7
+
8
+ test 'strategy_name returns provider if no options given' do
9
+ config = Devise::OmniAuth::Config.new :facebook, [{}]
10
+ assert_equal :facebook, config.strategy_name
11
+ end
12
+
13
+ test 'strategy_name returns provider if no name option are given' do
14
+ config = Devise::OmniAuth::Config.new :facebook, [{ :other => :option }]
15
+ assert_equal :facebook, config.strategy_name
16
+ end
17
+
18
+ test 'returns name option when have a name' do
19
+ config = Devise::OmniAuth::Config.new :facebook, [{ :name => :github }]
20
+ assert_equal :github, config.strategy_name
21
+ end
22
+
23
+ test "finds contrib strategies" do
24
+ config = Devise::OmniAuth::Config.new :facebook, [{}]
25
+ assert_equal OmniAuth::Strategies::Facebook, config.strategy_class
26
+ end
27
+
28
+ test "finds the strategy in OmniAuth's list by name" do
29
+ NamedTestStrategy = Class.new
30
+ NamedTestStrategy.send :include, OmniAuth::Strategy
31
+ NamedTestStrategy.option :name, :the_one
32
+
33
+ config = Devise::OmniAuth::Config.new :the_one, [{}]
34
+ assert_equal NamedTestStrategy, config.strategy_class
35
+ end
36
+
37
+ test "finds the strategy in OmniAuth's list by class name" do
38
+ UnNamedTestStrategy = Class.new
39
+ UnNamedTestStrategy.send :include, OmniAuth::Strategy
40
+
41
+ config = Devise::OmniAuth::Config.new :un_named_test_strategy, [{}]
42
+ assert_equal UnNamedTestStrategy, config.strategy_class
43
+ end
44
+
45
+ test 'attempts to load an as-yet not loaded plugin' do
46
+ config = Devise::OmniAuth::Config.new :my_strategy, [{}]
47
+ config_class = config.strategy_class
48
+ assert_equal MyStrategy, config_class
49
+ end
50
+
51
+ test 'allows the user to define a custom require path' do
52
+ config = Devise::OmniAuth::Config.new :my_other_strategy, [{:require => 'my_other_strategy'}]
53
+ config_class = config.strategy_class
54
+ assert_equal MyOtherStrategy, config_class
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ require 'omniauth'
2
+
3
+ class MyOtherStrategy
4
+ include OmniAuth::Strategy
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'omniauth'
2
+
3
+ class MyStrategy
4
+ include OmniAuth::Strategy
5
+ end
@@ -40,13 +40,13 @@ class OmniAuthRoutesTest < ActionController::TestCase
40
40
  end
41
41
 
42
42
  test 'should generate authorization path with params' do
43
- assert_match "/users/auth/open_id?openid_url=http%3A%2F%2Fyahoo.com",
44
- @controller.omniauth_authorize_path(:user, :open_id, :openid_url => "http://yahoo.com")
43
+ assert_match "/users/auth/openid?openid_url=http%3A%2F%2Fyahoo.com",
44
+ @controller.omniauth_authorize_path(:user, :openid, :openid_url => "http://yahoo.com")
45
45
  end
46
46
 
47
47
  test 'should not add a "?" if no param was sent' do
48
- assert_equal "/users/auth/open_id",
49
- @controller.omniauth_authorize_path(:user, :open_id)
48
+ assert_equal "/users/auth/openid",
49
+ @controller.omniauth_authorize_path(:user, :openid)
50
50
  end
51
51
 
52
52
  test 'should set script name in the path if present' do
@@ -11,7 +11,6 @@ RailsApp::Application.configure do
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
14
- config.action_view.debug_rjs = true
15
14
  config.action_controller.perform_caching = false
16
15
 
17
16
  # Don't care if the mailer can't send
@@ -177,8 +177,8 @@ Devise.setup do |config|
177
177
 
178
178
  # ==> OmniAuth
179
179
  config.omniauth :facebook, 'APP_ID', 'APP_SECRET', :scope => 'email,offline_access'
180
- config.omniauth :open_id
181
- config.omniauth :open_id, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
180
+ config.omniauth :openid
181
+ config.omniauth :openid, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
182
182
 
183
183
  # ==> Warden configuration
184
184
  # If you want to use other strategies, that are not supported by Devise, or
@@ -46,17 +46,17 @@ Rails.application.routes.draw do
46
46
 
47
47
  # Routes for constraints testing
48
48
  devise_for :headquarters_admin, :class_name => "Admin", :path => "headquarters", :constraints => {:host => /192\.168\.1\.\d\d\d/}
49
-
49
+
50
50
  constraints(:host => /192\.168\.1\.\d\d\d/) do
51
51
  devise_for :homebase_admin, :class_name => "Admin", :path => "homebase"
52
52
  end
53
53
 
54
54
  devise_for :skip_admin, :class_name => "Admin", :skip => :all
55
-
55
+
56
56
  # Routes for format=false testing
57
57
  devise_for :htmlonly_admin, :class_name => "Admin", :skip => [:confirmations, :unlocks], :path => "htmlonly_admin", :format => false, :skip_helpers => [:confirmations, :unlocks]
58
58
  devise_for :htmlonly_users, :class_name => "User", :only => [:confirmations, :unlocks], :path => "htmlonly_users", :format => false, :skip_helpers => true
59
-
59
+
60
60
  # Other routes for routing_test.rb
61
61
  devise_for :reader, :class_name => "User", :only => :passwords
62
62
 
@@ -71,7 +71,7 @@ Rails.application.routes.draw do
71
71
  :password => "secret", :confirmation => "verification",
72
72
  :unlock => "unblock", :sign_up => "register",
73
73
  :registration => "management", :cancel => "giveup"
74
- }
74
+ }, :failure_app => lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }
75
75
  end
76
76
 
77
77
  namespace :sign_out_via, :module => "devise" do
@@ -6,4 +6,5 @@ module SharedAdmin
6
6
  :timeoutable, :recoverable, :rememberable, :lockable,
7
7
  :unlock_strategy => :time
8
8
  end
9
+
9
10
  end
@@ -51,10 +51,37 @@ class ActiveSupport::TestCase
51
51
  old_values[key] = object.send key
52
52
  object.send :"#{key}=", value
53
53
  end
54
+ clear_cached_variables(new_values)
54
55
  yield
55
56
  ensure
57
+ clear_cached_variables(new_values)
56
58
  old_values.each do |key, value|
57
59
  object.send :"#{key}=", value
58
60
  end
59
61
  end
62
+
63
+ def clear_cached_variables(options)
64
+ if options.key?(:case_insensitive_keys) || options.key?(:strip_whitespace_keys)
65
+ Devise.mappings.each do |_, mapping|
66
+ mapping.to.instance_variable_set(:@devise_param_filter, nil)
67
+ end
68
+ end
69
+ end
70
+
71
+ def with_rails_version(constants)
72
+ saved_constants = {}
73
+
74
+ constants.each do |constant, val|
75
+ saved_constants[constant] = ::Rails::VERSION.const_get constant
76
+ Kernel::silence_warnings { ::Rails::VERSION.const_set(constant, val) }
77
+ end
78
+
79
+ begin
80
+ yield
81
+ ensure
82
+ constants.each do |constant, val|
83
+ Kernel::silence_warnings { ::Rails::VERSION.const_set(constant, saved_constants[constant]) }
84
+ end
85
+ end
86
+ end
60
87
  end
metadata CHANGED
@@ -1,80 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: devise
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease:
6
- segments:
7
- - 1
8
- - 4
9
- - 9
10
- version: 1.4.9
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.0.rc1
5
+ prerelease: 6
11
6
  platform: ruby
12
- authors:
13
- - "Jos\xC3\xA9 Valim"
14
- - "Carlos Ant\xC3\xB4nio"
7
+ authors:
8
+ - José Valim
9
+ - Carlos Antônio
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2011-10-20 00:00:00 +02:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2011-11-10 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: warden
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &70284288014020 !ruby/object:Gem::Requirement
26
18
  none: false
27
- requirements:
19
+ requirements:
28
20
  - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 17
31
- segments:
32
- - 1
33
- - 0
34
- - 3
35
- version: 1.0.3
21
+ - !ruby/object:Gem::Version
22
+ version: '1.1'
36
23
  type: :runtime
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: orm_adapter
40
24
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70284288014020
26
+ - !ruby/object:Gem::Dependency
27
+ name: orm_adapter
28
+ requirement: &70284288012200 !ruby/object:Gem::Requirement
42
29
  none: false
43
- requirements:
30
+ requirements:
44
31
  - - ~>
45
- - !ruby/object:Gem::Version
46
- hash: 25
47
- segments:
48
- - 0
49
- - 0
50
- - 3
32
+ - !ruby/object:Gem::Version
51
33
  version: 0.0.3
52
34
  type: :runtime
53
- version_requirements: *id002
54
- - !ruby/object:Gem::Dependency
55
- name: bcrypt-ruby
56
35
  prerelease: false
57
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *70284288012200
37
+ - !ruby/object:Gem::Dependency
38
+ name: bcrypt-ruby
39
+ requirement: &70284288011500 !ruby/object:Gem::Requirement
58
40
  none: false
59
- requirements:
41
+ requirements:
60
42
  - - ~>
61
- - !ruby/object:Gem::Version
62
- hash: 7
63
- segments:
64
- - 3
65
- - 0
66
- version: "3.0"
43
+ - !ruby/object:Gem::Version
44
+ version: '3.0'
67
45
  type: :runtime
68
- version_requirements: *id003
46
+ prerelease: false
47
+ version_requirements: *70284288011500
69
48
  description: Flexible authentication solution for Rails with Warden
70
49
  email: contact@plataformatec.com.br
71
50
  executables: []
72
-
73
51
  extensions: []
74
-
75
52
  extra_rdoc_files: []
76
-
77
- files:
53
+ files:
78
54
  - .gitignore
79
55
  - .travis.yml
80
56
  - CHANGELOG.rdoc
@@ -110,6 +86,7 @@ files:
110
86
  - lib/devise/controllers/scoped_views.rb
111
87
  - lib/devise/controllers/shared_helpers.rb
112
88
  - lib/devise/controllers/url_helpers.rb
89
+ - lib/devise/delegator.rb
113
90
  - lib/devise/encryptors/authlogic_sha512.rb
114
91
  - lib/devise/encryptors/base.rb
115
92
  - lib/devise/encryptors/clearance_sha1.rb
@@ -145,6 +122,7 @@ files:
145
122
  - lib/devise/omniauth/url_helpers.rb
146
123
  - lib/devise/orm/active_record.rb
147
124
  - lib/devise/orm/mongoid.rb
125
+ - lib/devise/param_filter.rb
148
126
  - lib/devise/path_checker.rb
149
127
  - lib/devise/rails.rb
150
128
  - lib/devise/rails/routes.rb
@@ -167,6 +145,9 @@ files:
167
145
  - lib/generators/mongoid/devise_generator.rb
168
146
  - lib/generators/templates/README
169
147
  - lib/generators/templates/devise.rb
148
+ - lib/generators/templates/markerb/confirmation_instructions.markerb
149
+ - lib/generators/templates/markerb/reset_password_instructions.markerb
150
+ - lib/generators/templates/markerb/unlock_instructions.markerb
170
151
  - lib/generators/templates/simple_form_for/confirmations/new.html.erb
171
152
  - lib/generators/templates/simple_form_for/passwords/edit.html.erb
172
153
  - lib/generators/templates/simple_form_for/passwords/new.html.erb
@@ -216,6 +197,9 @@ files:
216
197
  - test/models/trackable_test.rb
217
198
  - test/models/validatable_test.rb
218
199
  - test/models_test.rb
200
+ - test/omniauth/config_test.rb
201
+ - test/omniauth/my_other_strategy.rb
202
+ - test/omniauth/omniauth-my_strategy.rb
219
203
  - test/omniauth/url_helpers_test.rb
220
204
  - test/orm/active_record.rb
221
205
  - test/orm/mongoid.rb
@@ -278,41 +262,31 @@ files:
278
262
  - test/support/webrat/integrations/rails.rb
279
263
  - test/test_helper.rb
280
264
  - test/test_helpers_test.rb
281
- has_rdoc: true
282
265
  homepage: http://github.com/plataformatec/devise
283
266
  licenses: []
284
-
285
267
  post_install_message:
286
268
  rdoc_options: []
287
-
288
- require_paths:
269
+ require_paths:
289
270
  - lib
290
- required_ruby_version: !ruby/object:Gem::Requirement
271
+ required_ruby_version: !ruby/object:Gem::Requirement
291
272
  none: false
292
- requirements:
293
- - - ">="
294
- - !ruby/object:Gem::Version
295
- hash: 3
296
- segments:
297
- - 0
298
- version: "0"
299
- required_rubygems_version: !ruby/object:Gem::Requirement
273
+ requirements:
274
+ - - ! '>='
275
+ - !ruby/object:Gem::Version
276
+ version: '0'
277
+ required_rubygems_version: !ruby/object:Gem::Requirement
300
278
  none: false
301
- requirements:
302
- - - ">="
303
- - !ruby/object:Gem::Version
304
- hash: 3
305
- segments:
306
- - 0
307
- version: "0"
279
+ requirements:
280
+ - - ! '>'
281
+ - !ruby/object:Gem::Version
282
+ version: 1.3.1
308
283
  requirements: []
309
-
310
284
  rubyforge_project: devise
311
- rubygems_version: 1.5.3
285
+ rubygems_version: 1.8.11
312
286
  signing_key:
313
287
  specification_version: 3
314
288
  summary: Flexible authentication solution for Rails with Warden
315
- test_files:
289
+ test_files:
316
290
  - test/controllers/helpers_test.rb
317
291
  - test/controllers/internal_helpers_test.rb
318
292
  - test/controllers/sessions_controller_test.rb
@@ -355,6 +329,9 @@ test_files:
355
329
  - test/models/trackable_test.rb
356
330
  - test/models/validatable_test.rb
357
331
  - test/models_test.rb
332
+ - test/omniauth/config_test.rb
333
+ - test/omniauth/my_other_strategy.rb
334
+ - test/omniauth/omniauth-my_strategy.rb
358
335
  - test/omniauth/url_helpers_test.rb
359
336
  - test/orm/active_record.rb
360
337
  - test/orm/mongoid.rb