Upload#is_downloadable? returns true for https sources
This commit is contained in:
@@ -247,7 +247,7 @@ class Upload < ActiveRecord::Base
|
||||
module DownloaderMethods
|
||||
# Determines whether the source is downloadable
|
||||
def is_downloadable?
|
||||
source =~ /^http:\/\// && file_path.blank?
|
||||
source =~ /^https?:\/\// && file_path.blank?
|
||||
end
|
||||
|
||||
# Downloads the file to destination_path
|
||||
|
||||
@@ -79,6 +79,23 @@ class UploadTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "determining if a file is downloadable" do
|
||||
should "classify HTTP sources as downloadable" do
|
||||
@upload = FactoryGirl.create(:source_upload, source: "http://www.example.com/1.jpg")
|
||||
assert_not_nil(@upload.is_downloadable?)
|
||||
end
|
||||
|
||||
should "classify HTTPS sources as downloadable" do
|
||||
@upload = FactoryGirl.create(:source_upload, source: "https://www.example.com/1.jpg")
|
||||
assert_not_nil(@upload.is_downloadable?)
|
||||
end
|
||||
|
||||
should "classify non-HTTP/HTTPS sources as not downloadable" do
|
||||
@upload = FactoryGirl.create(:source_upload, source: "ftp://www.example.com/1.jpg")
|
||||
assert_nil(@upload.is_downloadable?)
|
||||
end
|
||||
end
|
||||
|
||||
context "file processor" do
|
||||
should "parse and process a cgi file representation" do
|
||||
FileUtils.cp("#{Rails.root}/test/files/test.jpg", "#{Rails.root}/tmp")
|
||||
|
||||
Reference in New Issue
Block a user