User cancelled order handling
This commit is contained in:
@@ -4,7 +4,8 @@ App.List = DS.Model.extend
|
||||
needs_help: attr 'boolean'
|
||||
needs_payment: attr 'boolean'
|
||||
user_requests_closing: attr('boolean')
|
||||
users: DS.hasMany('user', async: true)
|
||||
# users: DS.hasMany('user', async: true)
|
||||
users: DS.hasMany('user')
|
||||
is_paid: attr 'boolean'
|
||||
#has_active_orders: attr 'boolean'
|
||||
|
||||
|
||||
@@ -39,6 +39,11 @@ App.ApplicationController = Ember.Controller.extend
|
||||
data.join_request.user = user
|
||||
join_request = @store.createRecord 'join_request', data.join_request
|
||||
@transitionToRoute 'join_requests'
|
||||
order_cancelled: (data)->
|
||||
if order = App.Order.findCached(data.id)
|
||||
order.markCancelled()
|
||||
@events.orders_placed_count.call(@, count: data.orders_placed_count) if data.orders_placed_count == 0 or data.orders_placed_count
|
||||
@events.orders_in_process_count.call(@, count: data.orders_in_process_count) if data.orders_in_process_count == 0 or data.orders_in_process_count
|
||||
join_request_rejected: (data)->
|
||||
# Remove join request from connected users
|
||||
join_request = @store.all('join_request').findBy 'id', data.id
|
||||
|
||||
@@ -10,3 +10,5 @@ App.Order = DS.Model.extend
|
||||
display: (->
|
||||
@get('product_orders').map((po) -> "#{po.get('quantity')} x #{po.get('product.name')}").join(', ')
|
||||
).property('product_orders.@each.quantity', 'product_orders.@each.product.@each.name')
|
||||
markCancelled: ->
|
||||
@set 'state', 'cancelled'
|
||||
|
||||
@@ -4,3 +4,7 @@ DS.Model.reopen
|
||||
eraseRecord: ->
|
||||
@clearRelationships()
|
||||
@transitionTo('deleted.saved')
|
||||
DS.Model.reopenClass
|
||||
findCached: (id)->
|
||||
return null unless id
|
||||
@store.all(@typeKey).findProperty('id', id)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -43,9 +43,9 @@ Bugs
|
||||
----
|
||||
|
||||
- Dragging supplier table from one section to the other fails
|
||||
- Supplier tables pagination styling (make ember!)
|
||||
- supplier counters in user view (no supplier in active list?)
|
||||
- supplier main board section selector selects first section option and not the supplier name, which is added using prompt thingy. Maybe setting ApplicationController.active_section in stead of IndexController.active_section for scope locking
|
||||
- User order total and price not working properly
|
||||
|
||||
Post release
|
||||
============
|
||||
@@ -53,3 +53,8 @@ Post release
|
||||
- Chromecast app Waiter app Users can disable their own help request (maak ongedaan?) Users can disable their own bill request (maak ongedaan?) Think about extra confirmation box for these requests Supplier section 100% on ember :)
|
||||
- Do not destroy tables with active list
|
||||
- Test list view when table is destroyed
|
||||
|
||||
Supplier
|
||||
--------
|
||||
|
||||
- tables#index Make table actions available
|
||||
|
||||
Reference in New Issue
Block a user