factory_burgers 1.1.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/factory_burgers/models/factory.rb +13 -4
- data/lib/factory_burgers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9295f1111fa80d54c0919b4b86286d0e40c08b347e02953600732969b0b884c5
|
4
|
+
data.tar.gz: bbe23568cdca871bf0b876c0c5c3e8600ba9336f1cf100ee2ca5c547e533db2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c38e40099ee535b7c342dc4a57920ed978db06b5d5aa43958d81d170ecd8aa6c080ea57b9039ad3282c1bdb0ebf0d4a868cada2283ea0ae692e3d7c3d4b99960
|
7
|
+
data.tar.gz: 6f01930967401fd63066ea8fff9283fc951d8901fad8649e46983d0f9b7191c6a98b2466fa9916f53be9744683c4d1d3fa7c56dbbeb0e89c4c0dd4d3b8277bef
|
@@ -13,7 +13,8 @@ module FactoryBurgers
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def valid?
|
16
|
-
|
16
|
+
# Non-ActiveRecord factories are not supported; we don't know how to set their columns, persist records, etc.
|
17
|
+
active_record?
|
17
18
|
end
|
18
19
|
|
19
20
|
def to_h
|
@@ -34,7 +35,7 @@ module FactoryBurgers
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def class_name
|
37
|
-
build_class.base_class.name
|
38
|
+
active_record? ? build_class.base_class.name : build_class.name
|
38
39
|
end
|
39
40
|
|
40
41
|
def traits
|
@@ -48,13 +49,21 @@ module FactoryBurgers
|
|
48
49
|
private
|
49
50
|
|
50
51
|
def build_class
|
51
|
-
|
52
|
+
return @build_class if defined?(@build_class)
|
53
|
+
|
54
|
+
@build_class = factory.build_class
|
52
55
|
rescue NameError
|
53
56
|
# Some usages of factories include pseudo "abstract" factory parent classes that do not point to a real class
|
54
|
-
nil
|
57
|
+
@build_class = nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def active_record?
|
61
|
+
build_class.present? && build_class < ActiveRecord::Base
|
55
62
|
end
|
56
63
|
|
57
64
|
def settable_columns
|
65
|
+
return [] if !active_record?
|
66
|
+
|
58
67
|
factory.build_class.columns.reject { |col| col.name == build_class.primary_key }
|
59
68
|
end
|
60
69
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_burgers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Schwartz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot
|