Sha256: 434f2629f0fdf5c2b46af83862d7d4cefe93f897e3bb0bdd6f360266a8b7f1a9

Contents?: true

Size: 831 Bytes

Versions: 3

Compression:

Stored size: 831 Bytes

Contents

# encoding: utf-8
require './test/helper'
require 'paperclip/attachment'

class AttachmentProcessingTest < Test::Unit::TestCase
  def setup
    rebuild_model
  end

  should 'process attachments given a valid assignment' do
    file = File.new(fixture_file("5k.png"))
    Dummy.validates_attachment_content_type :avatar, :content_type => "image/png"
    instance = Dummy.new
    attachment = instance.avatar
    attachment.expects(:post_process)

    attachment.assign(file)
  end

  should 'not process attachments if the assignment does not pass validation' do
    file = File.new(fixture_file("5k.png"))
    Dummy.validates_attachment_content_type :avatar, :content_type => "image/tiff"
    instance = Dummy.new
    attachment = instance.avatar
    attachment.expects(:post_process).never

    attachment.assign(file)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paperclip-3.4.2 test/attachment_processing_test.rb
paperclip-3.4.1 test/attachment_processing_test.rb
paperclip-3.4.0 test/attachment_processing_test.rb