Remove duplicated spec, better error message suppression, fix shipping test to wait correctly

This commit is contained in:
stveep
2017-04-09 18:44:05 +01:00
committed by Rob Harrington
parent 3b4ffe1f70
commit 38c25c412f
6 changed files with 9 additions and 19 deletions

View File

@@ -15,8 +15,6 @@ Spree::Admin::OrdersController.class_eval do
# Ensure that the distributor is set for an order when
before_filter :ensure_distribution, only: :new
# before_filter :clear_errors, only: :update
# After updating an order, the fees should be updated as well
# Currently, adding or deleting line items does not trigger updating the
# fees! This is a quick fix for that.

View File

@@ -2,5 +2,5 @@
-# Suppress errors when manually creating a new order - needs to proceed to edit page
-# without having line items (which otherwise gives a validation error)
- unless @order.created_at > 20.seconds.ago
- unless params["suppress_error_msg"]
= render partial: "spree/shared/error_messages", :locals => { :target => @order }

View File

@@ -17,6 +17,8 @@
%div{"ng-app" => "admin.orders", "ng-controller" => "ordersCtrl"}
= form_for @order, url: admin_order_url(@order), method: :put do |f|
= render 'spree/admin/orders/_form/distribution_fields'
-# This param passed to stop validation error in next page due to no line items in order yet:
= hidden_field_tag 'suppress_error_msg', "true"
= button_tag :class => 'secondary radius expand small', :id => 'update-button' do
%i.icon-arrow-right
= t(:next)

View File

@@ -156,8 +156,6 @@ Openfoodnetwork::Application.routes.draw do
end
resource :invoice_settings, only: [:edit, :update]
post '/order/:id/update', to: :update, controller: 'orders'
end
namespace :api do

View File

@@ -12,7 +12,6 @@ feature %q{
@product = create(:simple_product)
@distributor = create(:distributor_enterprise, owner: @user, charges_sales_tax: true)
@order_cycle = create(:simple_order_cycle, name: 'One', distributors: [@distributor], variants: [@product.variants.first])
@oc_overrides = create(:order_cycle_with_overrides)
@order = create(:order_with_totals_and_distribution, user: @user, distributor: @distributor, order_cycle: @order_cycle, state: 'complete', payment_state: 'balance_due')
@customer = create(:customer, enterprise: @distributor, email: @user.email, user: @user, ship_address: create(:address))
@@ -54,6 +53,8 @@ feature %q{
select2_select @order_cycle.name, from: 'order_order_cycle_id'
click_button 'Next'
# it suppresses validation errors when setting distribution
page.should_not have_selector '#errorExplanation'
page.should have_content 'ADD PRODUCT'
targetted_select2_search @product.name, from: '#add_variant_id', dropdown_css: '.select2-drop'
click_link 'Add'
@@ -85,6 +86,8 @@ feature %q{
scenario "displays error when incorrect distribution for products is chosen" do
d = create(:distributor_enterprise)
oc = create(:simple_order_cycle, distributors: [d])
puts d.name
puts @distributor.name
@order.state = 'cart'; @order.completed_at = nil; @order.save
@@ -99,7 +102,6 @@ feature %q{
select2_select oc.name, from: 'order_order_cycle_id'
click_button 'Update And Recalculate Fees'
page.should have_content "Distributor or order cycle cannot supply the products in your cart"
end
@@ -151,7 +153,7 @@ feature %q{
# And I select that customer's email address and save the order
targetted_select2_search @customer.email, from: '#customer_search_override', dropdown_css: '.select2-drop'
click_button 'Continue'
within('h1.page-title') { page.should have_content "Shipments" }
page.should have_selector "h1.page-title", text: "Shipments"
# Then their addresses should be associated with the order
order = Spree::Order.last
@@ -246,17 +248,6 @@ feature %q{
end
scenario "with overrides it uses the overriden price" do
login_to_admin_section
new_order_with_distribution(@oc_overrides.distributors.first, @oc_overrides)
product = @oc_overrides.products.first
targetted_select2_search product.name, from: '#add_variant_id', dropdown_css: '.select2-drop'
click_link 'Add'
page.has_selector? "table.index tbody[data-hook='admin_order_form_line_items'] tr" # Wait for JS
page.should have_selector 'td', text: "119.99"
end
# Working around intermittent click failing
# Possible causes of failure:

View File

@@ -328,6 +328,7 @@ feature %q{
select2_select dist.name, from: 'order_distributor_id'
page.should have_select2 'order_order_cycle_id', with_options: ['Overidden (open)']
select2_select order_cycle.name, from: 'order_order_cycle_id'
click_button 'Next'
end
# Reproducing a bug, issue #1446