Skip to content

create_list does not correctly override parameter #1787

@GMolini

Description

@GMolini

Description

Ive got a factory bot definition like this

FactoryBot.define do
  factory :emails_message, class: 'Emails::Message' do
    subject { Faker::Lorem.sentence }
    thread_subject { Faker::Lorem.sentence }
    from { Faker::Internet.unique.email }
    from_display_name { "#{Faker::Name.name} <#{from}>" }
  end
end

If I create a list like this:

  email_address = "test@example.com"
  emails = create_list(:emails_message, 10, from: email_address)

Its very weird because it uses the correct from in the from_display_name, but is incorrectly saved in the from attribute

If I print the emails: p emails.map { |r| [r.from, r.from_display_name] }

[["daniela.graham@jast.test", "Prof. Trudi Langosh <test@example.com>"], ["marlys@robel-schmeler.test", "Courtney Becker <test@example.com>"], ["antoine@metz.test", "Ollie Steuber <test@example.com>"], ["sue_harber@medhurst.example", "Johnathan Marvin <test@example.com>"], ["maximo@prosacco-grant.example", "Jacinto O'Reilly <test@example.com>"], ["lindsey@schulist.example", "Mrs. Thanh Schinner <test@example.com>"], ["dominique@kuvalis-wehner.test", "Stevie Larson <test@example.com>"], ["manda@thiel-ziemann.test", "Alena Abbott MD <test@example.com>"], ["fabian.grady@leffler-bechtelar.test", "Lavona Becker Ret. <test@example.com>"], ["gilberto_gleichner@rau.test", "Msgr. Vada Rolfson <test@example.com>"]]

System configuration

factory_bot version: 6.2.1
rails version: 7.0.8
ruby version: 3.2.2

Edit: Ive updated factory_bot to version 6.5.5 and factory_bot_rails to 6.5.1 and it still happens

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions