devise 2.0.1 → 2.0.2

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,7 +1,19 @@
1
- == 2.0.1
1
+ == 2.0.2
2
2
 
3
3
  Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0
4
4
 
5
+ * enhancements
6
+ * Add devise_i18n_options to customize I18n message
7
+
8
+ * bug fix
9
+ * Ensure Devise.available_router_name defaults to :main_app
10
+ * Set autocomplete to off for password on edit forms
11
+ * Better error messages in case a trackable model can't be saved
12
+ * Show a warning in case someone gives a pluralized name to devise generator
13
+ * Fix test behavior for rspec subject requests (by @sj26)
14
+
15
+ == 2.0.1
16
+
5
17
  * enhancements
6
18
  * Improved error messages on deprecation warnings
7
19
  * Hide Devise's internal generators from `rails g` command
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devise (2.0.0)
4
+ devise (2.0.1)
5
5
  bcrypt-ruby (~> 3.0)
6
6
  orm_adapter (~> 0.0.3)
7
7
  railties (~> 3.1)
data/README.md CHANGED
@@ -89,11 +89,11 @@ Once you have solidified your understanding of Rails and authentication mechanis
89
89
 
90
90
  ## Getting started
91
91
 
92
- Devise 2.0 works with Rails 3.1 onwards. You can install it with:
92
+ Devise 2.0 works with Rails 3.1 onwards. You can add it to your Gemfile with:
93
93
 
94
- ```console
95
- gem install devise
96
- ```
94
+ gem 'devise'
95
+
96
+ Run the bundle command to install it.
97
97
 
98
98
  After you install Devise and add it to your Gemfile, you need to run the generator:
99
99
 
@@ -5,7 +5,7 @@ class DeviseController < Devise.parent_controller.constantize
5
5
  helper DeviseHelper
6
6
 
7
7
  helpers = %w(resource scope_name resource_name signed_in_resource
8
- resource_class devise_mapping devise_controller?)
8
+ resource_class devise_mapping)
9
9
  hide_action *helpers
10
10
  helper_method *helpers
11
11
 
@@ -38,11 +38,6 @@ class DeviseController < Devise.parent_controller.constantize
38
38
  @devise_mapping ||= request.env["devise.mapping"]
39
39
  end
40
40
 
41
- # Overwrites devise_controller? to return true
42
- def devise_controller?
43
- true
44
- end
45
-
46
41
  protected
47
42
 
48
43
  # Checks whether it's a devise mapped resource or not.
@@ -136,6 +131,7 @@ MESSAGE
136
131
  options[:scope] = "devise.#{controller_name}"
137
132
  options[:default] = Array(options[:default]).unshift(kind.to_sym)
138
133
  options[:resource_name] = resource_name
134
+ options = devise_i18n_options(options) if respond_to?(:devise_i18n_options, true)
139
135
  message = I18n.t("#{resource_name}.#{kind}", options)
140
136
  flash[key] = message if message.present?
141
137
  end
@@ -160,7 +156,7 @@ MESSAGE
160
156
 
161
157
  # Override prefixes to consider the scoped view.
162
158
  def _prefixes #:nodoc:
163
- @_prefixes ||= if self.class.scoped_views?
159
+ @_prefixes ||= if self.class.scoped_views? && devise_mapping
164
160
  super.unshift("#{devise_mapping.scoped_path}/#{controller_name}")
165
161
  else
166
162
  super
@@ -7,7 +7,7 @@
7
7
  <%= f.email_field :email %></div>
8
8
 
9
9
  <div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
10
- <%= f.password_field :password %></div>
10
+ <%= f.password_field :password, :autocomplete => "off" %></div>
11
11
 
12
12
  <div><%= f.label :password_confirmation %><br />
13
13
  <%= f.password_field :password_confirmation %></div>
@@ -299,6 +299,10 @@ module Devise
299
299
  end
300
300
  end
301
301
 
302
+ def self.available_router_name
303
+ router_name || :main_app
304
+ end
305
+
302
306
  def self.omniauth_providers
303
307
  omniauth_configs.keys
304
308
  end
@@ -75,9 +75,9 @@ module Devise
75
75
  # the controllers defined inside devise. Useful if you want to apply a before
76
76
  # filter to all controllers, except the ones in devise:
77
77
  #
78
- # before_filter :my_filter, :unless => { |c| c.devise_controller? }
78
+ # before_filter :my_filter, :unless => :devise_controller?
79
79
  def devise_controller?
80
- false
80
+ is_a?(DeviseController)
81
81
  end
82
82
 
83
83
  # Tell warden that params authentication is allowed for that specific page.
@@ -60,7 +60,7 @@ module Devise
60
60
  private
61
61
 
62
62
  def _devise_route_context
63
- @_devise_route_context ||= send(Devise.router_name)
63
+ @_devise_route_context ||= send(Devise.available_router_name)
64
64
  end
65
65
  end
66
66
  end
@@ -89,7 +89,7 @@ module Devise
89
89
  route = :"new_#{scope}_session_path"
90
90
  opts[:format] = request_format unless skip_format?
91
91
 
92
- context = send(Devise.router_name)
92
+ context = send(Devise.available_router_name)
93
93
 
94
94
  if context.respond_to?(route)
95
95
  context.send(route, opts)
@@ -23,7 +23,8 @@ module Devise
23
23
  self.sign_in_count ||= 0
24
24
  self.sign_in_count += 1
25
25
 
26
- save(:validate => false)
26
+ save(:validate => false) or raise "Devise trackable could not save #{inspect}." \
27
+ "Please make sure a model using trackable can be saved at sign in."
27
28
  end
28
29
  end
29
30
  end
@@ -9,13 +9,13 @@ module ActionDispatch::Routing
9
9
 
10
10
  @devise_finalized ||= begin
11
11
  if Devise.router_name.nil? && self != Rails.application.try(:routes)
12
- warn "[Devise] We have detected that you are using devise_for inside engine routes. " \
12
+ warn "[DEVISE] We have detected that you are using devise_for inside engine routes. " \
13
13
  "In this case, you probably want to set Devise.router_name = MOUNT_POINT, where " \
14
14
  "MOUNT_POINT is a symbol representing where this engine will be mounted at. For " \
15
- "now, Devise will default the mount point to :main_app."
15
+ "now Devise will default the mount point to :main_app. You can explicitly set it" \
16
+ " to :main_app as well in case you want to keep the current behavior."
16
17
  end
17
18
 
18
- Devise.router_name ||= :main_app
19
19
  Devise.configure_warden!
20
20
  Devise.regenerate_helpers!
21
21
  true
@@ -15,9 +15,8 @@ module Devise
15
15
 
16
16
  # Override process to consider warden.
17
17
  def process(*)
18
- result = nil
19
- _catch_warden { result = super }
20
- result
18
+ # Make sure we always return @response, a la ActionController::TestCase::Behaviour#process, even if warden interrupts
19
+ _catch_warden { super } || @response
21
20
  end
22
21
 
23
22
  # We need to setup the environment variables and the response in the controller.
@@ -66,6 +65,8 @@ module Devise
66
65
 
67
66
  protected
68
67
 
68
+ # Catch warden continuations and handle like the middleware would.
69
+ # Returns nil when interrupted, otherwise the normal result of the block.
69
70
  def _catch_warden(&block)
70
71
  result = catch(:warden, &block)
71
72
 
@@ -1,3 +1,3 @@
1
1
  module Devise
2
- VERSION = "2.0.1".freeze
2
+ VERSION = "2.0.2".freeze
3
3
  end
@@ -1,6 +1,8 @@
1
1
  module Devise
2
2
  module Generators
3
3
  class DeviseGenerator < Rails::Generators::NamedBase
4
+ include Rails::Generators::ResourceHelpers
5
+
4
6
  namespace "devise"
5
7
  source_root File.expand_path("../templates", __FILE__)
6
8
 
@@ -1,15 +1,14 @@
1
-
2
1
  ===============================================================================
3
2
 
4
3
  Some setup you must do manually if you haven't yet:
5
4
 
6
- 1. Setup default url options for your specific environment. Here is an
7
- example of development environment:
5
+ 1. Ensure you have defined default url options in your environments files. Here
6
+ is an example of default_url_options appropriate for a development environment
7
+ in config/environments/development.rb:
8
8
 
9
9
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
10
10
 
11
- This is a required Rails configuration. In production it must be the
12
- actual host of your application
11
+ In production, :host should be set to the actual host of your application.
13
12
 
14
13
  2. Ensure you have defined root_url to *something* in your config/routes.rb.
15
14
  For example:
@@ -5,7 +5,7 @@
5
5
 
6
6
  <div class="inputs">
7
7
  <%= f.input :email, :required => true, :autofocus => true %>
8
- <%= f.input :password, :hint => "leave it blank if you don't want to change it", :required => false %>
8
+ <%= f.input :password, :autocomplete => "off", :hint => "leave it blank if you don't want to change it", :required => false %>
9
9
  <%= f.input :password_confirmation, :required => false %>
10
10
  <%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %>
11
11
  </div>
@@ -71,19 +71,21 @@ class HelpersTest < ActionController::TestCase
71
71
  end
72
72
 
73
73
  test 'does not issue blank flash messages' do
74
- MyController.send(:public, :set_flash_message)
75
74
  I18n.stubs(:t).returns(' ')
76
- @controller.set_flash_message :notice, :send_instructions
75
+ @controller.send :set_flash_message, :notice, :send_instructions
77
76
  assert flash[:notice].nil?
78
- MyController.send(:protected, :set_flash_message)
79
77
  end
80
78
 
81
79
  test 'issues non-blank flash messages normally' do
82
- MyController.send(:public, :set_flash_message)
83
80
  I18n.stubs(:t).returns('non-blank')
84
- @controller.set_flash_message :notice, :send_instructions
85
- assert flash[:notice] == 'non-blank'
86
- MyController.send(:protected, :set_flash_message)
81
+ @controller.send :set_flash_message, :notice, :send_instructions
82
+ assert_equal 'non-blank', flash[:notice]
83
+ end
84
+
85
+ test 'uses custom i18n options' do
86
+ @controller.stubs(:devise_i18n_options).returns(:default => "devise custom options")
87
+ @controller.send :set_flash_message, :notice, :invalid_i18n_messagesend_instructions
88
+ assert_equal 'devise custom options', flash[:notice]
87
89
  end
88
90
 
89
91
  test 'navigational_formats not returning a wild card' do
metadata CHANGED
@@ -1,67 +1,94 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: devise
3
- version: !ruby/object:Gem::Version
4
- version: 2.0.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
5
  prerelease:
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 2
10
+ version: 2.0.2
6
11
  platform: ruby
7
- authors:
8
- - José Valim
9
- - Carlos Antônio
12
+ authors:
13
+ - "Jos\xC3\xA9 Valim"
14
+ - "Carlos Ant\xC3\xB4nio"
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2012-02-09 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2012-02-15 00:00:00 +01:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
16
23
  name: warden
17
- requirement: &2152591440 !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
18
26
  none: false
19
- requirements:
27
+ requirements:
20
28
  - - ~>
21
- - !ruby/object:Gem::Version
22
- version: '1.1'
29
+ - !ruby/object:Gem::Version
30
+ hash: 13
31
+ segments:
32
+ - 1
33
+ - 1
34
+ version: "1.1"
23
35
  type: :runtime
24
- prerelease: false
25
- version_requirements: *2152591440
26
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
27
38
  name: orm_adapter
28
- requirement: &2152588140 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
29
41
  none: false
30
- requirements:
42
+ requirements:
31
43
  - - ~>
32
- - !ruby/object:Gem::Version
44
+ - !ruby/object:Gem::Version
45
+ hash: 25
46
+ segments:
47
+ - 0
48
+ - 0
49
+ - 3
33
50
  version: 0.0.3
34
51
  type: :runtime
35
- prerelease: false
36
- version_requirements: *2152588140
37
- - !ruby/object:Gem::Dependency
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
38
54
  name: bcrypt-ruby
39
- requirement: &2152586020 !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
40
57
  none: false
41
- requirements:
58
+ requirements:
42
59
  - - ~>
43
- - !ruby/object:Gem::Version
44
- version: '3.0'
60
+ - !ruby/object:Gem::Version
61
+ hash: 7
62
+ segments:
63
+ - 3
64
+ - 0
65
+ version: "3.0"
45
66
  type: :runtime
46
- prerelease: false
47
- version_requirements: *2152586020
48
- - !ruby/object:Gem::Dependency
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
49
69
  name: railties
50
- requirement: &2152584880 !ruby/object:Gem::Requirement
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
51
72
  none: false
52
- requirements:
73
+ requirements:
53
74
  - - ~>
54
- - !ruby/object:Gem::Version
55
- version: '3.1'
75
+ - !ruby/object:Gem::Version
76
+ hash: 5
77
+ segments:
78
+ - 3
79
+ - 1
80
+ version: "3.1"
56
81
  type: :runtime
57
- prerelease: false
58
- version_requirements: *2152584880
82
+ version_requirements: *id004
59
83
  description: Flexible authentication solution for Rails with Warden
60
84
  email: contact@plataformatec.com.br
61
85
  executables: []
86
+
62
87
  extensions: []
88
+
63
89
  extra_rdoc_files: []
64
- files:
90
+
91
+ files:
65
92
  - .gitignore
66
93
  - .travis.yml
67
94
  - CHANGELOG.rdoc
@@ -274,31 +301,41 @@ files:
274
301
  - test/support/webrat/integrations/rails.rb
275
302
  - test/test_helper.rb
276
303
  - test/test_helpers_test.rb
304
+ has_rdoc: true
277
305
  homepage: http://github.com/plataformatec/devise
278
306
  licenses: []
307
+
279
308
  post_install_message:
280
309
  rdoc_options: []
281
- require_paths:
310
+
311
+ require_paths:
282
312
  - lib
283
- required_ruby_version: !ruby/object:Gem::Requirement
313
+ required_ruby_version: !ruby/object:Gem::Requirement
284
314
  none: false
285
- requirements:
286
- - - ! '>='
287
- - !ruby/object:Gem::Version
288
- version: '0'
289
- required_rubygems_version: !ruby/object:Gem::Requirement
315
+ requirements:
316
+ - - ">="
317
+ - !ruby/object:Gem::Version
318
+ hash: 3
319
+ segments:
320
+ - 0
321
+ version: "0"
322
+ required_rubygems_version: !ruby/object:Gem::Requirement
290
323
  none: false
291
- requirements:
292
- - - ! '>='
293
- - !ruby/object:Gem::Version
294
- version: '0'
324
+ requirements:
325
+ - - ">="
326
+ - !ruby/object:Gem::Version
327
+ hash: 3
328
+ segments:
329
+ - 0
330
+ version: "0"
295
331
  requirements: []
332
+
296
333
  rubyforge_project: devise
297
- rubygems_version: 1.8.15
334
+ rubygems_version: 1.5.3
298
335
  signing_key:
299
336
  specification_version: 3
300
337
  summary: Flexible authentication solution for Rails with Warden
301
- test_files:
338
+ test_files:
302
339
  - test/controllers/helpers_test.rb
303
340
  - test/controllers/internal_helpers_test.rb
304
341
  - test/controllers/sessions_controller_test.rb