Skip to content
This repository
Browse code

Use a better method name to check the requirement of password confirm…

…ation

Also improve changelog entries related to secure password to proper
highlight.
  • Loading branch information...
commit 3a33e8ea85f025d5ba575318583d1038889a2ba1 1 parent 017b0fb
Carlos Antonio da Silva authored January 07, 2014
6  activemodel/CHANGELOG.md
Source Rendered
@@ -19,8 +19,8 @@
19 19
 
20 20
     *Bogdan Gusiev*
21 21
 
22  
-*   Fix has_secure_password. `password_confirmation` validations are triggered
23  
-    even if no `password_confirmation` is set.
  22
+*   Fix `has_secure_password` not to trigger `password_confirmation` validations
  23
+    if no `password_confirmation` is set.
24 24
 
25 25
     *Vladimir Kiselev*
26 26
 
@@ -33,7 +33,7 @@
33 33
 
34 34
     *Charles Bergeron*
35 35
 
36  
-*   Fix regression in has_secure_password. When a password is set, but a
  36
+*   Fix regression in `has_secure_password`. When a password is set, but a
37 37
     confirmation is an empty string, it would incorrectly save.
38 38
 
39 39
     *Steve Klabnik* and *Phillip Calvin*
10  activemodel/lib/active_model/secure_password.rb
@@ -57,9 +57,9 @@ def has_secure_password(options = {})
57 57
         include InstanceMethodsOnActivation
58 58
 
59 59
         if options.fetch(:validations, true)
60  
-          validates_confirmation_of :password, if: :should_confirm_password?
  60
+          validates_confirmation_of :password, if: :password_confirmation_required?
61 61
           validates_presence_of     :password, on: :create
62  
-          validates_presence_of     :password_confirmation, if: :should_confirm_password?
  62
+          validates_presence_of     :password_confirmation, if: :password_confirmation_required?
63 63
 
64 64
           before_create { raise "Password digest missing on new record" if password_digest.blank? }
65 65
         end
@@ -113,9 +113,9 @@ def password_confirmation=(unencrypted_password)
113 113
 
114 114
       private
115 115
 
116  
-      def should_confirm_password?
117  
-        password_confirmation && password.present?
118  
-      end
  116
+        def password_confirmation_required?
  117
+          password_confirmation && password.present?
  118
+        end
119 119
     end
120 120
   end
121 121
 end

0 notes on commit 3a33e8e

Please sign in to comment.
Something went wrong with that request. Please try again.