diff options
author | Jason Lee <huacnlee@gmail.com> | 2018-10-06 11:47:10 +0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2018-10-05 20:47:10 -0700 |
commit | 33f940f1407870f451e19c479f816edaf9ab0c1e (patch) | |
tree | a21101f37f691c9552f5df1212de5e725b20ac50 | |
parent | e156fc125bfc13db17efbadd502d8d2e7591d0fa (diff) | |
download | rails-33f940f1407870f451e19c479f816edaf9ab0c1e.tar.gz rails-33f940f1407870f451e19c479f816edaf9ab0c1e.tar.bz2 rails-33f940f1407870f451e19c479f816edaf9ab0c1e.zip |
Fix has_rich_text with `:body` keywords error. (#16)
-rw-r--r-- | lib/action_text/attribute.rb | 2 | ||||
-rw-r--r-- | test/dummy/app/models/message.rb | 1 | ||||
-rw-r--r-- | test/unit/model_test.rb | 5 |
3 files changed, 7 insertions, 1 deletions
diff --git a/lib/action_text/attribute.rb b/lib/action_text/attribute.rb index 8439073c00..992a6a410a 100644 --- a/lib/action_text/attribute.rb +++ b/lib/action_text/attribute.rb @@ -28,7 +28,7 @@ module ActionText end def #{name}=(body) - #{name}.body = body + self.#{name}.body = body end CODE diff --git a/test/dummy/app/models/message.rb b/test/dummy/app/models/message.rb index db63a1fe3f..9ea4dbfe78 100644 --- a/test/dummy/app/models/message.rb +++ b/test/dummy/app/models/message.rb @@ -1,3 +1,4 @@ class Message < ApplicationRecord has_rich_text :content + has_rich_text :body end diff --git a/test/unit/model_test.rb b/test/unit/model_test.rb index a9a49cbffd..50632c19a7 100644 --- a/test/unit/model_test.rb +++ b/test/unit/model_test.rb @@ -29,4 +29,9 @@ class ActionText::ModelTest < ActiveSupport::TestCase message = Message.create!(subject: "Greetings", content: "<h1>Hello world</h1>") assert_equal "Hello world", message.content.to_plain_text end + + test "save body" do + message = Message.create(subject: "Greetings", body: "<h1>Hello world</h1>") + assert_equal "Hello world", message.body.to_plain_text + end end |