FIX: use new changed method name and remove whitespaces
This commit is contained in:
parent
bc949cf684
commit
f5ac01253a
|
@ -8,16 +8,16 @@ module HasUrl
|
|||
|
||||
def get_from_url(url)
|
||||
return if url.blank?
|
||||
|
||||
|
||||
uri = begin
|
||||
URI(URI.unescape(url))
|
||||
rescue URI::Error
|
||||
end
|
||||
|
||||
|
||||
return if uri&.path.blank?
|
||||
data = extract_url(uri.path)
|
||||
return if data.blank?
|
||||
|
||||
|
||||
self.find_by("url LIKE ?", "%#{data[1]}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ class UploadRecovery
|
|||
recover_post_upload(post, Upload.sha1_from_short_url(orig_src))
|
||||
end
|
||||
elsif url = (media["href"] || media["src"])
|
||||
data = Upload.extract_upload_url(url)
|
||||
data = Upload.extract_url(url)
|
||||
next unless data
|
||||
|
||||
sha1 = data[2]
|
||||
|
@ -58,7 +58,7 @@ class UploadRecovery
|
|||
background = user_profile.public_send(column)
|
||||
|
||||
if background.present? && !Upload.exists?(url: background)
|
||||
data = Upload.extract_upload_url(background)
|
||||
data = Upload.extract_url(background)
|
||||
next unless data
|
||||
sha1 = data[2]
|
||||
|
||||
|
|
|
@ -95,6 +95,14 @@ describe Upload do
|
|||
expect(created_upload.valid?).to eq(false)
|
||||
end
|
||||
|
||||
context ".extract_url" do
|
||||
let(:url) { 'https://example.com/uploads/default/original/1X/d1c2d40ab994e8410c.png' }
|
||||
|
||||
it 'should return the right part of url' do
|
||||
expect(Upload.extract_url(url).to_s).to eq('/original/1X/d1c2d40ab994e8410c.png')
|
||||
end
|
||||
end
|
||||
|
||||
context ".get_from_url" do
|
||||
let(:sha1) { "10f73034616a796dfd70177dc54b6def44c4ba6f" }
|
||||
let(:upload) { Fabricate(:upload, sha1: sha1) }
|
||||
|
|
Loading…
Reference in New Issue