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-p320/gems/rake-10.1.1/lib/rake/rake_test_loader
Started
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
.......
Finished in 0.329809 seconds.
7 tests, 25 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 36382
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/rake_test_loader
Started
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
.......E..............
Finished in 0.563383 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:289: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-30/depot/app/controllers/line_items_controller.rb:50: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:150: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:441:in `_run__4348429515401137004__process_action__1680733533186679063__callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:94: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:52:in `block in instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:52:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:119:in `process'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:41: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:414:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/test_case.rb:47:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/test_case.rb:357:in `post'
/home/rubys/git/awdwr/edition4/work-192-30/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:42:in `assert_difference'
/home/rubys/git/awdwr/edition4/work-192-30/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 21088
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(assigns(:line_item).cart)
end
Rerun the previously failing test to verify the fix.
ruby -I test test/functional/line_items_controller_test.rb
Loaded suite test/functional/line_items_controller_test
Started
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
.......
Finished in 0.342464 seconds.
7 tests, 10 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 62831
10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button