This quick-fixes an issue with existing award emoji not being valid anymore
Gitlab::Emoji#gl_emoji_tag now returns early instead of raising a 500 error. Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
4a81867df1
commit
b196ee31d7
2 changed files with 18 additions and 15 deletions
|
@ -44,27 +44,17 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
# CSS sprite fallback takes precedence over image fallback
|
# CSS sprite fallback takes precedence over image fallback
|
||||||
def gl_emoji_tag(name, image: false, sprite: false, force_fallback: false)
|
def gl_emoji_tag(name)
|
||||||
emoji_name = emojis_aliases[name] || name
|
emoji_name = emojis_aliases[name] || name
|
||||||
emoji_info = emojis[emoji_name]
|
emoji_info = emojis[emoji_name]
|
||||||
emoji_fallback_image_source = ActionController::Base.helpers.url_to_image("emoji/#{emoji_info['name']}.png")
|
return unless emoji_info
|
||||||
emoji_fallback_sprite_class = "emoji-#{emoji_name}"
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
name: emoji_name,
|
name: emoji_name,
|
||||||
unicode_version: emoji_unicode_version(emoji_name)
|
unicode_version: emoji_unicode_version(emoji_name)
|
||||||
}
|
}
|
||||||
data[:fallback_src] = emoji_fallback_image_source if image
|
|
||||||
data[:fallback_sprite_class] = emoji_fallback_sprite_class if sprite
|
ActionController::Base.helpers.content_tag('gl-emoji', emoji_info['moji'], data: data)
|
||||||
ActionController::Base.helpers.content_tag 'gl-emoji',
|
|
||||||
class: ("emoji-icon #{emoji_fallback_sprite_class}" if force_fallback && sprite),
|
|
||||||
data: data do
|
|
||||||
if force_fallback && !sprite
|
|
||||||
emoji_image_tag(emoji_name, emoji_fallback_image_source)
|
|
||||||
else
|
|
||||||
emoji_info['moji']
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,8 +17,21 @@ describe 'Awards Emoji', feature: true do
|
||||||
login_as(user)
|
login_as(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'visiting an issue with a legacy award emoji that is not valid anymore' do
|
||||||
|
before do
|
||||||
|
# The `heart_tip` emoji is not valid anymore so we need to skip validation
|
||||||
|
issue.award_emoji.build(user: user, name: 'heart_tip').save!(validate: false)
|
||||||
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Regression test: https://gitlab.com/gitlab-org/gitlab-ce/issues/29529
|
||||||
|
it 'does not shows a 500 page' do
|
||||||
|
expect(page).to have_text(issue.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'Click award emoji from issue#show' do
|
describe 'Click award emoji from issue#show' do
|
||||||
let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") }
|
let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
visit namespace_project_issue_path(project.namespace, project, issue)
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
||||||
|
|
Loading…
Reference in a new issue