diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb index 0942ea6..6bf3590 100644 --- a/app/controllers/notices_controller.rb +++ b/app/controllers/notices_controller.rb @@ -6,5 +6,11 @@ class NoticesController < ApplicationController @notice = App.report_error!(params[:data] || request.raw_post) render :xml => @notice end + + # Redirects a notice to the problem page. Useful when using User Information at Airbrake gem. + def locate + problem = Notice.find(params[:id]).problem + redirect_to app_err_path(problem.app, problem) + end end diff --git a/config/routes.rb b/config/routes.rb index 37667b2..7227aac 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,7 @@ Errbit::Application.routes.draw do # Hoptoad Notifier Routes match '/notifier_api/v2/notices' => 'notices#create' + match '/locate/:id' => 'notices#locate' match '/deploys.txt' => 'deploys#create' resources :notices, :only => [:show] diff --git a/spec/controllers/notices_controller_spec.rb b/spec/controllers/notices_controller_spec.rb index 488e33a..3673dd4 100644 --- a/spec/controllers/notices_controller_spec.rb +++ b/spec/controllers/notices_controller_spec.rb @@ -1,6 +1,9 @@ require 'spec_helper' describe NoticesController do + it_requires_authentication :for => { :locate => :get } + + let(:app) { Fabricate(:app) } context 'notices API' do before do @@ -44,5 +47,21 @@ describe NoticesController do end end + describe "GET /locate/:id" do + context 'when logged in as an admin' do + before(:each) do + @user = Fabricate(:admin) + sign_in @user + end + + it "should locate notice and redirect to problem" do + problem = Fabricate(:problem, :app => app, :environment => "production") + notice = Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) + get :locate, :id => notice.id + response.should redirect_to(app_err_path(problem.app, problem)) + end + end + end + end -- libgit2 0.21.2