A platform for community discussion. Free, open, simple.
FEATURE: Let reviewables override the score type title. (#16234)
Roman Rizzi746f8f37973e
diff --git a/app/models/reviewable_score.rb b/app/models/reviewable_score.rbindex 34080a944d9..2cc5cb63bd5 100644--- a/app/models/reviewable_score.rb+++ b/app/models/reviewable_score.rb@@ -53,7 +53,7 @@ class ReviewableScore < ActiveRecord::Baseenddef score_type- Reviewable::Collection::Item.new(reviewable_score_type)+ Reviewable::Collection::Item.new(reviewable_score_type, reason: reason)enddef took_action?diff --git a/app/serializers/reviewable_score_type_serializer.rb b/app/serializers/reviewable_score_type_serializer.rbindex 60368ebcbce..a5f32e38111 100644--- a/app/serializers/reviewable_score_type_serializer.rb+++ b/app/serializers/reviewable_score_type_serializer.rb@@ -5,6 +5,8 @@ class ReviewableScoreTypeSerializer < ApplicationSerializer# Allow us to share post action type translations for backwards compatibilitydef title+ # Calling #try here because post action types don't have a reason method.+ I18n.t("reviewables.reason_titles.#{object.try(:reason)}", default: nil) ||I18n.t("post_action_types.#{ReviewableScore.types[id]}.title", default: nil) ||I18n.t("reviewable_score_types.#{ReviewableScore.types[id]}.title")enddiff --git a/lib/reviewable/collection.rb b/lib/reviewable/collection.rbindex 1a9b354fbc5..449877a1667 100644--- a/lib/reviewable/collection.rb+++ b/lib/reviewable/collection.rb@@ -4,10 +4,11 @@ class Reviewable < ActiveRecord::Baseclass Collectionclass Iteminclude ActiveModel::Serialization- attr_reader :id+ attr_reader :id, :reason- def initialize(id)+ def initialize(id, reason: nil)@id = id+ @reason = reasonendend