mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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:
commit
1add7387b3
3 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue