title: Mass Assignment Security Error when testing new action with Agile Web tutorial using Rails 3.2
body: <p>I am going through the Agile Web tutorial with some slight changes. When I run functional tests in Rails 3.2, I am getting the following error:</p>
  
  <pre><code>test_should_get_new(OrdersControllerTest):
  ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: cart, deal
  </code></pre>
  
  <p>Here is the orders_controller_test.rb code:</p>
  
  <pre><code>test "should get new" do
    cart = Cart.create
    session[:cart_id] = cart.id
    LineItem.create(cart: cart, deal: deals(:one))
  
    get :new
    assert_response :success
  end
  </code></pre>
  
  <p>Here is the orders fixtures:</p>
  
  <pre><code>one:
    name: MyString
    address: MyText
    email: MyString
    pay_type: Check
  </code></pre>
  
  <p>Here is the line items fixtures:</p>
  
  <pre><code>one:
    deal: one
    order: one
  </code></pre>
  
  <p>Here is the deals fixture:</p>
  
  <pre><code>one:
    title: MyString
    description: MyText
    image_url: MyString
    price: 9.99
  </code></pre>
  
  <p>Here is the order controller code:</p>
  
  <pre><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>I tried using FactoryGirl but still got the same error message. Here is the code:</p>
  
  <pre><code>test "should get new" do
    cart = FactoryGirl.build(:cart)
    session[:cart_id] = cart.id
    LineItem.create(cart: cart, deal: deals(:one))
  
    get :new
    assert_response :success
  end
  </code></pre>
  
  <p>And the FactoryGirl code:</p>
  
  <pre><code>FactoryGirl.define do  
    factory :cart do
    end
  end
  </code></pre>
  
  <p>For FactoryGirl I also tried 'create' instead of 'build' and got the same error message.</p>
  
  <p>Although I could turn off the mass assignment error in config, I would rather not since I prefer to test properly.</p>
  
  <p>Any suggestions please?</p>