mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 10:52:45 +08:00
FIX: Use CDN for custom emojis (#11401)
This commit is contained in:
parent
ed52577e1c
commit
154c8c3fef
|
@ -2,4 +2,8 @@
|
|||
|
||||
class EmojiSerializer < ApplicationSerializer
|
||||
attributes :name, :url, :group
|
||||
|
||||
def url
|
||||
Discourse.store.cdn_url(object.url)
|
||||
end
|
||||
end
|
||||
|
|
23
spec/serializers/emoji_serializer_spec.rb
Normal file
23
spec/serializers/emoji_serializer_spec.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user