Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add convenience method for retrieving emojis

Kabiru Mwenja993991ae7687
diff --git a/app/models/emoji_reaction.rb b/app/models/emoji_reaction.rb
index db414e4b586..00d0432a477 100644
--- a/app/models/emoji_reaction.rb
+++ b/app/models/emoji_reaction.rb
@@ -53,4 +53,8 @@ class EmojiReaction < ApplicationRecord
def self.emoji(reaction)
EMOJI_MAP[reaction.to_sym]
end
+
+ def emoji
+ self.class.emoji(reaction)
+ end
end
diff --git a/lib/api/v3/emoji_reactions/emoji_reaction_representer.rb b/lib/api/v3/emoji_reactions/emoji_reaction_representer.rb
index 044fb3540c5..0b54e7e661e 100644
--- a/lib/api/v3/emoji_reactions/emoji_reaction_representer.rb
+++ b/lib/api/v3/emoji_reactions/emoji_reaction_representer.rb
@@ -84,9 +84,7 @@ module API
exec_context: :decorator,
getter: ->(*) { "#{represented.reactable_id}-#{represented.reaction}" }
property :reaction
- property :emoji,
- exec_context: :decorator,
- getter: ->(*) { ::EmojiReaction.emoji(represented.reaction) }
+ property :emoji
property :reactions_count
date_time_property :first_created_at, as: :firstReactionAt
diff --git a/spec/models/emoji_reaction_spec.rb b/spec/models/emoji_reaction_spec.rb
index 28f92b352a4..f9202942428 100644
--- a/spec/models/emoji_reaction_spec.rb
+++ b/spec/models/emoji_reaction_spec.rb
@@ -89,4 +89,11 @@ RSpec.describe EmojiReaction do
expect(described_class.emoji("rock_on")).to be_nil
end
end
+
+ describe "#emoji" do
+ it "returns the emoji for the reaction" do
+ emoji_reaction = build_stubbed(:emoji_reaction, reaction: :thumbs_up)
+ expect(emoji_reaction.emoji).to eq("👍")
+ end
+ end
end