Commit 8a40d68c by Nick Quaranto

Using File.expand_path when comparing paths since 1.9 treats some as absolute

parent 4f684612
...@@ -487,12 +487,10 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -487,12 +487,10 @@ class AttachmentTest < Test::Unit::TestCase
rebuild_model rebuild_model
@instance = Dummy.new @instance = Dummy.new
@attachment = Paperclip::Attachment.new(:avatar, @instance) @attachment = Paperclip::Attachment.new(:avatar, @instance)
@file = File.new(File.join(File.dirname(__FILE__), @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb')
"fixtures",
"5k.png"), 'rb')
end end
teardown do teardown do
@file.close @file.close
Paperclip::Attachment.default_options.merge!(@old_defaults) Paperclip::Attachment.default_options.merge!(@old_defaults)
end end
...@@ -509,13 +507,13 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -509,13 +507,13 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal "/avatars/original/missing.png", @attachment.url assert_equal "/avatars/original/missing.png", @attachment.url
assert_equal "/avatars/blah/missing.png", @attachment.url(:blah) assert_equal "/avatars/blah/missing.png", @attachment.url(:blah)
end end
should "return nil as path when no file assigned" do should "return nil as path when no file assigned" do
assert @attachment.to_file.nil? assert @attachment.to_file.nil?
assert_equal nil, @attachment.path assert_equal nil, @attachment.path
assert_equal nil, @attachment.path(:blah) assert_equal nil, @attachment.path(:blah)
end end
context "with a file assigned in the database" do context "with a file assigned in the database" do
setup do setup do
@attachment.stubs(:instance_read).with(:file_name).returns("5k.png") @attachment.stubs(:instance_read).with(:file_name).returns("5k.png")
...@@ -534,7 +532,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -534,7 +532,7 @@ class AttachmentTest < Test::Unit::TestCase
should "make sure the updated_at mtime is in the url if it is defined" do should "make sure the updated_at mtime is in the url if it is defined" do
assert_match %r{#{Time.now.to_i}$}, @attachment.url(:blah) assert_match %r{#{Time.now.to_i}$}, @attachment.url(:blah)
end end
should "make sure the updated_at mtime is NOT in the url if false is passed to the url method" do should "make sure the updated_at mtime is NOT in the url if false is passed to the url method" do
assert_no_match %r{#{Time.now.to_i}$}, @attachment.url(:blah, false) assert_no_match %r{#{Time.now.to_i}$}, @attachment.url(:blah, false)
end end
...@@ -550,12 +548,12 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -550,12 +548,12 @@ class AttachmentTest < Test::Unit::TestCase
end end
should "return the proper path when filename has a single .'s" do should "return the proper path when filename has a single .'s" do
assert_equal "./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.png", @attachment.path assert_equal File.expand_path("./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.png"), File.expand_path(@attachment.path)
end end
should "return the proper path when filename has multiple .'s" do should "return the proper path when filename has multiple .'s" do
@attachment.stubs(:instance_read).with(:file_name).returns("5k.old.png") @attachment.stubs(:instance_read).with(:file_name).returns("5k.old.png")
assert_equal "./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.old.png", @attachment.path assert_equal File.expand_path("./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.old.png"), File.expand_path(@attachment.path)
end end
context "when expecting three styles" do context "when expecting three styles" do
......
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