41 lines
1.1 KiB
Ruby
41 lines
1.1 KiB
Ruby
require 'spec_helper'
|
|
|
|
|
|
describe Order do
|
|
let(:supplier) { create :supplier }
|
|
let(:user) { create :user }
|
|
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' }
|
|
subject { order }
|
|
|
|
its(:placed?) { should be_true }
|
|
its(:active?) { should be_false }
|
|
|
|
describe 'count_active_for_supplier_and_list' do
|
|
before { order }
|
|
it 'counts active orders for a list with objects' do
|
|
Order.count_active_for_supplier_and_list(supplier, list).should == 1
|
|
end
|
|
it 'counts active orders for a list with ids' do
|
|
Order.count_active_for_supplier_and_list(supplier.id, list.id).should == 1
|
|
end
|
|
it 'does not count inactive orders' do
|
|
order.close!
|
|
Order.count_active_for_supplier_and_list(supplier, list).should == 0
|
|
end
|
|
end
|
|
|
|
|
|
describe '.for_supplier' do
|
|
before { order }
|
|
it 'works' do
|
|
Order.for_supplier(supplier).should == order
|
|
end
|
|
|
|
it 'paginates'
|
|
end
|
|
|
|
end
|