fix upload controller test

This commit is contained in:
albert 2011-07-17 18:50:51 -04:00
parent 98403d0cb7
commit 5a2644f4a6
3 changed files with 9 additions and 9 deletions

View File

@ -17,7 +17,7 @@ class Upload < ActiveRecord::Base
module ValidationMethods
def uploader_is_not_limited
if !uploader.can_upload?
update_column(:status, "error: uploader has reached their daily limit")
update_attribute(:status, "error: uploader has reached their daily limit")
end
end
@ -29,19 +29,19 @@ class Upload < ActiveRecord::Base
def validate_file_exists
unless File.exists?(file_path)
update_column(:status, "error: file does not exist")
update_attribute(:status, "error: file does not exist")
end
end
def validate_file_content_type
unless is_valid_content_type?
update_column(:status, "error: invalid content type (#{file_ext} not allowed)")
update_attribute(:status, "error: invalid content type (#{file_ext} not allowed)")
end
end
def validate_md5_confirmation
if !md5_confirmation.blank? && md5_confirmation != md5
update_column(:status, "error: md5 mismatch")
update_attribute(:status, "error: md5 mismatch")
end
end
end
@ -49,7 +49,7 @@ class Upload < ActiveRecord::Base
module ConversionMethods
def process!
CurrentUser.scoped(uploader, uploader_ip_addr) do
update_column(:status, "processing")
update_attribute(:status, "processing")
if is_downloadable?
download_from_source(temp_file_path)
end
@ -67,12 +67,12 @@ class Upload < ActiveRecord::Base
if post.save
update_attributes(:status => "completed", :post_id => post.id)
else
update_column(:status, "error: " + post.errors.full_messages.join(", "))
update_attribute(:status, "error: " + post.errors.full_messages.join(", "))
end
end
rescue Exception => x
raise
update_column(:status, "error: #{x} - #{x.message}")
update_attribute(:status, "error: #{x} - #{x.message}")
ensure
delete_temp_file
end
@ -99,7 +99,7 @@ class Upload < ActiveRecord::Base
def merge_tags(post)
post.tag_string += " #{tag_string}"
post.save
update_column(:status, "duplicate: #{post.id}")
update_attribute(:status, "duplicate: #{post.id}")
end
end

View File

@ -3,7 +3,7 @@ require 'test_helper'
class UploadsControllerTest < ActionController::TestCase
context "The uploads controller" do
setup do
@user = Factory.create(:user)
@user = Factory.create(:contributor_user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB