class ActionText::FixtureSet
entry and will ensure the Action Text relationship is intact.
When processed, Active Record will insert database records for each fixture
body: <div>Hello, world.</div>
name: content
record: first (Article)
first:
entry’s ‘record:` key as a polymorphic relationship:
`test/fixtures/action_text/rich_texts.yml`, making sure to declare each
Then declare the ActionText::RichText fixture data in
title: An Article
first:
for `Article` instances in `test/fixtures/articles.yml`:
To declare fixture data for the related `content`, first declare fixture data
end
has_rich_text :content
class Article < ApplicationRecord
Consider an `Article` class:
from ActiveRecord::Base instances and can therefore be populated by fixtures.
Like other Active Record-backed models, ActionText::RichText records inherit
### YAML
To learn more about fixtures, read the ActiveRecord::FixtureSet documentation.
sample data.
Fixtures are a way of organizing data that you want to test against; in short,
# Action Text FixtureSet
def self.attachment(fixture_set_name, label, column_type: :integer)
body:
name: content
record: second (Article)
second:
in `test/fixtures/action_text/rich_texts.yml`:
embedding a call to `ActionText::FixtureSet.attachment` in the `body:` value
You can attach a mention of `articles(:first)` to `second`'s `content` by
title: Another Article
second:
`test/fixtures/articles.yml`:
For example, consider a second `Article` fixture declared in
### Examples
Fixtures support Action Text attachments as part of their `body` HTML.
def self.attachment(fixture_set_name, label, column_type: :integer) signed_global_id = ActiveRecord::FixtureSet.signed_global_id fixture_set_name, label, column_type: column_type, for: ActionText::Attachable::LOCATOR_NAME %(<action-text-attachment sgid="#{signed_global_id}"></action-text-attachment>) end