Need help with a test

Hi,

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 = ClientVariation.new
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
new_client_variation.save
end
flash[:notice] = “Concept linked”
redirect_to(:action => “list”)
end

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.new
new_concept.name = “concept a lier”
new_concept.description = “ce concept va etre lie”
new_concept.save
#give it a variation
new_variation = Variation.new
new_variation.name_fr = “nom de la variation”
new_variation.description = “name of the variation”
new_variation.concept_id = new_concept.id
new_variation.save

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

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

end

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
work.

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!