Skip to content

Instantly share code, notes, and snippets.

@softcraft-development
Created May 24, 2010 20:54
Show Gist options
  • Save softcraft-development/412413 to your computer and use it in GitHub Desktop.
Save softcraft-development/412413 to your computer and use it in GitHub Desktop.
def test_update_nested
ingredient = Factory.create(:ingredient)
put :update,
:id=>ingredient.recipe.friendly_id,
:recipe=> {
:name=> ingredient.recipe.name,
:ingredients_attributes=>{
"0"=>{
:name=>ingredient.name,
:amount=>ingredient.amount,
:"id"=>ingredient.id,
:_destroy=>"1"
}
}
}
recipe = Recipe.find(ingredient.recipe.id)
assert_equal 0, recipe.ingredients.size
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment