Thibaud Guillaume-Gentil
unread,Feb 10, 2009, 10:30:06 AM2/10/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Remarkable
Hi,
I want to fix allow_mass_assignment_of (when used with
attr_accessible) and submit a patch via GitHub with related new specs,
but I can't figure out where ActiveRecord models are defined for
testing (it's magic?) for example:
User has it { should allow_mass_assignment_of(:name, :age) }, but
where User model has "attr_accessible :name, :age" defined?
It will be great, if you can explain me how it's work. :-)
The bug is in allow_mass_assignment_of_matcher.rb at line 30 & 31
return true unless protected.include?(attribute.to_s)
return true unless accessible.empty? || accessible.include?
(attribute.to_s)
should be
return true if !protected.empty? && !protected.include?
(attribute.to_s)
return true if !accessible.empty? && accessible.include?
(attribute.to_s)
otherwise it will always return true if attr_protected is not defined.
There's certainly the same kind of bug in the deprecated
protect_attributes_matcher.rb.