Skip to content

Commit df363fc

Browse files
committed
Add failing spec
1 parent ffbdc51 commit df363fc

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Diff for: spec/chrono_model/history_models_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
expected['boos'] = Boo::History if defined?(Boo::History)
1616

1717
expected['sub_bars'] = SubBar::History if defined?(SubBar::History)
18+
expected['sub_sub_bars'] = SubSubBar::History if defined?(SubSubBar::History)
1819

1920
# default_scope_spec
2021
expected['defoos'] = Defoo::History if defined?(Defoo::History)

Diff for: spec/chrono_model/time_machine/as_of_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@
147147
it { expect(Foo.as_of($t.subbar.ts[1]).includes(:bars, :sub_bars).first.sub_bars.first.name).to eq 'bar sub-bar' }
148148
it { expect(Foo.as_of($t.subbar.ts[2]).includes(:bars, :sub_bars).first.sub_bars.first.name).to eq 'sub-bar sub-bar' }
149149
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 }
150152
end
151153

152154
it 'does not raise RecordNotFound when no history records are found' do

Diff for: spec/support/time_machine/structure.rb

+15
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class ::Foo < ActiveRecord::Base
3030

3131
has_many :bars
3232
has_many :sub_bars, through: :bars
33+
has_many :sub_sub_bars, through: :sub_bars
3334

3435
belongs_to :goo, class_name: 'FooGoo', optional: true
3536
end
@@ -93,10 +94,22 @@ class ::SubBar < ActiveRecord::Base
9394
include ChronoModel::TimeMachine
9495

9596
belongs_to :bar
97+
has_many :sub_sub_bars
9698

9799
has_timeline with: :bar
98100
end
99101

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+
100113
adapter.create_table 'bazs' do |t|
101114
t.string :name
102115
t.references :bar
@@ -126,6 +139,8 @@ class ::Baz < ActiveRecord::Base
126139
$t.subbar = ts_eval { SubBar.create! name: 'sub-bar', bar: $t.bar }
127140
ts_eval($t.subbar) { update! name: 'bar sub-bar' }
128141

142+
ts_eval { SubSubBar.create! name: 'sub-sub-bar', sub_bar: $t.subbar }
143+
129144
ts_eval($t.foo) { update! name: 'new foo' }
130145

131146
ts_eval($t.bar) { update! name: 'bar bar' }

0 commit comments

Comments
 (0)