Skip to content

Commit

Permalink
Fix factorybot failures after bump to v5
Browse files Browse the repository at this point in the history
The default value for `FactoryBot.use_parent_strategy` changed from `false`
to `true` at [v5.0.0](thoughtbot/factory_bot_rails#314)

This caused some validation errors in role creation in tests because the
attached role assignments weren't created correctly due to the new FactoryBot
configuration.

We could set `FactoryBot.use_parent_strategy = false`, but I think it's
better to update the factories themselves.
  • Loading branch information
sihugh committed Jul 30, 2019
1 parent 60cc189 commit fe89133
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/factories/roles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

trait :occupied do
after :build do |role, _|
role.role_appointments = [FactoryBot.build(:role_appointment)]
role.role_appointments = [FactoryBot.create(:role_appointment)]
end
end

trait :vacant do
after :build do |role, _|
role.role_appointments = [FactoryBot.build(:role_appointment, :ended)]
role.role_appointments = [FactoryBot.create(:role_appointment, :ended)]
end
end
end

0 comments on commit fe89133

Please sign in to comment.