Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Backport ActiveModel 3.2 fix

Improve test coverage for whitelisted attribute names
  • Loading branch information...
commit cf9218da27098ab23f1436fd54652a0f54b30f6c 1 parent 24eeae2
@cgriego authored
View
5 lib/active_attr/attributes.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
View
8 spec/functional/active_attr/attributes_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.