In my Rails 3.2.2 project, I have the following:
class Photo < ActiveRecord::Base
belongs_to :album
default_scope order: :title
extend FriendlyId
friendly_id :title, :use => :slugged
validates :title, :presence => true
validates :title, :uniqueness => {:scope => :album_id}
validates :file, :attachment_presence => true
has_attached_file :file, :path => (Rails.root + "photos/:id/:style/:filename").to_s,
:url => "/photos/:style/:id",
:styles => { :small => "450x450>"}
end
class PhotoTest < ActiveSupport::TestCase
should belong_to(:album)
should validate_presence_of(:title)
should have_attached_file(:file)
should validate_attachment_presence(:file)
end
The 'should validate_attachment_presence(:file)' test always flunks, but I can't figure out why. I have other unit tests with required attachments that test out fine.
Any ideas?
cd to/where/paperclip/is/located
and then run bundle install
to install dependencies. You then run rake
or rake test
(can't remember which) to test paperclip against your system, to see if there is something wrong with paperclip setup on your system - Ekampp 2012-04-08 13:16
should validate_attachment_presence(:file)
always fails. As suggested by @Ekampp I ran the Paperclip tests, but they finished without any errors - rkallensee 2012-04-15 15:00
For me the problem disappeared after I upgraded to Paperclip 3.0.3 - seems like the bug is now fixed.