Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign klass to defined_traits to pass it's class to ActiveSuport::Notifications #1600

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

makicamel
Copy link
Contributor

@makicamel makicamel commented Nov 20, 2023

#1587 published factory_bot.compile_factory notification.
That maked to be able tracking the attributes and traits, e.g. thoughtbot/factory_bot_rails#419 .
But when using trait the payload has no class, so assign definition's class to defined_traits.

Fix thoughtbot/factory_bot_rails#431

andyundso added a commit to simplificator/renovate-preset that referenced this pull request Nov 20, 2023
There is an issue in the newest release with traits:
thoughtbot/factory_bot_rails#431
thoughtbot/factory_bot#1600

as we use this library in many projects, I suggest to add a separate group for it in the preset until the bug is fixed, so we can continue to merge the non-major dependencies for this week.
andyundso added a commit to simplificator/renovate-preset that referenced this pull request Nov 20, 2023
There is an issue in the newest release with traits:
thoughtbot/factory_bot_rails#431
thoughtbot/factory_bot#1600

as we use this library in many projects, I suggest to add a separate group for it in the preset until the bug is fixed, so we can continue to merge the non-major dependencies for this week.
@olleolleolle
Copy link

All of my factories did work with this change, except

FactoryBot.define do
  trait :base_deposit_trait do
    amount { 1.5 }
    currency { "SEK" }
    deposited_at { Time.now }
    transaction_id { "123" }
    organization { FactoryBot.create(:organization) }
  end

  factory :foo_deposit, traits: %i[ base_deposit_trait ] do
    type { "FooDeposit" }
  end

  factory :bar_deposit, traits: %i[ base_deposit_trait ] do
    type { "BarDeposit" }
  end

  factory :baz_deposit, traits: %i[ base_deposit_trait ] do
    type { "BazDeposit" }
  end
end

...and this failed with the NoMethodError: undefined method '<' for nil:NilClass error.

@pauljacksonrodgers
Copy link

I am also seeing the same regression NoMethodError: undefined method '<' for nil:NilClass for some of my factories in the latest release.

@mike-burns mike-burns force-pushed the define-trait-with-klass branch from 2f0efba to b1d8e4f Compare November 20, 2023 17:24
@mike-burns mike-burns merged commit b1d8e4f into thoughtbot:main Nov 20, 2023
74 checks passed
@mike-burns
Copy link
Contributor

Released in 6.4.1. Thank you for tracking that down!

@makicamel makicamel deleted the define-trait-with-klass branch November 20, 2023 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6.3.0: NoMethodError: undefined method '<' for nil:NilClass when using a factory with traits
4 participants