-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
Description
Description
# db/structure.sql
CREATE TABLE public.realtors (
.......
duplicate_id character varying,
duplicate boolean DEFAULT false NOT NULL,
.......
# spec/factories/realtors.rb
FactoryBot.define do
factory :realtor do
.......
duplicate_id { pry; Faker::Alphanumeric.alpha(number: 10) }
.......
# in some spec
realtor1 = create(:realtor, id: 6, duplicate: true, duplicate_id: 'dup1')
[1] pry> realtor1.duplicate_id
=> nil
So, it does not set any value from factory neither from wrote manually
Reproduction Steps
Create the realtors table with the duplicate_id column.
Define a factory for realtor with a duplicate_id attribute.
Create a realtor object in a test, specifying a value for duplicate_id.
Check the value of duplicate_id on the created object; it is nil instead of the expected value.
Expected behavior
The duplicate_id should be set to the value specified manually in the test when creating a realtor object.
Actual behavior
The duplicate_id is set to nil, ignoring both the factory-generated value and the manually specified value.
System configuration
factory_bot_rails (6.2.0):
rails (7.0.8):
ruby (3.2.1):