File tree Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 1
1
PATH
2
2
remote: .
3
3
specs:
4
- deb (0.0.8 )
4
+ deb (0.0.10 )
5
5
docile
6
6
rails
7
7
Original file line number Diff line number Diff line change @@ -18,12 +18,12 @@ def self.start(&block)
18
18
Docile . dsl_eval ( Deb ::Builder . new , &block ) . build
19
19
end
20
20
21
- def rollback!
21
+ def rollback! ( ref = nil )
22
22
tran = self
23
23
self . class . start! do
24
24
tran . debit_items . each { |di | credit ( di . account , di . amount ) }
25
25
tran . credit_items . each { |ci | debit ( ci . account , ci . amount ) }
26
- reference ( tran )
26
+ reference ( ref || tran )
27
27
kind ( tran . kind )
28
28
description ( "Rollback of #{ tran . description } " )
29
29
end
Original file line number Diff line number Diff line change 1
1
module Deb
2
- VERSION = "0.0.9 "
2
+ VERSION = "0.0.10 "
3
3
end
Original file line number Diff line number Diff line change @@ -131,12 +131,30 @@ module Deb
131
131
@liability . reload . current_balance . should == 7
132
132
end
133
133
134
- describe :rollback do
134
+ it "should receive custom rollback references" do
135
+ @transaction . save!
136
+ transaction2 = Transaction . start do
137
+ debit @asset , 12
138
+ credit @revenue , 5
139
+ credit @liability , 7
140
+ description "foobar"
141
+ kind "baz"
142
+ end
143
+ transaction2 . save!
144
+ @rollback = @transaction . rollback! ( transaction2 )
145
+ @rollback . transactionable . should == transaction2
146
+ end
147
+
148
+ describe :default_rollback do
135
149
before ( :each ) do
136
150
@transaction . save!
137
151
@rollback = @transaction . rollback!
138
152
end
139
153
154
+ it "should keep the reference" do
155
+ @rollback . transactionable . should == @transaction
156
+ end
157
+
140
158
it "should be okay" do
141
159
@rollback . should_not be_new_record
142
160
end
You can’t perform that action at this time.
0 commit comments