Whitespace cleanup
[merb_mart.git] / spec / models / transaction_spec.rb
blob9a77812aa917ca338f3539a9fde996a8ca9e83b6
1 require File.join( File.dirname(__FILE__), "..", "spec_helper" )
3 describe Transaction do
4   before(:each) do
5     DataMapper.auto_migrate!
6   end
8   describe "associations" do
9     it "should belong to an order" do
10       order = Order.gen
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)
19     end
21     it "should belong to an account" do
22       account = Account.gen
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)
31     end
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
39     end
40   end
41 end