diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-11 17:07:05 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-11 17:07:05 -0700 |
commit | 00a9d4b91cccdd88146cbe716eca844dcdfa08e7 (patch) | |
tree | 77398a4e98eb391258813fef47f1ecf57ae58972 /activesupport/test | |
parent | 0f6e764e4060b75ea8a335e6971209a08bf8b40a (diff) | |
parent | 0cac68d3bed3e6bf8ec2eb994858e4a179046941 (diff) | |
download | rails-00a9d4b91cccdd88146cbe716eca844dcdfa08e7.tar.gz rails-00a9d4b91cccdd88146cbe716eca844dcdfa08e7.tar.bz2 rails-00a9d4b91cccdd88146cbe716eca844dcdfa08e7.zip |
Merge branch 'master' into wip_abstract_controller
Conflicts:
actionpack/lib/action_controller/abstract/callbacks.rb
actionpack/lib/action_controller/abstract/renderer.rb
actionpack/lib/action_controller/base/base.rb
actionpack/lib/action_controller/dispatch/dispatcher.rb
actionpack/lib/action_controller/routing/route_set.rb
actionpack/lib/action_controller/testing/process.rb
actionpack/test/abstract_controller/layouts_test.rb
actionpack/test/controller/filters_test.rb
actionpack/test/controller/helper_test.rb
actionpack/test/controller/render_test.rb
actionpack/test/new_base/test_helper.rb
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 16 | ||||
-rw-r--r-- | activesupport/test/dependency_module_test.rb | 77 | ||||
-rw-r--r-- | activesupport/test/ordered_hash_test.rb | 10 |
3 files changed, 103 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index d65a5323bf..ece5466abb 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -646,6 +646,22 @@ class HashToXmlTest < Test::Unit::TestCase assert_equal expected_topic_hash, Hash.from_xml(topic_xml)["rsp"]["photos"]["photo"] end + def test_all_caps_key_from_xml + test_xml = <<-EOT + <ABC3XYZ> + <TEST>Lorem Ipsum</TEST> + </ABC3XYZ> + EOT + + expected_hash = { + "ABC3XYZ" => { + "TEST" => "Lorem Ipsum" + } + } + + assert_equal expected_hash, Hash.from_xml(test_xml) + end + def test_empty_array_from_xml blog_xml = <<-XML <blog> diff --git a/activesupport/test/dependency_module_test.rb b/activesupport/test/dependency_module_test.rb new file mode 100644 index 0000000000..07090d15a1 --- /dev/null +++ b/activesupport/test/dependency_module_test.rb @@ -0,0 +1,77 @@ +require 'abstract_unit' +require 'active_support/dependency_module' + +class DependencyModuleTest < Test::Unit::TestCase + module Baz + extend ActiveSupport::DependencyModule + + module ClassMethods + def baz + "baz" + end + + def included_ran=(value) + @@included_ran = value + end + + def included_ran + @@included_ran + end + end + + included do + self.included_ran = true + end + + def baz + "baz" + end + end + + module Bar + extend ActiveSupport::DependencyModule + + depends_on Baz + + def bar + "bar" + end + + def baz + "bar+" + super + end + end + + def setup + @klass = Class.new + end + + def test_module_is_included_normally + @klass.send(:include, Baz) + assert_equal "baz", @klass.new.baz + assert_equal DependencyModuleTest::Baz, @klass.included_modules[0] + + @klass.send(:include, Baz) + assert_equal "baz", @klass.new.baz + assert_equal DependencyModuleTest::Baz, @klass.included_modules[0] + end + + def test_class_methods_are_extended + @klass.send(:include, Baz) + assert_equal "baz", @klass.baz + assert_equal DependencyModuleTest::Baz::ClassMethods, (class << @klass; self.included_modules; end)[0] + end + + def test_included_block_is_ran + @klass.send(:include, Baz) + assert_equal true, @klass.included_ran + end + + def test_modules_dependencies_are_met + @klass.send(:include, Bar) + assert_equal "bar", @klass.new.bar + assert_equal "bar+baz", @klass.new.baz + assert_equal "baz", @klass.baz + assert_equal [DependencyModuleTest::Bar, DependencyModuleTest::Baz], @klass.included_modules[0..1] + end +end diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb index 7cd8c8a8f4..647938dd87 100644 --- a/activesupport/test/ordered_hash_test.rb +++ b/activesupport/test/ordered_hash_test.rb @@ -51,6 +51,10 @@ class OrderedHashTest < Test::Unit::TestCase assert_same @ordered_hash, @ordered_hash.to_hash end + def test_to_a + assert_equal @keys.zip(@values), @ordered_hash.to_a + end + def test_has_key assert_equal true, @ordered_hash.has_key?('blue') assert_equal true, @ordered_hash.key?('blue') @@ -158,4 +162,10 @@ class OrderedHashTest < Test::Unit::TestCase def test_inspect assert @ordered_hash.inspect.include?(@hash.inspect) end + + def test_alternate_initialization + alternate = ActiveSupport::OrderedHash[1,2,3,4] + assert_kind_of ActiveSupport::OrderedHash, alternate + assert_equal [1, 3], alternate.keys + end end |