Skip to content

Commit

Permalink
Cleanup attribute setting in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Turner committed Aug 26, 2011
1 parent 8014c6d commit 6f9ba67
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions spec/models/test_document.rb
Expand Up @@ -21,10 +21,11 @@ module InstanceMethods

def test_set_attributes(attrs)
attrs.each do |key, val|
key = key.to_s
if Mongoid.allow_dynamic_fields ||
fields.keys.any? { |k| k.to_s == key.to_s } ||
associations.any? { |a| a[0].to_s == key.to_s || a[1].foreign_key.to_s == key.to_s }
@attributes[key] = val
fields.keys.any? { |k| k.to_s == key } ||
associations.any? { |a| a[0].to_s == key || a[1].foreign_key.to_s == key }
@attributes[key] = self.typed_value_for(key, val)
end
end
self
Expand Down

0 comments on commit 6f9ba67

Please sign in to comment.