Agile Web Development with Rails, Edition 4

Agile Web Development with Rails, Edition 4

12.7 Iteration J2: Email Notifications 12.3 Iteration G3: Pagination

12.4 Playtime

</32 tests, 5\d assertions, 0 failures, 0 errors/> expected but was
<"(in /home/rubys/svn/rails4/Book/util/work/depot)">.

Traceback:
  /home/rubys/svn/rails4/Book/util/checkdepot.rb:169
rake test
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from /home/rubys/.rvm/gems/ruby-1.8.7-p249/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
(in /home/rubys/svn/rails4/Book/util/work/depot)
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from /home/rubys/.rvm/gems/ruby-1.8.7-p249/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p249%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.........
Finished in 0.230461 seconds.
 
9 tests, 30 assertions, 0 failures, 0 errors
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from /home/rubys/.rvm/gems/ruby-1.8.7-p249/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p249%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
........E......F...F.F.........
Finished in 0.90666 seconds.
 
  1) Error:
test_should_create_line_item_via_ajax(LineItemsControllerTest):
ActionView::Template::Error: Missing partial carts/cart with {:handlers=>[:rxml, :erb, :rjs, :builder, :rhtml], :locale=>[:en, :en], :formats=>[:js]} in view paths "/home/rubys/svn/rails4/Book/util/work/depot/app/views"
    app/views/line_items/create.js.rjs:5
    app/views/line_items/create.js.rjs:1
    /test/functional/line_items_controller_test.rb:57:in `test_should_create_line_item_via_ajax'
    /test/functional/line_items_controller_test.rb:55:in `test_should_create_line_item_via_ajax'
 
  2) Failure:
test_should_create_order(OrdersControllerTest) [/test/functional/orders_controller_test.rb:20]:
"Order.count" didn't change by 1.
<3> expected but was
<2>.
 
  3) Failure:
test_should_get_new(OrdersControllerTest) [/test/functional/orders_controller_test.rb:16]:
Expected response to be a <:success>, but was <302>
 
  4) Failure:
test_should_update_order(OrdersControllerTest) [/test/functional/orders_controller_test.rb:39]:
Expected response to be a <:redirect>, but was <200>
 
31 tests, 46 assertions, 3 failures, 1 errors
Errors running test:functionals!
edit test/functional/orders_controller_test.rb
  test "requires item in cart" do
    get :new
    assert_redirected_to store_path
    assert_equal flash[:notice], 'Your cart is empty'
  end
 
  test "should get new" do
    cart = Cart.create
    session[:cart_id] = cart.id
    LineItem.create(:cart => cart, :product => products(:ruby))
 
    get :new
    assert_response :success
  end
edit test/functional/orders_controller_test.rb
require 'test_helper'
 
class OrdersControllerTest < ActionController::TestCase
  # ...
  test "should create order" do
    assert_difference('Order.count') do
      post :create, :order => @order.attributes
    end
 
    assert_redirected_to store_path
  end
end

Update the test data in the fixture

edit test/fixtures/orders.yml
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 
one:
  name: Dave Thomas
  address: MyText
  email: dave@example.org
  pay_type: Check
 
two:
  name: MyString
  address: MyText
  email: MyString
  pay_type: MyString

move a line item from a cart to an order

edit test/fixtures/line_items.yml
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 
one:
  product: ruby
  order: one
 
two:
  product: ruby
  cart: one
rake test
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from /home/rubys/.rvm/gems/ruby-1.8.7-p249/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
(in /home/rubys/svn/rails4/Book/util/work/depot)
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from /home/rubys/.rvm/gems/ruby-1.8.7-p249/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p249%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.........
Finished in 0.133155 seconds.
 
9 tests, 30 assertions, 0 failures, 0 errors
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from /home/rubys/.rvm/gems/ruby-1.8.7-p249/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p249%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
........E.......................
Finished in 0.799205 seconds.
 
  1) Error:
test_should_create_line_item_via_ajax(LineItemsControllerTest):
ActionView::Template::Error: Missing partial carts/cart with {:handlers=>[:rxml, :erb, :rjs, :builder, :rhtml], :locale=>[:en, :en], :formats=>[:js]} in view paths "/home/rubys/svn/rails4/Book/util/work/depot/app/views"
    app/views/line_items/create.js.rjs:5
    app/views/line_items/create.js.rjs:1
    /test/functional/line_items_controller_test.rb:57:in `test_should_create_line_item_via_ajax'
    /test/functional/line_items_controller_test.rb:55:in `test_should_create_line_item_via_ajax'
 
32 tests, 49 assertions, 0 failures, 1 errors
Errors running test:functionals!
git commit -a -m "Orders"
Created commit cbbc0db: Orders
 6 files changed, 76 insertions(+), 4 deletions(-)
git tag iteration-h

12.7 Iteration J2: Email Notifications 12.3 Iteration G3: Pagination