Sha256: 5fd51cf8c37280afb739ab56462b8eb507f338b5157c5c68c1fbadfed9015ab1

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

require './test/helper'

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

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

      teardown { @file.close }

      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
    end

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

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

      teardown { @file.close }

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

      should "return a replaced version for path" do
        assert_match /.+\/spaced_file\.png/, @dummy.avatar.path
      end

      should "return a replaced version for url" do
        assert_match /.+\/spaced_file\.png/, @dummy.avatar.url
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
paperclip-3.0.4 test/storage/filesystem_test.rb
paperclip-3.0.3 test/storage/filesystem_test.rb
cloudfuji_paperclip-3.0.3 test/storage/filesystem_test.rb