From 6a77309d66b04220321e12873a083110e47840e7 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Wed, 3 Oct 2018 15:05:16 -0400 Subject: Fix content attachment test --- test/dummy/app/models/person.rb | 7 +++++++ test/dummy/app/views/people/_trix_content_attachment.html.erb | 3 +++ test/dummy/db/migrate/20181003185713_create_people.rb | 9 +++++++++ test/dummy/db/schema.rb | 8 +++++++- test/unit/attachment_test.rb | 1 + 5 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/dummy/app/models/person.rb create mode 100644 test/dummy/app/views/people/_trix_content_attachment.html.erb create mode 100644 test/dummy/db/migrate/20181003185713_create_people.rb diff --git a/test/dummy/app/models/person.rb b/test/dummy/app/models/person.rb new file mode 100644 index 0000000000..0ded356d5b --- /dev/null +++ b/test/dummy/app/models/person.rb @@ -0,0 +1,7 @@ +class Person < ApplicationRecord + include ActionText::Attachable + + def to_trix_content_attachment_partial_path + "people/trix_content_attachment" + end +end diff --git a/test/dummy/app/views/people/_trix_content_attachment.html.erb b/test/dummy/app/views/people/_trix_content_attachment.html.erb new file mode 100644 index 0000000000..7db2334126 --- /dev/null +++ b/test/dummy/app/views/people/_trix_content_attachment.html.erb @@ -0,0 +1,3 @@ + + <%= person.name %> + diff --git a/test/dummy/db/migrate/20181003185713_create_people.rb b/test/dummy/db/migrate/20181003185713_create_people.rb new file mode 100644 index 0000000000..1d5922d389 --- /dev/null +++ b/test/dummy/db/migrate/20181003185713_create_people.rb @@ -0,0 +1,9 @@ +class CreatePeople < ActiveRecord::Migration[5.2] + def change + create_table :people do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 5179d7269f..39216ebd23 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_02_12_164506) do +ActiveRecord::Schema.define(version: 2018_10_03_185713) do create_table "action_text_rich_texts", force: :cascade do |t| t.string "name", null: false @@ -49,4 +49,10 @@ ActiveRecord::Schema.define(version: 2018_02_12_164506) do t.datetime "updated_at", null: false end + create_table "people", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + end diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index a31ef1afd0..56a4ea1dd8 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -34,6 +34,7 @@ class ActionText::AttachmentTest < ActiveSupport::TestCase end test "converts to TrixAttachment with content" do + attachable = Person.create! name: "Javan" attachment = attachment_from_html(%Q()) trix_attachment = attachment.to_trix_attachment -- cgit v1.2.3