public
Rubygem
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/thoughtbot/shoulda.git
Updated should_protect_attributes to fix issue when attr_protected is used and 
attribute is missing.
boone (author)
Wed Sep 03 14:39:58 -0700 2008
Ryan McGeary (committer)
Sun Sep 14 18:19:44 -0700 2008
commit  2d2c1a477e69e5c601f9d7f77c52a5a8cef6b8f1
tree    9cac5d3c58dc910a1fb1a0b619a59a3c94b18bf4
parent  ebd37ea2d0aca9e41319e8217dc159dab9a82b34
...
118
119
120
121
 
 
122
123
124
...
118
119
120
 
121
122
123
124
125
0
@@ -118,7 +118,8 @@ module ThoughtBot # :nodoc:
0
               protected = klass.protected_attributes || []
0
               accessible = klass.accessible_attributes || []
0
 
0
-              assert protected.include?(attribute.to_s) || !accessible.include?(attribute.to_s),
0
+              assert protected.include?(attribute.to_s) ||
0
+                (!accessible.empty? && !accessible.include?(attribute.to_s)),
0
                      (accessible.empty? ?
0
                        "#{klass} is protecting #{protected.to_a.to_sentence}, but not #{attribute}." :
0
                        "#{klass} has made #{attribute} accessible")

Comments