aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-06-27 16:20:58 +0200
committerGitHub <noreply@github.com>2018-06-27 16:20:58 +0200
commitb430ba4754f59934acb4806c83d10dee5af8de9e (patch)
tree1d7482d313f05a800f63a3a490293c9593b2a6a2 /test
parenta4af9580d604221ec36d2cd5671eb7f256ae5173 (diff)
parent60050ee41275eda25601beaa453e26841511d492 (diff)
downloadrails-b430ba4754f59934acb4806c83d10dee5af8de9e.tar.gz
rails-b430ba4754f59934acb4806c83d10dee5af8de9e.tar.bz2
rails-b430ba4754f59934acb4806c83d10dee5af8de9e.zip
Merge pull request #1 from basecamp/separate-rich-text-record
Separate Rich Text record
Diffstat (limited to 'test')
-rw-r--r--test/dummy/app/views/messages/_form.html.erb2
-rw-r--r--test/dummy/config/environments/development.rb2
-rw-r--r--test/dummy/db/migrate/20180208205311_create_messages.rb2
-rw-r--r--test/dummy/db/migrate/2018052816_create_action_text_tables.rb14
-rw-r--r--test/dummy/db/schema.rb11
-rw-r--r--test/unit/content_test.rb4
-rw-r--r--test/unit/model_test.rb10
7 files changed, 38 insertions, 7 deletions
diff --git a/test/dummy/app/views/messages/_form.html.erb b/test/dummy/app/views/messages/_form.html.erb
index bd5f0bea4a..3b8a174884 100644
--- a/test/dummy/app/views/messages/_form.html.erb
+++ b/test/dummy/app/views/messages/_form.html.erb
@@ -18,7 +18,7 @@
<div class="field">
<%= form.label :content %>
- <%= form.rich_text_field :content, class: "trix-content" %>
+ <%= form.rich_text_area :content, class: "trix-content" %>
</div>
<div class="actions">
diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb
index 42768bf68c..f09b9a00c4 100644
--- a/test/dummy/config/environments/development.rb
+++ b/test/dummy/config/environments/development.rb
@@ -1,6 +1,6 @@
Rails.application.configure do
# Verifies that versions and hashed value of the package contents in the project's package.json
- config.webpacker.check_yarn_integrity = true
+ # config.webpacker.check_yarn_integrity = true
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
diff --git a/test/dummy/db/migrate/20180208205311_create_messages.rb b/test/dummy/db/migrate/20180208205311_create_messages.rb
index 6817d5933f..8e43559672 100644
--- a/test/dummy/db/migrate/20180208205311_create_messages.rb
+++ b/test/dummy/db/migrate/20180208205311_create_messages.rb
@@ -2,8 +2,6 @@ class CreateMessages < ActiveRecord::Migration[5.2]
def change
create_table :messages do |t|
t.string :subject
- t.text :content
-
t.timestamps
end
end
diff --git a/test/dummy/db/migrate/2018052816_create_action_text_tables.rb b/test/dummy/db/migrate/2018052816_create_action_text_tables.rb
new file mode 100644
index 0000000000..872987749a
--- /dev/null
+++ b/test/dummy/db/migrate/2018052816_create_action_text_tables.rb
@@ -0,0 +1,14 @@
+class CreateActionTextTables < ActiveRecord::Migration[5.2]
+ def change
+ create_table :action_text_rich_texts do |t|
+ t.string :name, null: false
+ t.text :body, limit: 16777215, null: false
+ t.references :record, null: false, polymorphic: true, index: false
+
+ t.datetime :created_at, null: false
+ t.datetime :updated_at, null: false
+
+ t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
+ end
+ end
+end
diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb
index f892368183..30bf844e9c 100644
--- a/test/dummy/db/schema.rb
+++ b/test/dummy/db/schema.rb
@@ -12,6 +12,16 @@
ActiveRecord::Schema.define(version: 2018_02_12_164506) do
+ create_table "action_text_rich_texts", force: :cascade do |t|
+ t.string "name", null: false
+ t.text "body", limit: 16777215, null: false
+ t.string "record_type", null: false
+ t.integer "record_id", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
+ end
+
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -35,7 +45,6 @@ ActiveRecord::Schema.define(version: 2018_02_12_164506) do
create_table "messages", force: :cascade do |t|
t.string "subject"
- t.text "content"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
diff --git a/test/unit/content_test.rb b/test/unit/content_test.rb
index e5773361e4..b1a06e2cfa 100644
--- a/test/unit/content_test.rb
+++ b/test/unit/content_test.rb
@@ -3,8 +3,8 @@ require_relative '../test_helper'
module ActionText
class ContentTest < ActiveSupport::TestCase
test "plain text conversion" do
- message = Message.create!(subject: "Greetings", content: "<h1>Hello world</h1>")
- assert_equal "Hello world", message.content.to_plain_text
+ message = Message.new(subject: "Greetings", content: "<h1>Hello world</h1>")
+ assert_equal "Hello world", message.content.body.to_plain_text
end
end
end
diff --git a/test/unit/model_test.rb b/test/unit/model_test.rb
new file mode 100644
index 0000000000..b7c5333c4d
--- /dev/null
+++ b/test/unit/model_test.rb
@@ -0,0 +1,10 @@
+require_relative '../test_helper'
+
+module ActionText
+ class ModelTest < ActiveSupport::TestCase
+ test "saving content" do
+ message = Message.create!(subject: "Greetings", content: "<h1>Hello world</h1>")
+ assert_equal "Hello world", message.content.body.to_plain_text
+ end
+ end
+end