Need help with a test



I have this controller method that I need to test:

def link_concept_to_client
concept_to_link = Concept.find(params[:concept_id])
# take all the variations for the concept
for variation in concept_to_link.variations
new_client_variation =
new_client_variation.client = session[:active_client]
new_client_variation.variation = variation
new_client_variation.name_fr = variation.name_fr
new_client_variation.name_en = variation.name_en
flash[:notice] = “Concept linked”
redirect_to(:action => “list”)

it is working fine when I use it in dev, but when I run this test (see
next), it fails:

def test_link_concept
#create a new concept
new_concept = = “concept a lier”
new_concept.description = “ce concept va etre lie”
#give it a variation
new_variation =
new_variation.name_fr = “nom de la variation”
new_variation.description = “name of the variation”
new_variation.concept_id =

#link it to the client
get :link_concept_to_client, {:concept_id  =>}, 

{:active_client => clients(:air_canada)}
#there should now be a client_variation for the variation
assert_equal new_variation.name_fr, (ClientVariation.find_by_name_fr


Sorry for the blooted code, I had to decompose everything in small part
to locate the problem…

The error message is:
NoMethodError: You have a nil object when you didn’t expect it!
The error occured while evaluating nil.name_fr
specific_controller_test.rb:45:in `test_link_concept’

The weird thing is that the first assert works which means that there is
something in the DB for that record, but the second assertion doesnt

Anyone has an idea?

Thanks a lot!


Forget about this, running all my tests I located the source of the
problem… totaly not related to this!