From 20d6630c1bb70f09e1f6a135bd3f9d690ad28250 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sun, 22 Jun 2008 11:41:51 +0200 Subject: Replaced country_options_for_select with old, untranslated version and moved country-related helpers to a new FormCountryHelper helper module so that they can easily be moved to a plugin. Updated tests accordingly. --- .../test/template/form_country_helper_test.rb | 772 +++++++++++++++++++++ .../test/template/form_options_helper_i18n_test.rb | 26 - .../test/template/form_options_helper_test.rb | 766 +------------------- 3 files changed, 775 insertions(+), 789 deletions(-) create mode 100644 actionpack/test/template/form_country_helper_test.rb delete mode 100644 actionpack/test/template/form_options_helper_i18n_test.rb (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_country_helper_test.rb b/actionpack/test/template/form_country_helper_test.rb new file mode 100644 index 0000000000..224b2e21c2 --- /dev/null +++ b/actionpack/test/template/form_country_helper_test.rb @@ -0,0 +1,772 @@ +require 'abstract_unit' + +class FormCountryHelperTest < ActionView::TestCase + tests ActionView::Helpers::FormCountryHelper + + silence_warnings do + Post = Struct.new('Post', :title, :author_name, :body, :secret, :written_on, :category, :origin) + end + + def test_country_select + @post = Post.new + @post.origin = "Denmark" + expected_select = <<-COUNTRIES + +COUNTRIES + assert_dom_equal(expected_select[0..-2], country_select("post", "origin")) + end + + def test_country_select_with_priority_countries + @post = Post.new + @post.origin = "Denmark" + expected_select = <<-COUNTRIES + +COUNTRIES + assert_dom_equal(expected_select[0..-2], country_select("post", "origin", ["New Zealand", "Nicaragua"])) + end + + def test_country_select_with_selected_priority_country + @post = Post.new + @post.origin = "New Zealand" + expected_select = <<-COUNTRIES + +COUNTRIES + assert_dom_equal(expected_select[0..-2], country_select("post", "origin", ["New Zealand", "Nicaragua"])) + end +end \ No newline at end of file diff --git a/actionpack/test/template/form_options_helper_i18n_test.rb b/actionpack/test/template/form_options_helper_i18n_test.rb deleted file mode 100644 index c9fc0768bb..0000000000 --- a/actionpack/test/template/form_options_helper_i18n_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'abstract_unit' - -class FormOptionsHelperI18nTests < Test::Unit::TestCase - include ActionView::Helpers::FormOptionsHelper - attr_reader :request - - def setup - @request = mock - end - - def test_country_options_for_select_given_a_locale_it_does_not_check_request_for_locale - request.expects(:locale).never - country_options_for_select :locale => 'en-US' - end - - def test_country_options_for_select_given_no_locale_it_checks_request_for_locale - request.expects(:locale).returns 'en-US' - country_options_for_select - end - - def test_country_options_for_select_translates_country_names - countries = ActionView::Helpers::FormOptionsHelper::COUNTRIES - I18n.expects(:translate).with(:'countries.names', 'en-US').returns countries - country_options_for_select :locale => 'en-US' - end -end \ No newline at end of file diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index 3f89a5e426..5ba81aac02 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -412,769 +412,6 @@ class FormOptionsHelperTest < ActionView::TestCase assert_dom_equal expected, collection_select("post", "author_name", @posts, "author_name", "author_name", { :include_blank => true, :name => 'post[author_name][]' }, :multiple => true) end - def test_country_select - @post = Post.new - @post.origin = "Denmark" - expected_select = <<-COUNTRIES - -COUNTRIES - assert_dom_equal(expected_select[0..-2], country_select("post", "origin")) - end - - def test_country_select_with_priority_countries - @post = Post.new - @post.origin = "Denmark" - expected_select = <<-COUNTRIES - -COUNTRIES - assert_dom_equal(expected_select[0..-2], country_select("post", "origin", ["New Zealand", "Nicaragua"])) - end - - def test_country_select_with_selected_priority_country - @post = Post.new - @post.origin = "New Zealand" - expected_select = <<-COUNTRIES - -COUNTRIES - assert_dom_equal(expected_select[0..-2], country_select("post", "origin", ["New Zealand", "Nicaragua"])) - end - def test_time_zone_select @firm = Firm.new("D") html = time_zone_select( "firm", "time_zone" ) @@ -1327,4 +564,7 @@ COUNTRIES html end + def test_countries_is_deprectated + assert_deprecated(/COUNTRIES/) { ActionView::Helpers::FormOptionsHelper::COUNTRIES.size } + end end -- cgit v1.2.3