Add couchbase with modifications, formalize broadcaster and make testable and some other stuff

This commit is contained in:
2014-03-06 18:08:39 +01:00
parent 3f117c76b0
commit 0e7a39b819
28 changed files with 456 additions and 35 deletions
+60
View File
@@ -37,4 +37,64 @@ describe Order do
it 'paginates'
end
describe '#is_being_processed!' do
describe 'broadcasting' do
it 'broadcasts order info to the user' do
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'order_being_processed' ).with(id: order.id, list_id: list.id)
end
describe 'counters' do
before do
# hack some initial values
Qwaiter::Counter.set "supplier:#{supplier.id}:orders_in_process", 7
Qwaiter::Counter.set "supplier:#{supplier.id}:orders_delivered", 9
end
it 'reduces the orders_in_process count and communicates it to user' do
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'orders_in_process_count' ).with(count: 6)
end
it 'increases the orders_delivered count and communicates it to user' do
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'orders_delivered_count' ).with(count: 10)
end
it 'reduces the orders_in_process count and communicates it to supplier' do
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'orders_in_process_count' ).with(count: 6)
end
it 'increases the orders_in_process count and communicates it to supplier' do
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'orders_delivered_count' ).with(count: 10)
end
end
it 'broadcasts order info to the supplier' do
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'order_being_processed' ).with(id: order.id, list_id: list.id)
end
end
end
describe '#is_delivered!' do
describe 'broadcasting' do
describe 'counters' do
before do
# hack some initial values
Qwaiter::Counter.set "supplier:#{supplier.id}:orders_in_process", 7
Qwaiter::Counter.set "supplier:#{supplier.id}:orders_delivered", 9
end
it 'decreases the orders_delivered count and communicates it to user' do
expect{ order.is_delivered! }.to broadcast_to_user(user.id).message( 'orders_delivered_count' ).with(count: 8)
end
it 'decreases the orders_in_process count and communicates it to supplier' do
expect{ order.is_delivered! }.to broadcast_to_supplier(supplier.id).message( 'orders_delivered_count' ).with(count: 8)
end
end
end
end
end