From 78f736db454adef347dd2d3dbc80439af32a51b1 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 15 May 2020 09:55:12 +0200 Subject: [PATCH 01/13] Add red border on quantity field when it must be updated --- app/assets/stylesheets/darkswarm/shopping-cart.css.scss | 4 ++++ app/views/spree/orders/_line_item.html.haml | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/darkswarm/shopping-cart.css.scss b/app/assets/stylesheets/darkswarm/shopping-cart.css.scss index bd4a5019c8..3423102b72 100644 --- a/app/assets/stylesheets/darkswarm/shopping-cart.css.scss +++ b/app/assets/stylesheets/darkswarm/shopping-cart.css.scss @@ -102,6 +102,10 @@ float: right; } } + + input.warning { + border: 1px solid $clr-brick; + } } .item-thumb-image { diff --git a/app/views/spree/orders/_line_item.html.haml b/app/views/spree/orders/_line_item.html.haml index cfd4d4a500..5aab298b51 100644 --- a/app/views/spree/orders/_line_item.html.haml +++ b/app/views/spree/orders/_line_item.html.haml @@ -23,7 +23,11 @@ = line_item.single_display_amount_with_adjustments.to_html %td.text-center.cart-item-quantity{"data-hook" => "cart_item_quantity"} - finalized_quantity = @order.completed? ? line_item.quantity : 0 - = item_form.number_field :quantity, :min => 0, "ofn-on-hand" => "#{variant.on_demand && 9999 || variant.on_hand}", "finalizedquantity" => finalized_quantity, "ng-model" => "line_item_#{line_item.id}", :class => "line_item_quantity", :size => 5 + = item_form.number_field :quantity, + :min => 0, "ofn-on-hand" => "#{variant.on_demand && 9999 || variant.on_hand}", + "finalizedquantity" => finalized_quantity, :class => "line_item_quantity", :size => 5, + "ng-model" => "line_item_#{line_item.id}", + "ng-class" => "{ warning: #{@insufficient_stock_lines.andand.include? line_item} }" %td.cart-item-total.text-right{"data-hook" => "cart_item_total"} = line_item.display_amount_with_adjustments.to_html unless line_item.quantity.nil? From 73b533690e505ba8fcd2729459fe9f643e8892dc Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 15 May 2020 10:01:44 +0200 Subject: [PATCH 02/13] Refactor cart update button syntax --- app/views/spree/orders/form/_cart_actions_row.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/orders/form/_cart_actions_row.html.haml b/app/views/spree/orders/form/_cart_actions_row.html.haml index ec3ce122ea..44f74ff858 100644 --- a/app/views/spree/orders/form/_cart_actions_row.html.haml +++ b/app/views/spree/orders/form/_cart_actions_row.html.haml @@ -1,7 +1,7 @@ %tr %td{colspan:"2"} %td - = button_tag :class => 'secondary radius expand small', :id => 'update-button' do + %button#update-button.secondary.radius.expand.small %i.ofn-i_023-refresh = t(:update) %td From 42195b76d3bfc168dc4035725d9486bc2509cb74 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 15 May 2020 10:27:58 +0200 Subject: [PATCH 03/13] Highlight update button when cart page form is "dirty" --- .../darkswarm/controllers/cart_form_controller.js.coffee | 2 ++ app/views/spree/orders/edit.html.haml | 3 ++- app/views/spree/orders/form/_cart_actions_row.html.haml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/controllers/cart_form_controller.js.coffee diff --git a/app/assets/javascripts/darkswarm/controllers/cart_form_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/cart_form_controller.js.coffee new file mode 100644 index 0000000000..73fe91793f --- /dev/null +++ b/app/assets/javascripts/darkswarm/controllers/cart_form_controller.js.coffee @@ -0,0 +1,2 @@ +Darkswarm.controller "CartFormCtrl", ($scope) -> + diff --git a/app/views/spree/orders/edit.html.haml b/app/views/spree/orders/edit.html.haml index f654cfebb1..d9cdb977b3 100644 --- a/app/views/spree/orders/edit.html.haml +++ b/app/views/spree/orders/edit.html.haml @@ -33,7 +33,8 @@ - else %div{"data-hook" => "outside_cart_form"} - = form_for @order, :url => main_app.update_cart_path, :html => {:id => 'update-cart'} do |order_form| + = form_for @order, :url => main_app.update_cart_path, + :html => {id: 'update-cart', name: "form", "ng-controller"=> 'CartFormCtrl'} do |order_form| %div{"data-hook" => "inside_cart_form"} %div{"data-hook" => "cart_items"} .row diff --git a/app/views/spree/orders/form/_cart_actions_row.html.haml b/app/views/spree/orders/form/_cart_actions_row.html.haml index 44f74ff858..1070f773b2 100644 --- a/app/views/spree/orders/form/_cart_actions_row.html.haml +++ b/app/views/spree/orders/form/_cart_actions_row.html.haml @@ -1,7 +1,7 @@ %tr %td{colspan:"2"} %td - %button#update-button.secondary.radius.expand.small + %button#update-button.secondary.radius.expand.small{"ng-class" => "{ alert: form.$dirty }"} %i.ofn-i_023-refresh = t(:update) %td From 3ba11826616c02ca0ab9a78e91aae45ae3e95248 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 15 May 2020 11:33:41 +0200 Subject: [PATCH 04/13] Dynamically mark quantity field as invalid when stock is incorrect --- .../validate_stock_quantity.js.coffee | 17 +++++++++++++++++ .../darkswarm/shopping-cart.css.scss | 2 +- app/views/spree/orders/_line_item.html.haml | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee b/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee new file mode 100644 index 0000000000..404a9759e1 --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee @@ -0,0 +1,17 @@ +Darkswarm.directive "validateStockQuantity", -> + restrict: 'A' + require: "ngModel" + + link: (scope, element, attr, ngModel) -> + ngModel.$parsers.push (selectedQuantity) -> + if parseInt(selectedQuantity) > scope.available_quantity() + ngModel.$setValidity('stock', false); + else + ngModel.$setValidity('stock', true); + + selectedQuantity + + scope.available_quantity = -> + on_hand = parseInt(attr.ofnOnHand) + finalized_quantity = parseInt(attr.finalizedquantity) || 0 # finalizedquantity is optional + on_hand + finalized_quantity diff --git a/app/assets/stylesheets/darkswarm/shopping-cart.css.scss b/app/assets/stylesheets/darkswarm/shopping-cart.css.scss index 3423102b72..a20897fe2b 100644 --- a/app/assets/stylesheets/darkswarm/shopping-cart.css.scss +++ b/app/assets/stylesheets/darkswarm/shopping-cart.css.scss @@ -103,7 +103,7 @@ } } - input.warning { + input.ng-invalid-stock { border: 1px solid $clr-brick; } } diff --git a/app/views/spree/orders/_line_item.html.haml b/app/views/spree/orders/_line_item.html.haml index 5aab298b51..918a520fdf 100644 --- a/app/views/spree/orders/_line_item.html.haml +++ b/app/views/spree/orders/_line_item.html.haml @@ -27,7 +27,7 @@ :min => 0, "ofn-on-hand" => "#{variant.on_demand && 9999 || variant.on_hand}", "finalizedquantity" => finalized_quantity, :class => "line_item_quantity", :size => 5, "ng-model" => "line_item_#{line_item.id}", - "ng-class" => "{ warning: #{@insufficient_stock_lines.andand.include? line_item} }" + "validate-stock-quantity" => true %td.cart-item-total.text-right{"data-hook" => "cart_item_total"} = line_item.display_amount_with_adjustments.to_html unless line_item.quantity.nil? From c2efa901c2565d52d8891f70b649c2821ba6c81b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 15 May 2020 11:34:04 +0200 Subject: [PATCH 05/13] Don't highlight update button when form is invalid --- app/views/spree/orders/form/_cart_actions_row.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/orders/form/_cart_actions_row.html.haml b/app/views/spree/orders/form/_cart_actions_row.html.haml index 1070f773b2..a7005a5eb6 100644 --- a/app/views/spree/orders/form/_cart_actions_row.html.haml +++ b/app/views/spree/orders/form/_cart_actions_row.html.haml @@ -1,7 +1,7 @@ %tr %td{colspan:"2"} %td - %button#update-button.secondary.radius.expand.small{"ng-class" => "{ alert: form.$dirty }"} + %button#update-button.secondary.radius.expand.small{"ng-class" => "{ alert: form.$dirty && form.$valid }"} %i.ofn-i_023-refresh = t(:update) %td From 63e4430ea4fd576196a1984c5be8dad0aba44283 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 15 May 2020 13:36:10 +0200 Subject: [PATCH 06/13] Update cart page links to be disabled when changes are required and form is unsaved See: https://stackoverflow.com/questions/23425254/enable-disable-anchor-tags-using-angularjs --- .../directives/disable_dynamically.js.coffee | 12 ++++++++++++ app/views/spree/orders/form/_cart_links.html.haml | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/directives/disable_dynamically.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/disable_dynamically.js.coffee b/app/assets/javascripts/darkswarm/directives/disable_dynamically.js.coffee new file mode 100644 index 0000000000..7cff41f3f4 --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/disable_dynamically.js.coffee @@ -0,0 +1,12 @@ +# Allows disabling of link buttons via disabled attribute. +# This is normally ignored, ie the link appears disabled but is still clickable. + +Darkswarm.directive "disableDynamically", -> + restrict: 'A' + + link: (scope, element, attrs) -> + element.on 'click', (e) -> + if attrs.disabled + e.preventDefault() + return + diff --git a/app/views/spree/orders/form/_cart_links.html.haml b/app/views/spree/orders/form/_cart_links.html.haml index 8da012cd78..d63d9395ac 100644 --- a/app/views/spree/orders/form/_cart_links.html.haml +++ b/app/views/spree/orders/form/_cart_links.html.haml @@ -1,5 +1,5 @@ .row.links{'data-hook' => "cart_buttons"} - %a.button.large.secondary{href: current_shop_products_path} + %a.button.large.secondary{href: current_shop_products_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true} = t :orders_edit_continue - %a#checkout-link.button.large.primary.right{href: main_app.checkout_path} + %a#checkout-link.button.large.primary.right{href: main_app.checkout_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true} = t :orders_edit_checkout From fe27c8466e46f751b2b08990b50ccf38a3aa1d65 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 15 May 2020 12:57:34 +0200 Subject: [PATCH 07/13] Add feature specs for full cart page stock correction process --- .../spree/orders/form/_cart_links.html.haml | 2 +- spec/features/consumer/shopping/cart_spec.rb | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/views/spree/orders/form/_cart_links.html.haml b/app/views/spree/orders/form/_cart_links.html.haml index d63d9395ac..798a428f7c 100644 --- a/app/views/spree/orders/form/_cart_links.html.haml +++ b/app/views/spree/orders/form/_cart_links.html.haml @@ -1,5 +1,5 @@ .row.links{'data-hook' => "cart_buttons"} - %a.button.large.secondary{href: current_shop_products_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true} + %a.continue-shopping.button.large.secondary{href: current_shop_products_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true} = t :orders_edit_continue %a#checkout-link.button.large.primary.right{href: main_app.checkout_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true} = t :orders_edit_checkout diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index 6a02206e1d..b032bdee01 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -201,6 +201,40 @@ feature "full-page cart", js: true do expect(page).to have_content "Insufficient stock available, only 2 remaining" expect(page).to have_field "order_line_items_attributes_0_quantity", with: '1' end + + describe "full UX for correcting selected quantities with insufficient stock" do + before do + add_product_to_cart order, product_with_tax, quantity: 5 + variant.update_attributes! on_hand: 4, on_demand: false + end + + it "gives clear user feedback during the correcting process" do + visit main_app.cart_path + + # shows a relevant Flash message + expect(page).to have_selector ".alert-box", text: I18n.t('spree.orders.error_flash_for_unavailable_items') + + # "Continue Shopping" and "Checkout" buttons are disabled + expect(page).to have_selector "a.continue-shopping[disabled=disabled]" + expect(page).to have_selector "a#checkout-link[disabled=disabled]" + + # Quantity field clearly marked as invalid and "Update" button is not highlighted + expect(page).to have_selector "#order_line_items_attributes_0_quantity.ng-invalid-stock" + expect(page).to_not have_selector "#update-button.alert" + + fill_in "order_line_items_attributes_0_quantity", with: 4 + + # Quantity field not marked as invalid and "Update" button is highlighted after correction + expect(page).to_not have_selector "#order_line_items_attributes_0_quantity.ng-invalid-stock" + expect(page).to have_selector "#update-button.alert" + + click_button I18n.t("update") + + # "Continue Shopping" and "Checkout" buttons are not disabled after cart is updated + expect(page).to_not have_selector "a.continue-shopping[disabled=disabled]" + expect(page).to_not have_selector "a#checkout-link[disabled=disabled]" + end + end end end From f7b4717f29fe40b4fbf8590145d7efbccde87850 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 18 May 2020 14:49:03 +0200 Subject: [PATCH 08/13] Improve validation code --- .../directives/validate_stock_quantity.js.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee b/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee index 404a9759e1..132f03c22a 100644 --- a/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee @@ -4,10 +4,10 @@ Darkswarm.directive "validateStockQuantity", -> link: (scope, element, attr, ngModel) -> ngModel.$parsers.push (selectedQuantity) -> - if parseInt(selectedQuantity) > scope.available_quantity() - ngModel.$setValidity('stock', false); - else - ngModel.$setValidity('stock', true); + valid_number = parseInt(selectedQuantity) != NaN + valid_quantity = parseInt(selectedQuantity) <= scope.available_quantity() + + ngModel.$setValidity('stock', (valid_number && valid_quantity) ); selectedQuantity From 111e700799b65c7b36bfe99254b01b20b99f16bd Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 18 May 2020 16:14:14 +0200 Subject: [PATCH 09/13] Update invalid input feedback --- app/assets/stylesheets/darkswarm/shopping-cart.css.scss | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/shopping-cart.css.scss b/app/assets/stylesheets/darkswarm/shopping-cart.css.scss index a20897fe2b..90e0fc276d 100644 --- a/app/assets/stylesheets/darkswarm/shopping-cart.css.scss +++ b/app/assets/stylesheets/darkswarm/shopping-cart.css.scss @@ -103,8 +103,10 @@ } } - input.ng-invalid-stock { - border: 1px solid $clr-brick; + input { + &.ng-invalid-stock, &.ng-invalid-number { + border: 1px solid $clr-brick; + } } } From f9f76f90829da236c24b376e07d658aa89e8129c Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 18 May 2020 16:16:22 +0200 Subject: [PATCH 10/13] Move reused available stock logic to service --- .../javascripts/darkswarm/directives/on_hand.js.coffee | 6 ++---- .../darkswarm/directives/validate_stock_quantity.js.coffee | 6 ++---- .../darkswarm/services/stock_quantity.js.coffee | 7 +++++++ 3 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/services/stock_quantity.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/on_hand.js.coffee b/app/assets/javascripts/darkswarm/directives/on_hand.js.coffee index 1086363676..e5cba8a5cb 100644 --- a/app/assets/javascripts/darkswarm/directives/on_hand.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/on_hand.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.directive "ofnOnHand", -> +Darkswarm.directive "ofnOnHand", (StockQuantity) -> restrict: 'A' require: "ngModel" @@ -23,6 +23,4 @@ Darkswarm.directive "ofnOnHand", -> viewValue scope.available_quantity = -> - on_hand = parseInt(attr.ofnOnHand) - finalized_quantity = parseInt(attr.finalizedquantity) || 0 # finalizedquantity is optional - on_hand + finalized_quantity + StockQuantity.available_quantity(attr.ofnOnHand, attr.finalizedquantity) diff --git a/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee b/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee index 132f03c22a..5d5395c5f5 100644 --- a/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.directive "validateStockQuantity", -> +Darkswarm.directive "validateStockQuantity", (StockQuantity) -> restrict: 'A' require: "ngModel" @@ -12,6 +12,4 @@ Darkswarm.directive "validateStockQuantity", -> selectedQuantity scope.available_quantity = -> - on_hand = parseInt(attr.ofnOnHand) - finalized_quantity = parseInt(attr.finalizedquantity) || 0 # finalizedquantity is optional - on_hand + finalized_quantity + StockQuantity.available_quantity(attr.ofnOnHand, attr.finalizedquantity) diff --git a/app/assets/javascripts/darkswarm/services/stock_quantity.js.coffee b/app/assets/javascripts/darkswarm/services/stock_quantity.js.coffee new file mode 100644 index 0000000000..efc6b67eb4 --- /dev/null +++ b/app/assets/javascripts/darkswarm/services/stock_quantity.js.coffee @@ -0,0 +1,7 @@ +Darkswarm.factory "StockQuantity", -> + new class StockQuantity + available_quantity: (on_hand, finalized_quantity) -> + on_hand = parseInt(on_hand) + finalized_quantity = parseInt(finalized_quantity) || 0 # finalized_quantity is optional + + on_hand + finalized_quantity From d70174beccae5a6d3d23195f5d2e27d78b146047 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 18 May 2020 16:26:47 +0200 Subject: [PATCH 11/13] Use fresh scope for each quantity field --- .../darkswarm/directives/validate_stock_quantity.js.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee b/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee index 5d5395c5f5..3ceee62a4d 100644 --- a/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/validate_stock_quantity.js.coffee @@ -1,6 +1,7 @@ Darkswarm.directive "validateStockQuantity", (StockQuantity) -> restrict: 'A' require: "ngModel" + scope: true link: (scope, element, attr, ngModel) -> ngModel.$parsers.push (selectedQuantity) -> From e3c337ef7efd3b0ba42a035ce0b06311dc670f4d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 18 May 2020 16:41:57 +0200 Subject: [PATCH 12/13] Fix mixed error display issue --- app/assets/stylesheets/darkswarm/shopping-cart.css.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/stylesheets/darkswarm/shopping-cart.css.scss b/app/assets/stylesheets/darkswarm/shopping-cart.css.scss index 90e0fc276d..d00f3915e7 100644 --- a/app/assets/stylesheets/darkswarm/shopping-cart.css.scss +++ b/app/assets/stylesheets/darkswarm/shopping-cart.css.scss @@ -72,6 +72,12 @@ } // Shopping cart +#update-cart { + #errorExplanation { + display: none; + } +} + #cart-detail { .cart-item-delete, .bought-item-delete { a { From 6b3a7228ce2a1167481f9dabd41cee5d9ddd4dcd Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 19 May 2020 20:22:38 +0200 Subject: [PATCH 13/13] Update flash message with instruction to update the quantities --- config/locales/en.yml | 2 +- spec/controllers/spree/orders_controller_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 01ba7cebd2..22ab15af3d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3409,7 +3409,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using format: ! '%Y-%m-%d' js_format: 'yy-mm-dd' orders: - error_flash_for_unavailable_items: "An item in your cart has become unavailable." + error_flash_for_unavailable_items: "An item in your cart has become unavailable. Please update the selected quantities." edit: login_to_view_order: "Please log in to view your order." bought: diff --git a/spec/controllers/spree/orders_controller_spec.rb b/spec/controllers/spree/orders_controller_spec.rb index c018a98873..783c868366 100644 --- a/spec/controllers/spree/orders_controller_spec.rb +++ b/spec/controllers/spree/orders_controller_spec.rb @@ -161,7 +161,7 @@ describe Spree::OrdersController, type: :controller do it "displays a flash message when we view the cart" do spree_get :edit expect(response.status).to eq 200 - expect(flash[:error]).to eq("An item in your cart has become unavailable.") + expect(flash[:error]).to eq I18n.t('spree.orders.error_flash_for_unavailable_items') end end @@ -173,7 +173,7 @@ describe Spree::OrdersController, type: :controller do it "displays a flash message when we view the cart" do spree_get :edit expect(response.status).to eq 200 - expect(flash[:error]).to eq("An item in your cart has become unavailable.") + expect(flash[:error]).to eq I18n.t('spree.orders.error_flash_for_unavailable_items') end end end