Skip to content

Commit

Permalink
Add failing spec for #295
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed May 25, 2024
1 parent 804afe2 commit 8e39b8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spec/chrono_model/time_machine/as_of_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@
it { expect(Foo.as_of($t.subbar.ts[3]).includes(:bars, :sub_bars).first.sub_bars.first.name).to eq 'new sub-bar' }

it { expect(Foo.as_of(Time.now).includes(:bars, :sub_bars, :sub_sub_bars).first.sub_sub_bars.compact.size).to eq 1 }

it { expect(Foo.as_of(Time.now).includes(:active_sub_bars).first.name).to eq 'new foo' }
end

it 'does not raise RecordNotFound when no history records are found' do
Expand Down
6 changes: 6 additions & 0 deletions spec/support/time_machine/structure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def up
adapter.create_table 'sub_bars', temporal: true do |t|
t.string :name
t.references :bar
t.boolean :active, default: true
end

adapter.create_table 'sub_sub_bars', temporal: true do |t|
Expand All @@ -87,6 +88,8 @@ class ::Bar < ActiveRecord::Base

belongs_to :foo
has_many :sub_bars
has_many :active_sub_bars, -> { active }, class_name: 'SubBar', dependent: nil, inverse_of: false

has_one :baz

has_timeline with: :foo
Expand Down Expand Up @@ -121,6 +124,7 @@ class ::Foo < ActiveRecord::Base
has_many :tars, foreign_key: :foo_refering, primary_key: :refee_foo
has_many :sub_bars, through: :bars
has_many :sub_sub_bars, through: :sub_bars
has_many :active_sub_bars, through: :bars

belongs_to :goo, class_name: 'FooGoo', optional: true
end
Expand All @@ -147,6 +151,8 @@ class ::SubBar < ActiveRecord::Base
belongs_to :bar
has_many :sub_sub_bars

scope :active, -> { where(active: true) }

has_timeline with: :bar
end

Expand Down

0 comments on commit 8e39b8b

Please sign in to comment.