Browse files

Merge pull request #18 from arunagw/master

Known attributes should be uniq.
  • Loading branch information...
2 parents 4095921 + 425ec90 commit 2e29f680ca6a66bfd66fe5fde82c9c0823fc4cea @jeremy jeremy committed Apr 18, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/active_resource/base.rb
  2. +6 −0 test/cases/base/schema_test.rb
View
2 lib/active_resource/base.rb
@@ -1019,7 +1019,7 @@ def schema
# gathered from the provided <tt>schema</tt>, or from the attributes
# set on this instance after it has been fetched from the remote system.
def known_attributes
- self.class.known_attributes + self.attributes.keys.map(&:to_s)
+ (self.class.known_attributes + self.attributes.keys.map(&:to_s)).uniq
end
View
6 test/cases/base/schema_test.rb
@@ -406,6 +406,12 @@ def teardown
assert known_attrs.include?(the_attr), "should have found schema attr: #{the_attr} in known attributes, but only had: #{known_attrs.inspect}"
end
end
+
+ test 'known attributes should be unique' do
+ new_schema = {'age' => 'integer', 'name' => 'string'}
+ Person.schema = new_schema
+ assert_equal Person.new(:age => 20, :name => 'Matz').known_attributes, ['age', 'name']
+ end
end

0 comments on commit 2e29f68

Please sign in to comment.