diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-28 18:21:35 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-28 18:21:35 -0800 |
commit | ffad4927b1803765fca78241d2f368c33888c048 (patch) | |
tree | a006dd07c2f5a82143140a214dfad0febdeceb7b /actionpack/test | |
parent | 21df2bfc4a916d5f9bbffa48fec0f08235d276b9 (diff) | |
download | rails-ffad4927b1803765fca78241d2f368c33888c048.tar.gz rails-ffad4927b1803765fca78241d2f368c33888c048.tar.bz2 rails-ffad4927b1803765fca78241d2f368c33888c048.zip |
mutations can't be done without the consent of our proxy object. This
is one benefit of choosing composition over inheritance.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/flash_hash_test.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/actionpack/test/controller/flash_hash_test.rb b/actionpack/test/controller/flash_hash_test.rb index 9b69a2648e..e7ae7ce5f5 100644 --- a/actionpack/test/controller/flash_hash_test.rb +++ b/actionpack/test/controller/flash_hash_test.rb @@ -75,6 +75,7 @@ module ActionDispatch def test_discard_no_args @hash['hello'] = 'world' @hash.discard + @hash.sweep assert_equal({}, @hash.to_hash) end @@ -83,8 +84,69 @@ module ActionDispatch @hash['hello'] = 'world' @hash['omg'] = 'world' @hash.discard 'hello' + @hash.sweep assert_equal({'omg' => 'world'}, @hash.to_hash) end + + def test_keep_sweep + @hash['hello'] = 'world' + + @hash.sweep + assert_equal({'hello' => 'world'}, @hash.to_hash) + end + + def test_update_sweep + @hash['hello'] = 'world' + @hash.update({'hi' => 'mom'}) + + @hash.sweep + assert_equal({'hello' => 'world', 'hi' => 'mom'}, @hash.to_hash) + end + + def test_delete_sweep + @hash['hello'] = 'world' + @hash['hi'] = 'mom' + @hash.delete 'hi' + + @hash.sweep + assert_equal({'hello' => 'world'}, @hash.to_hash) + end + + def test_clear_sweep + @hash['hello'] = 'world' + @hash.clear + + @hash.sweep + assert_equal({}, @hash.to_hash) + end + + def test_replace_sweep + @hash['hello'] = 'world' + @hash.replace({'hi' => 'mom'}) + + @hash.sweep + assert_equal({'hi' => 'mom'}, @hash.to_hash) + end + + def test_discard_then_add + @hash['hello'] = 'world' + @hash['omg'] = 'world' + @hash.discard 'hello' + @hash['hello'] = 'world' + + @hash.sweep + assert_equal({'omg' => 'world', 'hello' => 'world'}, @hash.to_hash) + end + + def test_keep_all_sweep + @hash['hello'] = 'world' + @hash['omg'] = 'world' + @hash.discard 'hello' + @hash.keep + + @hash.sweep + assert_equal({'omg' => 'world', 'hello' => 'world'}, @hash.to_hash) + end end end |