diff --git a/rails_application/app/views/orders/show.html.erb b/rails_application/app/views/orders/show.html.erb index 638d35996..23a261411 100644 --- a/rails_application/app/views/orders/show.html.erb +++ b/rails_application/app/views/orders/show.html.erb @@ -23,7 +23,7 @@ <%= button_to("Pay", pay_order_path(@order.uid), class: "mr-3 ml-3 inline-flex items-center px-4 py-2 border rounded-md shadow-sm text-sm font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 border-transparent text-white bg-blue-600 hover:bg-blue-700") %> <% end %> - <% unless @order.state == "Cancelled" %> + <% if (@order.state != "Cancelled" && @order.state != "Paid") %> <%= button_to("Cancel Order", cancel_order_path(@order.uid), class: "inline-flex items-center px-4 py-2 border rounded-md shadow-sm text-sm font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-50 border-gray-300 text-gray-700 bg-white hover:bg-gray-50") %> <% end %> <% end %> diff --git a/rails_application/test/integration/orders_test.rb b/rails_application/test/integration/orders_test.rb index 38bfa7838..a9030b301 100644 --- a/rails_application/test/integration/orders_test.rb +++ b/rails_application/test/integration/orders_test.rb @@ -140,6 +140,32 @@ def test_cancel assert_select("dd", "Cancelled") end + def test_confirmed_order_doesnt_show_cancel_button + shopify_id = register_customer("Shopify") + + order_id = SecureRandom.uuid + async_remote_id = register_product("Async Remote", 39, 10) + + Sidekiq::Job.drain_all + + get "/" + get "/orders/new" + post "/orders/#{order_id}/add_item?product_id=#{async_remote_id}" + post "/orders", + params: { + "authenticity_token" => "[FILTERED]", + "order_id" => order_id, + "customer_id" => shopify_id, + "commit" => "Submit order" + } + post "/orders/#{order_id}/pay" + Shipments::MarkOrderSubmitted.drain + follow_redirect! + assert_select("td", text: "Paid") + get "/orders/#{order_id}" + assert_select("button", 2) + end + private def assert_res_browser_order_history