我的代码
def destroy
@line_item = LineItem.find(params[:id])
@line_item.destroy
respond_to do |format|
if current_cart.line_items.empty?
format.html {redirect_to store_path, notice: 'Your cart is empty'}
else
format.html { redirect_to current_cart, notice:'Product removed.' }
end
format.xml { head :ok }
end
end
我的考试
test "should destroy line_item" do
assert_difference('LineItem.count', -1) do
delete :destroy, id: @line_item
end
assert_redirected_to Cart.find(session[:cart_id])
end
如果我的购物车是空的,我怎样才能测试我的多次重定向?