2017-07-23 11:36:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:50:17 -04:00
|
|
|
require "abstract_unit"
|
2009-08-26 08:00:06 -04:00
|
|
|
|
|
|
|
class FormOptionsHelperI18nTests < ActionView::TestCase
|
|
|
|
tests ActionView::Helpers::FormOptionsHelper
|
|
|
|
|
|
|
|
def setup
|
2016-08-06 12:50:17 -04:00
|
|
|
@prompt_message = "Select!"
|
2009-08-26 08:00:06 -04:00
|
|
|
I18n.backend.send(:init_translations)
|
2016-08-06 13:36:34 -04: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
|
2016-08-06 13:36:34 -04:00
|
|
|
assert_called_with(I18n, :translate, ["helpers.select.prompt", { default: "Please select" }]) do
|
|
|
|
select("post", "category", [], prompt: true)
|
2015-08-22 00:03:53 -04:00
|
|
|
end
|
2009-08-26 08:00:06 -04:00
|
|
|
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>),
|
2016-08-06 13:36:34 -04:00
|
|
|
select("post", "category", [], prompt: true)
|
2009-08-26 08:00:06 -04:00
|
|
|
)
|
|
|
|
end
|
2010-01-06 20:19:55 -05:00
|
|
|
end
|