has_dynamic_columns 0.2.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -3
- data/README.md +25 -1
- data/has_dynamic_columns.gemspec +3 -1
- data/lib/generators/has_dynamic_columns/active_record_generator.rb +1 -1
- data/lib/generators/has_dynamic_columns/templates/migration.rb +4 -4
- data/lib/generators/has_dynamic_columns/templates/migration_0.3.0.rb +89 -0
- data/lib/generators/has_dynamic_columns/upgrade_0_3_0_active_record_generator.rb +22 -0
- data/lib/has_dynamic_columns/active_record/query_methods.rb +1 -167
- data/lib/has_dynamic_columns/active_record/relation.rb +1 -21
- data/lib/has_dynamic_columns/active_record/v3/query_methods.rb +281 -0
- data/lib/has_dynamic_columns/active_record/v3/relation.rb +34 -0
- data/lib/has_dynamic_columns/active_record/v4/query_methods.rb +257 -0
- data/lib/has_dynamic_columns/active_record/v4/relation.rb +34 -0
- data/lib/has_dynamic_columns/dynamic_column_boolean_datum.rb +5 -0
- data/lib/has_dynamic_columns/dynamic_column_date_datum.rb +5 -0
- data/lib/has_dynamic_columns/dynamic_column_datetime_datum.rb +5 -0
- data/lib/has_dynamic_columns/dynamic_column_datum.rb +8 -54
- data/lib/has_dynamic_columns/dynamic_column_enum_datum.rb +5 -0
- data/lib/has_dynamic_columns/dynamic_column_float_datum.rb +5 -0
- data/lib/has_dynamic_columns/dynamic_column_integer_datum.rb +5 -0
- data/lib/has_dynamic_columns/dynamic_column_string_datum.rb +5 -0
- data/lib/has_dynamic_columns/dynamic_column_text_datum.rb +5 -0
- data/lib/has_dynamic_columns/dynamic_column_time_datum.rb +5 -0
- data/lib/has_dynamic_columns/dynamic_column_timestamp_datum.rb +5 -0
- data/lib/has_dynamic_columns/model/class_methods.rb +22 -2
- data/lib/has_dynamic_columns/version.rb +1 -1
- data/lib/has_dynamic_columns.rb +11 -0
- data/rspec_rvm +39 -0
- data/spec/factories/account.rb +24 -0
- data/spec/factories/customer.rb +35 -0
- data/spec/has_dynamic_columns/active_record/query_methods_spec.rb +252 -0
- data/spec/has_dynamic_columns/dynamic_columns_integer_datum_spec.rb +124 -0
- data/spec/has_dynamic_columns/dynamic_columns_string_datum_spec.rb +7 -0
- data/spec/has_dynamic_columns_spec.rb +93 -63
- data/spec/spec_helper.rb +13 -8
- metadata +67 -6
@@ -14,17 +14,17 @@ describe HasDynamicColumns do
|
|
14
14
|
account.activerecord_dynamic_columns.build(:dynamic_type => "CustomerAddress", :key => "address_1", :data_type => "string")
|
15
15
|
account.activerecord_dynamic_columns.build(:dynamic_type => "CustomerAddress", :key => "address_2", :data_type => "string")
|
16
16
|
|
17
|
-
field = account.activerecord_dynamic_columns.build(:dynamic_type => "CustomerAddress", :key => "country", :data_type => "
|
17
|
+
field = account.activerecord_dynamic_columns.build(:dynamic_type => "CustomerAddress", :key => "country", :data_type => "enum")
|
18
18
|
field.dynamic_column_options.build(:key => "canada")
|
19
19
|
field.dynamic_column_options.build(:key => "usa")
|
20
20
|
field.dynamic_column_options.build(:key => "mexico")
|
21
21
|
|
22
|
-
field = account.activerecord_dynamic_columns.build(:dynamic_type => "CustomerAddress", :key => "city", :data_type => "
|
22
|
+
field = account.activerecord_dynamic_columns.build(:dynamic_type => "CustomerAddress", :key => "city", :data_type => "enum")
|
23
23
|
field.dynamic_column_options.build(:key => "toronto")
|
24
24
|
field.dynamic_column_options.build(:key => "alberta")
|
25
25
|
field.dynamic_column_options.build(:key => "vancouver")
|
26
26
|
|
27
|
-
field = account.activerecord_dynamic_columns.build(:dynamic_type => "CustomerAddress", :key => "province", :data_type => "
|
27
|
+
field = account.activerecord_dynamic_columns.build(:dynamic_type => "CustomerAddress", :key => "province", :data_type => "enum")
|
28
28
|
field.dynamic_column_options.build(:key => "ontario")
|
29
29
|
field.dynamic_column_options.build(:key => "quebec")
|
30
30
|
|
@@ -53,9 +53,12 @@ describe HasDynamicColumns do
|
|
53
53
|
account
|
54
54
|
end
|
55
55
|
|
56
|
-
describe HasDynamicColumns::ActiveRecord
|
56
|
+
describe HasDynamicColumns::ActiveRecord do
|
57
57
|
it 'should find everyone in the current account scope' do
|
58
|
-
customer = Customer.create(
|
58
|
+
customer = Customer.create(
|
59
|
+
:account => account,
|
60
|
+
:name => "Butch Marshall"
|
61
|
+
)
|
59
62
|
customer.fields = {
|
60
63
|
"first_name" => "Butch",
|
61
64
|
"last_name" => "Marshall",
|
@@ -64,7 +67,10 @@ describe HasDynamicColumns do
|
|
64
67
|
}
|
65
68
|
customer.save
|
66
69
|
|
67
|
-
customer = Customer.create(
|
70
|
+
customer = Customer.create(
|
71
|
+
:account => account,
|
72
|
+
:name => "John Paterson"
|
73
|
+
)
|
68
74
|
customer.fields = {
|
69
75
|
"first_name" => "John",
|
70
76
|
"last_name" => "Paterson",
|
@@ -73,7 +79,10 @@ describe HasDynamicColumns do
|
|
73
79
|
}
|
74
80
|
customer.save
|
75
81
|
|
76
|
-
customer = Customer.create(
|
82
|
+
customer = Customer.create(
|
83
|
+
:account => account,
|
84
|
+
:name => "Steve Paterson"
|
85
|
+
)
|
77
86
|
customer.fields = {
|
78
87
|
"first_name" => "Steve",
|
79
88
|
"last_name" => "Paterson",
|
@@ -82,7 +91,10 @@ describe HasDynamicColumns do
|
|
82
91
|
}
|
83
92
|
customer.save
|
84
93
|
|
85
|
-
customer = Customer.create(
|
94
|
+
customer = Customer.create(
|
95
|
+
:account => account,
|
96
|
+
:name => "Carl Paterson"
|
97
|
+
)
|
86
98
|
customer.fields = {
|
87
99
|
"first_name" => "Carl",
|
88
100
|
"last_name" => "Paterson",
|
@@ -106,10 +118,58 @@ describe HasDynamicColumns do
|
|
106
118
|
.where.has_dynamic_columns(table[:first_name].eq("John")).with_scope(account)
|
107
119
|
.where.has_dynamic_columns(table[:last_name].eq("Paterson")).with_scope(account)
|
108
120
|
expect(result.all.length).to eq(1)
|
121
|
+
|
122
|
+
# Find
|
123
|
+
result = Customer
|
124
|
+
.where
|
125
|
+
.has_dynamic_columns(
|
126
|
+
Customer.arel_table[:trusted].eq(true)
|
127
|
+
).with_scope(account)
|
128
|
+
.where
|
129
|
+
.has_dynamic_columns(
|
130
|
+
Customer.arel_table[:first_name].eq("Steve").or(
|
131
|
+
Customer.arel_table[:first_name].eq("John")
|
132
|
+
)
|
133
|
+
).without_scope
|
134
|
+
expect(result.all.length).to eq(2)
|
135
|
+
|
136
|
+
# Find
|
137
|
+
result = Customer
|
138
|
+
.where
|
139
|
+
.has_dynamic_columns(
|
140
|
+
Customer.arel_table[:trusted].eq(false)
|
141
|
+
).with_scope(account)
|
142
|
+
.where
|
143
|
+
.has_dynamic_columns(
|
144
|
+
Customer.arel_table[:first_name].eq("Steve").or(
|
145
|
+
Customer.arel_table[:first_name].eq("John")
|
146
|
+
)
|
147
|
+
).without_scope
|
148
|
+
expect(result.all.length).to eq(0)
|
149
|
+
|
150
|
+
result = Customer
|
151
|
+
.where.has_dynamic_columns(Customer.arel_table[:trusted].eq(true)).with_scope(account)
|
152
|
+
.where.has_dynamic_columns(Customer.arel_table[:first_name].eq("Steve")).without_scope
|
153
|
+
expect(result.all.length).to eq(1)
|
154
|
+
|
155
|
+
# Find
|
156
|
+
result = Customer
|
157
|
+
.where
|
158
|
+
.has_dynamic_columns(
|
159
|
+
Customer.arel_table[:first_name].eq("Steve").or(
|
160
|
+
Customer.arel_table[:first_name].eq("John")
|
161
|
+
)
|
162
|
+
)
|
163
|
+
.with_scope(account)
|
164
|
+
|
165
|
+
expect(result.all.length).to eq(2)
|
109
166
|
end
|
110
167
|
|
111
168
|
it 'should find the single person in this scope' do
|
112
|
-
customer = Customer.create(
|
169
|
+
customer = Customer.create(
|
170
|
+
:account => account,
|
171
|
+
:name => "Merridyth Marshall"
|
172
|
+
)
|
113
173
|
customer.fields = {
|
114
174
|
"first_name" => "Merridyth",
|
115
175
|
"last_name" => "Marshall",
|
@@ -128,7 +188,10 @@ describe HasDynamicColumns do
|
|
128
188
|
end
|
129
189
|
|
130
190
|
it 'should find anyone with first names Steve or John in account 1\'s scope' do
|
131
|
-
customer = Customer.create(
|
191
|
+
customer = Customer.create(
|
192
|
+
:account => account,
|
193
|
+
:name => "Steve Jobs"
|
194
|
+
)
|
132
195
|
customer.fields = {
|
133
196
|
"first_name" => "Steve",
|
134
197
|
"last_name" => "Jobs",
|
@@ -136,9 +199,6 @@ describe HasDynamicColumns do
|
|
136
199
|
"trusted" => false,
|
137
200
|
}
|
138
201
|
customer.save
|
139
|
-
|
140
|
-
result = Customer.where.has_dynamic_columns(Customer.arel_table[:first_name].eq("Steve").or(Customer.arel_table[:first_name].eq("John"))).with_scope(Account.find(1))
|
141
|
-
expect(result.all.length).to eq(2)
|
142
202
|
end
|
143
203
|
|
144
204
|
it 'should find anyone with first names Steve or John in any scope' do
|
@@ -146,20 +206,6 @@ describe HasDynamicColumns do
|
|
146
206
|
expect(result.all.length).to eq(3)
|
147
207
|
end
|
148
208
|
|
149
|
-
it 'should find anyone with first names Steve or John and is trusted in any scope' do
|
150
|
-
result = Customer
|
151
|
-
.where.has_dynamic_columns(Customer.arel_table[:trusted].eq(true)).without_scope
|
152
|
-
.where.has_dynamic_columns(Customer.arel_table[:first_name].eq("Steve").or(Customer.arel_table[:first_name].eq("John"))).without_scope
|
153
|
-
expect(result.all.length).to eq(2)
|
154
|
-
end
|
155
|
-
|
156
|
-
it 'should find anyone with first names Steve and is not trusted in any scope' do
|
157
|
-
result = Customer
|
158
|
-
.where.has_dynamic_columns(Customer.arel_table[:trusted].eq(false)).without_scope
|
159
|
-
.where.has_dynamic_columns(Customer.arel_table[:first_name].eq("Steve")).without_scope
|
160
|
-
expect(result.all.length).to eq(1)
|
161
|
-
end
|
162
|
-
|
163
209
|
it 'should find all the Steves who are trusted in account 3\'s scope' do
|
164
210
|
result = Customer
|
165
211
|
.where.has_dynamic_columns(Customer.arel_table[:trusted].eq(true)).with_scope(Account.find(3))
|
@@ -167,13 +213,6 @@ describe HasDynamicColumns do
|
|
167
213
|
expect(result.all.length).to eq(0)
|
168
214
|
end
|
169
215
|
|
170
|
-
it 'should find all the Steves who are trusted in account 1\'s scope' do
|
171
|
-
result = Customer
|
172
|
-
.where.has_dynamic_columns(Customer.arel_table[:trusted].eq(true)).with_scope(Account.find(1))
|
173
|
-
.where.has_dynamic_columns(Customer.arel_table[:first_name].eq("Steve")).without_scope
|
174
|
-
expect(result.all.length).to eq(1)
|
175
|
-
end
|
176
|
-
|
177
216
|
it 'should find across column types if no scope specified' do
|
178
217
|
customer = Customer.create(:account => account2)
|
179
218
|
customer.fields = {
|
@@ -192,16 +231,6 @@ describe HasDynamicColumns do
|
|
192
231
|
).without_scope
|
193
232
|
expect(result.all.length).to eq(2)
|
194
233
|
end
|
195
|
-
|
196
|
-
it 'should restrict if scope specified' do
|
197
|
-
result = Customer
|
198
|
-
.where.has_dynamic_columns(
|
199
|
-
Customer.arel_table[:first_name].eq("John").or(
|
200
|
-
Customer.arel_table[:company].eq("Apple Computers")
|
201
|
-
)
|
202
|
-
).with_scope(Account.find(4))
|
203
|
-
expect(result.all.length).to eq(1)
|
204
|
-
end
|
205
234
|
end
|
206
235
|
|
207
236
|
describe Product do
|
@@ -233,6 +262,7 @@ describe HasDynamicColumns do
|
|
233
262
|
context 'when it has a defined has_many relationship' do
|
234
263
|
|
235
264
|
context 'when it has_many categories' do
|
265
|
+
|
236
266
|
it 'should work with dynamic_where' do
|
237
267
|
product1 = Product.new(:name => "Product #1", :account => account)
|
238
268
|
product2 = Product.new(:name => "Product #2", :account => account)
|
@@ -285,13 +315,13 @@ describe HasDynamicColumns do
|
|
285
315
|
end
|
286
316
|
|
287
317
|
it 'should return empty category_fields when no categories associated' do
|
288
|
-
json = product.as_json
|
318
|
+
json = product.as_json(:root => nil)
|
289
319
|
expect(json["category_fields"]).to eq({})
|
290
320
|
end
|
291
321
|
|
292
322
|
it 'should return empty category_fields when no category has no dynamic_columns' do
|
293
323
|
product.categories << @category0
|
294
|
-
json = product.as_json
|
324
|
+
json = product.as_json(:root => nil)
|
295
325
|
expect(json["category_fields"]).to eq({})
|
296
326
|
end
|
297
327
|
|
@@ -302,7 +332,7 @@ describe HasDynamicColumns do
|
|
302
332
|
"vin_number" => "123"
|
303
333
|
}
|
304
334
|
|
305
|
-
json = product.as_json
|
335
|
+
json = product.as_json(:root => nil)
|
306
336
|
expect(json["category_fields"]).to eq({"vin_number"=>"123"})
|
307
337
|
expect(product.new_record?).to eq(true)
|
308
338
|
end
|
@@ -315,13 +345,13 @@ describe HasDynamicColumns do
|
|
315
345
|
}
|
316
346
|
product.save
|
317
347
|
|
318
|
-
json = product.as_json
|
348
|
+
json = product.as_json(:root => nil)
|
319
349
|
expect(json["category_fields"]).to eq({"vin_number"=>"345"})
|
320
350
|
expect(product.new_record?).to eq(false)
|
321
351
|
|
322
352
|
product_id = product.id
|
323
353
|
product = Product.find(product_id)
|
324
|
-
json = product.as_json
|
354
|
+
json = product.as_json(:root => nil)
|
325
355
|
expect(json["category_fields"]).to eq({"vin_number"=>"345"})
|
326
356
|
end
|
327
357
|
end
|
@@ -339,35 +369,35 @@ describe HasDynamicColumns do
|
|
339
369
|
"vin_number" => "first:this is the vin number",
|
340
370
|
"serial_number" => "first:serial number!"
|
341
371
|
}
|
342
|
-
json = product.as_json
|
372
|
+
json = product.as_json(:root => nil)
|
343
373
|
expect(json["product_fields"]).to eq({"rarity"=>"very rare"})
|
344
374
|
expect(json["category_fields"]).to eq({"vin_number"=>"first:this is the vin number", "serial_number"=>"first:serial number!"})
|
345
375
|
|
346
376
|
product.save
|
347
|
-
json = product.as_json
|
377
|
+
json = product.as_json(:root => nil)
|
348
378
|
expect(json["product_fields"]).to eq({"rarity"=>"very rare"})
|
349
379
|
expect(json["category_fields"]).to eq({"vin_number"=>"first:this is the vin number", "serial_number"=>"first:serial number!"})
|
350
380
|
|
351
381
|
product_id = product.id
|
352
382
|
product = Product.find(product_id)
|
353
|
-
json = product.as_json
|
383
|
+
json = product.as_json(:root => nil)
|
354
384
|
expect(json["product_fields"]).to eq({"rarity"=>"very rare"})
|
355
385
|
expect(json["category_fields"]).to eq({"vin_number"=>"first:this is the vin number", "serial_number"=>"first:serial number!"})
|
356
386
|
|
357
387
|
product.category_fields = {
|
358
388
|
"serial_number" => "second:serial number!"
|
359
389
|
}
|
360
|
-
json = product.as_json
|
390
|
+
json = product.as_json(:root => nil)
|
361
391
|
expect(json["product_fields"]).to eq({"rarity"=>"very rare"})
|
362
392
|
expect(json["category_fields"]).to eq({"vin_number"=>"first:this is the vin number", "serial_number"=>"second:serial number!"})
|
363
393
|
|
364
394
|
product.save
|
365
|
-
json = product.as_json
|
395
|
+
json = product.as_json(:root => nil)
|
366
396
|
expect(json["product_fields"]).to eq({"rarity"=>"very rare"})
|
367
397
|
expect(json["category_fields"]).to eq({"vin_number"=>"first:this is the vin number", "serial_number"=>"second:serial number!"})
|
368
398
|
|
369
399
|
product = Product.find(product_id)
|
370
|
-
json = product.as_json
|
400
|
+
json = product.as_json(:root => nil)
|
371
401
|
expect(json["product_fields"]).to eq({"rarity"=>"very rare"})
|
372
402
|
expect(json["category_fields"]).to eq({"vin_number"=>"first:this is the vin number", "serial_number"=>"second:serial number!"})
|
373
403
|
|
@@ -382,13 +412,13 @@ describe HasDynamicColumns do
|
|
382
412
|
"funkier_data" => "this is funkier data",
|
383
413
|
"ok_data" => "this is ok data"
|
384
414
|
}
|
385
|
-
json = product.as_json
|
415
|
+
json = product.as_json(:root => nil)
|
386
416
|
expect(json["product_fields"]).to eq({"rarity"=>"very rare"})
|
387
417
|
expect(json["category_fields"]).to eq({"vin_number"=>"first:this is the vin number", "serial_number"=>"second:serial number!", "funky_data"=>nil, "funkier_data"=>"this is funkier data", "funkiest_data"=>nil, "ok_data"=>"this is ok data"})
|
388
418
|
|
389
419
|
product.save
|
390
420
|
product = Product.find(product_id)
|
391
|
-
json = product.as_json
|
421
|
+
json = product.as_json(:root => nil)
|
392
422
|
expect(json["product_fields"]).to eq({"rarity"=>"very rare"})
|
393
423
|
expect(json["category_fields"]).to eq({"vin_number"=>"first:this is the vin number", "serial_number"=>"second:serial number!", "funky_data"=>nil, "funkier_data"=>"this is funkier data", "funkiest_data"=>nil, "ok_data"=>"this is ok data"})
|
394
424
|
end
|
@@ -454,20 +484,20 @@ describe HasDynamicColumns do
|
|
454
484
|
c = customer
|
455
485
|
|
456
486
|
c.fields = { "trusted" => true }
|
457
|
-
expect(c.as_json["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>true})
|
487
|
+
expect(c.as_json(:root => nil)["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>true})
|
458
488
|
c.save
|
459
|
-
expect(c.as_json["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>true})
|
489
|
+
expect(c.as_json(:root => nil)["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>true})
|
460
490
|
|
461
491
|
c = Customer.find(c.id)
|
462
|
-
expect(c.as_json["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>true})
|
492
|
+
expect(c.as_json(:root => nil)["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>true})
|
463
493
|
|
464
494
|
c.fields = { "trusted" => false }
|
465
|
-
expect(c.as_json["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>false})
|
495
|
+
expect(c.as_json(:root => nil)["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>false})
|
466
496
|
c.save
|
467
|
-
expect(c.as_json["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>false})
|
497
|
+
expect(c.as_json(:root => nil)["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>false})
|
468
498
|
|
469
499
|
c = Customer.find(c.id)
|
470
|
-
expect(c.as_json["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>false})
|
500
|
+
expect(c.as_json(:root => nil)["fields"]).to eq({"first_name"=>"Butch", "last_name"=>"Marshall", "email"=>"butch.a.marshall@gmail.com", "trusted"=>false})
|
471
501
|
end
|
472
502
|
end
|
473
503
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'logger'
|
2
2
|
require 'rspec'
|
3
|
+
require 'factory_girl'
|
3
4
|
|
4
5
|
require 'has_dynamic_columns'
|
5
6
|
|
@@ -27,38 +28,40 @@ ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':me
|
|
27
28
|
ActiveRecord::Migration.verbose = false
|
28
29
|
|
29
30
|
require "generators/has_dynamic_columns/templates/migration"
|
31
|
+
require "generators/has_dynamic_columns/templates/migration_0.3.0"
|
30
32
|
ActiveRecord::Schema.define do
|
31
33
|
AddHasDynamicColumns.up
|
34
|
+
AddHasDynamicColumnsDatastore.up
|
32
35
|
|
33
36
|
create_table :accounts, force: true do |t|
|
34
37
|
t.string :name
|
35
|
-
t.timestamps
|
38
|
+
t.timestamps null: false
|
36
39
|
end
|
37
40
|
create_table :customers, force: true do |t|
|
38
41
|
t.string :name
|
39
42
|
t.integer :account_id
|
40
|
-
t.timestamps
|
43
|
+
t.timestamps null: false
|
41
44
|
end
|
42
45
|
create_table :customer_addresses, force: true do |t|
|
43
46
|
t.string :name
|
44
47
|
t.integer :customer_id
|
45
|
-
t.timestamps
|
48
|
+
t.timestamps null: false
|
46
49
|
end
|
47
50
|
create_table :products, force: true do |t|
|
48
51
|
t.string :name
|
49
52
|
t.integer :account_id
|
50
|
-
t.timestamps
|
53
|
+
t.timestamps null: false
|
51
54
|
end
|
52
55
|
create_table :categories, force: true do |t|
|
53
56
|
t.string :name
|
54
57
|
t.integer :account_id
|
55
|
-
t.timestamps
|
58
|
+
t.timestamps null: false
|
56
59
|
end
|
57
60
|
create_table :category_owners, force: true do |t|
|
58
61
|
t.integer :category_id
|
59
62
|
t.integer :owner_id
|
60
63
|
t.string :owner_type
|
61
|
-
t.timestamps
|
64
|
+
t.timestamps null: false
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
@@ -102,11 +105,13 @@ class CategoryOwner < ActiveRecord::Base
|
|
102
105
|
belongs_to :owner, :polymorphic => true
|
103
106
|
end
|
104
107
|
|
108
|
+
require_relative '../spec/factories/account'
|
109
|
+
require_relative '../spec/factories/customer'
|
110
|
+
|
105
111
|
RSpec.configure do |config|
|
112
|
+
config.include FactoryGirl::Syntax::Methods
|
106
113
|
config.after(:each) do
|
107
|
-
|
108
114
|
end
|
109
|
-
|
110
115
|
config.expect_with :rspec do |c|
|
111
116
|
c.syntax = :expect
|
112
117
|
end
|
metadata
CHANGED
@@ -1,29 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_dynamic_columns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Butch Marshall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '5.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: sqlite3
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: factory_girl
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">"
|
25
59
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
60
|
+
version: '0'
|
27
61
|
- !ruby/object:Gem::Dependency
|
28
62
|
name: bundler
|
29
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,20 +108,42 @@ files:
|
|
74
108
|
- lib/generators/has_dynamic_columns/has_dynamic_columns_generator.rb
|
75
109
|
- lib/generators/has_dynamic_columns/next_migration_version.rb
|
76
110
|
- lib/generators/has_dynamic_columns/templates/migration.rb
|
111
|
+
- lib/generators/has_dynamic_columns/templates/migration_0.3.0.rb
|
112
|
+
- lib/generators/has_dynamic_columns/upgrade_0_3_0_active_record_generator.rb
|
77
113
|
- lib/has_dynamic_columns.rb
|
78
114
|
- lib/has_dynamic_columns/active_record.rb
|
79
115
|
- lib/has_dynamic_columns/active_record/query_methods.rb
|
80
116
|
- lib/has_dynamic_columns/active_record/relation.rb
|
117
|
+
- lib/has_dynamic_columns/active_record/v3/query_methods.rb
|
118
|
+
- lib/has_dynamic_columns/active_record/v3/relation.rb
|
119
|
+
- lib/has_dynamic_columns/active_record/v4/query_methods.rb
|
120
|
+
- lib/has_dynamic_columns/active_record/v4/relation.rb
|
81
121
|
- lib/has_dynamic_columns/active_record_relation.rb
|
82
122
|
- lib/has_dynamic_columns/compatibility.rb
|
83
123
|
- lib/has_dynamic_columns/dynamic_column.rb
|
124
|
+
- lib/has_dynamic_columns/dynamic_column_boolean_datum.rb
|
125
|
+
- lib/has_dynamic_columns/dynamic_column_date_datum.rb
|
126
|
+
- lib/has_dynamic_columns/dynamic_column_datetime_datum.rb
|
84
127
|
- lib/has_dynamic_columns/dynamic_column_datum.rb
|
128
|
+
- lib/has_dynamic_columns/dynamic_column_enum_datum.rb
|
129
|
+
- lib/has_dynamic_columns/dynamic_column_float_datum.rb
|
130
|
+
- lib/has_dynamic_columns/dynamic_column_integer_datum.rb
|
85
131
|
- lib/has_dynamic_columns/dynamic_column_option.rb
|
132
|
+
- lib/has_dynamic_columns/dynamic_column_string_datum.rb
|
133
|
+
- lib/has_dynamic_columns/dynamic_column_text_datum.rb
|
134
|
+
- lib/has_dynamic_columns/dynamic_column_time_datum.rb
|
135
|
+
- lib/has_dynamic_columns/dynamic_column_timestamp_datum.rb
|
86
136
|
- lib/has_dynamic_columns/dynamic_column_validation.rb
|
87
137
|
- lib/has_dynamic_columns/model.rb
|
88
138
|
- lib/has_dynamic_columns/model/class_methods.rb
|
89
139
|
- lib/has_dynamic_columns/model/instance_methods.rb
|
90
140
|
- lib/has_dynamic_columns/version.rb
|
141
|
+
- rspec_rvm
|
142
|
+
- spec/factories/account.rb
|
143
|
+
- spec/factories/customer.rb
|
144
|
+
- spec/has_dynamic_columns/active_record/query_methods_spec.rb
|
145
|
+
- spec/has_dynamic_columns/dynamic_columns_integer_datum_spec.rb
|
146
|
+
- spec/has_dynamic_columns/dynamic_columns_string_datum_spec.rb
|
91
147
|
- spec/has_dynamic_columns_spec.rb
|
92
148
|
- spec/spec_helper.rb
|
93
149
|
homepage: https://github.com/butchmarshall/has_dynamic_columns
|
@@ -115,5 +171,10 @@ signing_key:
|
|
115
171
|
specification_version: 4
|
116
172
|
summary: Dynamic fields for activerecord models
|
117
173
|
test_files:
|
174
|
+
- spec/factories/account.rb
|
175
|
+
- spec/factories/customer.rb
|
176
|
+
- spec/has_dynamic_columns/active_record/query_methods_spec.rb
|
177
|
+
- spec/has_dynamic_columns/dynamic_columns_integer_datum_spec.rb
|
178
|
+
- spec/has_dynamic_columns/dynamic_columns_string_datum_spec.rb
|
118
179
|
- spec/has_dynamic_columns_spec.rb
|
119
180
|
- spec/spec_helper.rb
|