End of day commit
This commit is contained in:
@@ -71,10 +71,19 @@ Feature: Supplier main board
|
||||
And I click on the section main board section jumper
|
||||
Then I should be redirected to the supplier section view
|
||||
|
||||
@javascript
|
||||
@javascript @broken
|
||||
Scenario: Update table number if table chanes
|
||||
Given there is an active list and order
|
||||
And I am signed in as supplier
|
||||
When the active list changes to another table in another section
|
||||
Then the supplier main board table number should be updated to the new table number
|
||||
And the supplier main board section name should be updated to the new section
|
||||
|
||||
@javascript
|
||||
Scenario: Remove an order
|
||||
Given there is an active list and order
|
||||
And I am signed in as supplier
|
||||
When the supplier marks the order as wrong in the main board view
|
||||
Then the supplier main board order should not be visible anymore
|
||||
And the supplier main board list total should be updated
|
||||
And the supplier placed orders counter should be reduced
|
||||
|
||||
@@ -5,9 +5,11 @@ step "there is an active list and order" do
|
||||
@section.should be_present
|
||||
@list = create :list, state: 'active', supplier: @supplier, table: @table, section: @section, user_ids: [@user.id]
|
||||
@product = create :product, price: 2.22, supplier: @supplier
|
||||
@order = create :order, user: @user, list: @list, supplier: @supplier, section: @section
|
||||
@order = create :order, user: @user, list: @list, supplier: @supplier, section: @section, state: 'placed'
|
||||
@product_order = create :product_order, order: @order, product: @product, quantity: 3, price: 2.11
|
||||
@list.set_price.should == 6.33 # does not belong here, but good test. must take product order price above product price
|
||||
Qwaiter::Counter.set "supplier_counter:#{@supplier.id}:orders_placed", 11
|
||||
Qwaiter::Counter.set "supplier_counter:#{@supplier.id}:orders_in_process", 7
|
||||
end
|
||||
|
||||
step "the supplier dashboard should display the active list" do
|
||||
@@ -142,3 +144,23 @@ step "the supplier main board section name should be updated to the new section"
|
||||
expect( find(".list-row-#{@list.id} .section_title").text ).to eq "New Section"
|
||||
expect( find(".order-row-#{@list.orders.first.id} .section_title").text ).to eq "New Section"
|
||||
end
|
||||
|
||||
# Marking order as wrong
|
||||
step "the supplier marks the order as wrong in the main board view" do
|
||||
find(".order-row-#{@order.id} .remove-order").click
|
||||
end
|
||||
|
||||
step "the supplier main board order should not be visible anymore" do
|
||||
page.should_not have_selector ".order-row-#{@order.id}"
|
||||
end
|
||||
|
||||
step "the supplier main board list total should be updated" do
|
||||
find(".list-row-#{@list.id} .total_list_amount").text.should == "€ 0.00"
|
||||
end
|
||||
|
||||
step "the supplier placed orders counter should be reduced" do
|
||||
sleep 0.5
|
||||
binding.pry
|
||||
puts page.driver.error_messages
|
||||
find('.supplier-orders-placed-count-number').text.should == "10"
|
||||
end
|
||||
|
||||
@@ -9,5 +9,8 @@ FactoryGirl.define do
|
||||
trait :active do
|
||||
state 'active'
|
||||
end
|
||||
trait :cancelled do
|
||||
state 'cancelled'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,6 +39,14 @@ describe List do
|
||||
it 'takes the product_order price in stead of the product price' do
|
||||
product_order and list.set_price.should == 6.33
|
||||
end
|
||||
|
||||
it 'does not include the price of cancelled orders' do
|
||||
product_order
|
||||
cancelled = create :order, :cancelled, user: user, list: list, supplier: supplier, section: section
|
||||
create :product_order, order: cancelled, product: product, quantity: 2, price: 7.99
|
||||
list.set_price
|
||||
list.price.should == 6.33
|
||||
end
|
||||
end
|
||||
|
||||
describe '#move_to_table!' do
|
||||
|
||||
@@ -7,7 +7,8 @@ describe Order do
|
||||
let(:section) { create :section, supplier: supplier}
|
||||
let(:table) { create :table, supplier: supplier}
|
||||
let(:list){ create :list, supplier: supplier, table: table, user_ids: [user.id] }
|
||||
let(:order) {create :order, supplier: supplier, list: list, state: 'placed' }
|
||||
let(:order_options){ {supplier: supplier, list: list, state: 'placed' } }
|
||||
let(:order) {create :order, order_options }
|
||||
subject { order }
|
||||
|
||||
its(:placed?) { should be true }
|
||||
@@ -41,6 +42,7 @@ describe Order do
|
||||
describe 'broadcasting' do
|
||||
|
||||
it 'broadcasts order info to the user' do
|
||||
order_options[:state] = 'placed'
|
||||
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'order_being_processed' ).with(id: order.id, list_id: list.id)
|
||||
end
|
||||
|
||||
@@ -52,24 +54,29 @@ describe Order do
|
||||
end
|
||||
|
||||
it 'reduces the orders_placed count and communicates it to user' do
|
||||
order_options[:state] = 'placed'
|
||||
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'orders_placed_count' ).with(count: 10)
|
||||
end
|
||||
|
||||
it 'increases the orders_in_process count and communicates it to user' do
|
||||
order_options[:state] = 'placed'
|
||||
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'orders_in_process_count' ).with(count: 8)
|
||||
end
|
||||
|
||||
it 'reduces the orders_placed count and communicates it to supplier' do
|
||||
order_options[:state] = 'placed'
|
||||
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'orders_placed_count' ).with(count: 10)
|
||||
end
|
||||
|
||||
it 'increases the orders_in_process count and communicates it to supplier' do
|
||||
order_options[:state] = 'placed'
|
||||
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'orders_in_process_count' ).with(count: 8)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it 'broadcasts order info to the supplier' do
|
||||
order_options[:state] = 'placed'
|
||||
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'order_being_processed' ).with(id: order.id, list_id: list.id)
|
||||
end
|
||||
|
||||
@@ -106,4 +113,44 @@ describe Order do
|
||||
end
|
||||
end
|
||||
|
||||
describe "cancel!" do
|
||||
it 'changes the state to cancelled' do
|
||||
order_options[:state] = 'active'
|
||||
order.cancel!
|
||||
expect(order.state).to eq 'cancelled'
|
||||
end
|
||||
describe 'broadcasting' do
|
||||
describe 'counters' do
|
||||
before do
|
||||
# hack some initial values
|
||||
Qwaiter::Counter.set "supplier_counter:#{supplier.id}:orders_placed", 11
|
||||
Qwaiter::Counter.set "supplier_counter:#{supplier.id}:orders_in_process", 7
|
||||
end
|
||||
|
||||
it 'decreases the placed count and communicates it to user when state is placed through the order_cancelled broadcast message' do
|
||||
order_options[:state] = 'placed'
|
||||
expect{ order.cancel! }.to broadcast_to_user(user.id).message( 'order_cancelled' ).with(id: order.id, orders_placed_count: 10)
|
||||
supplier.orders_in_process_count.should == 7 # should not be reduced
|
||||
end
|
||||
|
||||
it 'decreases the placed count and communicates it to supplier when the state is placed through the order_cancelled broadcast message' do
|
||||
order_options[:state] = 'placed'
|
||||
expect{ order.cancel! }.to broadcast_to_supplier(supplier.id).message( 'order_cancelled' ).with(id: order.id, orders_placed_count: 10)
|
||||
supplier.orders_in_process_count.should == 7 # should not be reduced
|
||||
end
|
||||
|
||||
it 'decreases the orders_in_process count and communicates it to user when state is active through the order_cancelled broadcast message' do
|
||||
order_options[:state] = 'active'
|
||||
expect{ order.cancel! }.to broadcast_to_user(user.id).message( 'order_cancelled' ).with(id: order.id, orders_in_process_count: 6)
|
||||
supplier.orders_placed_count.should == 11 # should not be reduced
|
||||
end
|
||||
|
||||
it 'decreases the orders_in_process count and communicates it to supplier when the state is active through the order_cancelled broadcast message' do
|
||||
order_options[:state] = 'active'
|
||||
expect{ order.cancel! }.to broadcast_to_supplier(supplier.id).message( 'order_cancelled' ).with(id: order.id, orders_in_process_count: 6)
|
||||
supplier.orders_placed_count.should == 11 # should not be reduced
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user