fixed upload tests

This commit is contained in:
albert
2011-08-23 18:33:27 -04:00
parent 4265408581
commit ebee1eb665
4 changed files with 5 additions and 3 deletions

View File

@@ -260,7 +260,7 @@ class Upload < ActiveRecord::Base
self.file_path = temp_file_path
if file.tempfile
if file.respond_to?(:tempfile) && file.tempfile
FileUtils.cp(file.tempfile.path, file_path)
else
File.open(file_path, 'wb') do |out|

View File

@@ -64,7 +64,9 @@ class UploadsControllerTest < ActionController::TestCase
context "create action" do
should "create a new upload" do
assert_difference("Upload.count", 1) do
post :create, {:upload => {:file => upload_jpeg("#{Rails.root}/test/files/test.jpg"), :tag_string => "aaa", :rating => "q", :source => "aaa"}}, {:user_id => @user.id}
file = Rack::Test::UploadedFile.new("#{Rails.root}/test/files/test.jpg", "image/jpeg")
file.stubs(:tempfile).returns(file)
post :create, {:upload => {:file => file, :tag_string => "aaa", :rating => "q", :source => "aaa"}}, {:user_id => @user.id}
end
end
end

View File

@@ -18,7 +18,7 @@ module UploadTestMethods
define_method(:original_filename) {filename}
define_method(:content_type) {content_type}
end
tempfile
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB