fixed upload tests
This commit is contained in:
@@ -260,7 +260,7 @@ class Upload < ActiveRecord::Base
|
|||||||
|
|
||||||
self.file_path = temp_file_path
|
self.file_path = temp_file_path
|
||||||
|
|
||||||
if file.tempfile
|
if file.respond_to?(:tempfile) && file.tempfile
|
||||||
FileUtils.cp(file.tempfile.path, file_path)
|
FileUtils.cp(file.tempfile.path, file_path)
|
||||||
else
|
else
|
||||||
File.open(file_path, 'wb') do |out|
|
File.open(file_path, 'wb') do |out|
|
||||||
|
|||||||
@@ -64,7 +64,9 @@ class UploadsControllerTest < ActionController::TestCase
|
|||||||
context "create action" do
|
context "create action" do
|
||||||
should "create a new upload" do
|
should "create a new upload" do
|
||||||
assert_difference("Upload.count", 1) 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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
BIN
tmp/test.jpg
BIN
tmp/test.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB |
Reference in New Issue
Block a user