Permalink
Browse files

Backport ActiveModel 3.2 fix

Improve test coverage for whitelisted attribute names
  • Loading branch information...
1 parent 24eeae2 commit cf9218da27098ab23f1436fd54652a0f54b30f6c @cgriego committed Jun 27, 2012
Showing with 13 additions and 0 deletions.
  1. +5 −0 lib/active_attr/attributes.rb
  2. +8 −0 spec/functional/active_attr/attributes_spec.rb
@@ -266,6 +266,11 @@ def attributes=(attributes)
@attributes = attributes
end
+ # Overrides ActiveModel::AttributeMethods to backport 3.2 fix
+ def instance_method_already_implemented?(method_name)
+ generated_attribute_methods.method_defined?(method_name)
+ end
+
private
# Expand an attribute name into its generated methods names
@@ -218,6 +218,14 @@ def self.name
it ".attribute! does not raise" do
expect { model_class.attribute!(attribute_name) }.not_to raise_error
end
+
+ it "can be set and get" do
+ model_class.attribute attribute_name
+ model = model_class.new
+ value = mock
+ model.send "#{attribute_name}=", value
+ model.send(attribute_name).should equal value
+ end
end
shared_examples "defining dangerous attributes" do

0 comments on commit cf9218d

Please sign in to comment.