Skip to content

Commit

Permalink
Added rspec tests for order boolean states
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi authored and paroga committed Feb 5, 2021
1 parent f7b6585 commit ecda1c1
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion spec/models/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
expect(order).to be_finished
end

describe 'scopes' do
describe 'state scopes and boolean getters' do
let!(:open_order) { create :order, state: 'open' }
let!(:finished_order) { create :order, state: 'finished' }
let!(:received_order) { create :order, state: 'received' }
Expand All @@ -40,6 +40,34 @@
expect(Order.finished_not_closed.where(id: finished_order.id)).to exist
expect(Order.finished_not_closed.where(id: received_order.id)).to exist
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

it 'sends mail if min_order_quantity has been reached' do
Expand Down

0 comments on commit ecda1c1

Please sign in to comment.