add group_order spec
This commit is contained in:
parent
3a7d650ed8
commit
679fc673c7
2 changed files with 33 additions and 0 deletions
9
spec/factories/group_order.rb
Normal file
9
spec/factories/group_order.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
require 'factory_girl'
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
|
||||||
|
# requires order and ordergroup
|
||||||
|
factory :group_order do
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
24
spec/models/group_order_spec.rb
Normal file
24
spec/models/group_order_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe GroupOrder do
|
||||||
|
let(:user) { FactoryGirl.create :user, groups: [FactoryGirl.create(:ordergroup)] }
|
||||||
|
let(:supplier) { FactoryGirl.create :supplier, article_count: true }
|
||||||
|
let(:order) { FactoryGirl.create(:order, supplier: supplier, article_ids: supplier.articles.map(&:id)).reload }
|
||||||
|
|
||||||
|
it 'needs an order' do
|
||||||
|
FactoryGirl.build(:group_order, ordergroup: user.ordergroup).should_not be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'needs an ordergroup' do
|
||||||
|
FactoryGirl.build(:group_order, order: order).should_not be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
describe do
|
||||||
|
let(:go) { FactoryGirl.create :group_order, order: order, ordergroup: user.ordergroup }
|
||||||
|
|
||||||
|
it 'has zero price initially' do
|
||||||
|
go.price.should == 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue