FIX: include posts with data-orig-src attribute in have_uploads scope query.
This commit is contained in:
parent
3172172b52
commit
0e677daaee
|
@ -117,7 +117,7 @@ class Post < ActiveRecord::Base
|
||||||
|
|
||||||
scope :have_uploads, -> {
|
scope :have_uploads, -> {
|
||||||
where(
|
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}/%"
|
"%/uploads/#{RailsMultisite::ConnectionManagement.current_db}/%"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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
|
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'>")
|
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)
|
expect(Post.have_uploads.order(:id).pluck(:id)).to eq(ids)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue