0

在我的 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

'should validate_attachment_presence(:file)' 测试总是失败,但我不知道为什么。我有其他带有所需附件的单元测试,测试结果很好。

有任何想法吗?

4

1 回答 1

2

对我来说,升级到 Paperclip 3.0.3 后问题就消失了 - 似乎该错误现在已修复。

于 2012-05-05T17:03:33.040 回答