FIX: Use CDN URLs for topic thumbnails
This commit is contained in:
parent
162d125b83
commit
0495a748d0
|
@ -84,6 +84,8 @@ class Topic < ActiveRecord::Base
|
|||
Jobs.enqueue(:generate_topic_thumbnails, { topic_id: id, extra_sizes: extra_sizes })
|
||||
end
|
||||
|
||||
infos.each { |i| i[:url] = UrlHelper.cook_url(i[:url], secure: original.secure?) }
|
||||
|
||||
infos.sort_by! { |i| -i[:width] * i[:height] }
|
||||
end
|
||||
|
||||
|
@ -102,7 +104,9 @@ class Topic < ActiveRecord::Base
|
|||
record.max_width == Topic.share_thumbnail_size[0] &&
|
||||
record.max_height == Topic.share_thumbnail_size[1]
|
||||
end
|
||||
thumbnail&.optimized_image&.url || image_upload&.url
|
||||
|
||||
raw_url = thumbnail&.optimized_image&.url || image_upload&.url
|
||||
UrlHelper.cook_url(raw_url, secure: image_upload&.secure?)
|
||||
end
|
||||
|
||||
def featured_users
|
||||
|
|
|
@ -726,9 +726,9 @@ describe TopicView do
|
|||
end
|
||||
|
||||
it "uses the topic image as a fallback when posts have no image" do
|
||||
expect(topic_view_for_post(1).image_url).to eq(op_upload.url)
|
||||
expect(topic_view_for_post(2).image_url).to eq(op_upload.url)
|
||||
expect(topic_view_for_post(3).image_url).to eq(post3_upload.url)
|
||||
expect(topic_view_for_post(1).image_url).to end_with(op_upload.url)
|
||||
expect(topic_view_for_post(2).image_url).to end_with(op_upload.url)
|
||||
expect(topic_view_for_post(3).image_url).to end_with(post3_upload.url)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -736,7 +736,7 @@ describe TopicView do
|
|||
it "returns nil when posts have no image" do
|
||||
expect(topic_view_for_post(1).image_url).to eq(nil)
|
||||
expect(topic_view_for_post(2).image_url).to eq(nil)
|
||||
expect(topic_view_for_post(3).image_url).to eq(post3_upload.url)
|
||||
expect(topic_view_for_post(3).image_url).to end_with(post3_upload.url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ describe "Topic Thumbnails" do
|
|||
expect(thumbnails[0]["max_height"]).to eq(nil)
|
||||
expect(thumbnails[0]["width"]).to eq(image.width)
|
||||
expect(thumbnails[0]["height"]).to eq(image.height)
|
||||
expect(thumbnails[0]["url"]).to eq(image.url)
|
||||
expect(thumbnails[0]["url"]).to end_with(image.url)
|
||||
|
||||
# Run the job
|
||||
args = Jobs::GenerateTopicThumbnails.jobs.last["args"].first
|
||||
|
|
|
@ -54,7 +54,7 @@ describe TopicViewSerializer do
|
|||
it 'should return the image url' do
|
||||
json = serialize_topic(topic, user)
|
||||
|
||||
expect(json[:image_url]).to eq(image_upload.url)
|
||||
expect(json[:image_url]).to end_with(image_upload.url)
|
||||
end
|
||||
|
||||
it 'should have thumbnails' do
|
||||
|
|
Loading…
Reference in New Issue