Skip to content
Browse files

known attributes should be uniq

  • Loading branch information...
1 parent 4095921 commit 425ec90663a6d4ceb9467b662a017b0e9fded1ac @arunagw arunagw 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 425ec90

Please sign in to comment.
Something went wrong with that request. Please try again.