devise 1.5.2 → 1.5.3

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.

@@ -1,3 +1,10 @@
1
+ == 1.5.3
2
+
3
+ * bug fix
4
+ * Ensure delegator converts scope to symbol (by github.com/dmitriy-kiriyenko)
5
+ * Ensure passing :format => false to devise_for is not permanent
6
+ * Ensure path checker does not check invalid routes
7
+
1
8
  == 1.5.2
2
9
 
3
10
  * enhancements
@@ -8,9 +8,9 @@ module Devise
8
8
  def failure_app(env)
9
9
  app = env["warden.options"] &&
10
10
  (scope = env["warden.options"][:scope]) &&
11
- Devise.mappings[scope].failure_app
11
+ Devise.mappings[scope.to_sym].failure_app
12
12
 
13
13
  app || Devise::FailureApp
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -23,8 +23,7 @@ module Devise
23
23
  #
24
24
  class Mapping #:nodoc:
25
25
  attr_reader :singular, :scoped_path, :path, :controllers, :path_names,
26
- :class_name, :sign_out_via, :format, :used_routes, :used_helpers,
27
- :constraints, :defaults, :failure_app
26
+ :class_name, :sign_out_via, :format, :used_routes, :used_helpers, :failure_app
28
27
 
29
28
  alias :name :singular
30
29
 
@@ -64,8 +63,6 @@ module Devise
64
63
  default_failure_app(options)
65
64
  default_controllers(options)
66
65
  default_path_names(options)
67
- default_constraints(options)
68
- default_defaults(options)
69
66
  default_used_route(options)
70
67
  default_used_helpers(options)
71
68
  end
@@ -12,7 +12,8 @@ module Devise
12
12
  end
13
13
 
14
14
  def signing_out?
15
- @current_path == send("destroy_#{@scope}_session_path")
15
+ route = "destroy_#{@scope}_session_path"
16
+ respond_to?(route) && @current_path == send(route)
16
17
  end
17
18
  end
18
19
  end
@@ -185,7 +185,7 @@ module ActionDispatch::Routing
185
185
  options[:path_names] = (@scope[:path_names] || {}).merge(options[:path_names] || {})
186
186
  options[:constraints] = (@scope[:constraints] || {}).merge(options[:constraints] || {})
187
187
  options[:defaults] = (@scope[:defaults] || {}).merge(options[:defaults] || {})
188
- @scope[:options] = (@scope[:options] || {}).merge({:format => false}) if options[:format] == false
188
+ options[:options] = (@scope[:options] || {}).merge({:format => false}) if options[:format] == false
189
189
 
190
190
  resources.map!(&:to_sym)
191
191
 
@@ -208,7 +208,7 @@ module ActionDispatch::Routing
208
208
 
209
209
  devise_scope mapping.name do
210
210
  yield if block_given?
211
- with_devise_exclusive_scope mapping.fullpath, mapping.name, mapping.constraints, mapping.defaults do
211
+ with_devise_exclusive_scope mapping.fullpath, mapping.name, options do
212
212
  routes.each { |mod| send("devise_#{mod}", mapping, mapping.controllers) }
213
213
  end
214
214
  end
@@ -368,12 +368,15 @@ module ActionDispatch::Routing
368
368
  @scope[:path] = path
369
369
  end
370
370
 
371
- def with_devise_exclusive_scope(new_path, new_as, new_constraints, new_defaults) #:nodoc:
372
- old_as, old_path, old_module, old_constraints, old_defaults = @scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults]
373
- @scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults] = new_as, new_path, nil, new_constraints, new_defaults
371
+ def with_devise_exclusive_scope(new_path, new_as, options) #:nodoc:
372
+ old_as, old_path, old_module, old_constraints, old_defaults, old_options =
373
+ *@scope.values_at(:as, :path, :module, :constraints, :defaults, :options)
374
+ @scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults], @scope[:options] =
375
+ new_as, new_path, nil, *options.values_at(:constraints, :defaults, :options)
374
376
  yield
375
377
  ensure
376
- @scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults] = old_as, old_path, old_module, old_constraints, old_defaults
378
+ @scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults], @scope[:options] =
379
+ old_as, old_path, old_module, old_constraints, old_defaults, old_options
377
380
  end
378
381
 
379
382
  def raise_no_devise_method_error!(klass) #:nodoc:
@@ -1,3 +1,3 @@
1
1
  module Devise
2
- VERSION = "1.5.2".freeze
2
+ VERSION = "1.5.3".freeze
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+
3
+ class DelegatorTest < ActiveSupport::TestCase
4
+ def delegator
5
+ Devise::Delegator.new
6
+ end
7
+
8
+ test 'failure_app returns default failure app if no warden options in env' do
9
+ assert_equal Devise::FailureApp, delegator.failure_app({})
10
+ end
11
+
12
+ test 'failure_app returns default failure app if no scope in warden options' do
13
+ assert_equal Devise::FailureApp, delegator.failure_app({"warden.options" => {}})
14
+ end
15
+
16
+ test 'failure_app returns associated failure app by scope in the given environment' do
17
+ assert_kind_of Proc, delegator.failure_app({"warden.options" => {:scope => "manager"}})
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class PathCheckerTest < ActiveSupport::TestCase
4
+ test 'check if sign out path matches' do
5
+ path_checker = Devise::PathChecker.new({"PATH_INFO" => "/users/sign_out"}, :user)
6
+ assert path_checker.signing_out?
7
+
8
+ path_checker = Devise::PathChecker.new({"PATH_INFO" => "/users/sign_in"}, :user)
9
+ assert_not path_checker.signing_out?
10
+ end
11
+
12
+ test 'considers script name' do
13
+ path_checker = Devise::PathChecker.new({"SCRIPT_NAME" => "/users", "PATH_INFO" => "/sign_out"}, :user)
14
+ assert path_checker.signing_out?
15
+ end
16
+
17
+ test 'ignores invalid routes' do
18
+ path_checker = Devise::PathChecker.new({"PATH_INFO" => "/users/sign_in"}, :omg)
19
+ assert_not path_checker.signing_out?
20
+ end
21
+ end
@@ -225,6 +225,10 @@ class CustomizedRoutingTest < ActionController::TestCase
225
225
  assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => '/htmlonly_users/unlock.xml', :method => :get})
226
226
  end
227
227
  end
228
+
229
+ test 'map with format false is not permanent' do
230
+ assert_equal "/set.xml", @routes.url_helpers.set_path(:xml)
231
+ end
228
232
  end
229
233
 
230
234
  class ScopedRoutingTest < ActionController::TestCase
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-30 00:00:00.000000000 Z
13
+ date: 2011-12-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: warden
17
- requirement: &70351586247440 !ruby/object:Gem::Requirement
17
+ requirement: &2151820240 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '1.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70351586247440
25
+ version_requirements: *2151820240
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: orm_adapter
28
- requirement: &70351586246900 !ruby/object:Gem::Requirement
28
+ requirement: &2151818600 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70351586246900
36
+ version_requirements: *2151818600
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bcrypt-ruby
39
- requirement: &70351586246440 !ruby/object:Gem::Requirement
39
+ requirement: &2151816740 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '3.0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70351586246440
47
+ version_requirements: *2151816740
48
48
  description: Flexible authentication solution for Rails with Warden
49
49
  email: contact@plataformatec.com.br
50
50
  executables: []
@@ -159,6 +159,7 @@ files:
159
159
  - test/controllers/internal_helpers_test.rb
160
160
  - test/controllers/sessions_controller_test.rb
161
161
  - test/controllers/url_helpers_test.rb
162
+ - test/delegator_test.rb
162
163
  - test/devise_test.rb
163
164
  - test/encryptors_test.rb
164
165
  - test/failure_app_test.rb
@@ -201,6 +202,7 @@ files:
201
202
  - test/omniauth/url_helpers_test.rb
202
203
  - test/orm/active_record.rb
203
204
  - test/orm/mongoid.rb
205
+ - test/path_checker_test.rb
204
206
  - test/rails_app/Rakefile
205
207
  - test/rails_app/app/active_record/admin.rb
206
208
  - test/rails_app/app/active_record/shim.rb
@@ -280,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
282
  version: '0'
281
283
  requirements: []
282
284
  rubyforge_project: devise
283
- rubygems_version: 1.8.11
285
+ rubygems_version: 1.8.10
284
286
  signing_key:
285
287
  specification_version: 3
286
288
  summary: Flexible authentication solution for Rails with Warden
@@ -289,6 +291,7 @@ test_files:
289
291
  - test/controllers/internal_helpers_test.rb
290
292
  - test/controllers/sessions_controller_test.rb
291
293
  - test/controllers/url_helpers_test.rb
294
+ - test/delegator_test.rb
292
295
  - test/devise_test.rb
293
296
  - test/encryptors_test.rb
294
297
  - test/failure_app_test.rb
@@ -331,6 +334,7 @@ test_files:
331
334
  - test/omniauth/url_helpers_test.rb
332
335
  - test/orm/active_record.rb
333
336
  - test/orm/mongoid.rb
337
+ - test/path_checker_test.rb
334
338
  - test/rails_app/Rakefile
335
339
  - test/rails_app/app/active_record/admin.rb
336
340
  - test/rails_app/app/active_record/shim.rb