How to properly set up ActionText fixtures dependencies

Hello Rails community,

I’ve banged my head against the wall for the past few hours for one of my Rails apps on how to get minitest to work with the ActionText fixtures. I thought would share this here in case anyone else encounters this.

I eventually stumbled across this SO article which elucidates the mystery. I’ll give a quick overview here too.

So let’s consider we’re building a blog app, and we have a Post model like this:

class Post < ApplicationRecord
  has_rich_text :body

To properly link the Post fixture with the rich text dependency, we would need to set up our fixtures like this:

# test/fixtures/posts.yml
  title: Post
# test/fixtures/action_text/rich_texts.yml
  record: one (Post)
  name: body
  body: <p>Hello World</p>

Would it be possible to include this set up in the Rails Action Text Overview Guide too? I’m willing to work on the PR, just not entirely sure if I need approval first or not.



Hi Raul, this PR might be what you’re looking for, don’t hesitate to add comments there:

1 Like