test/storage/filesystem_test.rb in paperclip-3.0.4 vs test/storage/filesystem_test.rb in paperclip-3.1.0

- old
+ new

@@ -17,17 +17,32 @@ assert @dummy.save end should "store the original" do @dummy.save - assert File.exists?(@dummy.avatar.path) + assert_file_exists(@dummy.avatar.path) end should "store the thumbnail" do @dummy.save - assert File.exists?(@dummy.avatar.path(:thumbnail)) + assert_file_exists(@dummy.avatar.path(:thumbnail)) end + + should "be rewinded after flush_writes" do + @dummy.avatar.instance_eval "def after_flush_writes; end" + + files = @dummy.avatar.queued_for_write.values + @dummy.save + assert files.none?(&:eof?), "Expect all the files to be rewinded." + end + + should "be removed after after_flush_writes" do + paths = @dummy.avatar.queued_for_write.values.map(&:path) + @dummy.save + assert paths.none?{ |path| File.exists?(path) }, + "Expect all the files to be deleted." + end end context "with file that has space in file name" do setup do rebuild_model :styles => { :thumbnail => "25x25#" } @@ -39,10 +54,10 @@ end teardown { @file.close } should "store the file" do - assert File.exists?(@dummy.avatar.path) + assert_file_exists(@dummy.avatar.path) end should "return a replaced version for path" do assert_match /.+\/spaced_file\.png/, @dummy.avatar.path end