User foundation setup
This commit is contained in:
@@ -125,29 +125,29 @@ describe List do
|
||||
describe '#place_order' do
|
||||
|
||||
it 'returns an order object' do
|
||||
list.place_order(user, product.id => 7).should be_a Order
|
||||
list.place_order(product.id => 7, user: user).should be_a Order
|
||||
end
|
||||
|
||||
it 'creates an order' do
|
||||
expect{ list.place_order(user, product.id => 7) }.to change{ Order.count }.by(1)
|
||||
expect{ list.place_order(product.id => 7, user: user) }.to change{ Order.count }.by(1)
|
||||
end
|
||||
|
||||
describe 'broadcasting' do
|
||||
it 'broadcasts to the user and the supplier the active order counter' do
|
||||
list.place_order(user, product.id => 7)
|
||||
list.place_order(product.id => 7, user: user)
|
||||
|
||||
expect{
|
||||
list.place_order(user, product.id => 3)
|
||||
list.place_order(product.id => 3, user: user)
|
||||
}.to broadcast_to_user(user.id).message('orders_placed_count').with(count: 2)
|
||||
|
||||
expect{
|
||||
list.place_order(user, product.id => 5)
|
||||
list.place_order(product.id => 5, user: user)
|
||||
}.to broadcast_to_supplier(supplier.id).message('orders_placed_count').with(count: 3)
|
||||
end
|
||||
end
|
||||
|
||||
it 'sets the list price as kind of caching' do
|
||||
list.place_order(user, product.id => 7)
|
||||
list.place_order(product.id => 7, user: user)
|
||||
list.reload
|
||||
list.price.should == 15.54
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user