thoughtbot/factory_girl — Issue #248: Overriding a foreign key not working.
Author: budu
Created: 2011-11-29 20:23:07+00:00
State: open

I've got a factory the uses a sequence to set the foreign key in a model like this:

factory :player do
sequence(:team_id) do |n|
teams = Team.all
teams[n % teams.size].id
end
end

If I try the override this attribute in a build command (not tried create or stub yet), it doesn't get overrided:

FactoryGirl.build(:player, team_id: 42)