allow_mass_assignment_of bug and Testing

1 view
Skip to first unread message

Thibaud Guillaume-Gentil

unread,
Feb 10, 2009, 10:30:06 AM2/10/09
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.


José Valim

unread,
Feb 10, 2009, 10:40:58 AM2/10/09
to remarka...@googlegroups.com
Thibaud,

Unfortunately, Dr. Nic is not on Remarkable core, so no magic models yet! :)

The application used for tests is under spec/rails_root. It's currently using Rails 2.2.2, so be sure that it's installed!

And we already checking this, thanks! :)

José Valim

unread,
Feb 10, 2009, 11:04:11 AM2/10/09
to Remarkable

Thibaud Guillaume-Gentil

unread,
Feb 10, 2009, 1:20:56 PM2/10/09
to Remarkable
Great! Next time, I'll make the patch myself :-) Thanks

On Feb 10, 5:04 pm, José Valim <jose.va...@gmail.com> wrote:
> Just commited:
>
> http://github.com/carlosbrando/remarkable/commit/4a1b7f37a69f777a0f77...
Reply all
Reply to author
Forward
0 new messages