dbview_cti 0.2.1 → 0.2.2
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 +5 -13
- data/.travis.yml +6 -5
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/dbview_cti.gemspec +1 -1
- data/lib/db_view_cti/model/cti/associations.rb +3 -1
- data/lib/db_view_cti/model/cti/destroy.rb +10 -3
- data/lib/db_view_cti/schema_dumper.rb +2 -1
- data/lib/db_view_cti/version.rb +1 -1
- data/spec/dummy-rails-4/config/environments/test.rb +1 -1
- data/spec/dummy-rails-5/Rakefile +6 -0
- data/spec/dummy-rails-5/app/assets/config/manifest.js +4 -0
- data/spec/dummy-rails-5/app/assets/images/.keep +0 -0
- data/spec/dummy-rails-5/app/assets/javascripts/application.js +13 -0
- data/spec/dummy-rails-5/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy-rails-5/app/assets/javascripts/channels/.keep +0 -0
- data/spec/dummy-rails-5/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy-rails-5/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy-rails-5/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy-rails-5/app/controllers/application_controller.rb +3 -0
- data/spec/dummy-rails-5/app/controllers/concerns/.keep +0 -0
- data/spec/dummy-rails-5/app/helpers/application_helper.rb +2 -0
- data/spec/dummy-rails-5/app/jobs/application_job.rb +2 -0
- data/spec/dummy-rails-5/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy-rails-5/app/models.original/application_record.rb +3 -0
- data/spec/dummy-rails-5/app/models.original/concerns/.keep +0 -0
- data/spec/dummy-rails-5/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy-rails-5/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy-rails-5/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy-rails-5/bin/bundle +3 -0
- data/spec/dummy-rails-5/bin/rails +4 -0
- data/spec/dummy-rails-5/bin/rake +4 -0
- data/spec/dummy-rails-5/bin/setup +34 -0
- data/spec/dummy-rails-5/bin/update +29 -0
- data/spec/dummy-rails-5/config/application.rb +20 -0
- data/spec/dummy-rails-5/config/boot.rb +5 -0
- data/spec/dummy-rails-5/config/cable.yml +9 -0
- data/spec/dummy-rails-5/config/database.yml +24 -0
- data/spec/dummy-rails-5/config/environment.rb +5 -0
- data/spec/dummy-rails-5/config/environments/development.rb +54 -0
- data/spec/dummy-rails-5/config/environments/production.rb +86 -0
- data/spec/dummy-rails-5/config/environments/test.rb +42 -0
- data/spec/dummy-rails-5/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy-rails-5/config/initializers/assets.rb +11 -0
- data/spec/dummy-rails-5/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy-rails-5/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy-rails-5/config/initializers/dbview_cti.rb +8 -0
- data/spec/dummy-rails-5/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy-rails-5/config/initializers/inflections.rb +16 -0
- data/spec/dummy-rails-5/config/initializers/mime_types.rb +4 -0
- data/spec/dummy-rails-5/config/initializers/new_framework_defaults.rb +24 -0
- data/spec/dummy-rails-5/config/initializers/session_store.rb +3 -0
- data/spec/dummy-rails-5/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy-rails-5/config/locales/en.yml +23 -0
- data/spec/dummy-rails-5/config/puma.rb +47 -0
- data/spec/dummy-rails-5/config/routes.rb +3 -0
- data/spec/dummy-rails-5/config/secrets.yml +22 -0
- data/spec/dummy-rails-5/config/spring.rb +6 -0
- data/spec/dummy-rails-5/config.ru +5 -0
- data/spec/dummy-rails-5/lib/assets/.keep +0 -0
- data/spec/dummy-rails-5/log/.keep +0 -0
- data/spec/dummy-rails-5/public/404.html +67 -0
- data/spec/dummy-rails-5/public/422.html +67 -0
- data/spec/dummy-rails-5/public/500.html +66 -0
- data/spec/dummy-rails-5/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy-rails-5/public/apple-touch-icon.png +0 -0
- data/spec/dummy-rails-5/public/favicon.ico +0 -0
- data/spec/models/car_spec.rb +20 -20
- data/spec/models/motor_vehicle_spec.rb +9 -9
- data/spec/models/space_shuttle_spec.rb +52 -52
- data/spec/models/vehicle_spec.rb +24 -24
- data/spec/spec_helper.rb +11 -1
- metadata +72 -15
@@ -11,12 +11,12 @@ describe SpaceShuttle do
|
|
11
11
|
:space_ship_id => shuttle.convert_to(:space_ship).id)
|
12
12
|
expect {
|
13
13
|
shuttle.destroy
|
14
|
-
}.to raise_error
|
14
|
+
}.to raise_error(ActiveRecord::InvalidForeignKey)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "stores attributes that were added to ascendant classes after initial creation of the tables" do
|
18
18
|
shuttle = SpaceShuttle.create(:name => 'Discovery', :reliability => 100)
|
19
|
-
shuttle.convert_to(:space_ship).reliability.
|
19
|
+
expect(shuttle.convert_to(:space_ship).reliability).to eq 100
|
20
20
|
end
|
21
21
|
|
22
22
|
context 'associations' do
|
@@ -25,7 +25,7 @@ describe SpaceShuttle do
|
|
25
25
|
# its associated spaceship
|
26
26
|
(1..2).map { SpaceShip.create(:name => 'test') }
|
27
27
|
@shuttle = SpaceShuttle.create(:name => 'Discovery', :reliability => 100)
|
28
|
-
@shuttle.id.
|
28
|
+
expect(@shuttle.id).not_to eq @shuttle.convert_to(:space_ship).id
|
29
29
|
end
|
30
30
|
|
31
31
|
it "can use has_many associations defined in ascendant classes" do
|
@@ -40,25 +40,25 @@ describe SpaceShuttle do
|
|
40
40
|
@shuttle.launches = [ launch1, launch2 ]
|
41
41
|
@shuttle.save!
|
42
42
|
}.to change(Launch, :count).by(1)
|
43
|
-
@shuttle.launch_ids.sort.
|
43
|
+
expect(@shuttle.launch_ids.sort).to eq [ launch1.id, launch2.id ]
|
44
44
|
launch3.save!
|
45
45
|
@shuttle.launch_ids = [ launch1.id, launch3.id ]
|
46
|
-
@shuttle.launch_ids.sort.
|
46
|
+
expect(@shuttle.launch_ids.sort).to eq [ launch1.id, launch3.id ]
|
47
47
|
# test build functionality for adding to existing collection
|
48
48
|
expect {
|
49
49
|
@shuttle.launches.build(:date => Date.yesterday)
|
50
50
|
@shuttle.save!
|
51
51
|
}.to change(Launch, :count).by(1)
|
52
|
-
@shuttle.launches.order(:id).last.date.
|
52
|
+
expect(@shuttle.launches.order(:id).last.date).to eq Date.yesterday
|
53
53
|
# test build functionality for new collection
|
54
54
|
@shuttle.launches.clear
|
55
|
-
@shuttle.launch_ids.
|
55
|
+
expect(@shuttle.launch_ids).to eq []
|
56
56
|
expect {
|
57
57
|
@shuttle.name = 'Shuttle'
|
58
58
|
@shuttle.launches.build(:date => Date.yesterday)
|
59
59
|
@shuttle.save!
|
60
60
|
}.to change(Launch, :count).by(1)
|
61
|
-
@shuttle.name.
|
61
|
+
expect(@shuttle.name).to eq 'Shuttle'
|
62
62
|
# test build functionality for new collection and new object
|
63
63
|
shuttle = SpaceShuttle.new(:name => 'Endeavour', :reliability => 100)
|
64
64
|
expect {
|
@@ -70,13 +70,13 @@ describe SpaceShuttle do
|
|
70
70
|
}.to change(Launch, :count).by(2)
|
71
71
|
}.to change(SpaceShuttle, :count).by(1)
|
72
72
|
shuttle.reload
|
73
|
-
shuttle.name.
|
73
|
+
expect(shuttle.name).to eq 'Shuttle'
|
74
74
|
# test adding onto existing collection
|
75
75
|
expect {
|
76
76
|
shuttle.launches.build(:date => Date.today)
|
77
77
|
shuttle.save!
|
78
78
|
}.to change(Launch, :count).by(1)
|
79
|
-
shuttle.launches.order(:id).last.date.
|
79
|
+
expect(shuttle.launches.order(:id).last.date).to eq Date.today
|
80
80
|
end
|
81
81
|
|
82
82
|
it "supports assignment on the 'remote' side of a has_many association" do
|
@@ -106,7 +106,7 @@ describe SpaceShuttle do
|
|
106
106
|
]
|
107
107
|
@shuttle.save!
|
108
108
|
}.to change(Launch, :count).by(2)
|
109
|
-
@shuttle.launches.order(:date).map(&:date).
|
109
|
+
expect(@shuttle.launches.order(:date).map(&:date)).to eq [ Date.yesterday, Date.today ]
|
110
110
|
# do the same for a new object
|
111
111
|
shuttle = SpaceShuttle.new(:name => 'Endeavour', :reliability => 100)
|
112
112
|
expect {
|
@@ -117,7 +117,7 @@ describe SpaceShuttle do
|
|
117
117
|
shuttle.save!
|
118
118
|
}.to change(Launch, :count).by(2)
|
119
119
|
}.to change(SpaceShuttle, :count).by(1)
|
120
|
-
shuttle.launches.order(:date).map(&:date).
|
120
|
+
expect(shuttle.launches.order(:date).map(&:date)).to eq [ Date.yesterday, Date.today ]
|
121
121
|
end
|
122
122
|
|
123
123
|
it "can use has_many :through associations defined in ascendant classes" do
|
@@ -132,27 +132,27 @@ describe SpaceShuttle do
|
|
132
132
|
@shuttle.experiments = [ experiment1, experiment2 ]
|
133
133
|
@shuttle.save!
|
134
134
|
}.to change(Experiment, :count).by(1)
|
135
|
-
@shuttle.experiment_ids.sort.
|
135
|
+
expect(@shuttle.experiment_ids.sort).to eq [ experiment1.id, experiment2.id ]
|
136
136
|
experiment3.save!
|
137
137
|
@shuttle.experiment_ids = [ experiment1.id, experiment3.id ]
|
138
|
-
@shuttle.experiment_ids.sort.
|
139
|
-
Experiment.last.space_ships.first.specialize.id.
|
138
|
+
expect(@shuttle.experiment_ids.sort).to eq [ experiment1.id, experiment3.id ]
|
139
|
+
expect(Experiment.last.space_ships.first.specialize.id).to eq @shuttle.id
|
140
140
|
# test build functionality for adding to existing collection
|
141
141
|
expect {
|
142
142
|
@shuttle.experiments.build(:name => 'Superconductivity')
|
143
143
|
@shuttle.save!
|
144
144
|
}.to change(Experiment, :count).by(1)
|
145
|
-
@shuttle.experiments.order(:id).last.name.
|
145
|
+
expect(@shuttle.experiments.order(:id).last.name).to eq 'Superconductivity'
|
146
146
|
# test build functionality for new collection
|
147
147
|
@shuttle.experiments.clear
|
148
|
-
@shuttle.experiment_ids.
|
148
|
+
expect(@shuttle.experiment_ids).to eq []
|
149
149
|
expect {
|
150
150
|
@shuttle.name = 'Shuttle'
|
151
151
|
@shuttle.experiments.build(:name => 'Failed experiment')
|
152
152
|
@shuttle.save!
|
153
153
|
}.to change(Experiment, :count).by(1)
|
154
|
-
@shuttle.experiments.first.name.
|
155
|
-
@shuttle.name.
|
154
|
+
expect(@shuttle.experiments.first.name).to eq 'Failed experiment'
|
155
|
+
expect(@shuttle.name).to eq 'Shuttle'
|
156
156
|
# test build functionality for new collection and new object
|
157
157
|
shuttle = SpaceShuttle.new(:name => 'Endeavour', :reliability => 100)
|
158
158
|
expect {
|
@@ -164,20 +164,20 @@ describe SpaceShuttle do
|
|
164
164
|
}.to change(Experiment, :count).by(2)
|
165
165
|
}.to change(SpaceShuttle, :count).by(1)
|
166
166
|
shuttle.reload
|
167
|
-
shuttle.name.
|
168
|
-
shuttle.experiments.order(:name).map(&:name).
|
167
|
+
expect(shuttle.name).to eq 'Shuttle'
|
168
|
+
expect(shuttle.experiments.order(:name).map(&:name)).to eq ['Exp1', 'Exp2']
|
169
169
|
# test adding onto existing collection (new object)
|
170
170
|
expect {
|
171
171
|
shuttle.experiments.build(:name => 'Exp3')
|
172
172
|
shuttle.save!
|
173
173
|
}.to change(Experiment, :count).by(1)
|
174
|
-
shuttle.experiments.order(:name).map(&:name).
|
174
|
+
expect(shuttle.experiments.order(:name).map(&:name)).to eq ['Exp1', 'Exp2', 'Exp3']
|
175
175
|
end
|
176
176
|
|
177
177
|
it "supports operations on the 'remote' side of a has_many :through association" do
|
178
178
|
experiment = Experiment.new(:name => 'Zero-gravity')
|
179
179
|
shuttle2 = SpaceShuttle.create(:name => 'Endeavour', :reliability => 100)
|
180
|
-
shuttle2.id.
|
180
|
+
expect(shuttle2.id).not_to eq shuttle2.convert_to(:space_ship).id
|
181
181
|
expect {
|
182
182
|
experiment.space_ships = [@shuttle, shuttle2]
|
183
183
|
experiment.save!
|
@@ -211,7 +211,7 @@ describe SpaceShuttle do
|
|
211
211
|
]
|
212
212
|
@shuttle.save!
|
213
213
|
}.to change(Experiment, :count).by(2)
|
214
|
-
@shuttle.experiments.order(:name).map(&:name).
|
214
|
+
expect(@shuttle.experiments.order(:name).map(&:name)).to eq [ 'Exp1', 'Exp2' ]
|
215
215
|
# do the same for a new object
|
216
216
|
shuttle = SpaceShuttle.new(:name => 'Endeavour', :reliability => 100)
|
217
217
|
expect {
|
@@ -222,7 +222,7 @@ describe SpaceShuttle do
|
|
222
222
|
shuttle.save!
|
223
223
|
}.to change(Experiment, :count).by(2)
|
224
224
|
}.to change(SpaceShuttle, :count).by(1)
|
225
|
-
shuttle.experiments.order(:name).map(&:name).
|
225
|
+
expect(shuttle.experiments.order(:name).map(&:name)).to eq [ 'Exp1', 'Exp2' ]
|
226
226
|
end
|
227
227
|
|
228
228
|
it "can use has_one associations defined in ascendant classes" do
|
@@ -232,19 +232,19 @@ describe SpaceShuttle do
|
|
232
232
|
@shuttle.save!
|
233
233
|
}.to change(Captain, :count).by(1)
|
234
234
|
@shuttle.reload
|
235
|
-
@shuttle.captain.id.
|
235
|
+
expect(@shuttle.captain.id).to eq captain.id
|
236
236
|
@shuttle.captain.destroy
|
237
237
|
expect {
|
238
238
|
@shuttle.create_captain(:name => 'Glenn')
|
239
239
|
}.to change(Captain, :count).by(1)
|
240
|
-
@shuttle.captain.space_ship_id.
|
240
|
+
expect(@shuttle.captain.space_ship_id).to eq @shuttle.convert_to(:space_ship).id
|
241
241
|
Captain.all.map(&:destroy)
|
242
242
|
# test build for existing object
|
243
243
|
expect {
|
244
244
|
cap = @shuttle.build_captain(:name => 'Aldrinn')
|
245
245
|
@shuttle.save!
|
246
246
|
}.to change(Captain, :count).by(1)
|
247
|
-
@shuttle.captain.space_ship_id.
|
247
|
+
expect(@shuttle.captain.space_ship_id).to eq @shuttle.convert_to(:space_ship).id
|
248
248
|
# test build for new object
|
249
249
|
shuttle = SpaceShuttle.new(:name => 'Endeavour', :reliability => 100)
|
250
250
|
expect {
|
@@ -254,8 +254,8 @@ describe SpaceShuttle do
|
|
254
254
|
shuttle.save!
|
255
255
|
}.to change(Captain, :count).by(1)
|
256
256
|
}.to change(SpaceShuttle, :count).by(1)
|
257
|
-
shuttle.name.
|
258
|
-
shuttle.captain.space_ship_id.
|
257
|
+
expect(shuttle.name).to eq 'Shuttle'
|
258
|
+
expect(shuttle.captain.space_ship_id).to eq shuttle.convert_to(:space_ship).id
|
259
259
|
end
|
260
260
|
|
261
261
|
it "supports operations on the 'remote' side of a has_one association" do
|
@@ -283,7 +283,7 @@ describe SpaceShuttle do
|
|
283
283
|
@shuttle.captain_attributes = {:name => 'Haddock'}
|
284
284
|
@shuttle.save!
|
285
285
|
}.to change(Captain, :count).by(1)
|
286
|
-
@shuttle.captain.name.
|
286
|
+
expect(@shuttle.captain.name).to eq 'Haddock'
|
287
287
|
# do the same for a new object
|
288
288
|
shuttle = SpaceShuttle.new(:name => 'Endeavour', :reliability => 100)
|
289
289
|
expect {
|
@@ -292,7 +292,7 @@ describe SpaceShuttle do
|
|
292
292
|
shuttle.save!
|
293
293
|
}.to change(Captain, :count).by(1)
|
294
294
|
}.to change(SpaceShuttle, :count).by(1)
|
295
|
-
shuttle.captain.name.
|
295
|
+
expect(shuttle.captain.name).to eq 'Haddock'
|
296
296
|
end
|
297
297
|
|
298
298
|
it "can use has_and_belongs_to_many associations defined in ascendant classes" do
|
@@ -303,31 +303,31 @@ describe SpaceShuttle do
|
|
303
303
|
@shuttle.astronauts << astronaut1
|
304
304
|
@shuttle.save!
|
305
305
|
}.to change(Astronaut, :count).by(1)
|
306
|
-
@shuttle.astronauts.first.name.
|
306
|
+
expect(@shuttle.astronauts.first.name).to eq astronaut1.name
|
307
307
|
expect {
|
308
308
|
@shuttle.astronauts = [ astronaut1, astronaut2 ]
|
309
309
|
@shuttle.save!
|
310
310
|
}.to change(Astronaut, :count).by(1)
|
311
|
-
@shuttle.astronaut_ids.sort.
|
311
|
+
expect(@shuttle.astronaut_ids.sort).to eq [ astronaut1.id, astronaut2.id ]
|
312
312
|
astronaut3.save!
|
313
313
|
@shuttle.astronaut_ids = [ astronaut1.id, astronaut3.id ]
|
314
|
-
@shuttle.astronaut_ids.sort.
|
314
|
+
expect(@shuttle.astronaut_ids.sort).to eq [ astronaut1.id, astronaut3.id ]
|
315
315
|
# test build functionality for adding to existing collection
|
316
316
|
expect {
|
317
317
|
@shuttle.astronauts.build(:name => 'astro1')
|
318
318
|
@shuttle.save!
|
319
319
|
}.to change(Astronaut, :count).by(1)
|
320
|
-
@shuttle.astronauts.order(:id).last.name.
|
320
|
+
expect(@shuttle.astronauts.order(:id).last.name).to eq 'astro1'
|
321
321
|
# test build functionality for new collection
|
322
322
|
@shuttle.astronauts.clear
|
323
|
-
@shuttle.astronaut_ids.
|
323
|
+
expect(@shuttle.astronaut_ids).to eq []
|
324
324
|
expect {
|
325
325
|
@shuttle.name = 'Shuttle'
|
326
326
|
@shuttle.astronauts.build(:name => 'astro2')
|
327
327
|
@shuttle.save!
|
328
328
|
}.to change(Astronaut, :count).by(1)
|
329
|
-
@shuttle.astronauts.first.name.
|
330
|
-
@shuttle.name.
|
329
|
+
expect(@shuttle.astronauts.first.name).to eq 'astro2'
|
330
|
+
expect(@shuttle.name).to eq 'Shuttle'
|
331
331
|
# test build functionality for new collection and new object
|
332
332
|
shuttle = SpaceShuttle.new(:name => 'Endeavour', :reliability => 100)
|
333
333
|
expect {
|
@@ -339,32 +339,32 @@ describe SpaceShuttle do
|
|
339
339
|
}.to change(Astronaut, :count).by(2)
|
340
340
|
}.to change(SpaceShuttle, :count).by(1)
|
341
341
|
shuttle.reload
|
342
|
-
shuttle.name.
|
343
|
-
shuttle.astronauts.order(:name).map(&:name).
|
342
|
+
expect(shuttle.name).to eq 'Shuttle'
|
343
|
+
expect(shuttle.astronauts.order(:name).map(&:name)).to eq ['Astro1', 'Astro2']
|
344
344
|
# test adding onto existing collection (new object)
|
345
345
|
expect {
|
346
346
|
shuttle.astronauts.build(:name => 'Astro3')
|
347
347
|
shuttle.save!
|
348
348
|
}.to change(Astronaut, :count).by(1)
|
349
|
-
shuttle.astronauts.order(:name).map(&:name).
|
349
|
+
expect(shuttle.astronauts.order(:name).map(&:name)).to eq ['Astro1', 'Astro2', 'Astro3']
|
350
350
|
end
|
351
351
|
|
352
352
|
it "supports operations on the 'remote' side of a has_and_belongs_to_many association" do
|
353
353
|
astronaut = Astronaut.new(:name => 'Armstrong')
|
354
354
|
shuttle2 = SpaceShuttle.create(:name => 'Endeavour', :reliability => 100)
|
355
|
-
shuttle2.id.
|
355
|
+
expect(shuttle2.id).not_to eq shuttle2.convert_to(:space_ship).id
|
356
356
|
query = 'SELECT COUNT(*) FROM astronauts_space_ships'
|
357
|
-
ActiveRecord::Base.connection().execute(query)[0]['count'].to_i.
|
357
|
+
expect(ActiveRecord::Base.connection().execute(query)[0]['count'].to_i).to be_zero
|
358
358
|
astronaut.space_ships = [@shuttle, shuttle2]
|
359
359
|
astronaut.save!
|
360
|
-
ActiveRecord::Base.connection().execute(query)[0]['count'].to_i.
|
360
|
+
expect(ActiveRecord::Base.connection().execute(query)[0]['count'].to_i).to eq 2
|
361
361
|
astronaut.space_ships.delete(@shuttle, shuttle2)
|
362
|
-
ActiveRecord::Base.connection().execute(query)[0]['count'].to_i.
|
362
|
+
expect(ActiveRecord::Base.connection().execute(query)[0]['count'].to_i).to be_zero
|
363
363
|
astronaut.space_ships << @shuttle
|
364
364
|
astronaut.save!
|
365
|
-
ActiveRecord::Base.connection().execute(query)[0]['count'].to_i.
|
365
|
+
expect(ActiveRecord::Base.connection().execute(query)[0]['count'].to_i).to eq 1
|
366
366
|
astronaut.space_ships.destroy(@shuttle)
|
367
|
-
ActiveRecord::Base.connection().execute(query)[0]['count'].to_i.
|
367
|
+
expect(ActiveRecord::Base.connection().execute(query)[0]['count'].to_i).to be_zero
|
368
368
|
# make sure nil assignments raise activerecord exceptions and not exceptions in dbview_cti code
|
369
369
|
expect {
|
370
370
|
astronaut.space_ships = [nil]
|
@@ -386,7 +386,7 @@ describe SpaceShuttle do
|
|
386
386
|
]
|
387
387
|
@shuttle.save!
|
388
388
|
}.to change(Astronaut, :count).by(2)
|
389
|
-
@shuttle.astronauts.order(:name).map(&:name).
|
389
|
+
expect(@shuttle.astronauts.order(:name).map(&:name)).to eq [ 'Astro1', 'Astro2' ]
|
390
390
|
# do the same for a new object
|
391
391
|
shuttle = SpaceShuttle.new(:name => 'Endeavour', :reliability => 100)
|
392
392
|
expect {
|
@@ -397,7 +397,7 @@ describe SpaceShuttle do
|
|
397
397
|
shuttle.save!
|
398
398
|
}.to change(Astronaut, :count).by(2)
|
399
399
|
}.to change(SpaceShuttle, :count).by(1)
|
400
|
-
shuttle.astronauts.order(:name).map(&:name).
|
400
|
+
expect(shuttle.astronauts.order(:name).map(&:name)).to eq [ 'Astro1', 'Astro2' ]
|
401
401
|
end
|
402
402
|
|
403
403
|
it "doesn't choke on belongs_to associations" do
|
@@ -447,13 +447,13 @@ describe SpaceShuttle do
|
|
447
447
|
@shuttle.upgraded_to << shuttle2
|
448
448
|
@shuttle.save!
|
449
449
|
shuttle2.reload
|
450
|
-
shuttle2.upgraded_from.specialize.id.
|
450
|
+
expect(shuttle2.upgraded_from.specialize.id).to eq @shuttle.id
|
451
451
|
# check belongs_to side
|
452
452
|
shuttle3 = SpaceShuttle.create(:name => 'Endeavour', :reliability => 100)
|
453
453
|
@shuttle.upgraded_from = shuttle3
|
454
454
|
@shuttle.save!
|
455
455
|
@shuttle.reload
|
456
|
-
@shuttle.upgraded_from.specialize.id.
|
456
|
+
expect(@shuttle.upgraded_from.specialize.id).to eq shuttle3.id
|
457
457
|
end
|
458
458
|
|
459
459
|
end
|
data/spec/models/vehicle_spec.rb
CHANGED
@@ -7,34 +7,34 @@ describe Vehicle do
|
|
7
7
|
@car = Car.create(:name => 'MyCar')
|
8
8
|
vehicle = Vehicle.order(:id).last
|
9
9
|
car = vehicle.specialize
|
10
|
-
car.class.name.
|
11
|
-
car.id.
|
10
|
+
expect(car.class.name).to eq 'Car'
|
11
|
+
expect(car.id).to eq @car.id
|
12
12
|
|
13
13
|
@motorcycle = MotorCycle.create(:name => 'MyBike')
|
14
14
|
vehicle = Vehicle.order(:id).last
|
15
15
|
motorcycle = vehicle.specialize
|
16
|
-
motorcycle.class.name.
|
17
|
-
motorcycle.id.
|
16
|
+
expect(motorcycle.class.name).to eq 'MotorCycle'
|
17
|
+
expect(motorcycle.id).to eq @motorcycle.id
|
18
18
|
|
19
19
|
@motor_vehicle = MotorVehicle.create(:name => 'MyTrike')
|
20
20
|
vehicle = Vehicle.order(:id).last
|
21
21
|
motor_vehicle = vehicle.specialize
|
22
|
-
motor_vehicle.class.name.
|
23
|
-
motor_vehicle.id.
|
22
|
+
expect(motor_vehicle.class.name).to eq 'MotorVehicle'
|
23
|
+
expect(motor_vehicle.id).to eq @motor_vehicle.id
|
24
24
|
end
|
25
25
|
|
26
26
|
it "returns the correct type" do
|
27
27
|
@car = Car.create(:name => 'MyCar')
|
28
28
|
vehicle = Vehicle.order(:id).last
|
29
|
-
vehicle.type.
|
29
|
+
expect(vehicle.type).to eq 'Car'
|
30
30
|
|
31
31
|
@motorcycle = MotorCycle.create(:name => 'MyBike')
|
32
32
|
vehicle = Vehicle.order(:id).last
|
33
|
-
vehicle.type.
|
33
|
+
expect(vehicle.type).to eq 'MotorCycle'
|
34
34
|
|
35
35
|
@motor_vehicle = MotorVehicle.create(:name => 'MyTrike')
|
36
36
|
vehicle = Vehicle.order(:id).last
|
37
|
-
vehicle.type.
|
37
|
+
expect(vehicle.type).to eq 'MotorVehicle'
|
38
38
|
end
|
39
39
|
|
40
40
|
it "also destroys rows belonging to derived classes on destroy" do
|
@@ -51,24 +51,24 @@ describe Vehicle do
|
|
51
51
|
|
52
52
|
def test_destroy_variant(method)
|
53
53
|
car = Car.create(:name => 'MyCar')
|
54
|
-
Vehicle.count.
|
55
|
-
Car.cti_table_count.
|
56
|
-
MotorVehicle.cti_table_count.
|
54
|
+
expect(Vehicle.count).to eq 1
|
55
|
+
expect(Car.cti_table_count).to eq 1
|
56
|
+
expect(MotorVehicle.cti_table_count).to eq 1
|
57
57
|
vehicle = Vehicle.order(:id).last
|
58
58
|
vehicle.send(method)
|
59
|
-
Vehicle.count.
|
60
|
-
Car.cti_table_count.
|
61
|
-
MotorVehicle.cti_table_count.
|
59
|
+
expect(Vehicle.count).to eq 0
|
60
|
+
expect(Car.cti_table_count).to eq 0
|
61
|
+
expect(MotorVehicle.cti_table_count).to eq 0
|
62
62
|
# do the same for the space-branch (which has foreign key constraints)
|
63
63
|
shuttle = SpaceShuttle.create(:name => 'Discovery')
|
64
|
-
Vehicle.count.
|
65
|
-
SpaceShuttle.cti_table_count.
|
66
|
-
SpaceShip.cti_table_count.
|
64
|
+
expect(Vehicle.count).to eq 1
|
65
|
+
expect(SpaceShuttle.cti_table_count).to eq 1
|
66
|
+
expect(SpaceShip.cti_table_count).to eq 1
|
67
67
|
vehicle = Vehicle.order(:id).last
|
68
68
|
vehicle.send(method)
|
69
|
-
Vehicle.count.
|
70
|
-
SpaceShuttle.cti_table_count.
|
71
|
-
SpaceShip.cti_table_count.
|
69
|
+
expect(Vehicle.count).to eq 0
|
70
|
+
expect(SpaceShuttle.cti_table_count).to eq 0
|
71
|
+
expect(SpaceShip.cti_table_count).to eq 0
|
72
72
|
end
|
73
73
|
|
74
74
|
# simply to show that the gem doesn't interfere with foreign keys
|
@@ -76,15 +76,15 @@ describe Vehicle do
|
|
76
76
|
shuttle = SpaceShuttle.create(:name => 'Discovery')
|
77
77
|
expect {
|
78
78
|
Vehicle.delete_all
|
79
|
-
}.to raise_error
|
79
|
+
}.to raise_error(ActiveRecord::InvalidForeignKey)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "correctly reports ascendants" do
|
83
|
-
Vehicle.cti_ascendants.
|
83
|
+
expect(Vehicle.cti_ascendants).to eq []
|
84
84
|
end
|
85
85
|
|
86
86
|
it "correctly reports descendants" do
|
87
|
-
Vehicle.cti_all_descendants.
|
87
|
+
expect(Vehicle.cti_all_descendants).to eq %w( MotorVehicle Car MotorCycle SpaceShip SpaceShuttle )
|
88
88
|
end
|
89
89
|
|
90
90
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,6 @@ rails_major_version = 3
|
|
4
4
|
rails_major_version = ENV["RAILS_VERSION"][0] unless ENV["RAILS_VERSION"].nil?
|
5
5
|
require File.expand_path("../dummy-rails-#{rails_major_version}/config/environment", __FILE__)
|
6
6
|
require 'rspec/rails'
|
7
|
-
require 'rspec/autorun'
|
8
7
|
|
9
8
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
10
9
|
# in spec/support/ and its subdirectories.
|
@@ -37,4 +36,15 @@ RSpec.configure do |config|
|
|
37
36
|
# the seed, which is printed after each run.
|
38
37
|
# --seed 1234
|
39
38
|
config.order = "random"
|
39
|
+
|
40
|
+
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
41
|
+
# from the file location. You can explicitly opt-in to the feature using this
|
42
|
+
# config option.
|
43
|
+
# To explicitly tag specs without using automatic inference, set the `:type`
|
44
|
+
# metadata manually:
|
45
|
+
#
|
46
|
+
# describe ThingsController, :type => :controller do
|
47
|
+
# # Equivalent to being in spec/controllers
|
48
|
+
# end
|
49
|
+
config.infer_spec_type_from_file_location!
|
40
50
|
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbview_cti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michaël Van Damme
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.5'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: foreigner
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: This gem implements Class Table Inheritance (CTI) for Rails using database
|
@@ -60,8 +60,8 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
64
|
-
- .travis.yml
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
65
|
- CHANGELOG.md
|
66
66
|
- Gemfile
|
67
67
|
- MIT-LICENSE
|
@@ -196,6 +196,63 @@ files:
|
|
196
196
|
- spec/dummy-rails-4/public/422.html
|
197
197
|
- spec/dummy-rails-4/public/500.html
|
198
198
|
- spec/dummy-rails-4/public/favicon.ico
|
199
|
+
- spec/dummy-rails-5/Rakefile
|
200
|
+
- spec/dummy-rails-5/app/assets/config/manifest.js
|
201
|
+
- spec/dummy-rails-5/app/assets/images/.keep
|
202
|
+
- spec/dummy-rails-5/app/assets/javascripts/application.js
|
203
|
+
- spec/dummy-rails-5/app/assets/javascripts/cable.js
|
204
|
+
- spec/dummy-rails-5/app/assets/javascripts/channels/.keep
|
205
|
+
- spec/dummy-rails-5/app/assets/stylesheets/application.css
|
206
|
+
- spec/dummy-rails-5/app/channels/application_cable/channel.rb
|
207
|
+
- spec/dummy-rails-5/app/channels/application_cable/connection.rb
|
208
|
+
- spec/dummy-rails-5/app/controllers/application_controller.rb
|
209
|
+
- spec/dummy-rails-5/app/controllers/concerns/.keep
|
210
|
+
- spec/dummy-rails-5/app/helpers/application_helper.rb
|
211
|
+
- spec/dummy-rails-5/app/jobs/application_job.rb
|
212
|
+
- spec/dummy-rails-5/app/mailers/application_mailer.rb
|
213
|
+
- spec/dummy-rails-5/app/models.original/application_record.rb
|
214
|
+
- spec/dummy-rails-5/app/models.original/concerns/.keep
|
215
|
+
- spec/dummy-rails-5/app/views/layouts/application.html.erb
|
216
|
+
- spec/dummy-rails-5/app/views/layouts/mailer.html.erb
|
217
|
+
- spec/dummy-rails-5/app/views/layouts/mailer.text.erb
|
218
|
+
- spec/dummy-rails-5/bin/bundle
|
219
|
+
- spec/dummy-rails-5/bin/rails
|
220
|
+
- spec/dummy-rails-5/bin/rake
|
221
|
+
- spec/dummy-rails-5/bin/setup
|
222
|
+
- spec/dummy-rails-5/bin/update
|
223
|
+
- spec/dummy-rails-5/config.ru
|
224
|
+
- spec/dummy-rails-5/config/application.rb
|
225
|
+
- spec/dummy-rails-5/config/boot.rb
|
226
|
+
- spec/dummy-rails-5/config/cable.yml
|
227
|
+
- spec/dummy-rails-5/config/database.yml
|
228
|
+
- spec/dummy-rails-5/config/environment.rb
|
229
|
+
- spec/dummy-rails-5/config/environments/development.rb
|
230
|
+
- spec/dummy-rails-5/config/environments/production.rb
|
231
|
+
- spec/dummy-rails-5/config/environments/test.rb
|
232
|
+
- spec/dummy-rails-5/config/initializers/application_controller_renderer.rb
|
233
|
+
- spec/dummy-rails-5/config/initializers/assets.rb
|
234
|
+
- spec/dummy-rails-5/config/initializers/backtrace_silencers.rb
|
235
|
+
- spec/dummy-rails-5/config/initializers/cookies_serializer.rb
|
236
|
+
- spec/dummy-rails-5/config/initializers/dbview_cti.rb
|
237
|
+
- spec/dummy-rails-5/config/initializers/filter_parameter_logging.rb
|
238
|
+
- spec/dummy-rails-5/config/initializers/inflections.rb
|
239
|
+
- spec/dummy-rails-5/config/initializers/mime_types.rb
|
240
|
+
- spec/dummy-rails-5/config/initializers/new_framework_defaults.rb
|
241
|
+
- spec/dummy-rails-5/config/initializers/session_store.rb
|
242
|
+
- spec/dummy-rails-5/config/initializers/wrap_parameters.rb
|
243
|
+
- spec/dummy-rails-5/config/locales/en.yml
|
244
|
+
- spec/dummy-rails-5/config/puma.rb
|
245
|
+
- spec/dummy-rails-5/config/routes.rb
|
246
|
+
- spec/dummy-rails-5/config/secrets.yml
|
247
|
+
- spec/dummy-rails-5/config/spring.rb
|
248
|
+
- spec/dummy-rails-5/lib/assets/.keep
|
249
|
+
- spec/dummy-rails-5/log/.keep
|
250
|
+
- spec/dummy-rails-5/public/404.html
|
251
|
+
- spec/dummy-rails-5/public/422.html
|
252
|
+
- spec/dummy-rails-5/public/500.html
|
253
|
+
- spec/dummy-rails-5/public/apple-touch-icon-precomposed.png
|
254
|
+
- spec/dummy-rails-5/public/apple-touch-icon.png
|
255
|
+
- spec/dummy-rails-5/public/favicon.ico
|
199
256
|
- spec/models/car_spec.rb
|
200
257
|
- spec/models/motor_vehicle_spec.rb
|
201
258
|
- spec/models/space_shuttle_spec.rb
|
@@ -211,17 +268,17 @@ require_paths:
|
|
211
268
|
- lib
|
212
269
|
required_ruby_version: !ruby/object:Gem::Requirement
|
213
270
|
requirements:
|
214
|
-
- -
|
271
|
+
- - ">="
|
215
272
|
- !ruby/object:Gem::Version
|
216
273
|
version: '0'
|
217
274
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
275
|
requirements:
|
219
|
-
- -
|
276
|
+
- - ">="
|
220
277
|
- !ruby/object:Gem::Version
|
221
278
|
version: '0'
|
222
279
|
requirements: []
|
223
280
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.
|
281
|
+
rubygems_version: 2.4.8
|
225
282
|
signing_key:
|
226
283
|
specification_version: 4
|
227
284
|
summary: Class Table Inheritance (CTI) for Rails.
|