Merge pull request #2295 from evazion/fix-source-rewriting

Possible fix for #2294
This commit is contained in:
Toks
2014-10-29 00:18:48 -04:00
4 changed files with 16 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ gem "uglifier"
gem 'coffee-rails'
gem "therubyracer", :platforms => :ruby
gem "pry", :group => [:test, :development]
gem "pry-debugger", :group => [:test, :development]
gem "rails", "~> 4.1.5"
gem "pg"
gem "kgio"

View File

@@ -69,10 +69,17 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.7.0)
columnize (0.8.9)
crack (0.4.2)
safe_yaml (~> 1.0.0)
daemons (1.1.9)
dalli (2.7.0)
debugger (1.6.8)
columnize (>= 0.3.1)
debugger-linecache (~> 1.2.0)
debugger-ruby_core_source (~> 1.3.5)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.3.5)
delayed_job (4.0.1)
activesupport (>= 3.0, < 4.2)
delayed_job_active_record (4.0.1)
@@ -136,6 +143,9 @@ GEM
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pry-debugger (0.2.3)
debugger (~> 1.3)
pry (>= 0.9.10, < 0.11.0)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
@@ -259,6 +269,7 @@ DEPENDENCIES
pg
protected_attributes
pry
pry-debugger
radix62 (~> 1.0.1)
rails (~> 4.1.5)
rmagick

View File

@@ -91,7 +91,7 @@ class Upload < ActiveRecord::Base
CurrentUser.scoped(uploader, uploader_ip_addr) do
update_attribute(:status, "processing")
if is_downloadable?
download_from_source(temp_file_path)
self.source = download_from_source(temp_file_path)
end
validate_file_exists
self.content_type = file_header_to_content_type(file_path)
@@ -366,6 +366,7 @@ class Upload < ActiveRecord::Base
download = Downloads::File.new(source, destination_path)
download.download!
ugoira_service.load(download.data)
download.source
end
end

View File

@@ -221,6 +221,7 @@ class UploadTest < ActiveSupport::TestCase
end
post = Post.last
assert_equal("http://www.google.com/intl/en_ALL/images/logo.gif", post.source)
assert_equal("foo hoge lowres", post.tag_string)
assert_equal("s", post.rating)
assert_equal(@upload.uploader_id, post.uploader_id)
@@ -251,6 +252,7 @@ class UploadTest < ActiveSupport::TestCase
assert_equal("0d94800c4b520bf3d8adda08f95d31e2", post.md5)
assert_equal(60, post.image_width)
assert_equal(60, post.image_height)
assert_equal("http://i1.pixiv.net/img-zip-ugoira/img/2014/10/05/23/42/23/46378654_ugoira1920x1080.zip", post.source)
assert_operator(File.size(post.large_file_path), :>, 0)
assert_operator(File.size(post.preview_file_path), :>, 0)
end