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

After this change, a reason won't exclusively be a translation key anymore, but now, it can display a custom reason as well.
This commit is contained in:
Roman Rizzi 2024-08-14 15:53:59 -03:00 committed by GitHub
parent b7b233423d
commit 636d05fc20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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