temporal_tables 0.6.7 → 0.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff585572728100114c403af9f97e723d0c1d1760e73c46e7127d86849941cf0d
4
- data.tar.gz: c3f7f8d672c1d549c378be20996ed8594f51c53bf215c820d864fa936e4f572e
3
+ metadata.gz: 9863a5343174db0c24c2d0019fd9403d196824cc13cb3438598e8f8d950be485
4
+ data.tar.gz: 5aa981d770362f0a8a341991cf18cd0a7ea1e2dda5719275d03445b82f6f28ad
5
5
  SHA512:
6
- metadata.gz: 39d574fec08e359020dc88b2b7ef9d03ac6206da04517643d0686dbf02e1ecf6834d03742afadffd564bd7573076863bd82b3259059f0697b25594f9261f4f69
7
- data.tar.gz: 5493b7f16dd8cb2db633529037711ffb78224c5c42ab6e836f43901dacea20ade306e0103e09cc66f9349350e87da336032098cd7abb38430de18b5eb408a71e
6
+ metadata.gz: 1bc55839b61a4c816c650994ea297c1ea9a3fc9b9f37c3a89529c77c9e81e6049cd052707198c3b14501f0aec810c3e7a7350d5d94d1aa57e9ffbf3c9ee0255a
7
+ data.tar.gz: 7026b3448055ebf8eb1bcbf77898bff845eca5bcb728a4bed53dd40c562ec0710e9fe3eb3c7631394d8c2c137b0d1ad6f2b179b2951491d6da95e12983e51edc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- temporal_tables (0.6.7)
4
+ temporal_tables (0.6.9)
5
5
  rails (~> 5.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- temporal_tables (0.6.7)
4
+ temporal_tables (0.6.9)
5
5
  rails (~> 5.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- temporal_tables (0.6.7)
4
+ temporal_tables (0.6.9)
5
5
  rails (~> 5.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- temporal_tables (0.6.7)
4
+ temporal_tables (0.6.9)
5
5
  rails (~> 5.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- temporal_tables (0.6.7)
4
+ temporal_tables (0.6.9)
5
5
  rails (~> 5.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- temporal_tables (0.6.7)
4
+ temporal_tables (0.6.9)
5
5
  rails (~> 5.0)
6
6
 
7
7
  GEM
@@ -54,9 +54,13 @@ module TemporalTables
54
54
  end
55
55
 
56
56
  def find_sti_class(type_name)
57
- sti_class = super(type_name)
58
- sti_class = sti_class.history unless sti_class.respond_to?(:orig_class)
59
- sti_class
57
+ type_name += "History" unless type_name =~ /History\Z/
58
+
59
+ begin
60
+ super
61
+ rescue ActiveRecord::SubclassNotFound
62
+ superclass.send(:find_sti_class, type_name)
63
+ end
60
64
  end
61
65
  end
62
66
 
@@ -1,3 +1,3 @@
1
1
  module TemporalTables
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.9"
3
3
  end
@@ -108,5 +108,21 @@ describe Person do
108
108
  expect(emily.warts.first.hairiness).to eq(3)
109
109
  end
110
110
  end
111
+
112
+ describe "when working with STI one level deep" do
113
+ let!(:broom) { Broom.create person: emily, model: "Cackler 2000" }
114
+
115
+ it "should initialize model correctly" do
116
+ expect(emily.history.last.flying_machines).to eq([broom.history.last])
117
+ end
118
+ end
119
+
120
+ describe "when working with STI two levels deep" do
121
+ let!(:rocket_broom) { RocketBroom.create person: emily, model: "Pyrocackler 3000X" }
122
+
123
+ it "should initialize model correctly" do
124
+ expect(emily.history.last.flying_machines).to eq([rocket_broom.history.last])
125
+ end
126
+ end
111
127
  end
112
128
  end
@@ -0,0 +1,2 @@
1
+ class Broom < FlyingMachine
2
+ end
@@ -0,0 +1,3 @@
1
+ class FlyingMachine < ActiveRecord::Base
2
+ belongs_to :person
3
+ end
@@ -1,4 +1,5 @@
1
1
  class Person < ActiveRecord::Base
2
- belongs_to :coven
3
- has_many :warts
2
+ belongs_to :coven
3
+ has_many :warts
4
+ has_many :flying_machines
4
5
  end
@@ -0,0 +1,2 @@
1
+ class RocketBroom < Broom
2
+ end
@@ -1,6 +1,6 @@
1
1
  ActiveRecord::Schema.define do
2
2
  create_table :people, temporal: true, force: true do |t|
3
- t.references :coven
3
+ t.belongs_to :coven
4
4
  t.string :name
5
5
  end
6
6
 
@@ -10,7 +10,13 @@ ActiveRecord::Schema.define do
10
10
  add_temporal_table :covens
11
11
 
12
12
  create_table :warts, temporal: true, force: true do |t|
13
- t.references :person
13
+ t.belongs_to :person
14
14
  t.integer :hairiness
15
15
  end
16
+
17
+ create_table :flying_machines, temporal: true, force: true do |t|
18
+ t.belongs_to :person
19
+ t.string :type
20
+ t.string :model
21
+ end
16
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: temporal_tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brent Kroeker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-10 00:00:00.000000000 Z
11
+ date: 2019-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -107,8 +107,11 @@ files:
107
107
  - lib/temporal_tables/whodunnit.rb
108
108
  - spec/basic_history_spec.rb
109
109
  - spec/extensions/combustion.rb
110
+ - spec/internal/app/models/broom.rb
110
111
  - spec/internal/app/models/coven.rb
112
+ - spec/internal/app/models/flying_machine.rb
111
113
  - spec/internal/app/models/person.rb
114
+ - spec/internal/app/models/rocket_broom.rb
112
115
  - spec/internal/app/models/wart.rb
113
116
  - spec/internal/config/database.sample.yml
114
117
  - spec/internal/config/routes.rb
@@ -144,8 +147,11 @@ summary: Tracks all history of changes to a table automatically in a history tab
144
147
  test_files:
145
148
  - spec/basic_history_spec.rb
146
149
  - spec/extensions/combustion.rb
150
+ - spec/internal/app/models/broom.rb
147
151
  - spec/internal/app/models/coven.rb
152
+ - spec/internal/app/models/flying_machine.rb
148
153
  - spec/internal/app/models/person.rb
154
+ - spec/internal/app/models/rocket_broom.rb
149
155
  - spec/internal/app/models/wart.rb
150
156
  - spec/internal/config/database.sample.yml
151
157
  - spec/internal/config/routes.rb