Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Add failing test for pull-hotlinked codeblocks #23682

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions spec/jobs/pull_hotlinked_images_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,23 @@
expect(post.reload.raw).to eq("[Images](#{url})\n![](#{Upload.last.short_url})")
end

it "does not replace images in code blocks", skip: "Known issue" do
post = Fabricate(:post, raw: <<~RAW)
![realimage](#{image_url})
`![codeblockimage](#{image_url})`
RAW
stub_image_size

expect do Jobs::PullHotlinkedImages.new.execute(post_id: post.id) end.to change {
Upload.count
}.by(1)

expect(post.reload.raw).to eq(<<~RAW)
![realimage](#{Upload.last.short_url})
`![codeblockimage](#{image_url})`
RAW
end

it "replaces images without protocol" do
url = image_url.sub(/^https?\:/, "")
post = Fabricate(:post, raw: "<img alt='test' src='#{url}'>")
Expand Down
12 changes: 12 additions & 0 deletions spec/services/inline_uploads_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,18 @@
MD
end

it "should not replace identical markdown in code blocks", skip: "Known issue" do
md = <<~MD
`![image|690x290](#{upload.url})`
![image|690x290](#{upload.url})
MD

expect(InlineUploads.process(md)).to eq(<<~MD)
`![image|690x290](#{upload.url})`
![image|690x290](#{upload.short_url})
MD
end

it "should not be affected by an emoji" do
CustomEmoji.create!(name: "test", upload: upload3)
Emoji.clear_cache
Expand Down