test/factory.rb in encrypted_attributes-0.1.2 vs test/factory.rb in encrypted_attributes-0.1.3
- old
+ new
@@ -11,15 +11,19 @@
# Get valid attributes for the model
def valid_attributes_for(model, attributes = {})
name = model.to_s.underscore
send("#{name}_attributes", attributes)
+ attributes.stringify_keys!
attributes
end
# Build an unsaved record
def new_record(model, *args)
- model.new(valid_attributes_for(model, *args))
+ attributes = valid_attributes_for(model, *args)
+ record = model.new(attributes)
+ attributes.each {|attr, value| record.send("#{attr}=", value) if model.accessible_attributes && !model.accessible_attributes.include?(attr) || model.protected_attributes && model.protected_attributes.include?(attr)}
+ record
end
# Build and save/reload a record
def create_record(model, *args)
record = new_record(model, *args)