2009-08-26 08:00:06 -04:00
|
|
|
require 'abstract_unit'
|
|
|
|
|
|
|
|
class FormOptionsHelperI18nTests < ActionView::TestCase
|
|
|
|
tests ActionView::Helpers::FormOptionsHelper
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@prompt_message = 'Select!'
|
|
|
|
I18n.backend.send(:init_translations)
|
2010-01-06 20:19:55 -05:00
|
|
|
I18n.backend.store_translations :en, :helpers => { :select => { :prompt => @prompt_message } }
|
2009-08-26 08:00:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
I18n.backend = I18n::Backend::Simple.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_select_with_prompt_true_translates_prompt_message
|
2010-01-06 20:19:55 -05:00
|
|
|
I18n.expects(:translate).with('helpers.select.prompt', { :default => 'Please select' })
|
2009-08-26 08:00:06 -04:00
|
|
|
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
|
2010-01-06 20:19:55 -05:00
|
|
|
end
|