aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/option_merger_test.rb
diff options
context:
space:
mode:
authorLawrence Pit <lawrence.pit@gmail.com>2008-07-14 11:53:41 +1000
committerPratik Naik <pratiknaik@gmail.com>2008-07-17 01:59:08 +0100
commit40dbebba28bfa1c55737da7354542c3bdca4e1a1 (patch)
treef21c9a31379dae25b5cedae5ea00053a272d9408 /activesupport/test/option_merger_test.rb
parentcd6301557005617583e3f9ca5fb56297adcce7cc (diff)
downloadrails-40dbebba28bfa1c55737da7354542c3bdca4e1a1.tar.gz
rails-40dbebba28bfa1c55737da7354542c3bdca4e1a1.tar.bz2
rails-40dbebba28bfa1c55737da7354542c3bdca4e1a1.zip
Allow deep merging of hash values for nested with_options. [#490 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activesupport/test/option_merger_test.rb')
-rw-r--r--activesupport/test/option_merger_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/activesupport/test/option_merger_test.rb b/activesupport/test/option_merger_test.rb
index 509c6d3bad..0d72314880 100644
--- a/activesupport/test/option_merger_test.rb
+++ b/activesupport/test/option_merger_test.rb
@@ -38,6 +38,33 @@ class OptionMergerTest < Test::Unit::TestCase
end
end
+ def test_nested_method_with_options_containing_hashes_merge
+ with_options :conditions => { :method => :get } do |outer|
+ outer.with_options :conditions => { :domain => "www" } do |inner|
+ expected = { :conditions => { :method => :get, :domain => "www" } }
+ assert_equal expected, inner.method_with_options
+ end
+ end
+ end
+
+ def test_nested_method_with_options_containing_hashes_overwrite
+ with_options :conditions => { :method => :get, :domain => "www" } do |outer|
+ outer.with_options :conditions => { :method => :post } do |inner|
+ expected = { :conditions => { :method => :post, :domain => "www" } }
+ assert_equal expected, inner.method_with_options
+ end
+ end
+ end
+
+ def test_nested_method_with_options_containing_hashes_going_deep
+ with_options :html => { :class => "foo", :style => { :margin => 0, :display => "block" } } do |outer|
+ outer.with_options :html => { :title => "bar", :style => { :margin => "1em", :color => "#fff" } } do |inner|
+ expected = { :html => { :class => "foo", :title => "bar", :style => { :margin => "1em", :display => "block", :color => "#fff" } } }
+ assert_equal expected, inner.method_with_options
+ end
+ end
+ end
+
# Needed when counting objects with the ObjectSpace
def test_option_merger_class_method
assert_equal ActiveSupport::OptionMerger, ActiveSupport::OptionMerger.new('', '').class