factory_bot 6.4.6 → 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 +25 -0
- data/README.md +11 -8
- data/lib/factory_bot/attribute_assigner.rb +1 -1
- data/lib/factory_bot/definition.rb +4 -0
- data/lib/factory_bot/factory.rb +12 -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
- data/lib/factory_bot.rb +1 -0
- 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,30 @@
|
|
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
|
+
|
10
|
+
## 6.5.0 (September 6, 2024)
|
11
|
+
|
12
|
+
* fix: issue 1621 broken links in ref/factory.md by @elasticspoon in https://github.com/thoughtbot/factory_bot/pull/1623
|
13
|
+
* Add standard settings by @ydah in https://github.com/thoughtbot/factory_bot/pull/1625
|
14
|
+
* Call dynamic-readme reusable workflow by @stefannibrasil in https://github.com/thoughtbot/factory_bot/pull/1628
|
15
|
+
* Update README again by @stefannibrasil in https://github.com/thoughtbot/factory_bot/pull/1630
|
16
|
+
* Only run this workflow if the README has been updated by @stefannibrasil in https://github.com/thoughtbot/factory_bot/pull/1635
|
17
|
+
* Automatically Generated: Update Dynamic Section in README by @github-actions in https://github.com/thoughtbot/factory_bot/pull/1637
|
18
|
+
* Added a case for build_class to handle class names with underscores passed as a string by @m-gizzi in https://github.com/thoughtbot/factory_bot/pull/1642
|
19
|
+
* Add Ruby 3.3 to CI by @berkos in https://github.com/thoughtbot/factory_bot/pull/1615
|
20
|
+
* Update Dependabot configuration by @smaboshe in https://github.com/thoughtbot/factory_bot/pull/1655
|
21
|
+
* Add new maintainers to CODEOWNERS by @sarahraqueld in https://github.com/thoughtbot/factory_bot/pull/1651
|
22
|
+
* Improve docs formatting and fix filename conflicts by @sarahraqueld in https://github.com/thoughtbot/factory_bot/pull/1666
|
23
|
+
* Add a dynamic security workflow and a SECURITY.md file by @sarahraqueld in https://github.com/thoughtbot/factory_bot/pull/1677
|
24
|
+
* Automatically Generated: Update Dynamic Section in SECURITY by @github-actions in https://github.com/thoughtbot/factory_bot/pull/1678
|
25
|
+
* Ensure rails 7.2 compatibility by @Earlopain in https://github.com/thoughtbot/factory_bot/pull/1686
|
26
|
+
* Fix the factory definition in traits documentation by @ddieulivol in https://github.com/thoughtbot/factory_bot/pull/1688
|
27
|
+
|
3
28
|
## 6.4.6 (January 30, 2023)
|
4
29
|
|
5
30
|
* Fix: Bump minimum required Ruby in gemspec (Earlopain).
|
data/README.md
CHANGED
@@ -75,27 +75,30 @@ community](https://github.com/thoughtbot/factory_bot/graphs/contributors).
|
|
75
75
|
License
|
76
76
|
-------
|
77
77
|
|
78
|
-
factory_bot is Copyright © 2008
|
78
|
+
factory_bot is Copyright © 2008 Joe Ferris and thoughtbot. It is free
|
79
79
|
software, and may be redistributed under the terms specified in the
|
80
80
|
[LICENSE] file.
|
81
81
|
|
82
82
|
[LICENSE]: https://github.com/thoughtbot/factory_bot/blob/main/LICENSE
|
83
83
|
|
84
|
+
<!-- START /templates/footer.md -->
|
85
|
+
## About thoughtbot
|
84
86
|
|
85
|
-
|
86
|
-
----------------
|
87
|
-
|
88
|
-
![thoughtbot](https://thoughtbot.com/brand_assets/93:44.svg)
|
87
|
+
![thoughtbot](https://thoughtbot.com/thoughtbot-logo-for-readmes.svg)
|
89
88
|
|
90
|
-
|
89
|
+
This repo is maintained and funded by thoughtbot, inc.
|
91
90
|
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
92
91
|
|
93
92
|
We love open source software!
|
94
|
-
See [our other projects][community]
|
95
|
-
[hire
|
93
|
+
See [our other projects][community].
|
94
|
+
We are [available for hire][hire].
|
96
95
|
|
97
96
|
[community]: https://thoughtbot.com/community?utm_source=github
|
98
97
|
[hire]: https://thoughtbot.com/hire-us?utm_source=github
|
98
|
+
|
99
|
+
|
100
|
+
<!-- END /templates/footer.md -->
|
101
|
+
|
99
102
|
[ci-image]: https://github.com/thoughtbot/factory_bot/actions/workflows/build.yml/badge.svg?branch=main
|
100
103
|
[ci]: https://github.com/thoughtbot/factory_bot/actions?query=workflow%3ABuild+branch%3Amain
|
101
104
|
[grade-image]: https://codeclimate.com/github/thoughtbot/factory_bot/badges/gpa.svg
|
@@ -13,7 +13,7 @@ module FactoryBot
|
|
13
13
|
@evaluator.instance = build_class_instance
|
14
14
|
build_class_instance.tap do |instance|
|
15
15
|
attributes_to_set_on_instance.each do |attribute|
|
16
|
-
instance.public_send("#{attribute}=", get(attribute))
|
16
|
+
instance.public_send(:"#{attribute}=", get(attribute))
|
17
17
|
@attribute_names_assigned << attribute
|
18
18
|
end
|
19
19
|
end
|
data/lib/factory_bot/factory.rb
CHANGED
@@ -17,11 +17,14 @@ 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
|
24
25
|
class_name
|
26
|
+
elsif class_name.to_s.safe_constantize
|
27
|
+
class_name.to_s.safe_constantize
|
25
28
|
else
|
26
29
|
class_name.to_s.camelize.constantize
|
27
30
|
end
|
@@ -83,7 +86,7 @@ module FactoryBot
|
|
83
86
|
def compile
|
84
87
|
unless @compiled
|
85
88
|
parent.compile
|
86
|
-
|
89
|
+
inherit_parent_traits
|
87
90
|
@definition.compile(build_class)
|
88
91
|
build_hierarchy
|
89
92
|
@compiled = true
|
@@ -151,6 +154,13 @@ module FactoryBot
|
|
151
154
|
end
|
152
155
|
end
|
153
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
|
+
|
154
164
|
def initialize_copy(source)
|
155
165
|
super
|
156
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
data/lib/factory_bot.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.
|
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.
|
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
|