Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Allow completely custom score reasons. (#28348)

Roman Rizzi636d05fc20a7
diff --git a/app/serializers/reviewable_score_serializer.rb b/app/serializers/reviewable_score_serializer.rb
index 01f9be909d4..32e084e4328 100644
--- a/app/serializers/reviewable_score_serializer.rb
+++ b/app/serializers/reviewable_score_serializer.rb
@@ -42,9 +42,9 @@ class ReviewableScoreSerializer < ApplicationSerializer
if link_text
link = build_link_for(object.reason, link_text)
- text = I18n.t("reviewables.reasons.#{object.reason}", link: link, default: nil)
+ text = I18n.t("reviewables.reasons.#{object.reason}", link: link, default: object.reason)
else
- text = I18n.t("reviewables.reasons.#{object.reason}", default: nil)
+ text = I18n.t("reviewables.reasons.#{object.reason}", default: object.reason)
end
text
diff --git a/spec/serializers/reviewable_score_serializer_spec.rb b/spec/serializers/reviewable_score_serializer_spec.rb
index d23756a0381..cd603e7de02 100644
--- a/spec/serializers/reviewable_score_serializer_spec.rb
+++ b/spec/serializers/reviewable_score_serializer_spec.rb
@@ -54,6 +54,15 @@ RSpec.describe ReviewableScoreSerializer do
end
end
end
+
+ context "with custom reasons" do
+ it "serializes it without doing any translation" do
+ custom = "completely custom flag reason"
+ serialized = serialized_score(custom)
+
+ expect(serialized.reason).to eq(custom)
+ end
+ end
end
describe "#setting_name_for_reason" do