This project is archived and is in readonly mode.

#2932 ✓committed
javan (at javan)

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

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

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) .........................

Comments and changes to this ticket

  • Michael Koziarski

    Michael Koziarski August 3rd, 2009 @ 06:17 AM

    • Tag changed from 2.3.3, assert_redirected_to to 2.3.3, assert_redirected_to, bugmash
  • Josh Nichols

    Josh Nichols August 8th, 2009 @ 08:50 PM

    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

  • Josh Nichols

    Josh Nichols August 8th, 2009 @ 08:54 PM

    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)
    
    
  • Dan Croak

    Dan Croak August 8th, 2009 @ 09:03 PM

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

  • Josh Nichols

    Josh Nichols August 8th, 2009 @ 10:45 PM

    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.

  • Josh Nichols

    Josh Nichols August 8th, 2009 @ 11:12 PM

    I opened #3015 as a more general case of this issue, and included a better patch.

  • Jeremy Kemper

    Jeremy Kemper August 8th, 2009 @ 11:45 PM

    • State changed from “new” to “resolved”
    • Milestone changed from 2.x to 2.3.4

    2-3-stable: ab6d295ce41ba2aad400474dcf45052e7b631b53

  • Jeremy Kemper

    Jeremy Kemper August 9th, 2009 @ 12:58 AM

    • 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
  • Jeremy Kemper

    Jeremy Kemper August 9th, 2009 @ 12:58 AM

    • State changed from “new” to “resolved”
    • Milestone changed from 2.x to 2.3.4

    GRR lighthouse.

  • Repository

    Repository August 9th, 2009 @ 05:14 AM

    • State changed from “resolved” to “committed”

    (from [ab6d295ce41ba2aad400474dcf45052e7b631b53]) Fix caller in assert_redirected_to deprecation warning.

    [#2932 state:committed] http://github.com/rails/rails/commit/ab6d295ce41ba2aad400474dcf4505...

  • Josh Nichols

    Josh Nichols August 9th, 2009 @ 07:54 AM

    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?

  • Jeremy Kemper

    Jeremy Kemper August 9th, 2009 @ 07:11 PM

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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages