factory_bot 6.5.0 → 6.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +7 -0
- data/lib/factory_bot/definition.rb +4 -0
- data/lib/factory_bot/factory.rb +10 -2
- data/lib/factory_bot/linter.rb +13 -2
- data/lib/factory_bot/trait.rb +4 -0
- data/lib/factory_bot/version.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71c90d06521a4d6e1bbd613bdc1494919b2acde4117153524a11d8fbea53301c
|
4
|
+
data.tar.gz: 7e19bf127cf040c9f59fea525894019358e0502de695cf5957ac5eb91280e1d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff1b56b976b423b91d8f633fdb0d1ed2d13b5c75665547adbb4d6f1d90b15aff35459dcb2fd6479e6dccdfd98ce3a9bd2a13b1ced002704fb84c39e2d5ebb3f3
|
7
|
+
data.tar.gz: dfc7713d8511e0723ab41da77257c901ca2d5abdf04b21b8f81332bd4f6e6568d403a68fc7831529ab8cbed531c25bc068458ee28fb2b1d7f0b7ebeafda02a3a
|
data/NEWS.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 6.5.1 (January 31, 2025)
|
4
|
+
|
5
|
+
* Changed: execute linting tests within ActiveRecord transactions when available (Sean Doyle)
|
6
|
+
* Fix: Random test failure when tracking compilation time (CodeMeinster)
|
7
|
+
* Fix: Bump the minimum required activesupport version to 6.1 (Earlopain)
|
8
|
+
* Internal: Update development dependencies (Neil Carvalho)
|
9
|
+
|
3
10
|
## 6.5.0 (September 6, 2024)
|
4
11
|
|
5
12
|
* fix: issue 1621 broken links in ref/factory.md by @elasticspoon in https://github.com/thoughtbot/factory_bot/pull/1623
|
data/lib/factory_bot/factory.rb
CHANGED
@@ -17,7 +17,8 @@ module FactoryBot
|
|
17
17
|
end
|
18
18
|
|
19
19
|
delegate :add_callback, :declare_attribute, :to_create, :define_trait, :constructor,
|
20
|
-
:defined_traits, :inherit_traits, :append_traits,
|
20
|
+
:defined_traits, :defined_traits_names, :inherit_traits, :append_traits,
|
21
|
+
to: :@definition
|
21
22
|
|
22
23
|
def build_class
|
23
24
|
@build_class ||= if class_name.is_a? Class
|
@@ -85,7 +86,7 @@ module FactoryBot
|
|
85
86
|
def compile
|
86
87
|
unless @compiled
|
87
88
|
parent.compile
|
88
|
-
|
89
|
+
inherit_parent_traits
|
89
90
|
@definition.compile(build_class)
|
90
91
|
build_hierarchy
|
91
92
|
@compiled = true
|
@@ -153,6 +154,13 @@ module FactoryBot
|
|
153
154
|
end
|
154
155
|
end
|
155
156
|
|
157
|
+
def inherit_parent_traits
|
158
|
+
parent.defined_traits.each do |trait|
|
159
|
+
next if defined_traits_names.include?(trait.name)
|
160
|
+
define_trait(trait.clone)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
156
164
|
def initialize_copy(source)
|
157
165
|
super
|
158
166
|
@definition = @definition.clone
|
data/lib/factory_bot/linter.rb
CHANGED
@@ -70,7 +70,7 @@ module FactoryBot
|
|
70
70
|
def lint_factory(factory)
|
71
71
|
result = []
|
72
72
|
begin
|
73
|
-
FactoryBot.public_send(factory_strategy, factory.name)
|
73
|
+
in_transaction { FactoryBot.public_send(factory_strategy, factory.name) }
|
74
74
|
rescue => e
|
75
75
|
result |= [FactoryError.new(e, factory)]
|
76
76
|
end
|
@@ -80,7 +80,7 @@ module FactoryBot
|
|
80
80
|
def lint_traits(factory)
|
81
81
|
result = []
|
82
82
|
factory.definition.defined_traits.map(&:name).each do |trait_name|
|
83
|
-
FactoryBot.public_send(factory_strategy, factory.name, trait_name)
|
83
|
+
in_transaction { FactoryBot.public_send(factory_strategy, factory.name, trait_name) }
|
84
84
|
rescue => e
|
85
85
|
result |= [FactoryTraitError.new(e, factory, trait_name)]
|
86
86
|
end
|
@@ -106,5 +106,16 @@ module FactoryBot
|
|
106
106
|
:message
|
107
107
|
end
|
108
108
|
end
|
109
|
+
|
110
|
+
def in_transaction
|
111
|
+
if defined?(ActiveRecord::Base)
|
112
|
+
ActiveRecord::Base.transaction do
|
113
|
+
yield
|
114
|
+
raise ActiveRecord::Rollback
|
115
|
+
end
|
116
|
+
else
|
117
|
+
yield
|
118
|
+
end
|
119
|
+
end
|
109
120
|
end
|
110
121
|
end
|
data/lib/factory_bot/trait.rb
CHANGED
data/lib/factory_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.5.
|
4
|
+
version: 6.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Clayton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 6.1.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 6.1.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: activerecord
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,6 +81,20 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: mutex_m
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: rake
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -253,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
267
|
- !ruby/object:Gem::Version
|
254
268
|
version: '0'
|
255
269
|
requirements: []
|
256
|
-
rubygems_version: 3.5.
|
270
|
+
rubygems_version: 3.5.22
|
257
271
|
signing_key:
|
258
272
|
specification_version: 4
|
259
273
|
summary: factory_bot provides a framework and DSL for defining and using model instance
|