aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2009-08-26 14:00:06 +0200
committerJeremy Kemper <jeremy@bitsweat.net>2009-08-26 13:55:57 -0700
commitcc9af20da7af98464ece18d4abc6a22ef3f00b5d (patch)
treeacda0720f737ee2000a26b71dd0047fb1090a026 /actionpack/test/template
parenta7ca5595a21fa3bfd0ef51e6a56fbb80a13e040b (diff)
downloadrails-cc9af20da7af98464ece18d4abc6a22ef3f00b5d.tar.gz
rails-cc9af20da7af98464ece18d4abc6a22ef3f00b5d.tar.bz2
rails-cc9af20da7af98464ece18d4abc6a22ef3f00b5d.zip
I18n: use I18n for select helpers' prompt text
[#2252 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/form_options_helper_i18n_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/actionpack/test/template/form_options_helper_i18n_test.rb b/actionpack/test/template/form_options_helper_i18n_test.rb
new file mode 100644
index 0000000000..91e370efa7
--- /dev/null
+++ b/actionpack/test/template/form_options_helper_i18n_test.rb
@@ -0,0 +1,27 @@
+require 'abstract_unit'
+
+class FormOptionsHelperI18nTests < ActionView::TestCase
+ tests ActionView::Helpers::FormOptionsHelper
+
+ def setup
+ @prompt_message = 'Select!'
+ I18n.backend.send(:init_translations)
+ I18n.backend.store_translations :en, :support => { :select => { :prompt => @prompt_message } }
+ end
+
+ def teardown
+ I18n.backend = I18n::Backend::Simple.new
+ end
+
+ def test_select_with_prompt_true_translates_prompt_message
+ I18n.expects(:translate).with('support.select.prompt', { :default => 'Please select' })
+ select('post', 'category', [], :prompt => true)
+ end
+
+ def test_select_with_translated_prompt
+ assert_dom_equal(
+ %Q(<select id="post_category" name="post[category]"><option value="">#{@prompt_message}</option>\n</select>),
+ select('post', 'category', [], :prompt => true)
+ )
+ end
+end \ No newline at end of file