Sha256: fcc9d979ab3d0662443d4f2482d8ef3a2d357173153d36b02281fb2a114cc7e9

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require './test/helper'

class FileSystemTest < Test::Unit::TestCase
  context "Filesystem" do
    setup do
      rebuild_model :styles => { :thumbnail => "25x25#" }
      @dummy = Dummy.create!

      @dummy.avatar = File.open(fixture_file('5k.png'))
    end

    should "allow file assignment" do
      assert @dummy.save
    end

    should "store the original" do
      @dummy.save
      assert File.exists?(@dummy.avatar.path)
    end

    should "store the thumbnail" do
      @dummy.save
      assert File.exists?(@dummy.avatar.path(:thumbnail))
    end

    should "clean up file objects" do
      File.stubs(:exist?).returns(true)
      Paperclip::Tempfile.any_instance.expects(:close).at_least_once()
      Paperclip::Tempfile.any_instance.expects(:unlink).at_least_once()

      @dummy.save!
    end

    context "with file that has space in file name" do
      setup do
        rebuild_model :styles => { :thumbnail => "25x25#" }
        @dummy = Dummy.create!

        @dummy.avatar = File.open(fixture_file('spaced file.png'))
        @dummy.save
      end

      should "store the file" do
        assert File.exists?(@dummy.avatar.path)
      end

      should "store the path unescaped" do
        assert_match /\/spaced file\.png/, @dummy.avatar.path
      end

      should "return an escaped version of URL" do
        assert_match /\/spaced%20file\.png/, @dummy.avatar.url
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
cloudfuji_paperclip-2.4.6 test/storage/filesystem_test.rb
paperclip-2.5.1 test/storage/filesystem_test.rb
paperclip-2.5.0 test/storage/filesystem_test.rb