test/storage/filesystem_test.rb in paperclip-3.0.2 vs test/storage/filesystem_test.rb in paperclip-3.0.3

- old
+ new

@@ -1,37 +1,45 @@ require './test/helper' class FileSystemTest < Test::Unit::TestCase context "Filesystem" do - setup do - rebuild_model :styles => { :thumbnail => "25x25#" } - @dummy = Dummy.create! + context "normal file" do + setup do + rebuild_model :styles => { :thumbnail => "25x25#" } + @dummy = Dummy.create! - @dummy.avatar = File.open(fixture_file('5k.png')) - end + @file = File.open(fixture_file('5k.png')) + @dummy.avatar = @file + end - should "allow file assignment" do - assert @dummy.save - end + teardown { @file.close } - should "store the original" do - @dummy.save - assert File.exists?(@dummy.avatar.path) - end + should "allow file assignment" do + assert @dummy.save + end - should "store the thumbnail" do - @dummy.save - assert File.exists?(@dummy.avatar.path(:thumbnail)) + 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! - @dummy.avatar = File.open(fixture_file('spaced file.png')) + @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