Commit c48418b8 authored by Dan Jensen's avatar Dan Jensen

Allow numeric emoji names in validation

Sometimes the frontend sends numeric emoji names as numbers instead
of strings. Previously the backend would raise an ArgumentError when
it received a number. This modifies the backend to convert all values
to string before validating they are actual emoji names, thereby
fixing the bug.
parent 45e3f2e5
......@@ -41,7 +41,7 @@ class AwardEmojisFinder
def validate_name_param
return unless params[:name]
raise ArgumentError, 'Invalid name param' unless params[:name].in?(Gitlab::Emoji.emojis_names)
raise ArgumentError, 'Invalid name param' unless params[:name].to_s.in?(Gitlab::Emoji.emojis_names)
end
def validate_awarded_by_param
......
---
title: Fix backend validation of numeric emoji names
merge_request: 27101
author:
type: fixed
......@@ -20,6 +20,11 @@ describe AwardEmojisFinder do
)
end
it 'does not raise an error if `name` is numeric' do
subject = described_class.new(issue_1, { name: 100 })
expect { subject.execute }.not_to raise_error
end
it 'raises an error if `awarded_by` is invalid' do
expectation = [ArgumentError, 'Invalid awarded_by param']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment