vendredi 29 novembre 2019

How to test a model that has_attached_file

I'm testing a controller that is using a Product model which has "has_attached_file" as :cover.

As you know, cover is not a column in product table, so test is failing here.

image_tag(product.cover.url(:medium))

My question is, how can I create fixtures for those attached files and associate them to certain product.

This is product model:

class Product < ApplicationRecord

  has_attached_file :cover, styles: { large: "600x600", medium:"300x300", thumb: "150x150" }

...

Thank you all!

Aucun commentaire:

Enregistrer un commentaire