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
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.....
Finished in 0.343772 seconds.
5 tests, 23 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 53561
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.......E..............
Finished in 1.195133 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:309:in `find_with_ids'
/home/rubys/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:107:in `find'
/home/rubys/git/rails/activerecord/lib/active_record/base.rb:444:in `find'
/home/rubys/git/awdwr/edition4/work-192/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:167:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:10: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:416:in `_run__1787484660579726630__process_action__1406446248633156886__callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:81: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/rescue.rb:17:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:53:in `block in instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:53:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/params_wrapper.rb:198:in `process_action'
/home/rubys/git/rails/activerecord/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:121:in `process'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:45:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/testing.rb:17:in `process_with_new_base_test'
/home/rubys/git/rails/actionpack/lib/action_controller/test_case.rb:462:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/test_case.rb:49:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/test_case.rb:383:in `post'
/home/rubys/git/awdwr/edition4/work-192/depot/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:55:in `assert_difference'
/home/rubys/git/awdwr/edition4/work-192/depot/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 7263
Errors running test:functionals! #<RuntimeError: Command failed with status (1): [/home/rubys/.rvm/rubies/ruby-1.9.2-p290/bi...]>
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(assigns(:line_item).cart)
end
rake test
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.....
Finished in 0.403591 seconds.
5 tests, 23 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 29832
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
......................
Finished in 1.229374 seconds.
22 tests, 35 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 65471
10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button