rails/rails — pull request #7145 by juggler (2012-07-24 15:42:17+00:00)
Title: Issue with JSON serialization

Suppose we have simple model with custom `as_json`:

```ruby
class TestModel < ActiveRecord::Base

def some_method
'test output'
end

def as_json(options={})
options[:methods] ||= []
options[:methods].push(:some_method)
super options
end
end
```

And we want to serialize array of 10 records:

```ruby
([TestModel.new] * 10).as_json
```

Expected behaviour (for me) is that `some_method` will be called just 10 times. But I get 55 instead :smile:. This is because of modification of `options` variable, which passed in `super`

I've tested it with rails 3.2, 3.0.9 and latest master. With ActiveRecord and MongoMapper.