File tree 3 files changed +18
-0
lines changed
3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 15
15
expected [ 'boos' ] = Boo ::History if defined? ( Boo ::History )
16
16
17
17
expected [ 'sub_bars' ] = SubBar ::History if defined? ( SubBar ::History )
18
+ expected [ 'sub_sub_bars' ] = SubSubBar ::History if defined? ( SubSubBar ::History )
18
19
19
20
# default_scope_spec
20
21
expected [ 'defoos' ] = Defoo ::History if defined? ( Defoo ::History )
Original file line number Diff line number Diff line change 147
147
it { expect ( Foo . as_of ( $t. subbar . ts [ 1 ] ) . includes ( :bars , :sub_bars ) . first . sub_bars . first . name ) . to eq 'bar sub-bar' }
148
148
it { expect ( Foo . as_of ( $t. subbar . ts [ 2 ] ) . includes ( :bars , :sub_bars ) . first . sub_bars . first . name ) . to eq 'sub-bar sub-bar' }
149
149
it { expect ( Foo . as_of ( $t. subbar . ts [ 3 ] ) . includes ( :bars , :sub_bars ) . first . sub_bars . first . name ) . to eq 'new sub-bar' }
150
+
151
+ it { expect ( Foo . as_of ( Time . now ) . includes ( :bars , :sub_bars , :sub_sub_bars ) . first . sub_sub_bars . compact . size ) . to eq 1 }
150
152
end
151
153
152
154
it 'does not raise RecordNotFound when no history records are found' do
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ class ::Foo < ActiveRecord::Base
30
30
31
31
has_many :bars
32
32
has_many :sub_bars , through : :bars
33
+ has_many :sub_sub_bars , through : :sub_bars
33
34
34
35
belongs_to :goo , class_name : 'FooGoo' , optional : true
35
36
end
@@ -93,10 +94,22 @@ class ::SubBar < ActiveRecord::Base
93
94
include ChronoModel ::TimeMachine
94
95
95
96
belongs_to :bar
97
+ has_many :sub_sub_bars
96
98
97
99
has_timeline with : :bar
98
100
end
99
101
102
+ adapter . create_table 'sub_sub_bars' , temporal : true do |t |
103
+ t . string :name
104
+ t . references :sub_bar
105
+ end
106
+
107
+ class ::SubSubBar < ActiveRecord ::Base
108
+ include ChronoModel ::TimeMachine
109
+
110
+ belongs_to :sub_bar
111
+ end
112
+
100
113
adapter . create_table 'bazs' do |t |
101
114
t . string :name
102
115
t . references :bar
@@ -126,6 +139,8 @@ class ::Baz < ActiveRecord::Base
126
139
$t. subbar = ts_eval { SubBar . create! name : 'sub-bar' , bar : $t. bar }
127
140
ts_eval ( $t. subbar ) { update! name : 'bar sub-bar' }
128
141
142
+ ts_eval { SubSubBar . create! name : 'sub-sub-bar' , sub_bar : $t. subbar }
143
+
129
144
ts_eval ( $t. foo ) { update! name : 'new foo' }
130
145
131
146
ts_eval ( $t. bar ) { update! name : 'bar bar' }
You can’t perform that action at this time.
0 commit comments