Module: EvelpidonTestHelpers::ActiveModel::MassAssignment::Assertions
- Included in:
- ActiveSupport::TestCase
- Defined in:
- lib/evelpidon_test_helpers/active_model/mass_assignment.rb
Instance Method Summary collapse
-
#assert_attribute_protected(model, attribute, value = "foo") ⇒ Object
Asserts that the given
attribute
on the givenmodel
cannot be assigned through mass-assignment (like +update_attributes).
Instance Method Details
#assert_attribute_protected(model, attribute, value = "foo") ⇒ Object
Asserts that the given attribute
on the given model
cannot be assigned through mass-assignment (like +update_attributes).
11 12 13 14 15 16 17 18 |
# File 'lib/evelpidon_test_helpers/active_model/mass_assignment.rb', line 11 def assert_attribute_protected(model, attribute, value = "foo") model.send("#{attribute}=", nil) model.attributes = {attribute => value} assert_nil model.send(attribute), "#{attribute} could be set through 'update_attributes' call" model.send("#{attribute}=", value) assert_equal value, model.send(attribute) end |