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