为什么我的回形针验证_attachment_presence测试失败



在我的Rails 3.2.2项目中,我有以下内容:

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

"应该validate_attachment_presence(:file)"测试总是不及格,但我不知道为什么。我还有其他单元测试,需要附件,测试结果很好。

有什么想法吗?

对我来说,在升级到Paperclip 3.0.3后,这个问题就消失了——现在这个bug似乎已经修复了。

最新更新