Commit 761decf7 by Jon Yurek

Fixed 'too many open file' errors due to not closing test files

parent e345764e
...@@ -81,6 +81,8 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -81,6 +81,8 @@ class AttachmentTest < Test::Unit::TestCase
@dummy.avatar = @file @dummy.avatar = @file
end end
teardown { @file.close }
should "make sure that they are interpolated correctly" do should "make sure that they are interpolated correctly" do
assert_equal "1024.omg/1024-bbq/1024what/000/001/024.wtf", @dummy.avatar.path assert_equal "1024.omg/1024-bbq/1024what/000/001/024.wtf", @dummy.avatar.path
end end
...@@ -99,6 +101,8 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -99,6 +101,8 @@ class AttachmentTest < Test::Unit::TestCase
@dummy.avatar = @file @dummy.avatar = @file
end end
teardown { @file.close }
should "return the proper path" do should "return the proper path" do
temporary_rails_env(@rails_env) { temporary_rails_env(@rails_env) {
assert_equal "#{@rails_env}/#{@id}.png", @dummy.avatar.path assert_equal "#{@rails_env}/#{@id}.png", @dummy.avatar.path
...@@ -298,6 +302,8 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -298,6 +302,8 @@ class AttachmentTest < Test::Unit::TestCase
"5k.png"), 'rb') "5k.png"), 'rb')
end end
teardown { @file.close }
should "raise if there are not the correct columns when you try to assign" do should "raise if there are not the correct columns when you try to assign" do
@other_attachment = Paperclip::Attachment.new(:not_here, @instance) @other_attachment = Paperclip::Attachment.new(:not_here, @instance)
assert_raises(Paperclip::PaperclipError) do assert_raises(Paperclip::PaperclipError) do
...@@ -464,6 +470,8 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -464,6 +470,8 @@ class AttachmentTest < Test::Unit::TestCase
@file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb') @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb')
end end
teardown { @file.close }
should "not error when assigned an attachment" do should "not error when assigned an attachment" do
assert_nothing_raised { @dummy.avatar = @file } assert_nothing_raised { @dummy.avatar = @file }
end end
......
...@@ -29,6 +29,8 @@ class IntegrationTest < Test::Unit::TestCase ...@@ -29,6 +29,8 @@ class IntegrationTest < Test::Unit::TestCase
assert @dummy.save assert @dummy.save
end end
teardown { @file.close }
should "create its thumbnails properly" do should "create its thumbnails properly" do
assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:thumb)}"` assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:thumb)}"`
end end
...@@ -61,6 +63,8 @@ class IntegrationTest < Test::Unit::TestCase ...@@ -61,6 +63,8 @@ class IntegrationTest < Test::Unit::TestCase
@dummy.avatar = @file @dummy.avatar = @file
end end
teardown { @file.close }
context "when saved" do context "when saved" do
setup do setup do
@dummy.save @dummy.save
......
...@@ -14,6 +14,8 @@ class IOStreamTest < Test::Unit::TestCase ...@@ -14,6 +14,8 @@ class IOStreamTest < Test::Unit::TestCase
@file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb') @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb')
end end
teardown { @file.close }
context "that is sent #stream_to" do context "that is sent #stream_to" do
context "and given a String" do context "and given a String" do
......
...@@ -72,6 +72,8 @@ class PaperclipTest < Test::Unit::TestCase ...@@ -72,6 +72,8 @@ class PaperclipTest < Test::Unit::TestCase
@file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb')
end end
teardown { @file.close }
should "not error when trying to also create a 'blah' attachment" do should "not error when trying to also create a 'blah' attachment" do
assert_nothing_raised do assert_nothing_raised do
Dummy.class_eval do Dummy.class_eval do
......
...@@ -82,6 +82,8 @@ class StorageTest < Test::Unit::TestCase ...@@ -82,6 +82,8 @@ class StorageTest < Test::Unit::TestCase
@dummy.avatar = @file @dummy.avatar = @file
end end
teardown { @file.close }
should "not get a bucket to get a URL" do should "not get a bucket to get a URL" do
@dummy.avatar.expects(:s3).never @dummy.avatar.expects(:s3).never
@dummy.avatar.expects(:s3_bucket).never @dummy.avatar.expects(:s3_bucket).never
...@@ -144,6 +146,8 @@ class StorageTest < Test::Unit::TestCase ...@@ -144,6 +146,8 @@ class StorageTest < Test::Unit::TestCase
@dummy.avatar = @file @dummy.avatar = @file
end end
teardown { @file.close }
context "and saved" do context "and saved" do
setup do setup do
@s3_mock = stub @s3_mock = stub
...@@ -190,6 +194,8 @@ class StorageTest < Test::Unit::TestCase ...@@ -190,6 +194,8 @@ class StorageTest < Test::Unit::TestCase
@dummy.avatar = @file @dummy.avatar = @file
end end
teardown { @file.close }
should "still return a Tempfile when sent #to_io" do should "still return a Tempfile when sent #to_io" do
assert_equal Tempfile, @dummy.avatar.to_io.class assert_equal Tempfile, @dummy.avatar.to_io.class
end end
......
...@@ -35,6 +35,8 @@ class ThumbnailTest < Test::Unit::TestCase ...@@ -35,6 +35,8 @@ class ThumbnailTest < Test::Unit::TestCase
@file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb') @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb')
end end
teardown { @file.close }
[["600x600>", "434x66"], [["600x600>", "434x66"],
["400x400>", "400x61"], ["400x400>", "400x61"],
["32x32<", "434x66"] ["32x32<", "434x66"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment