Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing spec for #295 #296

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading