FIX: Use CDN for custom emojis (#11401)

This commit is contained in:
Bianca Nenciu 2020-12-07 13:36:08 +02:00 committed by GitHub
parent ed52577e1c
commit 154c8c3fef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -2,4 +2,8 @@
class EmojiSerializer < ApplicationSerializer
attributes :name, :url, :group
def url
Discourse.store.cdn_url(object.url)
end
end

View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe EmojiSerializer do
fab!(:emoji) do
CustomEmoji.create!(name: 'trout', upload: Fabricate(:upload))
Emoji.load_custom.first
end
subject { described_class.new(emoji, root: false) }
describe '#url' do
it 'returns a valid URL' do
expect(subject.url).to start_with('/uploads/')
end
it 'works with a CDN' do
set_cdn_url('https://cdn.com')
expect(subject.url).to start_with('https://cdn.com')
end
end
end