poly_belongs_to 0.2.9 → 0.3.0

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -3
  3. data/lib/poly_belongs_to/core.rb +15 -0
  4. data/lib/poly_belongs_to/pbt.rb +12 -8
  5. data/lib/poly_belongs_to/version.rb +1 -1
  6. data/test/core_test.rb +15 -0
  7. data/test/dummy/app/models/assembly.rb +3 -0
  8. data/test/dummy/app/models/big_company.rb +3 -0
  9. data/test/dummy/app/models/hmt_assembly.rb +4 -0
  10. data/test/dummy/app/models/hmt_part.rb +4 -0
  11. data/test/dummy/app/models/manifest.rb +4 -0
  12. data/test/dummy/app/models/part.rb +3 -0
  13. data/test/dummy/app/models/work_order.rb +1 -0
  14. data/test/dummy/db/development.sqlite3 +0 -0
  15. data/test/dummy/db/migrate/20161210074545_create_big_companies.rb +8 -0
  16. data/test/dummy/db/migrate/20161210074616_add_big_company_id_to_work_order.rb +6 -0
  17. data/test/dummy/db/migrate/20161210145334_create_assemblies.rb +8 -0
  18. data/test/dummy/db/migrate/20161210145355_create_parts.rb +8 -0
  19. data/test/dummy/db/migrate/20161210145757_create_assembly_part_join_table.rb +8 -0
  20. data/test/dummy/db/migrate/20161210150330_create_hmt_assemblies.rb +8 -0
  21. data/test/dummy/db/migrate/20161210150343_create_hmt_parts.rb +8 -0
  22. data/test/dummy/db/schema.rb +39 -3
  23. data/test/dummy/db/test.sqlite3 +0 -0
  24. data/test/dummy/log/test.log +23343 -0
  25. data/test/dummy/test/fixtures/assemblies.yml +12 -0
  26. data/test/dummy/test/fixtures/big_companies.yml +12 -0
  27. data/test/dummy/test/fixtures/hmt_assemblies.yml +12 -0
  28. data/test/dummy/test/fixtures/hmt_parts.yml +12 -0
  29. data/test/dummy/test/fixtures/parts.yml +12 -0
  30. data/test/dummy/test/models/assembly_test.rb +13 -0
  31. data/test/dummy/test/models/big_company_test.rb +13 -0
  32. data/test/dummy/test/models/hmt_assembly_test.rb +13 -0
  33. data/test/dummy/test/models/hmt_part_test.rb +13 -0
  34. data/test/dummy/test/models/part_test.rb +13 -0
  35. data/test/pbt_test.rb +17 -2
  36. metadata +51 -3
@@ -0,0 +1,12 @@
1
+ # Read about fixtures at
2
+ # http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
3
+
4
+ # This model initially had no columns defined. If you add columns to the
5
+ # model remove the '{}' from the fixture names and add the columns immediately
6
+ # below each fixture, per the syntax in the comments below
7
+ #
8
+ one: {}
9
+ # column: value
10
+ #
11
+ two: {}
12
+ # column: value
@@ -0,0 +1,12 @@
1
+ # Read about fixtures at
2
+ # http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
3
+
4
+ # This model initially had no columns defined. If you add columns to the
5
+ # model remove the '{}' from the fixture names and add the columns immediately
6
+ # below each fixture, per the syntax in the comments below
7
+ #
8
+ one: {}
9
+ # column: value
10
+ #
11
+ two: {}
12
+ # column: value
@@ -0,0 +1,12 @@
1
+ # Read about fixtures at
2
+ # http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
3
+
4
+ # This model initially had no columns defined. If you add columns to the
5
+ # model remove the '{}' from the fixture names and add the columns immediately
6
+ # below each fixture, per the syntax in the comments below
7
+ #
8
+ one: {}
9
+ # column: value
10
+ #
11
+ two: {}
12
+ # column: value
@@ -0,0 +1,12 @@
1
+ # Read about fixtures at
2
+ # http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
3
+
4
+ # This model initially had no columns defined. If you add columns to the
5
+ # model remove the '{}' from the fixture names and add the columns immediately
6
+ # below each fixture, per the syntax in the comments below
7
+ #
8
+ one: {}
9
+ # column: value
10
+ #
11
+ two: {}
12
+ # column: value
@@ -0,0 +1,12 @@
1
+ # Read about fixtures at
2
+ # http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
3
+
4
+ # This model initially had no columns defined. If you add columns to the
5
+ # model remove the '{}' from the fixture names and add the columns immediately
6
+ # below each fixture, per the syntax in the comments below
7
+ #
8
+ one: {}
9
+ # column: value
10
+ #
11
+ two: {}
12
+ # column: value
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class AssemblyTest < ActiveSupport::TestCase
4
+
5
+ def assembly
6
+ @assembly ||= Assembly.new
7
+ end
8
+
9
+ def test_valid
10
+ assert assembly.valid?
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class BigCompanyTest < ActiveSupport::TestCase
4
+
5
+ def big_company
6
+ @big_company ||= BigCompany.new
7
+ end
8
+
9
+ def test_valid
10
+ assert big_company.valid?
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class HmtAssemblyTest < ActiveSupport::TestCase
4
+
5
+ def hmt_assembly
6
+ @hmt_assembly ||= HmtAssembly.new
7
+ end
8
+
9
+ def test_valid
10
+ assert hmt_assembly.valid?
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class HmtPartTest < ActiveSupport::TestCase
4
+
5
+ def hmt_part
6
+ @hmt_part ||= HmtPart.new
7
+ end
8
+
9
+ def test_valid
10
+ assert hmt_part.valid?
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class PartTest < ActiveSupport::TestCase
4
+
5
+ def part
6
+ @part ||= Part.new
7
+ end
8
+
9
+ def test_valid
10
+ assert part.valid?
11
+ end
12
+
13
+ end
@@ -19,7 +19,7 @@ class PbtTest < ActiveSupport::TestCase
19
19
  PolyBelongsTo::Pbt::BuildCmd[profile, nil].must_be_nil
20
20
  end
21
21
 
22
- it "Reflects retruns has_one and has_many relationships" do
22
+ it "Reflects returns has_one and has_many relationships" do
23
23
  profile = profiles(:bob_prof)
24
24
  PolyBelongsTo::Pbt::Reflects[profile].sort.must_equal [:phones, :addresses, :photo].sort
25
25
  PolyBelongsTo::Pbt::Reflects[nil ].must_equal Array[]
@@ -31,6 +31,12 @@ class PbtTest < ActiveSupport::TestCase
31
31
  PolyBelongsTo::Pbt::ReflectsAsClasses[nil ].must_equal Array[]
32
32
  end
33
33
 
34
+ it "Reflects & ReflectsAsClasses accept boolean for HABTM" do
35
+ obj = Part.new
36
+ PolyBelongsTo::Pbt::Reflects[obj, :habtm].must_equal [:assemblies]
37
+ PolyBelongsTo::Pbt::ReflectsAsClasses[obj, :habtm].must_equal [Assembly]
38
+ end
39
+
34
40
  it "IsReflected gives boolean of child" do
35
41
  profile = profiles(:bob_prof)
36
42
  PolyBelongsTo::Pbt::IsReflected[profile, Phone].must_equal true
@@ -118,6 +124,15 @@ class PbtTest < ActiveSupport::TestCase
118
124
  fc.must_be_kind_of(PolyBelongsTo::FakedCollection)
119
125
  fc.must_be :empty?
120
126
  end
121
- end
122
127
 
128
+ it "sanity checks Reflects & ReflectsAsClasses possible snake_case CamelCase future changes" do
129
+ [
130
+ [WorkOrder.new, :events, Event],
131
+ [BigCompany.new, :work_orders, WorkOrder]
132
+ ].each do |obj, a, b|
133
+ PolyBelongsTo::Pbt::Reflects[obj].must_equal [a]
134
+ PolyBelongsTo::Pbt::ReflectsAsClasses[obj].map(&:hash).must_equal [b].map(&:hash)
135
+ end
136
+ end
137
+ end
123
138
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poly_belongs_to
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-09 00:00:00.000000000 Z
11
+ date: 2016-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -110,7 +110,9 @@ files:
110
110
  - test/dummy/app/models/address.rb
111
111
  - test/dummy/app/models/address_book.rb
112
112
  - test/dummy/app/models/alpha.rb
113
+ - test/dummy/app/models/assembly.rb
113
114
  - test/dummy/app/models/beta.rb
115
+ - test/dummy/app/models/big_company.rb
114
116
  - test/dummy/app/models/capa.rb
115
117
  - test/dummy/app/models/car.rb
116
118
  - test/dummy/app/models/coffee.rb
@@ -118,6 +120,10 @@ files:
118
120
  - test/dummy/app/models/delta.rb
119
121
  - test/dummy/app/models/event.rb
120
122
  - test/dummy/app/models/geo_location.rb
123
+ - test/dummy/app/models/hmt_assembly.rb
124
+ - test/dummy/app/models/hmt_part.rb
125
+ - test/dummy/app/models/manifest.rb
126
+ - test/dummy/app/models/part.rb
121
127
  - test/dummy/app/models/phone.rb
122
128
  - test/dummy/app/models/photo.rb
123
129
  - test/dummy/app/models/profile.rb
@@ -151,6 +157,7 @@ files:
151
157
  - test/dummy/config/locales/en.yml
152
158
  - test/dummy/config/routes.rb
153
159
  - test/dummy/config/secrets.yml
160
+ - test/dummy/db/development.sqlite3
154
161
  - test/dummy/db/migrate/20150211224139_create_users.rb
155
162
  - test/dummy/db/migrate/20150211224157_create_tags.rb
156
163
  - test/dummy/db/migrate/20150211224225_create_phones.rb
@@ -172,17 +179,34 @@ files:
172
179
  - test/dummy/db/migrate/20160120231645_create_address_books.rb
173
180
  - test/dummy/db/migrate/20161209115003_create_events.rb
174
181
  - test/dummy/db/migrate/20161209115212_create_work_orders.rb
182
+ - test/dummy/db/migrate/20161210074545_create_big_companies.rb
183
+ - test/dummy/db/migrate/20161210074616_add_big_company_id_to_work_order.rb
184
+ - test/dummy/db/migrate/20161210145334_create_assemblies.rb
185
+ - test/dummy/db/migrate/20161210145355_create_parts.rb
186
+ - test/dummy/db/migrate/20161210145757_create_assembly_part_join_table.rb
187
+ - test/dummy/db/migrate/20161210150330_create_hmt_assemblies.rb
188
+ - test/dummy/db/migrate/20161210150343_create_hmt_parts.rb
175
189
  - test/dummy/db/schema.rb
176
190
  - test/dummy/db/test.sqlite3
177
191
  - test/dummy/log/development.log
178
192
  - test/dummy/log/test.log
179
193
  - test/dummy/public/favicon.ico
194
+ - test/dummy/test/fixtures/assemblies.yml
195
+ - test/dummy/test/fixtures/big_companies.yml
180
196
  - test/dummy/test/fixtures/coffees.yml
181
197
  - test/dummy/test/fixtures/events.yml
198
+ - test/dummy/test/fixtures/hmt_assemblies.yml
199
+ - test/dummy/test/fixtures/hmt_parts.yml
200
+ - test/dummy/test/fixtures/parts.yml
182
201
  - test/dummy/test/fixtures/work_orders.yml
183
202
  - test/dummy/test/models/address_book_test.rb
203
+ - test/dummy/test/models/assembly_test.rb
204
+ - test/dummy/test/models/big_company_test.rb
184
205
  - test/dummy/test/models/coffee_test.rb
185
206
  - test/dummy/test/models/event_test.rb
207
+ - test/dummy/test/models/hmt_assembly_test.rb
208
+ - test/dummy/test/models/hmt_part_test.rb
209
+ - test/dummy/test/models/part_test.rb
186
210
  - test/dummy/test/models/work_order_test.rb
187
211
  - test/dup_test.rb
188
212
  - test/faked_collection_test.rb
@@ -215,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
239
  requirements:
216
240
  - - ">="
217
241
  - !ruby/object:Gem::Version
218
- version: '0'
242
+ version: 1.9.3
219
243
  required_rubygems_version: !ruby/object:Gem::Requirement
220
244
  requirements:
221
245
  - - ">="
@@ -247,13 +271,17 @@ test_files:
247
271
  - test/faked_collection_test.rb
248
272
  - test/core_test.rb
249
273
  - test/dummy/db/test.sqlite3
274
+ - test/dummy/db/development.sqlite3
250
275
  - test/dummy/db/schema.rb
276
+ - test/dummy/db/migrate/20161210150343_create_hmt_parts.rb
251
277
  - test/dummy/db/migrate/20150220230146_create_squishies.rb
252
278
  - test/dummy/db/migrate/20161209115003_create_events.rb
253
279
  - test/dummy/db/migrate/20161209115212_create_work_orders.rb
254
280
  - test/dummy/db/migrate/20150322233755_create_delta.rb
255
281
  - test/dummy/db/migrate/20150322233743_create_capas.rb
256
282
  - test/dummy/db/migrate/20150216092449_create_contacts.rb
283
+ - test/dummy/db/migrate/20161210145334_create_assemblies.rb
284
+ - test/dummy/db/migrate/20161210145757_create_assembly_part_join_table.rb
257
285
  - test/dummy/db/migrate/20150301100658_create_tires.rb
258
286
  - test/dummy/db/migrate/20150322233733_create_beta.rb
259
287
  - test/dummy/db/migrate/20150322233720_create_alphas.rb
@@ -261,6 +289,7 @@ test_files:
261
289
  - test/dummy/db/migrate/20150211224225_create_phones.rb
262
290
  - test/dummy/db/migrate/20160120224015_add_contactable_to_contacts.rb
263
291
  - test/dummy/db/migrate/20150220213422_create_geo_locations.rb
292
+ - test/dummy/db/migrate/20161210145355_create_parts.rb
264
293
  - test/dummy/db/migrate/20160120231645_create_address_books.rb
265
294
  - test/dummy/db/migrate/20150216092519_create_ssns.rb
266
295
  - test/dummy/db/migrate/20150211224157_create_tags.rb
@@ -269,6 +298,9 @@ test_files:
269
298
  - test/dummy/db/migrate/20150511161648_create_coffees.rb
270
299
  - test/dummy/db/migrate/20150301100722_create_cars.rb
271
300
  - test/dummy/db/migrate/20150216092411_create_photos.rb
301
+ - test/dummy/db/migrate/20161210074616_add_big_company_id_to_work_order.rb
302
+ - test/dummy/db/migrate/20161210074545_create_big_companies.rb
303
+ - test/dummy/db/migrate/20161210150330_create_hmt_assemblies.rb
272
304
  - test/dummy/config/initializers/mime_types.rb
273
305
  - test/dummy/config/initializers/session_store.rb
274
306
  - test/dummy/config/initializers/assets.rb
@@ -289,6 +321,7 @@ test_files:
289
321
  - test/dummy/config/database.yml
290
322
  - test/dummy/app/controllers/application_controller.rb
291
323
  - test/dummy/app/helpers/application_helper.rb
324
+ - test/dummy/app/models/manifest.rb
292
325
  - test/dummy/app/models/coffee.rb
293
326
  - test/dummy/app/models/ssn.rb
294
327
  - test/dummy/app/models/event.rb
@@ -299,14 +332,19 @@ test_files:
299
332
  - test/dummy/app/models/alpha.rb
300
333
  - test/dummy/app/models/car.rb
301
334
  - test/dummy/app/models/tire.rb
335
+ - test/dummy/app/models/part.rb
302
336
  - test/dummy/app/models/user.rb
337
+ - test/dummy/app/models/big_company.rb
303
338
  - test/dummy/app/models/geo_location.rb
304
339
  - test/dummy/app/models/address.rb
340
+ - test/dummy/app/models/hmt_assembly.rb
305
341
  - test/dummy/app/models/delta.rb
306
342
  - test/dummy/app/models/phone.rb
307
343
  - test/dummy/app/models/profile.rb
344
+ - test/dummy/app/models/hmt_part.rb
308
345
  - test/dummy/app/models/squishy.rb
309
346
  - test/dummy/app/models/tag.rb
347
+ - test/dummy/app/models/assembly.rb
310
348
  - test/dummy/app/models/photo.rb
311
349
  - test/dummy/app/models/beta.rb
312
350
  - test/dummy/app/views/layouts/application.html.erb
@@ -319,12 +357,22 @@ test_files:
319
357
  - test/dummy/bin/rails
320
358
  - test/dummy/bin/bundle
321
359
  - test/dummy/bin/setup
360
+ - test/dummy/test/fixtures/big_companies.yml
361
+ - test/dummy/test/fixtures/hmt_assemblies.yml
362
+ - test/dummy/test/fixtures/parts.yml
322
363
  - test/dummy/test/fixtures/work_orders.yml
364
+ - test/dummy/test/fixtures/hmt_parts.yml
323
365
  - test/dummy/test/fixtures/events.yml
324
366
  - test/dummy/test/fixtures/coffees.yml
367
+ - test/dummy/test/fixtures/assemblies.yml
368
+ - test/dummy/test/models/assembly_test.rb
369
+ - test/dummy/test/models/hmt_part_test.rb
325
370
  - test/dummy/test/models/coffee_test.rb
326
371
  - test/dummy/test/models/address_book_test.rb
327
372
  - test/dummy/test/models/work_order_test.rb
373
+ - test/dummy/test/models/part_test.rb
328
374
  - test/dummy/test/models/event_test.rb
375
+ - test/dummy/test/models/big_company_test.rb
376
+ - test/dummy/test/models/hmt_assembly_test.rb
329
377
  - test/pbt_test.rb
330
378
  - test/major_version_changes_test.rb