Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/virtus/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def attributes
def attributes=(attributes)
attribute_set.set(self, attributes)
end
alias_method :update_attributes, :attributes=

end # MassAssignment

Expand Down
6 changes: 6 additions & 0 deletions spec/integration/mass_assignment_with_accessors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def _id=(value)
expect(subject.subcategory).to eq('Furniture')
end

specify 'can be updated with #update_attributes' do
subject.update_attributes({:categories => ['Home', 'Furniture']})
expect(subject.category).to eq('Home')
expect(subject.subcategory).to eq('Furniture')
end

specify 'respects accessor visibility' do
expect(subject.id).not_to eq(100)
end
Expand Down