Added rspec tests for order boolean states
This commit is contained in:
parent
f7b65856aa
commit
ecda1c1478
1 changed files with 29 additions and 1 deletions
|
@ -17,7 +17,7 @@ describe Order do
|
||||||
expect(order).to be_finished
|
expect(order).to be_finished
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'scopes' do
|
describe 'state scopes and boolean getters' do
|
||||||
let!(:open_order) { create :order, state: 'open' }
|
let!(:open_order) { create :order, state: 'open' }
|
||||||
let!(:finished_order) { create :order, state: 'finished' }
|
let!(:finished_order) { create :order, state: 'finished' }
|
||||||
let!(:received_order) { create :order, state: 'received' }
|
let!(:received_order) { create :order, state: 'received' }
|
||||||
|
@ -40,6 +40,34 @@ describe Order do
|
||||||
expect(Order.finished_not_closed.where(id: finished_order.id)).to exist
|
expect(Order.finished_not_closed.where(id: finished_order.id)).to exist
|
||||||
expect(Order.finished_not_closed.where(id: received_order.id)).to exist
|
expect(Order.finished_not_closed.where(id: received_order.id)).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should return valid boolean states for open orders' do
|
||||||
|
expect(open_order.open?).to be(true)
|
||||||
|
expect(open_order.finished?).to be(false)
|
||||||
|
expect(open_order.received?).to be(false)
|
||||||
|
expect(open_order.closed?).to be(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return valid boolean states for finished orders' do
|
||||||
|
expect(finished_order.open?).to be(false)
|
||||||
|
expect(finished_order.finished?).to be(true)
|
||||||
|
expect(finished_order.received?).to be(false)
|
||||||
|
expect(finished_order.closed?).to be(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return valid boolean states for received orders' do
|
||||||
|
expect(received_order.open?).to be(false)
|
||||||
|
expect(received_order.finished?).to be(true)
|
||||||
|
expect(received_order.received?).to be(true)
|
||||||
|
expect(received_order.closed?).to be(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return valid boolean states for closed orders' do
|
||||||
|
expect(closed_order.open?).to be(false)
|
||||||
|
expect(closed_order.finished?).to be(false)
|
||||||
|
expect(closed_order.received?).to be(false)
|
||||||
|
expect(closed_order.closed?).to be(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends mail if min_order_quantity has been reached' do
|
it 'sends mail if min_order_quantity has been reached' do
|
||||||
|
|
Loading…
Reference in a new issue