Sha256: 3c319158279f1bc81c188d6127f95b46a662a17dc44a95f9b1b851ce0600ab7a

Contents?: true

Size: 746 Bytes

Versions: 22

Compression:

Stored size: 746 Bytes

Contents

require 'spec_helper'

describe "Saving an attachment" do
  use_model_class(:Thing, :value => :integer)

  #
  # The list of files this process has open.
  #
  def open_files
    `lsof -p #{Process.pid} -F n`.split(/\n/).sort
  end

  it "should not leave any file handles left open" do
    tmp = temporary_directory
    Thing.has_attachment :photo do
      path "#{tmp}/:style.png"
      style :small, :size => '10x10'
      process :after => :save do
        resize
      end
    end

    path = create_image("#{temporary_directory}/tmp.jpg")
    open(path) do |file|
      @initial_open_files = open_files
      thing = Thing.new(:photo => file)
      thing.save.should be_true
      open_files.should == @initial_open_files
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
bulldog-0.0.2 spec/integration/saving_an_attachment_spec.rb
bulldog-0.0.1 spec/integration/saving_an_attachment_spec.rb