From 4cebe3b4b47245b85e36839d442399cf3c508fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Fri, 22 Jun 2018 16:59:27 +0200 Subject: [PATCH 1/2] [api] Do not use succeed + surround `succeed` appends a string to the end of a Haml block, and `surround` appends strings to the end and the beginning. Because of that, if we already need to use `surround`, it doesn't make sense to use `succeed` as well. It is also more readable, as what we want is just a comma after the closing parenthesis. --- .../app/views/webui/request/_superseded_by_message.html.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/api/app/views/webui/request/_superseded_by_message.html.haml b/src/api/app/views/webui/request/_superseded_by_message.html.haml index 45074a8b3b4..c8d671635a3 100644 --- a/src/api/app/views/webui/request/_superseded_by_message.html.haml +++ b/src/api/app/views/webui/request/_superseded_by_message.html.haml @@ -5,9 +5,8 @@ This request supersedes: - superseding.each_with_index do |bs_request, index| = link_to "request #{bs_request.number}", request_show_path(number: bs_request.number) - = succeed (', ' if index < superseding.length - 1) do - = surround '(', ')' do - = link_to('Show diff', request_show_path(number: bs_request.superseded_by, diff_to_superseded: bs_request.number)) + = surround '(', ")#{', ' if index < superseding.length - 1 }" do + = link_to('Show diff', request_show_path(number: bs_request.superseded_by, diff_to_superseded: bs_request.number)) - if superseded_by.present? .grid_16.alpha.omega.box-invisible .ui-state-info.ui-corner-all.ui-widget-shadow.padding-10pt#request-superseded-by-hint From 4a5709fae5a88fcc085ac72657a97e454a807845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Fri, 22 Jun 2018 17:04:34 +0200 Subject: [PATCH 2/2] [api] Use superseding.last instead of index We want a comma except for the last record, because of that I think that it is more readable to use `superseding.last` than using an index and comparing it with `superseding.length - 1`. This way we also don't need to use `each_with_index`, as we don't really care of what index every record have. This may be a matter of taste, but I find it more elegant. --- .../app/views/webui/request/_superseded_by_message.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/app/views/webui/request/_superseded_by_message.html.haml b/src/api/app/views/webui/request/_superseded_by_message.html.haml index c8d671635a3..73d5584f499 100644 --- a/src/api/app/views/webui/request/_superseded_by_message.html.haml +++ b/src/api/app/views/webui/request/_superseded_by_message.html.haml @@ -3,9 +3,9 @@ .ui-state-info.ui-corner-all.ui-widget-shadow.padding-10pt#request-supersedes-hint %span.ui-icon.ui-icon-info This request supersedes: - - superseding.each_with_index do |bs_request, index| + - superseding.each do |bs_request| = link_to "request #{bs_request.number}", request_show_path(number: bs_request.number) - = surround '(', ")#{', ' if index < superseding.length - 1 }" do + = surround '(', ")#{', ' unless bs_request == superseding.last }" do = link_to('Show diff', request_show_path(number: bs_request.superseded_by, diff_to_superseded: bs_request.number)) - if superseded_by.present? .grid_16.alpha.omega.box-invisible