Skip to content

Commit ee2462f

Browse files
authored
Merge pull request #19 from rom-rb/fix-traits
Fix multiple traits for persisted factories
2 parents 7eb8a86 + 600d058 commit ee2462f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/rom/factory/builder/persistable.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def create(*traits, **attrs)
2323
tuple = tuple(*traits, attrs)
2424
persisted = persist(tuple)
2525

26-
if tuple_evaluator.has_associations?(*traits)
26+
if tuple_evaluator.has_associations?(traits)
2727
tuple_evaluator.persist_associations(tuple, persisted, *traits)
2828

2929
pk = primary_key_names.map { |key| persisted[key] }

spec/integration/rom/factory_spec.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,18 @@
303303

304304
f.trait :jane do |t|
305305
t.first_name 'Jane'
306-
t.last_name 'Doe'
307306
308307
end
308+
309+
f.trait :doe do |t|
310+
t.last_name 'Doe'
311+
end
309312
end
310313

311-
jane = factories[:user, :jane]
314+
jane = factories[:user, :jane, :doe]
312315

313316
expect(jane.first_name).to eql('Jane')
317+
expect(jane.last_name).to eql('Doe')
314318
expect(jane.email).to eql('[email protected]')
315319
end
316320

0 commit comments

Comments
 (0)