rails/rails — pull request #15451 by laurocaetano (2014-05-31 21:52:17+00:00)
Title: Fix regression for HashWithIndifferentAccess#dup

The PR #14518 just added the following regression to `HashWithIndifferentAccess#dup`:

```ruby
hash = ActiveSupport::HashWithIndifferentAccess.new({ a: { b: 'b' } })
dup = hash.dup
dup[:a][:c] = 'c'

hash[:a][:c] #=> "c"
# it was modifying the original hash too
dup[:a][:c] #=> "c"
```

Just reverting #14518 and backporting 03f35a27dc88335550ca0ab1d21e46948c9f5093 solves the problem.

It now behaves as expected:

```ruby
hash = ActiveSupport::HashWithIndifferentAccess.new({ a: { b: 'b' } })
dup = hash.dup
dup[:a][:c] = 'c'

hash[:a][:c] #=> nil
# does not modify the original hash
dup[:a][:c] #=> "c"
```

Also I added a regression test (that shall be cherry-picked to master, maybe?).

cc @rafaelfranca @robin850