1 require File.join( File.dirname(__FILE__), "..", "spec_helper" )
3 describe Transaction do
5 DataMapper.auto_migrate!
8 describe "associations" do
9 it "should belong to an order" do
11 transaction = Transaction.gen(:order => order)
12 transaction.order.should == order
13 transaction.should be_valid
15 transaction = Transaction.create(Transaction.gen_attrs.except(:order))
16 transaction.order.should be_nil
17 transaction.should_not be_valid
18 transaction.errors.should include(:order)
21 it "should belong to an account" do
23 transaction = Transaction.gen(:account => account)
24 transaction.account.should == account
25 transaction.should be_valid
27 transaction = Transaction.create(Transaction.gen_attrs.except(:account))
28 transaction.account.should be_nil
29 transaction.should_not be_valid
30 transaction.errors.should include(:account)
33 it "should belong to a customer through the transaction" do
34 pending "i figure out this whole :through business"
35 customer = Customer.gen
36 order = Order.gen(:customer => customer)
37 transaction = Transaction.gen(:order => order)
38 transaction.customer.should == customer