Skip to content

Commit 6acb1cb

Browse files
committed
Instruction: displays better diff for scopes
1 parent 2f7bba2 commit 6acb1cb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/decorators/authorization_request_event_decorator.rb

+14-2
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,31 @@ def changelog_diffs_without_blank_values
7474
changelog_diffs.reject { |_h, v| v[0].blank? }
7575
end
7676

77+
# rubocop:disable Metrics/AbcSize
7778
def build_scopes_change(values)
7879
new_scopes = values[1] - values[0]
7980
removed_scopes = values[0] - values[1]
8081

8182
[
8283
new_scopes.map do |scope|
83-
h.content_tag(:li, t('authorization_request_event.changelog_entry_new_scope', value: scope).html_safe)
84+
h.content_tag(:li, t('authorization_request_event.changelog_entry_new_scope', value: humanized_scope(scope)).html_safe)
8485
end,
8586
removed_scopes.map do |scope|
86-
h.content_tag(:li, t('authorization_request_event.changelog_entry_removed_scope', value: scope).html_safe)
87+
h.content_tag(:li, t('authorization_request_event.changelog_entry_removed_scope', value: humanized_scope(scope)).html_safe)
8788
end
8889
]
8990
end
91+
# rubocop:enable Metrics/AbcSize
92+
93+
def humanized_scope(scope_value)
94+
scope = authorization_request.definition.scopes.find { |s| s.value == scope_value }
95+
96+
if scope
97+
[scope.name, "(#{scope_value})"].join(' ')
98+
else
99+
scope_value
100+
end
101+
end
90102

91103
def build_attribute_change(attribute, values)
92104
if values[0].blank?

0 commit comments

Comments
 (0)