From 33f940f1407870f451e19c479f816edaf9ab0c1e Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Sat, 6 Oct 2018 11:47:10 +0800 Subject: Fix has_rich_text with `:body` keywords error. (#16) --- lib/action_text/attribute.rb | 2 +- test/dummy/app/models/message.rb | 1 + test/unit/model_test.rb | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) 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: "

Hello world

") assert_equal "Hello world", message.content.to_plain_text end + + test "save body" do + message = Message.create(subject: "Greetings", body: "

Hello world

") + assert_equal "Hello world", message.body.to_plain_text + end end -- cgit v1.2.3