aboutsummaryrefslogtreecommitdiffstats
path: root/actiontext/test/template
diff options
context:
space:
mode:
Diffstat (limited to 'actiontext/test/template')
-rw-r--r--actiontext/test/template/form_helper_test.rb50
1 files changed, 48 insertions, 2 deletions
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 \
+ '<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
+ '<input type="hidden" name="message[content]" id="message_content_trix_input_message" />' \
+ '<trix-editor placeholder="Content" id="message_content" input="message_content_trix_input_message" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/:signed_id/:filename">' \
+ "</trix-editor>" \
+ "</form>",
+ 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 \
+ '<form action="/messages" accept-charset="UTF-8" data-remote="true" method="post">' \
+ '<input type="hidden" name="message[title]" id="message_title_trix_input_message" />' \
+ '<trix-editor placeholder="Story title" id="message_title" input="message_title_trix_input_message" class="trix-content" data-direct-upload-url="http://test.host/rails/active_storage/direct_uploads" data-blob-url-template="http://test.host/rails/active_storage/blobs/:signed_id/:filename">' \
+ "</trix-editor>" \
+ "</form>",
+ output_buffer
end
end