brynary / rack-bug

Debugging toolbar for Rack applications implemented as middleware
MIT License
1.08k stars 104 forks source link

problem with profile, explain, select #22

Closed ebertech closed 14 years ago

ebertech commented 14 years ago

noticed that profile, explain and select in the queries tab are broken. The reason is in bug.rb you've got a condition:

if toolbar_requested? && ip_authorized? && password_authorized? && !@original_request.xhr? @toolbar.call(env) else @app.call(env) end

but the requests are xhr requests so they get sent to the app and the app says 404. My solution is:

         if toolbar_requested? && ip_authorized? && password_authorized? && non_toolbar_xhr?
          @toolbar.call(env)
        else
          @app.call(env)
        end
      end

    private 

      def non_toolbar_xhr?
        !@original_request.xhr? || @original_request.path =~ /^\/__rack_bug__/
      end
lukemelia commented 14 years ago

I think your solution makes sense. Would you mind packaging it up with a test and a patch?

ebertech commented 14 years ago

Hi,

Here's the patch: http://gist.github.com/575682 Here's the patch to the spec: http://gist.github.com/575687

There's already a test in there that makes sure XHR requests aren't modified and this just makes all of the SQL panel tests send in :xhr => true. I reran the tests and they all pass.

lukemelia commented 14 years ago

Looks good. I'll get it applied after dinner. Thanks! Would you like to be credited as "ebertech" or another name?

ebertech commented 14 years ago

Hi, ebertech is fine.

lukemelia commented 14 years ago

Applied in f15849bec3ebfe20eb28bd5b1ac161f74369a56d. Thanks.