Skip to content

Commit

Permalink
Enforce attr_accessible on #attributes=
Browse files Browse the repository at this point in the history
Closes #342
  • Loading branch information
bkeepers committed Nov 7, 2011
1 parent 87afcda commit 3b61c4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mongo_mapper/plugins/accessible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def attr_accessible(*attrs)
end

module InstanceMethods
def assign(attrs={})
def attributes=(attrs={})
super(filter_inaccessible_attrs(attrs))
end

Expand Down
6 changes: 6 additions & 0 deletions test/functional/test_accessible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class AccessibleTest < Test::Unit::TestCase
@doc.admin.should be_false
end

should "ignore inaccessible attribute on #attributes=" do
@doc.attributes = {:name => 'Ren Hoek', :admin => true}
@doc.name.should == 'Ren Hoek'
@doc.admin.should be_false
end

should "be indifferent to whether the accessible keys are strings or symbols" do
@doc.update_attributes!("name" => 'Stimpson J. Cat', "admin" => true)
@doc.name.should == 'Stimpson J. Cat'
Expand Down

0 comments on commit 3b61c4e

Please sign in to comment.