Shoulda and Paperclip testing
- by trobrock
I am trying to test a couple models that have an attachment with Paperclip. I have all of my validations passing except for the content-type check.
# myapp/test/unit/project_test.rb
should_have_attached_file :logo
should_validate_attachment_presence :logo
should validate_attachment_size(:logo).less_than(1.megabyte)
should_validate_attachment_content_type :logo, :valid => ["image/png", "image/jpeg", "image/pjpeg", "image/x-png"]
# myapp/app/models/project.rb
has_attached_file :logo, :styles => { :small => "100x100>", :medium => "200x200>" }
validates_attachment_presence :logo
validates_attachment_size :logo, :less_than => 1.megabyte
validates_attachment_content_type :logo, :content_type => ["image/png", "image/jpeg", "image/pjpeg", "image/x-png"]
The errors I am getting:
1) Failure:
test: Client should validate the content types allowed on attachment logo. (ClientTest)
[/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/assertions.rb:55:in `assert_accepts'
vendor/plugins/paperclip/shoulda_macros/paperclip.rb:44:in `__bind_1276100387_499280'
/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `call'
/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `test: Client should validate the content types allowed on attachment logo. ']:
Content types image/png, image/jpeg, image/pjpeg, image/x-png should be accepted and rejected by logo
This happens on two different models that are set up the same way.