Merge pull request #37951 from t0yohei/add-missing-action-to-action-text

Action Text: Add method to confirm rich text content existence by adding ? after content name
This commit is contained in:
Rafael França 2020-03-19 16:26:52 -04:00 committed by GitHub
commit 1add7387b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -1,3 +1,7 @@
* Add method to confirm rich text content existence by adding `?` after content name.
*Kyohei Toyoda*
* The `fill_in_rich_text_area` system test helper locates a Trix editor and fills it in with the given HTML:
```ruby

View File

@ -13,6 +13,7 @@ module ActionText
# end
#
# message = Message.create!(content: "<h1>Funny times!</h1>")
# message.content? #=> true
# message.content.to_s # => "<h1>Funny times!</h1>"
# message.content.to_plain_text # => "Funny times!"
#
@ -29,6 +30,10 @@ module ActionText
rich_text_#{name} || build_rich_text_#{name}
end
def #{name}?
rich_text_#{name}.present?
end
def #{name}=(body)
self.#{name}.body = body
end

View File

@ -18,6 +18,7 @@ class ActionText::ModelTest < ActiveSupport::TestCase
assert message.content.nil?
assert message.content.blank?
assert message.content.empty?
assert_not message.content?
assert_not message.content.present?
end
@ -26,6 +27,7 @@ class ActionText::ModelTest < ActiveSupport::TestCase
assert_not message.content.nil?
assert message.content.blank?
assert message.content.empty?
assert_not message.content?
assert_not message.content.present?
end