Fix product ordering pricing and improve acceptance user product ordering coverage
This commit is contained in:
@@ -21,7 +21,7 @@ App.TableController = Ember.ObjectController.extend
|
|||||||
if existing = @store.all('product_order').find((po)-> po.get('product') == product and not po.get('order'))
|
if existing = @store.all('product_order').find((po)-> po.get('product') == product and not po.get('order'))
|
||||||
existing.increment()
|
existing.increment()
|
||||||
else
|
else
|
||||||
@store.createRecord 'product_order', product: product
|
@store.createRecord 'product_order', product: product, price: product.get('price')
|
||||||
joinOccupiedTable: ->
|
joinOccupiedTable: ->
|
||||||
#@secured =>
|
#@secured =>
|
||||||
Ember.$.post('/user/join_occupied_table.json', table_id: @get('model.id'))
|
Ember.$.post('/user/join_occupied_table.json', table_id: @get('model.id'))
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
hr.hide-for-medium-up
|
hr.hide-for-medium-up
|
||||||
if modelDisabled
|
if modelDisabled
|
||||||
a.tiny.button.right{action clearProductOrders} href="#" ×
|
a.tiny.button.right{action "clearProductOrders"} href="#" ×
|
||||||
.clearfix
|
.clearfix
|
||||||
.panel
|
.panel
|
||||||
ul.product-orders
|
ul.product-orders
|
||||||
each product_order in product_orders
|
each product_order in product_orders
|
||||||
li.product_order
|
li.product-order
|
||||||
= product_order.quantity
|
= product_order.quantity
|
||||||
| x
|
| x
|
||||||
= product_order.product.name
|
= product_order.product.name
|
||||||
button.product_order-remove.right{action removeProductOrder product_order}
|
button.product-order-remove.right{action "removeProductOrder" product_order}
|
||||||
span.icon
|
span.icon
|
||||||
span.currency=currency product_order.total
|
span.currency=currency product_order.total
|
||||||
else
|
else
|
||||||
@@ -19,4 +19,4 @@ if modelDisabled
|
|||||||
= t 'product_orders.total'
|
= t 'product_orders.total'
|
||||||
span.right.currency=currency orderTotal
|
span.right.currency=currency orderTotal
|
||||||
if product_orders
|
if product_orders
|
||||||
a.order-selected-products-button{action orderProducts} href="#"= t 'product_orders.order_button'
|
a.order-selected-products-button{action "orderProducts"} href="#"= t 'product_orders.order_button'
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ ul.product-orders
|
|||||||
border-bottom: none
|
border-bottom: none
|
||||||
border-top: 4px solid #333
|
border-top: 4px solid #333
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
.product_order-remove
|
.product-order-remove
|
||||||
+button-style($bg:$secondary-color)
|
+button-style($bg:$secondary-color)
|
||||||
+button-icon-only
|
+button-icon-only
|
||||||
//+button-size($padding:$button-tny)
|
//+button-size($padding:$button-tny)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<td>{{number}}</td>
|
<td>{{number}}</td>
|
||||||
<td class="currency">
|
<td class="currency">
|
||||||
{{#currency}}{{product_total}}{{/currency}}
|
{{#currency}}{{product_total}}{{/currency}}
|
||||||
<a class="product_order-remove-button" href=""><span class="fa fa-times fa-large"></span></a>
|
<a class="product-order-remove-button" href=""><span class="fa fa-times fa-large"></span></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/products}}
|
{{/products}}
|
||||||
|
|||||||
@@ -7,8 +7,11 @@ Feature: Ordering a product as a user
|
|||||||
And I am on the user homepage
|
And I am on the user homepage
|
||||||
When the user scans a table QR code
|
When the user scans a table QR code
|
||||||
And the user clicks on the order 'Heineken beer' twice
|
And the user clicks on the order 'Heineken beer' twice
|
||||||
And the user clicks on the order product button 'Apple Pie'
|
Then the user order 'Heineken beer' should be in the order list with price
|
||||||
And the user clicks on the user order button
|
And the user order total should not be visible for only one order
|
||||||
|
When the user clicks on the order product button 'Apple pie'
|
||||||
|
Then the user order total should be visible with the correct total price
|
||||||
|
When the user clicks on the user order button
|
||||||
Then the user should be redirected to the user order overview page
|
Then the user should be redirected to the user order overview page
|
||||||
And the user order should be created as a new order
|
And the user order should be created as a new order
|
||||||
When the user order gets marked as being in process
|
When the user order gets marked as being in process
|
||||||
@@ -18,4 +21,18 @@ Feature: Ordering a product as a user
|
|||||||
When the user orders list gets closed
|
When the user orders list gets closed
|
||||||
Then the user should be redirected to the archived list path
|
Then the user should be redirected to the archived list path
|
||||||
|
|
||||||
|
@javascript
|
||||||
Scenario: Resetting an active order
|
Scenario: Resetting an active order
|
||||||
|
Given There is an open supplier with a menu
|
||||||
|
And I am signed in as a user
|
||||||
|
And I am on the user homepage
|
||||||
|
When the user scans a table QR code
|
||||||
|
And the user clicks on the order 'Heineken beer' twice
|
||||||
|
And the user clicks on the order product button 'Apple pie'
|
||||||
|
And the user clicks on the clear order for the last order button
|
||||||
|
And the user clicks on the clear order for the last order button
|
||||||
|
Then the user should see an empty active order panel
|
||||||
|
And the user clicks on the order 'Heineken beer' twice
|
||||||
|
And the user clicks on the user order button
|
||||||
|
Then an order with 2 products 'Heineken beer' should have been created
|
||||||
|
And no order for the product 'Apple pie' should have been created
|
||||||
|
|||||||
@@ -3,3 +3,13 @@ step "A new order is placed" do
|
|||||||
@list = create :list, state: 'active', supplier: @supplier, table: @table, section: @section, user_ids: [@user.id]
|
@list = create :list, state: 'active', supplier: @supplier, table: @table, section: @section, user_ids: [@user.id]
|
||||||
@order = @list.place_order products: {@product.id => 2}, user: @user
|
@order = @list.place_order products: {@product.id => 2}, user: @user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
step "an order with :quantity products :product_name should have been created" do |quantity, product_name|
|
||||||
|
concerning_product = Product.find_by_name(product_name)
|
||||||
|
ProductOrder.find_by_quantity_and_product_id(quantity.to_i, concerning_product.id).should be_present
|
||||||
|
end
|
||||||
|
|
||||||
|
step "no order for the product :product_name should have been created" do |product_name|
|
||||||
|
concerning_product = Product.find_by_name(product_name)
|
||||||
|
ProductOrder.find_by_product_id(concerning_product.id).should_not be_present
|
||||||
|
end
|
||||||
|
|||||||
@@ -45,3 +45,38 @@ end
|
|||||||
step "the user page should have product information :product_description" do |product_description|
|
step "the user page should have product information :product_description" do |product_description|
|
||||||
page.should have_content product_description
|
page.should have_content product_description
|
||||||
end
|
end
|
||||||
|
|
||||||
|
step "the user order :product_name should be in the order list with price" do |product_name|
|
||||||
|
concerning_product = Product.find_by_name(product_name)
|
||||||
|
ember_order = ember_store['product_orders'].find{|po| po['product_id'] == concerning_product.id}
|
||||||
|
quantity = ember_order['quantity']
|
||||||
|
order_price = quantity * concerning_product.price
|
||||||
|
within '.product-orders .product-order' do
|
||||||
|
page.should have_content product_name
|
||||||
|
if quantity > 1
|
||||||
|
page.should have_content "#{quantity} x"
|
||||||
|
end
|
||||||
|
page.should have_content order_price
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user order total should not be visible for only one order" do
|
||||||
|
page.should_not have_selector ".product-orders .total"
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user order total should be visible with the correct total price" do
|
||||||
|
within ".product-orders .total" do
|
||||||
|
page.should have_content "8.96" # more dynamic in the future if needed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user clicks on the clear order for the last order button" do
|
||||||
|
within page.all('.product-orders .product-order').last do
|
||||||
|
find('.product-order-remove').click
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user should see an empty active order panel" do
|
||||||
|
no_orders_message = page.evaluate_script(%|t('product_orders.no_orders')|)
|
||||||
|
page.find('.product-orders').text.should == no_orders_message
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user