Testing and loading attachment_fu models using fixtures
You might think that I’m an attachment_fu fanboy, because this post is also about that plugin. However, I found that there is only little information available on this, therefore I thought it would be nice to share this with you.
Say you have setup fixtures to load as basic content for your site (using
rake db:fixtures:load) or you’d like to do tests on already existing attachment_fu enriched model classes. The problem here is that the fixture data is not handled by the plugin; if you supply an image, it will not automagically create thumbnails for you. There didn’t seem to be a way to do this. Tonight however, I found a nice plugin from someone who was struggling with the same problem. It’s called attachment_fu_fixtures. attachment_fu_fixtures overrides the
insert_fixture method to allow any attachment fixtures to be handled by attachment_fu, instead of just inserting the data into the database.
A small example from the README on how it can be used:
= fixtures/images.yml harbour: title: victoria harbour attachment_file: test/images/harbour.png user: mynyml
The attachment_file attribute is recognized by the plugin and replaced by fields required for attachment_fu. For more info, see the plugin homepage, which is hosted on GitHub.
~ by moiristo on July 31, 2008.