title: Expected response to be a <:success>, but was <302>
body: <p>I'm following "Agile web development with rails" book. I have a problem.
  this is my <code>new</code> method in <code>order</code> controller:
  </p>
  
  <pre class="lang-rb prettyprint-override"><code>def new
    @cart = current_cart
    if @cart.line_items.empty?
      redirect_to store_url, notice: "Your cart is empty"
      return
    end
  
    @order = Order.new
  
    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @order }
    end
  end
  </code></pre>
  
  <p>And this is the test:</p>
  
  <pre class="lang-rb prettyprint-override"><code>test "should get new" do
    cart = Cart.create
    session[:cart_id] = cart.id
    li = LineItem.create(product: products(:ruby))
    li.cart = cart
  
    get :new
    assert_response :success
  end
  </code></pre>
  
  <p>the <code>rake test</code> shows a failure: </p>
  
  <pre class="lang-rb prettyprint-override"><code>Expected response to be a &lt;:success&gt;, but was &lt;302&gt;
  </code></pre>
  
  <p>I checked it with rails command line as follows:</p>
  
  <pre class="lang-rb prettyprint-override"><code>cart = Cart.create
  =&gt; #&lt;Cart id: 24, created_at: "2012-07-09 08:39:36", updated_at: "2012-07-09 08:39:36"&gt;
  
  products = Product.create(:title =&gt; "Lorem Ipsum", :description =&gt; "Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem", :price =&gt; 49.50, :image_url =&gt; "ruby.png")
  =&gt; #&lt;Product id: nil, title: "Lorem Ipsum", description: "Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem", image_url: "ruby.png", price: #&lt;BigDecimal:434f108,'0.495E2',18(45)&gt;, created_at: nil, updated_at: nil&gt;
  
  li = LineItem.create(product: products)
  =&gt; #&lt;LineItem id: 106, product_id: nil, cart_id: nil, created_at: "2012-07-09 08:41:29", updated_at: "2012-07-09 08:41:29", quantity: 1, price: nil, order_id: nil&gt;
  
  li.cart = cart
  =&gt; #&lt;Cart id: 24, created_at: "2012-07-09 08:39:36", updated_at: "2012-07-09 08:39:36"&gt;
  </code></pre>
  
  <p><code>li.cart</code> shows the corresponding <code>cart</code>, but <code>cart.line_items</code> is empty. the two model (carts and line_items) and related to each other. why is the <code>cart.line_items</code> empty?</p>