factory_bot_rails 6.4.2 → 6.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +15 -0
- data/README.md +10 -20
- data/lib/factory_bot_rails/factory_validator.rb +0 -16
- data/lib/factory_bot_rails/railtie.rb +0 -13
- metadata +7 -7
- data/lib/factory_bot_rails/factory_validator/active_record_validator.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c891e6c2be284a3021b951364c826af87e0b44a5df42a0bf5e46724551af1c5
|
4
|
+
data.tar.gz: b00c271f28ebaca3026ab9c7da3a02ea348ecead85cb15cfa275337c9eb5e84f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3064dcddfc012355940f8ed7ab03e454d8d9fef625004eca93b5d6f3e054ba1acfb8151771b3526dc6b6e7f51517289d69934c48cd4b8e957e71cfcacd76cbaf
|
7
|
+
data.tar.gz: e887d43df27d88d2979136201293dc8b601af0cc5f243e278706fbdd370fb317783b65a25a6950b218e010bb65c35182f5eac6b7f98dad1539fc8d8e8079650e
|
data/NEWS.md
CHANGED
@@ -3,6 +3,21 @@ there might not be any notable changes in new versions of this project.
|
|
3
3
|
|
4
4
|
# NEWS
|
5
5
|
|
6
|
+
## 6.4.4 (October 25, 2024)
|
7
|
+
|
8
|
+
* Changed: Bump Factory Bot 6.5.0
|
9
|
+
|
10
|
+
## 6.4.3 (December 29, 2023)
|
11
|
+
|
12
|
+
* Changed: allow sequence definitions for ActiveRecord primary keys (Mike
|
13
|
+
Burns).
|
14
|
+
* Changed: Support Ruby 3.0+, Rails 6.1+ (Mike Burns)
|
15
|
+
* Documentation improvements (obregonia1).
|
16
|
+
* Internal: GitHub Actions improvements (Lorenzo Zabot, ydah).
|
17
|
+
* Internal: RubyGems points to changelog (Tilo Sloboda).
|
18
|
+
* Internal: Bump standard, rake, activerecord, appraisal, rspec-rails (Mike
|
19
|
+
Burns).
|
20
|
+
|
6
21
|
## 6.4.2 (November 23, 2023)
|
7
22
|
* Fixed: Fix Rails 7.1.2 + monkey-patched ActiveRecord compatibility (Adif
|
8
23
|
Sgaid, Benoit Tigeot)
|
data/README.md
CHANGED
@@ -152,22 +152,6 @@ rails generate factory_bot:model NAME [field:type field:type] [options]
|
|
152
152
|
|
153
153
|
[default factory template]: https://github.com/thoughtbot/factory_bot_rails/tree/main/lib/generators/factory_bot/model/templates/factories.erb
|
154
154
|
|
155
|
-
### Active Record Configuration
|
156
|
-
|
157
|
-
By default, FactoryBot will refuse to generate Active Record primary key
|
158
|
-
columns. Without additional configuration, an Active Record model treats a
|
159
|
-
column named `id` as its primary key.
|
160
|
-
|
161
|
-
For example, defining an `id` attribute with `add_attribute(:id)`, `id { ... }`,
|
162
|
-
or `sequence(:id)` will raise a `FactoryBot::AttributeDefinitionError`.
|
163
|
-
|
164
|
-
You can disable this behavior by adding the following to `config/application.rb`
|
165
|
-
or the appropriate environment configuration in `config/environments`:
|
166
|
-
|
167
|
-
```ruby
|
168
|
-
config.factory_bot.reject_primary_key_attributes = false
|
169
|
-
```
|
170
|
-
|
171
155
|
## Contributing
|
172
156
|
|
173
157
|
Please see [CONTRIBUTING.md](CONTRIBUTING.md).
|
@@ -177,21 +161,27 @@ community](https://github.com/thoughtbot/factory_bot_rails/graphs/contributors).
|
|
177
161
|
|
178
162
|
## License
|
179
163
|
|
180
|
-
factory_bot_rails is Copyright © 2008
|
164
|
+
factory_bot_rails is Copyright © 2008 Joe Ferris and thoughtbot. It is free
|
181
165
|
software, and may be redistributed under the terms specified in the
|
182
166
|
[LICENSE](LICENSE) file.
|
183
167
|
|
168
|
+
<!-- START /templates/footer.md -->
|
184
169
|
## About thoughtbot
|
185
170
|
|
186
|
-
![thoughtbot](https://thoughtbot.com/
|
171
|
+
![thoughtbot](https://thoughtbot.com/thoughtbot-logo-for-readmes.svg)
|
187
172
|
|
188
|
-
|
173
|
+
This repo is maintained and funded by thoughtbot, inc.
|
189
174
|
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
190
175
|
|
191
|
-
We
|
176
|
+
We love open source software!
|
192
177
|
See [our other projects][community].
|
193
178
|
We are [available for hire][hire].
|
194
179
|
|
180
|
+
[community]: https://thoughtbot.com/community?utm_source=github
|
181
|
+
[hire]: https://thoughtbot.com/hire-us?utm_source=github
|
182
|
+
|
183
|
+
<!-- END /templates/footer.md -->
|
184
|
+
|
195
185
|
[fb]: https://github.com/thoughtbot/factory_bot
|
196
186
|
[grade]: https://codeclimate.com/github/thoughtbot/factory_bot_rails
|
197
187
|
[grade-image]: https://codeclimate.com/github/thoughtbot/factory_bot_rails.svg
|
@@ -15,25 +15,9 @@ module FactoryBotRails
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def validate_compiled_factory
|
18
|
-
if Rails.version >= "6.0"
|
19
|
-
rails_6_0_support
|
20
|
-
else
|
21
|
-
rails_5_2_support
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def rails_6_0_support
|
26
18
|
proc do |event|
|
27
19
|
@validators.each { |validator| validator.validate!(event.payload) }
|
28
20
|
end
|
29
21
|
end
|
30
|
-
|
31
|
-
def rails_5_2_support
|
32
|
-
proc do |*notification_event_arguments|
|
33
|
-
event = ActiveSupport::Notifications::Event.new(*notification_event_arguments)
|
34
|
-
|
35
|
-
rails_6_0_support.call(event)
|
36
|
-
end
|
37
|
-
end
|
38
22
|
end
|
39
23
|
end
|
@@ -10,7 +10,6 @@ module FactoryBotRails
|
|
10
10
|
class Railtie < Rails::Railtie
|
11
11
|
config.factory_bot = ActiveSupport::OrderedOptions.new
|
12
12
|
config.factory_bot.definition_file_paths = FactoryBot.definition_file_paths
|
13
|
-
config.factory_bot.reject_primary_key_attributes = true
|
14
13
|
config.factory_bot.validator = FactoryBotRails::FactoryValidator.new
|
15
14
|
|
16
15
|
initializer "factory_bot.set_fixture_replacement" do
|
@@ -21,18 +20,6 @@ module FactoryBotRails
|
|
21
20
|
FactoryBot.definition_file_paths = definition_file_paths
|
22
21
|
end
|
23
22
|
|
24
|
-
initializer "factory_bot.reject_primary_key_attributes" do
|
25
|
-
ActiveSupport.on_load :active_record do
|
26
|
-
config = Rails.configuration.factory_bot
|
27
|
-
|
28
|
-
if config.reject_primary_key_attributes
|
29
|
-
require "factory_bot_rails/factory_validator/active_record_validator"
|
30
|
-
|
31
|
-
config.validator.add_validator FactoryValidator::ActiveRecordValidator.new
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
23
|
config.after_initialize do |app|
|
37
24
|
FactoryBot.find_definitions
|
38
25
|
Reloader.new(app).run
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_bot_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.4.
|
4
|
+
version: 6.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Ferris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '6.
|
19
|
+
version: '6.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '6.
|
26
|
+
version: '6.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: railties
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,6 @@ files:
|
|
80
80
|
- lib/factory_bot_rails.rb
|
81
81
|
- lib/factory_bot_rails/definition_file_paths.rb
|
82
82
|
- lib/factory_bot_rails/factory_validator.rb
|
83
|
-
- lib/factory_bot_rails/factory_validator/active_record_validator.rb
|
84
83
|
- lib/factory_bot_rails/generator.rb
|
85
84
|
- lib/factory_bot_rails/generators/non_rspec_generator.rb
|
86
85
|
- lib/factory_bot_rails/generators/null_generator.rb
|
@@ -94,7 +93,8 @@ files:
|
|
94
93
|
homepage: https://github.com/thoughtbot/factory_bot_rails
|
95
94
|
licenses:
|
96
95
|
- MIT
|
97
|
-
metadata:
|
96
|
+
metadata:
|
97
|
+
changelog_uri: https://github.com/thoughtbot/factory_bot_rails/blob/main/NEWS.md
|
98
98
|
post_install_message:
|
99
99
|
rdoc_options: []
|
100
100
|
require_paths:
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
113
|
+
rubygems_version: 3.5.22
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: factory_bot_rails provides integration between factory_bot and rails 5.0
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module FactoryBotRails
|
2
|
-
class FactoryValidator
|
3
|
-
class ActiveRecordValidator
|
4
|
-
def validate!(payload)
|
5
|
-
attributes, for_class = payload.values_at(:attributes, :class)
|
6
|
-
attributes.each do |attribute|
|
7
|
-
if for_class < ActiveRecord::Base && for_class.primary_key == attribute.name.to_s
|
8
|
-
raise FactoryBot::AttributeDefinitionError, <<~ERROR
|
9
|
-
Attribute generates #{for_class.primary_key.inspect} primary key for #{for_class.name}"
|
10
|
-
|
11
|
-
Do not define #{for_class.primary_key.inspect}. Instead, rely on the database to generate it.
|
12
|
-
ERROR
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|