Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Deprecation warning for assert_redirected_to doesn't tell you where the offending code is

#2932

As of 2.3.3 assert_redirected_to warns you if you test against a partial hash of params, but it makes it very difficult to find that failing test. Here's a snip of the output from my functional tests running:

..............................................................................................................................................................DEPRECATION WARNING: Using assert_redirected_to with partial hash arguments is deprecated. Specify the full set arguments instead. (called from clean_backtrace at /Volumes/Inkling/gitinkling/vendor/rails/actionpack/lib/action_controller/test_case.rb:114) .........................

Reported by javan (at javan) · July 21st, 2009 @ 04:28 PM

State: committed
Milestone: 2.3.4
Assigned to: nobody
Importance: none

Activity

  1. Michael Koziarski
    Michael Koziarski
    • Tag changed from 2.3.3, assert_redirected_to to 2.3.3, assert_redirected_to, bugmash

    August 3rd, 2009 @ 06:17 AM

  2. Josh Nichols
    Josh Nichols

    I have found this deprecation notice not to be reproducible. I found where it should be displayed, but have no idea what arguments to pass to make it happen.

    Additionally, there does not seem to be a test for this deprecation in test/controllers/action_pack_assertions_test.rb

    August 8th, 2009 @ 08:50 PM

  3. Josh Nichols
    Josh Nichols

    I take that back... verified:

    Controller:

    class MonkeysController < ApplicationController
      def index

    redirect_to :controller =&gt; 'monkeys', :action =&gt; :show
    
    
    
    
    end
    def show
    end end

    Test:
    @@@ruby class MonkeysControllerTest < ActionController::TestCase
    test "assert_redirected_to" do

    get :index
    assert_redirected_to :action => :show
    

    end end

    
    And the output...
    
    DEPRECATION WARNING: Using assert_redirected_to with partial hash arguments is deprecated. Specify the full set arguments instead. (called from clean_backtrace at /Users/nichoj/code/experimental/2340-verification/vendor/rails/actionpack/lib/action_controller/test_case.rb:114)
    
    

    August 8th, 2009 @ 08:54 PM

  4. Dan Croak
    Dan Croak

    Josh is working on changing the output to include file and line number.

    August 8th, 2009 @ 09:03 PM

  5. Josh Nichols
    Josh Nichols

    So, I've attached a patch that tries to use backtrace_cleaner for Deprecation. It works for the example case, but there's a few tests it seems to break, when it enters the cleaning process.

    August 8th, 2009 @ 10:45 PM

  6. Josh Nichols
    Josh Nichols

    I opened #3015 use backtrace_cleaners when using Deprecation#warn as a more general case of this issue, and included a better patch.

    August 8th, 2009 @ 11:12 PM

  7. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to resolved
    • Milestone changed from 2.x to 2.3.4

    2-3-stable: ab6d295ce41ba2aad400474dcf45052e7b631b53

    August 8th, 2009 @ 11:45 PM

  8. Jeremy Kemper
    Jeremy Kemper
    • State changed from resolved to new
    • Tag changed from 2.3.3, assert_redirected_to, bugmash to 2.3.3, assert_redirected_to
    • Milestone changed from 2.3.4 to 2.x

    August 9th, 2009 @ 12:58 AM

  9. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to resolved
    • Milestone changed from 2.x to 2.3.4

    GRR lighthouse.

    August 9th, 2009 @ 12:58 AM

  10. Repository
  11. Josh Nichols
    Josh Nichols

    I'm a little confused why you'd go and apply super-specific fix for this, ie assert_redirected_to, when there's a fix for a more general problem of Deprecation.warn reporting the wrong line.

    I mean, I guess it's technically fixed for this particular reporting, but why make it brittle to what's calling it, and also having it remain for everything else using Deprecation.warn?

    August 9th, 2009 @ 07:54 AM

  12. Jeremy Kemper
    Jeremy Kemper

    Because it's quick and easy and your better, more general fix was not
    available yet!

    August 9th, 2009 @ 07:11 PM