diff options
author | Rémy Coutable <remy@rymai.me> | 2016-07-18 07:35:30 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-07-18 07:35:30 +0000 |
commit | 65352b5baaf269a609b024fd13efc81e8bbdcefa (patch) | |
tree | d311bae9c90a704f2427aadf442ac4c69407e731 /app/models | |
parent | 1bf57b75119deb79f5826245d4c69a0a83cc4864 (diff) | |
parent | e21492b810bf9cd30f0e60836c056a72e830f427 (diff) | |
download | gitlab-ce-65352b5baaf269a609b024fd13efc81e8bbdcefa.tar.gz |
Merge branch 'normalize_emoji_aliases_paths' into 'master'
Fix not normalized emoji paths
## What does this MR do?
It normalizes emoji names in `api` and `toggle_award`
## Are there points in the code the reviewer needs to double check?
## Why was this MR needed?
User was able to store +1 and thumbsup to databse, causing UI inconsistency.
## What are the relevant issue numbers?
Fixes #19104
## Screenshots (if relevant)
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] API support added
- Tests
- [x] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
See merge request !5060
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/awardable.rb | 9 | ||||
-rw-r--r-- | app/models/note.rb | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/app/models/concerns/awardable.rb b/app/models/concerns/awardable.rb index 06beff177b1..800a16ab246 100644 --- a/app/models/concerns/awardable.rb +++ b/app/models/concerns/awardable.rb @@ -65,8 +65,7 @@ module Awardable def create_award_emoji(name, current_user) return unless emoji_awardable? - - award_emoji.create(name: name, user: current_user) + award_emoji.create(name: normalize_name(name), user: current_user) end def remove_award_emoji(name, current_user) @@ -80,4 +79,10 @@ module Awardable create_award_emoji(emoji_name, current_user) end end + + private + + def normalize_name(name) + Gitlab::AwardEmoji.normalize_emoji_name(name) + end end diff --git a/app/models/note.rb b/app/models/note.rb index 8dca2ef09a8..0ce10c77de9 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -229,8 +229,7 @@ class Note < ActiveRecord::Base end def award_emoji_name - original_name = note.match(Banzai::Filter::EmojiFilter.emoji_pattern)[1] - Gitlab::AwardEmoji.normalize_emoji_name(original_name) + note.match(Banzai::Filter::EmojiFilter.emoji_pattern)[1] end private |