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

rake test
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from /home/rubys/.rvm/gems/ruby-1.8.8-r28169/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
(in /home/rubys/svn/rails4/Book/util/work-188/depot)
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from /home/rubys/.rvm/gems/ruby-1.8.8-r28169/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.8-r28169%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.........
Finished in 0.156573 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.8-r28169/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.8-r28169%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
...............F...F.F.........
Finished in 0.907417 seconds.
 
  1) 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>.
 
  2) Failure:
test_should_get_new(OrdersControllerTest) [test/functional/orders_controller_test.rb:16]:
Expected response to be a <:success>, but was <302>
 
  3) Failure:
test_should_update_order(OrdersControllerTest) [test/functional/orders_controller_test.rb:39]:
Expected response to be a <:redirect>, but was <200>
 
31 tests, 49 assertions, 3 failures, 0 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.8-r28169/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
(in /home/rubys/svn/rails4/Book/util/work-188/depot)
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from /home/rubys/.rvm/gems/ruby-1.8.8-r28169/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.8-r28169%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.........
Finished in 0.170221 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.8-r28169/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.8-r28169%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
................................
Finished in 0.912462 seconds.
 
32 tests, 52 assertions, 0 failures, 0 errors
git commit -a -m "Orders"
Created commit c7f0146: Orders
 6 files changed, 76 insertions(+), 4 deletions(-)
git tag iteration-h

12.7 Iteration J2: Email Notifications 12.3 Iteration G3: Pagination