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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5c3936bec9745b84c192a908a995e3c3c8bb98fbcda27daebcf7cd41a0d0cd8
4
- data.tar.gz: 576aa1c24552479d5677780c2ac7526b1924f56e4aa103214fb5e5c8f72043fa
3
+ metadata.gz: 9295f1111fa80d54c0919b4b86286d0e40c08b347e02953600732969b0b884c5
4
+ data.tar.gz: bbe23568cdca871bf0b876c0c5c3e8600ba9336f1cf100ee2ca5c547e533db2b
5
5
  SHA512:
6
- metadata.gz: ddf8512b84b2f980821d7fa5de497f4ef4c7278d7547cbe9ba21701ea6ab34dc6c04db43628aedae059f22d13ad06b6e5977bdf3a2865aaf325c565218972c8c
7
- data.tar.gz: 1acf7f0fc12a78e629e186472f07206e21218e51af5e580035c2e5c623bd81037a4eb5cf4ea83372e495041360830acdba9b0d75162d2d2062b933f42234009f
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
- build_class.present?
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
- factory.build_class
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
 
@@ -1,3 +1,3 @@
1
1
  module FactoryBurgers
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.1.3'.freeze
3
3
  end
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.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-19 00:00:00.000000000 Z
11
+ date: 2023-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot