Skip to content

Commit 1892774

Browse files
authored
allow showing problem by id (errbit#1467)
Co-authored-by: burnettk <[email protected]>
1 parent c9a6c35 commit 1892774

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

app/controllers/problems_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ def show
5656
@comment = Comment.new
5757
end
5858

59+
def show_by_id
60+
problem = Problem.find(params[:id])
61+
redirect_to app_problem_path(problem.app, problem)
62+
end
63+
5964
def xhr_sparkline
6065
render partial: 'problems/sparkline', layout: false
6166
end

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
end
5858
end
5959

60+
get 'problems/:id' => 'problems#show_by_id'
61+
6062
get 'health/readiness' => 'health#readiness'
6163
get 'health/liveness' => 'health#liveness'
6264
get 'health/api-key-tester' => 'health#api_key_tester'

spec/controllers/problems_controller_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,21 @@
122122
end
123123
end
124124

125+
# you do not need an app id, strictly speaking, to find
126+
# a problem, and if your metrics system does not happen
127+
# to know the app id, but does know the problem id,
128+
# it can be handy to have a way to link in to errbit.
129+
describe "GET /problems/:id" do
130+
before do
131+
sign_in user
132+
end
133+
134+
it "should redirect to the standard problems page" do
135+
get :show_by_id, id: err.problem.id
136+
expect(response).to redirect_to(app_problem_path(app, err.problem.id))
137+
end
138+
end
139+
125140
describe "GET /apps/:app_id/problems/:id" do
126141
before do
127142
sign_in user

0 commit comments

Comments
 (0)