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:
parent
b7b233423d
commit
636d05fc20
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue