diff options
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 22 | ||||
-rw-r--r-- | activeresource/test/cases/base_test.rb | 3 | ||||
-rw-r--r-- | activesupport/test/core_ext/object/to_query_test.rb | 5 |
3 files changed, 14 insertions, 16 deletions
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 048f96c9a9..d59bbec4a9 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -1,6 +1,6 @@ # encoding: utf-8 require 'abstract_unit' -require 'active_support/ordered_options' +require 'active_support/ordered_hash' require 'controller/fake_controllers' class UrlHelperTest < ActiveSupport::TestCase @@ -31,17 +31,13 @@ class UrlHelperTest < ActiveSupport::TestCase {} end - def abcd(hash = {}) - hash_for(:a => :b, :c => :d).merge(hash) - end - - def hash_for(opts = {}) - {:controller => "foo", :action => "bar"}.merge(opts) + def hash_for(opts = []) + ActiveSupport::OrderedHash[*([:controller, "foo", :action, "bar"].concat(opts))] end alias url_hash hash_for def test_url_for_does_not_escape_urls - assert_equal "/?a=b&c=d", url_for(abcd) + assert_equal "/?a=b&c=d", url_for(hash_for([:a, :b, :c, :d])) end def test_url_for_with_back @@ -128,7 +124,7 @@ class UrlHelperTest < ActiveSupport::TestCase end def test_link_tag_with_host_option - hash = hash_for(:host => "www.example.com") + hash = hash_for([:host, "www.example.com"]) expected = %q{<a href="http://www.example.com/">Test Link</a>} assert_dom_equal(expected, link_to('Test Link', hash)) end @@ -294,7 +290,7 @@ class UrlHelperTest < ActiveSupport::TestCase def test_current_page_with_params_that_match @request = request_for_url("/?order=desc&page=1") - assert current_page?(hash_for(:order => "desc", :page => "1")) + assert current_page?(hash_for([:order, "desc", :page, "1"])) assert current_page?("http://www.example.com/?order=desc&page=1") end @@ -316,20 +312,20 @@ class UrlHelperTest < ActiveSupport::TestCase @request = request_for_url("/?order=desc&page=1") assert_equal "Showing", - link_to_unless_current("Showing", hash_for(:order=>'desc', :page=>'1')) + link_to_unless_current("Showing", hash_for([:order, 'desc', :page, '1'])) assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/?order=desc&page=1") @request = request_for_url("/?order=desc") assert_equal %{<a href="/?order=asc">Showing</a>}, - link_to_unless_current("Showing", hash_for(:order => :asc)) + link_to_unless_current("Showing", hash_for([:order, :asc])) assert_equal %{<a href="http://www.example.com/?order=asc">Showing</a>}, link_to_unless_current("Showing", "http://www.example.com/?order=asc") @request = request_for_url("/?order=desc") assert_equal %{<a href="/?order=desc&page=2\">Showing</a>}, - link_to_unless_current("Showing", hash_for(:order => "desc", :page => 2)) + link_to_unless_current("Showing", hash_for([:order, "desc", :page, 2])) assert_equal %{<a href="http://www.example.com/?order=desc&page=2">Showing</a>}, link_to_unless_current("Showing", "http://www.example.com/?order=desc&page=2") diff --git a/activeresource/test/cases/base_test.rb b/activeresource/test/cases/base_test.rb index 4d036d73cc..a176c037d5 100644 --- a/activeresource/test/cases/base_test.rb +++ b/activeresource/test/cases/base_test.rb @@ -6,6 +6,7 @@ require "fixtures/sound" require "fixtures/beast" require "fixtures/proxy" require 'active_support/json' +require 'active_support/ordered_hash' require 'active_support/core_ext/hash/conversions' require 'mocha' @@ -555,7 +556,7 @@ class BaseTest < Test::Unit::TestCase assert_equal '/people.xml?name[]=bob&name[]=your+uncle%2Bme&name[]=&name[]=false', Person.collection_path(:name => ['bob', 'your uncle+me', nil, false]) - assert_equal '/people.xml?struct[a][]=2&struct[a][]=1&struct[b]=fred', Person.collection_path(:struct => {:a => [2,1], 'b' => 'fred'}) + assert_equal '/people.xml?struct[a][]=2&struct[a][]=1&struct[b]=fred', Person.collection_path(:struct => ActiveSupport::OrderedHash[:a, [2,1], 'b', 'fred']) end def test_custom_element_path diff --git a/activesupport/test/core_ext/object/to_query_test.rb b/activesupport/test/core_ext/object/to_query_test.rb index 4d655913cc..e28b4cd493 100644 --- a/activesupport/test/core_ext/object/to_query_test.rb +++ b/activesupport/test/core_ext/object/to_query_test.rb @@ -1,4 +1,5 @@ require 'abstract_unit' +require 'active_support/ordered_hash' require 'active_support/core_ext/object/to_query' class ToQueryTest < Test::Unit::TestCase @@ -18,12 +19,12 @@ class ToQueryTest < Test::Unit::TestCase def test_nested_conversion assert_query_equal 'person[login]=seckar&person[name]=Nicholas', - :person => {:name => 'Nicholas', :login => 'seckar'} + :person => ActiveSupport::OrderedHash[:login, 'seckar', :name, 'Nicholas'] end def test_multiple_nested assert_query_equal 'account[person][id]=20&person[id]=10', - :person => {:id => 10}, :account => {:person => {:id => 20}} + ActiveSupport::OrderedHash[:account, {:person => {:id => 20}}, :person, {:id => 10}] end def test_array_values |