From 0f20a6f0aaecda85c1b698f3ddecf34d76a2ee35 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Fri, 5 Jun 2020 07:43:15 +0530 Subject: [PATCH] FIX: use `short_path` of flair upload to get signed url for secure media. If we use `upload.url` for secure urls then the images won't render. --- app/models/group.rb | 2 +- spec/jobs/migrate_group_flair_images_spec.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/group.rb b/app/models/group.rb index d99fb257212..0988cc3303a 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -750,7 +750,7 @@ class Group < ActiveRecord::Base end def flair_url - flair_icon.presence || flair_upload&.url + flair_icon.presence || flair_upload&.short_path end protected diff --git a/spec/jobs/migrate_group_flair_images_spec.rb b/spec/jobs/migrate_group_flair_images_spec.rb index ff3428fc989..cc72d26fa21 100644 --- a/spec/jobs/migrate_group_flair_images_spec.rb +++ b/spec/jobs/migrate_group_flair_images_spec.rb @@ -28,7 +28,9 @@ RSpec.describe Jobs::MigrateGroupFlairImages do end.to change { Upload.count }.by(1) group.reload - expect(group.flair_upload).to eq(Upload.last) + upload = Upload.last + expect(group.flair_upload).to eq(upload) + expect(group.flair_url).to eq(upload.short_path) expect(group[:flair_url]).to eq(nil) end