From b3778c5708f430da968e2a6995741fc082e92156 Mon Sep 17 00:00:00 2001 From: Abhay Nikam Date: Thu, 21 Feb 2019 22:13:57 +0530 Subject: Allows rich_text_area_tag to add I18n translated placeholder text if placeholder option set to true --- actiontext/test/template/form_helper_test.rb | 50 ++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'actiontext/test') diff --git a/actiontext/test/template/form_helper_test.rb b/actiontext/test/template/form_helper_test.rb index a8c7a4dae2..cf7e4c0c69 100644 --- a/actiontext/test/template/form_helper_test.rb +++ b/actiontext/test/template/form_helper_test.rb @@ -5,6 +5,26 @@ require "test_helper" class ActionText::FormHelperTest < ActionView::TestCase tests ActionText::TagHelper + def form_with(*) + @output_buffer = super + end + + teardown do + I18n.backend.reload! + end + + setup do + I18n.backend.store_translations("placeholder", + activerecord: { + attributes: { + message: { + title: "Story title" + } + } + } + ) + end + test "form with rich text area" do form_with model: Message.new, scope: :message do |form| form.rich_text_area :content @@ -61,7 +81,33 @@ class ActionText::FormHelperTest < ActionView::TestCase output_buffer end - def form_with(*) - @output_buffer = super + test "form with rich text area having placeholder without locale" do + form_with model: Message.new, scope: :message do |form| + form.rich_text_area :content, placeholder: true + end + + assert_dom_equal \ + '
' \ + '' \ + '' \ + "" \ + "
", + output_buffer + end + + test "form with rich text area having placeholder with locale" do + I18n.with_locale :placeholder do + form_with model: Message.new, scope: :message do |form| + form.rich_text_area :title, placeholder: true + end + end + + assert_dom_equal \ + '
' \ + '' \ + '' \ + "" \ + "
", + output_buffer end end -- cgit v1.2.3