Issue with STI and Factory Girl Rails -
i having issue classes not being set appropriately when dealing single table inheritance class , factory girl.
my factory is:
factory :team name "test name" store_password 'password' end factory :sales_team, class: team, parent: :team type 'salesteam' end factory :retail_sales_team, class: team, parent: :team type 'retailsalesteam' end
(i have tried :sales_team , :retail_sales_team nested inside factory :team do)
and in spec do
@team = factorygirl.create(:retail_sales_team, name: "test team")
if call
@team.class.name #=> "team"
and when try pass @team object
belongs_to :team , class_name: 'retailsalesteam'
i error
failure/error: @sale = factorygirl.create(:sale, kpi: @kpi, user: @user, team: @team) activerecord::associationtypemismatch: retailsalesteam(#70151785667180) expected, got team(#70151730184960)
let me know if there other information can provide , in advance!
Comments
Post a Comment