Skip to content

Commit

Permalink
Merge pull request #19 from rom-rb/fix-traits
Browse files Browse the repository at this point in the history
Fix multiple traits for persisted factories
  • Loading branch information
solnic authored Mar 12, 2018
2 parents 7eb8a86 + 600d058 commit ee2462f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rom/factory/builder/persistable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create(*traits, **attrs)
tuple = tuple(*traits, attrs)
persisted = persist(tuple)

if tuple_evaluator.has_associations?(*traits)
if tuple_evaluator.has_associations?(traits)
tuple_evaluator.persist_associations(tuple, persisted, *traits)

pk = primary_key_names.map { |key| persisted[key] }
Expand Down
8 changes: 6 additions & 2 deletions spec/integration/rom/factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,18 @@

f.trait :jane do |t|
t.first_name 'Jane'
t.last_name 'Doe'
t.email '[email protected]'
end

f.trait :doe do |t|
t.last_name 'Doe'
end
end

jane = factories[:user, :jane]
jane = factories[:user, :jane, :doe]

expect(jane.first_name).to eql('Jane')
expect(jane.last_name).to eql('Doe')
expect(jane.email).to eql('[email protected]')
end

Expand Down

0 comments on commit ee2462f

Please sign in to comment.