From 32c0f6777aadb6a0a755158bd27fb144d58d9efb Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Mon, 29 Mar 2021 14:27:46 -0700 Subject: [PATCH 1/2] don't allow edits to adjustments for canceled orders --- .../admin/adjustments/_adjustments_table.html.haml | 7 ++++--- spec/features/admin/adjustments_spec.rb | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/views/spree/admin/adjustments/_adjustments_table.html.haml b/app/views/spree/admin/adjustments/_adjustments_table.html.haml index 7b916f5aee..cbc7df005b 100644 --- a/app/views/spree/admin/adjustments/_adjustments_table.html.haml +++ b/app/views/spree/admin/adjustments/_adjustments_table.html.haml @@ -17,6 +17,7 @@ %td.align-center.label= adjustment.label %td.align-center.amount= adjustment.display_amount.to_html %td.align-center.included-tax= adjustment.display_included_tax.to_html - %td.actions - = link_to_edit adjustment, no_text: true - = link_to_delete adjustment, no_text: true + - unless @order.canceled? + %td.actions + = link_to_edit adjustment, no_text: true + = link_to_delete adjustment, no_text: true diff --git a/spec/features/admin/adjustments_spec.rb b/spec/features/admin/adjustments_spec.rb index 9d74afd410..2a906824b3 100644 --- a/spec/features/admin/adjustments_spec.rb +++ b/spec/features/admin/adjustments_spec.rb @@ -87,4 +87,17 @@ feature ' expect(page).to have_selector 'td.amount', text: '110' expect(page).to have_selector 'td.included-tax', text: '10' end + + scenario "viewing adjustments on a canceled order" do + # Given a taxed adjustment + adjustment = create(:adjustment, label: "Extra Adjustment", adjustable: order, + amount: 110, included_tax: 10, order: order) + order.cancel! + + login_as_admin_and_visit spree.edit_admin_order_path(order) + + click_link 'Adjustments' + + expect(page).to_not have_selector('tr a.icon-edit') + end end From c0cbd1e6888002879d3d602d6e1d91f6101086cf Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Fri, 2 Apr 2021 12:26:59 -0700 Subject: [PATCH 2/2] remove new adjustment button for canceled orders --- app/views/spree/admin/adjustments/index.html.haml | 3 ++- spec/features/admin/adjustments_spec.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/spree/admin/adjustments/index.html.haml b/app/views/spree/admin/adjustments/index.html.haml index 4aa8de7967..31d0e9bff9 100644 --- a/app/views/spree/admin/adjustments/index.html.haml +++ b/app/views/spree/admin/adjustments/index.html.haml @@ -6,7 +6,8 @@ = t(:adjustments) - content_for :page_actions do - %li= button_link_to t(:new_adjustment), new_admin_order_adjustment_url(@order), :icon => 'icon-plus' + - unless @order.canceled? + %li= button_link_to t(:new_adjustment), new_admin_order_adjustment_url(@order), :icon => 'icon-plus' = render partial: 'spree/admin/shared/order_links' %li= button_link_to t(:back_to_orders_list), admin_orders_path, :icon => 'icon-arrow-left' diff --git a/spec/features/admin/adjustments_spec.rb b/spec/features/admin/adjustments_spec.rb index 2a906824b3..9e6b192bc3 100644 --- a/spec/features/admin/adjustments_spec.rb +++ b/spec/features/admin/adjustments_spec.rb @@ -99,5 +99,6 @@ feature ' click_link 'Adjustments' expect(page).to_not have_selector('tr a.icon-edit') + expect(page).to_not have_selector('a.icon-plus'), text: I18n.t(:new_adjustment) end end