User cancelled order handling

This commit is contained in:
2014-08-14 14:11:14 +02:00
parent 6da2d7a40e
commit 0e605828bd
11 changed files with 76 additions and 5 deletions
+22
View File
@@ -10,3 +10,25 @@ Feature: Active list view
And the user opens the side menu again
And the user clicks on the active list link in the side menu
Then the user should see the order in the active list view
@javascript
Scenario: Order disappears and counter adjusts when a placed order is cancelled
Given There is an open supplier with a menu
And there is a signed in user with a placed order
And the user is on the active list page
And the supplier orders placed counter for the user should be 1
When the order gets cancelled
And I wait 1 second
Then the user should not see the order in the active list view
And the supplier orders placed counter for the user should be 0
@javascript
Scenario: Order disappears and counter adjusts when an active order is cancelled
Given There is an open supplier with a menu
And there is a signed in user with an active order
And the user is on the active list page
And the supplier orders in process counter for the user should be 1
When the order gets cancelled
And I wait 1 second
Then the user should not see the order in the active list view
And the supplier orders in process counter for the user should be 0
+6 -2
View File
@@ -7,14 +7,18 @@ step "the list is marked as in need of payment" do
@list.needs_payment!
end
step "the user has an active list" do
step "the user has an active list with a/an :order_status order" do |order_status|
@list = create :list, supplier: @supplier, table: @table, user_ids: [@user.id]
@product ||= create :product, supplier: @supplier, name: 'Beer', price: 2.34
@order = create :order, supplier: @supplier, list: @list
@order = create :order, order_status.to_sym, supplier: @supplier, list: @list
@product_order = create :product_order, order: @order, product: @product, quantity: 2, price: 2.34
@user.reload
@user.active_list_id = @list.id
@user.save
case order_status.to_sym
when :placed then @supplier.increment_orders_placed_count!
when :active then @supplier.increment_orders_in_process_count!
end
end
step "the list should be marked as closed" do
+4
View File
@@ -47,3 +47,7 @@ end
step "the user orders list gets closed" do
@order.list.close!
end
step "the order gets cancelled" do
@order.cancel!
end
@@ -5,3 +5,11 @@ end
step "the user should see the order in the active list view" do
page.evaluate_script(%|$('.order-row-#{@order.id}').text()|).first(14).should == '2 x Beer€ 4.68'
end
step "the user should not see the order in the active list view" do
page.should_not have_selector ".order-row-#{@order.id}"
end
step "the supplier counters in the user active list view should be updated" do
binding.pry
end
@@ -19,14 +19,23 @@ end
step "the user has an active order" do
step 'there is a section'
step 'there is a table'
step 'the user has an active list'
step 'the user has an active list with an active order'
end
step "the user has a placed order" do
step 'there is a section'
step 'there is a table'
step 'the user has an active list with a placed order'
end
step "there is a signed in user with an active order" do
step "I am signed in as a user"
step "the user has an active order"
end
step "there is a signed in user with a placed order" do
step "I am signed in as a user"
step "the user has a placed order"
end
step "the user clicks on the more info button for the product with name :product_name" do |product_name|
product = @product && @product.name == product_name ? @product : Product.find_by_name(product_name)
@@ -0,0 +1,7 @@
step "the supplier orders placed counter for the user should be :count" do |count|
page.find(".supplier-orders-placed-count").text.should == count # both string values
end
step "the supplier orders in process counter for the user should be :count" do |count|
page.find(".supplier-orders-in-process-count").text.should == count # both string values
end