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?
For me the problem disappeared after I upgraded to Paperclip 3.0.3 - seems like the bug is now fixed.