Fix ActionText::Serialization when dumping an ActionText::RichText
This commit is contained in:
parent
5aa6083335
commit
458908ed42
|
@ -15,6 +15,8 @@ module ActionText
|
||||||
nil
|
nil
|
||||||
when self
|
when self
|
||||||
content.to_html
|
content.to_html
|
||||||
|
when ActionText::RichText
|
||||||
|
content.body.to_html
|
||||||
else
|
else
|
||||||
new(content).to_html
|
new(content).to_html
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,6 +60,13 @@ class ActionText::ModelTest < ActiveSupport::TestCase
|
||||||
assert_equal "Hello world", message.content.to_plain_text
|
assert_equal "Hello world", message.content.to_plain_text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "duplicating content" do
|
||||||
|
message = Message.create!(subject: "Greetings", content: "<b>Hello!</b>")
|
||||||
|
other_message = Message.create!(subject: "Greetings", content: message.content)
|
||||||
|
|
||||||
|
assert_equal message.content.body.to_html, other_message.content.body.to_html
|
||||||
|
end
|
||||||
|
|
||||||
test "saving body" do
|
test "saving body" do
|
||||||
message = Message.create(subject: "Greetings", body: "<h1>Hello world</h1>")
|
message = Message.create(subject: "Greetings", body: "<h1>Hello world</h1>")
|
||||||
assert_equal "Hello world", message.body.to_plain_text
|
assert_equal "Hello world", message.body.to_plain_text
|
||||||
|
|
Loading…
Reference in New Issue