diff --git a/app/models/upload.rb b/app/models/upload.rb index b037e60de..c22128b14 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -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 diff --git a/test/functional/uploads_controller_test.rb b/test/functional/uploads_controller_test.rb index b763c8a2f..dba826462 100644 --- a/test/functional/uploads_controller_test.rb +++ b/test/functional/uploads_controller_test.rb @@ -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 diff --git a/tmp/test.jpg b/tmp/test.jpg deleted file mode 100644 index 253c508d9..000000000 Binary files a/tmp/test.jpg and /dev/null differ