factory_bot_rails 6.4.2 → 6.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS.md +11 -0
- data/README.md +0 -16
- data/lib/factory_bot_rails/factory_validator.rb +0 -16
- data/lib/factory_bot_rails/railtie.rb +0 -13
- metadata +5 -5
- 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: 70ac3e65ecb946bde74a107d453206896d96a0bdd02d52f6e9d99cc4b11ace65
|
4
|
+
data.tar.gz: c5478bf4191651ac02e944af9d118f2243b10fd508073b0911c9b165ad6afd1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ff19ee6c07babb79676b2ecea45b5abc8dcc6af75042409a3a4e373e9db91787b0f0506d626700303414fc9b2e50f355c2757e1ec9289fccdcf14b6239f30e8
|
7
|
+
data.tar.gz: d1a7e2c0c2966eff606e58addc63fe1dba533934fcb45ff1c7399ce5afd5604f1efab1d755e133bcd54f6b12850c76df88108b74df0da19917864e0c94ad8b92
|
data/NEWS.md
CHANGED
@@ -3,6 +3,17 @@ there might not be any notable changes in new versions of this project.
|
|
3
3
|
|
4
4
|
# NEWS
|
5
5
|
|
6
|
+
## 6.4.3 (December 29, 2023)
|
7
|
+
|
8
|
+
* Changed: allow sequence definitions for ActiveRecord primary keys (Mike
|
9
|
+
Burns).
|
10
|
+
* Changed: Support Ruby 3.0+, Rails 6.1+ (Mike Burns)
|
11
|
+
* Documentation improvements (obregonia1).
|
12
|
+
* Internal: GitHub Actions improvements (Lorenzo Zabot, ydah).
|
13
|
+
* Internal: RubyGems points to changelog (Tilo Sloboda).
|
14
|
+
* Internal: Bump standard, rake, activerecord, appraisal, rspec-rails (Mike
|
15
|
+
Burns).
|
16
|
+
|
6
17
|
## 6.4.2 (November 23, 2023)
|
7
18
|
* Fixed: Fix Rails 7.1.2 + monkey-patched ActiveRecord compatibility (Adif
|
8
19
|
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).
|
@@ -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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Ferris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot
|
@@ -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.4.
|
113
|
+
rubygems_version: 3.4.10
|
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
|