public
Fork of thoughtbot/shoulda
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/boone/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
commit  9065d991580e77239bf78159153b51380b1b3433
tree    4d7f97b10db97e5c025bdf637aa14b289f4334af
parent  0def06d2b9ca43de86cc9ecc06f11ea64c565b2f
...
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