10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button
Once again, get the tests working, and add tests for the smarter cart.
See that the tests fail.
rake test
(in /home/rubys/svn/rails4/Book/util/work-193/depot)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.3-r28190%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.......
Finished in 0.132880 seconds.
7 tests, 25 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 23559
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.3-r28190%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.......E..............
Finished in 0.547606 seconds.
1) Error:
test_should_create_line_item(LineItemsControllerTest):
ActiveRecord::RecordNotFound: Couldn't find Product without an ID
/home/rubys/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:272:in `find_with_ids'
/home/rubys/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:102:in `find'
/home/rubys/git/rails/activerecord/lib/active_record/base.rb:403:in `find'
/home/rubys/svn/rails4/Book/util/work-193/depot/app/controllers/line_items_controller.rb:46:in `create'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:145:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:11:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:433:in `_run__496012782__process_action__331404987__callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:408:in `_run_process_action_callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:88:in `run_callbacks'
/home/rubys/git/rails/actionpack/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `block in process_action'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:48:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:28:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rescue.rb:8:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:114:in `process'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:40:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/testing.rb:12:in `process_with_new_base_test'
/home/rubys/git/rails/actionpack/lib/action_controller/test_case.rb:390:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/test_case.rb:333:in `post'
test/functional/line_items_controller_test.rb:21:in `block (2 levels) in <class:LineItemsControllerTest>'
/home/rubys/git/rails/activesupport/lib/active_support/testing/assertions.rb:42:in `assert_difference'
test/functional/line_items_controller_test.rb:20:in `block in <class:LineItemsControllerTest>'
22 tests, 33 assertions, 0 failures, 1 errors, 0 skips
Test run options: --seed 18750
Errors running test:functionals!
Update parameters passed as well as expected target of redirect
edit test/functional/line_items_controller_test.rb
test "should create line_item" do
assert_difference('LineItem.count') do
post :create, :product_id => products(:ruby).id
end
assert_redirected_to cart_path(LineItem.last.cart_id)
end
rake test
(in /home/rubys/svn/rails4/Book/util/work-193/depot)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.3-r28190%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.......
Finished in 0.133621 seconds.
7 tests, 25 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 23714
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.3-r28190%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
......................
Finished in 0.762640 seconds.
22 tests, 35 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 58533
10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button