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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -