mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: remove 'crawl_images' site setting (#14646)
This commit is contained in:
@@ -37,6 +37,7 @@ describe Jobs::ProcessPost do
|
||||
it 'processes posts' do
|
||||
post = Fabricate(:post, raw: "<img src='#{Discourse.base_url_no_prefix}/awesome/picture.png'>")
|
||||
expect(post.cooked).to match(/http/)
|
||||
stub_image_size
|
||||
|
||||
Jobs::ProcessPost.new.execute(post_id: post.id)
|
||||
post.reload
|
||||
@@ -53,6 +54,7 @@ describe Jobs::ProcessPost do
|
||||
it "extracts links to quoted posts" do
|
||||
quoted_post = Fabricate(:post, raw: "This is a post with a link to https://www.discourse.org", post_number: 42)
|
||||
post.update_columns(raw: "This quote is the best\n\n[quote=\"#{quoted_post.user.username}, topic:#{quoted_post.topic_id}, post:#{quoted_post.post_number}\"]\n#{quoted_post.excerpt}\n[/quote]")
|
||||
stub_image_size
|
||||
# when creating a quote, we also create the reflexion link
|
||||
expect { Jobs::ProcessPost.new.execute(post_id: post.id) }.to change { TopicLink.count }.by(2)
|
||||
end
|
||||
@@ -60,6 +62,7 @@ describe Jobs::ProcessPost do
|
||||
it "extracts links to oneboxed topics" do
|
||||
oneboxed_post = Fabricate(:post)
|
||||
post.update_columns(raw: "This post is the best\n\n#{oneboxed_post.full_url}")
|
||||
stub_image_size
|
||||
# when creating a quote, we also create the reflexion link
|
||||
expect { Jobs::ProcessPost.new.execute(post_id: post.id) }.to change { TopicLink.count }.by(2)
|
||||
end
|
||||
|
||||
@@ -31,7 +31,6 @@ describe Jobs::PullHotlinkedImages do
|
||||
"#{Discourse.base_url}/#{upload_path}/original/1X/c530c06cf89c410c0355d7852644a73fc3ec8c04.png"
|
||||
)
|
||||
|
||||
SiteSetting.crawl_images = true
|
||||
SiteSetting.download_remote_images_to_local = true
|
||||
SiteSetting.max_image_size_kb = 2
|
||||
SiteSetting.download_remote_images_threshold = 0
|
||||
@@ -62,6 +61,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
|
||||
it 'replaces images' do
|
||||
post = Fabricate(:post, raw: "<img src='#{image_url}'>")
|
||||
stub_image_size
|
||||
|
||||
expect do
|
||||
Jobs::PullHotlinkedImages.new.execute(post_id: post.id)
|
||||
@@ -73,6 +73,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
|
||||
it 'removes downloaded images when they are no longer needed' do
|
||||
post = Fabricate(:post, raw: "<img src='#{image_url}'>")
|
||||
stub_image_size
|
||||
post.rebake!
|
||||
post.reload
|
||||
expect(post.post_uploads.count).to eq(1)
|
||||
@@ -85,6 +86,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
|
||||
it 'replaces images again after edit' do
|
||||
post = Fabricate(:post, raw: "<img src='#{image_url}'>")
|
||||
stub_image_size
|
||||
|
||||
expect do
|
||||
post.rebake!
|
||||
@@ -104,6 +106,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
|
||||
it 'replaces encoded image urls' do
|
||||
post = Fabricate(:post, raw: "<img src='#{encoded_image_url}'>")
|
||||
stub_image_size
|
||||
expect do
|
||||
Jobs::PullHotlinkedImages.new.execute(post_id: post.id)
|
||||
end.to change { Upload.count }.by(1)
|
||||
@@ -143,6 +146,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
it 'replaces correct image URL' do
|
||||
url = image_url.sub("/2e/Longcat1.png", '')
|
||||
post = Fabricate(:post, raw: "[Images](#{url})\n")
|
||||
stub_image_size
|
||||
|
||||
expect do
|
||||
Jobs::PullHotlinkedImages.new.execute(post_id: post.id)
|
||||
@@ -154,6 +158,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
it 'replaces images without protocol' do
|
||||
url = image_url.sub(/^https?\:/, '')
|
||||
post = Fabricate(:post, raw: "<img alt='test' src='#{url}'>")
|
||||
stub_image_size
|
||||
|
||||
expect do
|
||||
Jobs::PullHotlinkedImages.new.execute(post_id: post.id)
|
||||
@@ -166,6 +171,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
url = image_url.sub(/\.[a-zA-Z0-9]+$/, '')
|
||||
stub_request(:get, url).to_return(body: png, headers: { "Content-Type" => "image/png" })
|
||||
post = Fabricate(:post, raw: "<img src='#{url}'>")
|
||||
stub_image_size
|
||||
|
||||
expect do
|
||||
Jobs::PullHotlinkedImages.new.execute(post_id: post.id)
|
||||
@@ -182,6 +188,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
.to_return(status: 200, body: file_from_fixtures("smallest.png"))
|
||||
|
||||
post = Fabricate(:post, raw: "<img src='#{url}'>")
|
||||
stub_image_size
|
||||
|
||||
expect { Jobs::PullHotlinkedImages.new.execute(post_id: post.id) }
|
||||
.to change { Upload.count }.by(1)
|
||||
@@ -261,6 +268,7 @@ describe Jobs::PullHotlinkedImages do
|
||||

|
||||

|
||||
MD
|
||||
stub_image_size
|
||||
|
||||
expect { Jobs::PullHotlinkedImages.new.execute(post_id: post.id) }
|
||||
.to change { Upload.count }.by(1)
|
||||
@@ -281,6 +289,7 @@ describe Jobs::PullHotlinkedImages do
|
||||

|
||||

|
||||
MD
|
||||
stub_image_size
|
||||
|
||||
expect { Jobs::PullHotlinkedImages.new.execute(post_id: post.id) }
|
||||
.to change { Upload.count }.by(1)
|
||||
@@ -296,6 +305,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
#{image_url}
|
||||
[/img]
|
||||
MD
|
||||
stub_image_size
|
||||
|
||||
expect { Jobs::PullHotlinkedImages.new.execute(post_id: post.id) }
|
||||
.to change { Upload.count }.by(1)
|
||||
@@ -336,6 +346,8 @@ describe Jobs::PullHotlinkedImages do
|
||||
|
||||
it 'replaces image src' do
|
||||
post = Fabricate(:post, raw: "#{url}")
|
||||
stub_image_size
|
||||
|
||||
post.rebake!
|
||||
post.reload
|
||||
|
||||
@@ -345,6 +357,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
|
||||
it 'associates uploads correctly' do
|
||||
post = Fabricate(:post, raw: "#{url}")
|
||||
stub_image_size
|
||||
post.rebake!
|
||||
post.reload
|
||||
|
||||
@@ -364,6 +377,7 @@ describe Jobs::PullHotlinkedImages do
|
||||
<img src='#{broken_image_url}'>
|
||||
<a href='#{url}'><img src='#{large_image_url}'></a>
|
||||
BODY
|
||||
stub_image_size
|
||||
|
||||
2.times do
|
||||
post.rebake!
|
||||
|
||||
Reference in New Issue
Block a user