1

I am relatively new to rails. I want to include paperclip with FactoryGirl in my unit tests. A snippet from my code looks like

class User 

  has_attached_file :photo,
    :styles => {
      :medium => "200x200" 
    }

   validates_attachment_content_type :photo, :content_type =>  /\Aimage\/.*\Z/

end

I am aware of this question How Do I Use Factory Girl To Generate A Paperclip Attachment? but it is an old post.

I also want to note that, the images i want to test are not local, but a URL is provided to Paperclip to fetch the image and resize it. Is it possible to include paperclip inside the factories?.

Thanks a lot, Shady

Community
  • 1
  • 1
Shady Hussein
  • 513
  • 8
  • 24
  • Almost what is suggested in the old post i pointed to. Using "avatar" or paperclip keywords in my factory. I always get "undefined method" which is logically. – Shady Hussein Feb 17 '14 at 15:07
  • `avatar` is not a keyword. It just refers to paperclip attachment name which in your case is `photo`. You should try it with `photo` and not `avatar`. – Kirti Thorat Feb 17 '14 at 15:09
  • Could you please share your `factory` details of `User model`. – Kirti Thorat Feb 17 '14 at 18:24

0 Answers0