FIX: include posts with data-orig-src attribute in have_uploads scope query.

This commit is contained in:
Vinoth Kannan 2019-05-16 16:39:38 +05:30
parent 3172172b52
commit 0e677daaee
2 changed files with 2 additions and 1 deletions

View File

@ -117,7 +117,7 @@ class Post < ActiveRecord::Base
scope :have_uploads, -> {
where(
"(posts.cooked LIKE '%<a %' OR posts.cooked LIKE '%<img %') AND (posts.cooked LIKE ? OR posts.cooked LIKE '%/original/%' OR posts.cooked LIKE '%/optimized/%')",
"(posts.cooked LIKE '%<a %' OR posts.cooked LIKE '%<img %') AND (posts.cooked LIKE ? OR posts.cooked LIKE '%/original/%' OR posts.cooked LIKE '%/optimized/%' OR posts.cooked LIKE '%data-orig-src=%')",
"%/uploads/#{RailsMultisite::ConnectionManagement.current_db}/%"
)
}

View File

@ -1348,6 +1348,7 @@ describe Post do
ids << Fabricate(:post, cooked: "A post with upload link <a href='https://cdn.example.com/original/1X/abc/defghijklmno.png'>").id
ids << Fabricate(:post, cooked: "A post with optimized image <img src='https://cdn.example.com/bucket/optimized/1X/abc/defghijklmno.png'>").id
Fabricate(:post, cooked: "A post with external link <a href='https://example.com/wp-content/uploads/abcdef.gif'>")
ids << Fabricate(:post, cooked: 'A post with missing upload <img src="https://cdn.example.com/images/transparent.png" data-orig-src="upload://defghijklmno.png">').id
expect(Post.have_uploads.order(:id).pluck(:id)).to eq(ids)
end
end