Agile Web Development with Rails, Edition 4

10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button

9.4 Playtime

RuntimeError: Edit test/controllers/line_items_controller_test.rb failed at makedepot.rb:1025

Traceback:
  

Once again, get the tests working, and add tests for the smarter cart.

See that the tests fail.

rails test
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from included at /home/rubys/.rvm/gems/ruby-2.3.0/gems/turbolinks-2.5.3/lib/turbolinks/xhr_url_for.rb:7)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from included at /home/rubys/.rvm/gems/ruby-2.3.0/gems/turbolinks-2.5.3/lib/turbolinks/xhr_url_for.rb:7)
rails aborted!
ActiveRecord::NoEnvironmentInSchemaError: 

    
Environment data not found in the schema. To resolve this issue, run: 

    
	bin/rails db:environment:set RAILS_ENV=test

    
/home/rubys/git/rails/activerecord/lib/active_record/migration.rb:1259:in `last_stored_environment'
/home/rubys/git/rails/activerecord/lib/active_record/tasks/database_tasks.rb:48:in `check_protected_environments!'
/home/rubys/git/rails/activerecord/lib/active_record/railties/databases.rake:11:in `block (2 levels) in <top (required)>'
/home/rubys/git/rails/activerecord/lib/active_record/railties/databases.rake:375:in `block (3 levels) in <top (required)>'
/home/rubys/git/rails/railties/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/home/rubys/git/rails/railties/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task'
/home/rubys/git/rails/railties/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/home/rubys/git/rails/railties/lib/rails/command.rb:20:in `run'
/home/rubys/git/rails/railties/lib/rails/commands.rb:19:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:test:load => db:test:purge => db:check_protected_environments
(See full trace by running task with --trace)
/home/rubys/git/rails/activerecord/lib/active_record/migration.rb:578:in `check_pending!':  (ActiveRecord::PendingMigrationError)

    
Migrations are pending. To resolve this issue, run:

    
	bin/rails db:migrate RAILS_ENV=test

    
	from /home/rubys/git/rails/activerecord/lib/active_record/migration.rb:591:in `load_schema_if_pending!'
	from /home/rubys/git/rails/activerecord/lib/active_record/migration.rb:597:in `block in maintain_test_schema!'
	from /home/rubys/git/rails/activerecord/lib/active_record/migration.rb:828:in `suppress_messages'
	from /home/rubys/git/rails/activerecord/lib/active_record/migration.rb:602:in `method_missing'
	from /home/rubys/git/rails/activerecord/lib/active_record/migration.rb:597:in `maintain_test_schema!'
	from /home/rubys/git/rails/railties/lib/rails/test_help.rb:15:in `<top (required)>'
	from /home/rubys/git/rails/activesupport/lib/active_support/dependencies.rb:302:in `require'
	from /home/rubys/git/rails/activesupport/lib/active_support/dependencies.rb:302:in `block in require'
	from /home/rubys/git/rails/activesupport/lib/active_support/dependencies.rb:268:in `load_dependency'
	from /home/rubys/git/rails/activesupport/lib/active_support/dependencies.rb:302:in `require'
	from /home/rubys/git/awdwr/edition4/work-230/depot/test/test_helper.rb:3:in `<top (required)>'
	from /home/rubys/git/awdwr/edition4/work-230/depot/test/controllers/carts_controller_test.rb:1:in `require'
	from /home/rubys/git/awdwr/edition4/work-230/depot/test/controllers/carts_controller_test.rb:1:in `<top (required)>'
	from /home/rubys/git/rails/railties/lib/rails/test_unit/test_requirer.rb:11:in `require'
	from /home/rubys/git/rails/railties/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
	from /home/rubys/git/rails/railties/lib/rails/test_unit/test_requirer.rb:10:in `each'
	from /home/rubys/git/rails/railties/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
	from /home/rubys/git/rails/railties/lib/rails/test_unit/minitest_plugin.rb:75:in `plugin_rails_init'
	from /home/rubys/.rvm/gems/ruby-2.3.0@global/gems/minitest-5.8.3/lib/minitest.rb:74:in `block in init_plugins'
	from /home/rubys/.rvm/gems/ruby-2.3.0@global/gems/minitest-5.8.3/lib/minitest.rb:72:in `each'
	from /home/rubys/.rvm/gems/ruby-2.3.0@global/gems/minitest-5.8.3/lib/minitest.rb:72:in `init_plugins'
	from /home/rubys/.rvm/gems/ruby-2.3.0@global/gems/minitest-5.8.3/lib/minitest.rb:123:in `run'
	from /home/rubys/git/rails/railties/lib/rails/commands/test.rb:9:in `<top (required)>'
	from /home/rubys/git/rails/railties/lib/rails/commands/commands_tasks.rb:138:in `require'
	from /home/rubys/git/rails/railties/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
	from /home/rubys/git/rails/railties/lib/rails/commands/commands_tasks.rb:95:in `test'
	from /home/rubys/git/rails/railties/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
	from /home/rubys/git/rails/railties/lib/rails/command.rb:20:in `run'
	from /home/rubys/git/rails/railties/lib/rails/commands.rb:19:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'

Update parameters passed as well as expected target of redirect

edit test/controllers/line_items_controller_test.rb
#<IndexError: regexp not matched>
  /home/rubys/git/gorp/lib/gorp/edit.rb:91:in `edit'
  makedepot.rb:1025:in `block (3 levels) in <main>'
  /home/rubys/git/gorp/lib/gorp/edit.rb:111:in `instance_exec'
  /home/rubys/git/gorp/lib/gorp/edit.rb:111:in `block in dcl'
  /home/rubys/git/gorp/lib/gorp/edit.rb:109:in `sub!'
  /home/rubys/git/gorp/lib/gorp/edit.rb:109:in `dcl'
  makedepot.rb:1024:in `block (2 levels) in <main>'
  /home/rubys/git/gorp/lib/gorp/edit.rb:173:in `instance_exec'
  /home/rubys/git/gorp/lib/gorp/edit.rb:173:in `edit'
  makedepot.rb:1023:in `block in <main>'
  /home/rubys/git/gorp/lib/gorp/output.rb:59:in `block (4 levels) in <top (required)>'
  /home/rubys/git/gorp/lib/gorp/output.rb:49:in `each'
  /home/rubys/git/gorp/lib/gorp/output.rb:49:in `block (3 levels) in <top (required)>'
  /home/rubys/.rvm/gems/ruby-2.3.0/gems/builder-3.2.2/lib/builder/xmlbase.rb:175:in `_nested_structures'
  /home/rubys/.rvm/gems/ruby-2.3.0/gems/builder-3.2.2/lib/builder/xmlbase.rb:68:in `tag!'
  /home/rubys/.rvm/gems/ruby-2.3.0/gems/builder-3.2.2/lib/builder/xmlbase.rb:93:in `method_missing'
  /home/rubys/git/gorp/lib/gorp/output.rb:22:in `block (2 levels) in <top (required)>'
  /home/rubys/.rvm/gems/ruby-2.3.0/gems/builder-3.2.2/lib/builder/xmlbase.rb:175:in `_nested_structures'
  /home/rubys/.rvm/gems/ruby-2.3.0/gems/builder-3.2.2/lib/builder/xmlbase.rb:68:in `tag!'
  /home/rubys/.rvm/gems/ruby-2.3.0/gems/builder-3.2.2/lib/builder/xmlbase.rb:93:in `method_missing'
  /home/rubys/git/gorp/lib/gorp/output.rb:11:in `block in <top (required)>'
    
require 'test_helper'
 
class LineItemsControllerTest < ActionDispatch::IntegrationTest
  setup do
    @line_item = line_items(:one)
  end
 
  test "should get index" do
    get line_items_url
    assert_response :success
  end
 
  test "should get new" do
    get new_line_item_url
    assert_response :success
  end
 
  test "should create line_item" do
    assert_difference('LineItem.count') do
      post line_items_url, params: { line_item: { cart_id: @line_item.cart_id, product_id: @line_item.product_id } }
    end
 
    assert_redirected_to line_item_path(LineItem.last)
  end
 
  test "should show line_item" do
    get line_item_url(@line_item)
    assert_response :success
  end
 
  test "should get edit" do
    get edit_line_item_url(@line_item)
    assert_response :success
  end
 
  test "should update line_item" do
    patch line_item_url(@line_item), params: { line_item: { cart_id: @line_item.cart_id, product_id: @line_item.product_id } }
    assert_redirected_to line_item_path(@line_item)
  end
 
  test "should destroy line_item" do
    assert_difference('LineItem.count', -1) do
      delete line_item_url(@line_item)
    end
 
    assert_redirected_to line_items_path
  end
end

Rerun the previously failing test to verify the fix.

rails test test/controllers/line_items_controller_test.rb
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from included at /home/rubys/.rvm/gems/ruby-2.3.0/gems/turbolinks-2.5.3/lib/turbolinks/xhr_url_for.rb:7)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from included at /home/rubys/.rvm/gems/ruby-2.3.0/gems/turbolinks-2.5.3/lib/turbolinks/xhr_url_for.rb:7)
rails aborted!
ActiveRecord::NoEnvironmentInSchemaError: 

    
Environment data not found in the schema. To resolve this issue, run: 

    
	bin/rails db:environment:set RAILS_ENV=test

    
/home/rubys/git/rails/activerecord/lib/active_record/migration.rb:1259:in `last_stored_environment'
/home/rubys/git/rails/activerecord/lib/active_record/tasks/database_tasks.rb:48:in `check_protected_environments!'
/home/rubys/git/rails/activerecord/lib/active_record/railties/databases.rake:11:in `block (2 levels) in <top (required)>'
/home/rubys/git/rails/activerecord/lib/active_record/railties/databases.rake:375:in `block (3 levels) in <top (required)>'
/home/rubys/git/rails/railties/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/home/rubys/git/rails/railties/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task'
/home/rubys/git/rails/railties/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/home/rubys/git/rails/railties/lib/rails/command.rb:20:in `run'
/home/rubys/git/rails/railties/lib/rails/commands.rb:19:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:test:load => db:test:purge => db:check_protected_environments
(See full trace by running task with --trace)
/home/rubys/git/rails/activerecord/lib/active_record/migration.rb:578:in `check_pending!':  (ActiveRecord::PendingMigrationError)

    
Migrations are pending. To resolve this issue, run:

    
	bin/rails db:migrate RAILS_ENV=test

    
	from /home/rubys/git/rails/activerecord/lib/active_record/migration.rb:591:in `load_schema_if_pending!'
	from /home/rubys/git/rails/activerecord/lib/active_record/migration.rb:597:in `block in maintain_test_schema!'
	from /home/rubys/git/rails/activerecord/lib/active_record/migration.rb:828:in `suppress_messages'
	from /home/rubys/git/rails/activerecord/lib/active_record/migration.rb:602:in `method_missing'
	from /home/rubys/git/rails/activerecord/lib/active_record/migration.rb:597:in `maintain_test_schema!'
	from /home/rubys/git/rails/railties/lib/rails/test_help.rb:15:in `<top (required)>'
	from /home/rubys/git/rails/activesupport/lib/active_support/dependencies.rb:302:in `require'
	from /home/rubys/git/rails/activesupport/lib/active_support/dependencies.rb:302:in `block in require'
	from /home/rubys/git/rails/activesupport/lib/active_support/dependencies.rb:268:in `load_dependency'
	from /home/rubys/git/rails/activesupport/lib/active_support/dependencies.rb:302:in `require'
	from /home/rubys/git/awdwr/edition4/work-230/depot/test/test_helper.rb:3:in `<top (required)>'
	from /home/rubys/git/awdwr/edition4/work-230/depot/test/controllers/line_items_controller_test.rb:1:in `require'
	from /home/rubys/git/awdwr/edition4/work-230/depot/test/controllers/line_items_controller_test.rb:1:in `<top (required)>'
	from /home/rubys/git/rails/railties/lib/rails/test_unit/test_requirer.rb:11:in `require'
	from /home/rubys/git/rails/railties/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
	from /home/rubys/git/rails/railties/lib/rails/test_unit/test_requirer.rb:10:in `each'
	from /home/rubys/git/rails/railties/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
	from /home/rubys/git/rails/railties/lib/rails/test_unit/minitest_plugin.rb:75:in `plugin_rails_init'
	from /home/rubys/.rvm/gems/ruby-2.3.0@global/gems/minitest-5.8.3/lib/minitest.rb:74:in `block in init_plugins'
	from /home/rubys/.rvm/gems/ruby-2.3.0@global/gems/minitest-5.8.3/lib/minitest.rb:72:in `each'
	from /home/rubys/.rvm/gems/ruby-2.3.0@global/gems/minitest-5.8.3/lib/minitest.rb:72:in `init_plugins'
	from /home/rubys/.rvm/gems/ruby-2.3.0@global/gems/minitest-5.8.3/lib/minitest.rb:123:in `run'
	from /home/rubys/git/rails/railties/lib/rails/commands/test.rb:9:in `<top (required)>'
	from /home/rubys/git/rails/railties/lib/rails/commands/commands_tasks.rb:138:in `require'
	from /home/rubys/git/rails/railties/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
	from /home/rubys/git/rails/railties/lib/rails/commands/commands_tasks.rb:95:in `test'
	from /home/rubys/git/rails/railties/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
	from /home/rubys/git/rails/railties/lib/rails/command.rb:20:in `run'
	from /home/rubys/git/rails/railties/lib/rails/commands.rb:19:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'

10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button