Commit c22ad2ce072127bccfc27b5b9ee2edfee4668dc7
1 parent
eaaa3696
Exists in
master
and in
1 other branch
Render issue body
Showing
3 changed files
with
60 additions
and
6 deletions
Show diff stats
app/controllers/problems_controller.rb
@@ -6,7 +6,6 @@ | @@ -6,7 +6,6 @@ | ||
6 | # COLLECTION => :index, :all, :destroy_several, :resolve_several, :unresolve_several, :merge_several, :unmerge_several, :search | 6 | # COLLECTION => :index, :all, :destroy_several, :resolve_several, :unresolve_several, :merge_several, :unmerge_several, :search |
7 | class ProblemsController < ApplicationController | 7 | class ProblemsController < ApplicationController |
8 | 8 | ||
9 | - | ||
10 | include ProblemsSearcher | 9 | include ProblemsSearcher |
11 | 10 | ||
12 | before_filter :need_selected_problem, :only => [ | 11 | before_filter :need_selected_problem, :only => [ |
@@ -62,7 +61,7 @@ class ProblemsController < ApplicationController | @@ -62,7 +61,7 @@ class ProblemsController < ApplicationController | ||
62 | end | 61 | end |
63 | 62 | ||
64 | def create_issue | 63 | def create_issue |
65 | - body = "" # TODO render_issue_body | 64 | + body = render_to_string "issue_trackers/issue", layout: false, formats: [:txt] |
66 | title = "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}" | 65 | title = "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}" |
67 | 66 | ||
68 | issue = Issue.new(problem: problem, user: current_user, title: title, body: body) | 67 | issue = Issue.new(problem: problem, user: current_user, title: title, body: body) |
@@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
1 | +[See this exception on Errbit](<%= app_problem_url problem.app, problem %> "See this exception on Errbit") | ||
2 | +<% if notice = problem.notices.first %> | ||
3 | +# <%= notice.message %> # | ||
4 | +## Summary ## | ||
5 | +<% if notice.request['url'].present? %> | ||
6 | +### URL ### | ||
7 | +[<%= notice.request['url'] %>](<%= notice.request['url'] %>)" | ||
8 | +<% end %> | ||
9 | +### Where ### | ||
10 | +<%= notice.where %> | ||
11 | + | ||
12 | +### Occured ### | ||
13 | +<%= notice.created_at.to_s(:micro) %> | ||
14 | + | ||
15 | +### Similar ### | ||
16 | +<%= (notice.problem.notices_count - 1).to_s %> | ||
17 | + | ||
18 | +## Params ## | ||
19 | +``` | ||
20 | +<%= pretty_hash(notice.params) %> | ||
21 | +``` | ||
22 | + | ||
23 | +## Session ## | ||
24 | +``` | ||
25 | +<%= pretty_hash(notice.session) %> | ||
26 | +``` | ||
27 | + | ||
28 | +## Backtrace ## | ||
29 | +``` | ||
30 | +<% notice.backtrace_lines.each do |line| %><%= line.number %>: <%= line.file_relative %> -> **<%= line.method %>** | ||
31 | +<% end %> | ||
32 | +``` | ||
33 | + | ||
34 | +## Environment ## | ||
35 | + | ||
36 | +<table> | ||
37 | +<% for key, val in notice.env_vars %> | ||
38 | + <tr> | ||
39 | + <td><%= key %>:</td> | ||
40 | + <td><%= val %></td> | ||
41 | + </tr> | ||
42 | +<% end %> | ||
43 | +</table> | ||
44 | +<% end %> | ||
45 | + |
spec/controllers/problems_controller_spec.rb
@@ -12,9 +12,7 @@ describe ProblemsController do | @@ -12,9 +12,7 @@ describe ProblemsController do | ||
12 | let(:admin) { Fabricate(:admin) } | 12 | let(:admin) { Fabricate(:admin) } |
13 | let(:problem) { Fabricate(:problem, :app => app, :environment => "production") } | 13 | let(:problem) { Fabricate(:problem, :app => app, :environment => "production") } |
14 | 14 | ||
15 | - | ||
16 | describe "GET /problems" do | 15 | describe "GET /problems" do |
17 | - #render_views | ||
18 | context 'when logged in as an admin' do | 16 | context 'when logged in as an admin' do |
19 | before(:each) do | 17 | before(:each) do |
20 | sign_in admin | 18 | sign_in admin |
@@ -287,8 +285,9 @@ describe ProblemsController do | @@ -287,8 +285,9 @@ describe ProblemsController do | ||
287 | expect(line[0]).to eq(title) | 285 | expect(line[0]).to eq(title) |
288 | end | 286 | end |
289 | 287 | ||
290 | - it "should save the right body" do | ||
291 | - pending | 288 | + it "should renders the issue body" do |
289 | + post :create_issue, app_id: problem.app.id, id: problem.id, format: 'html' | ||
290 | + expect(response).to render_template("issue_trackers/issue") | ||
292 | end | 291 | end |
293 | 292 | ||
294 | it "should update the problem" do | 293 | it "should update the problem" do |
@@ -296,6 +295,17 @@ describe ProblemsController do | @@ -296,6 +295,17 @@ describe ProblemsController do | ||
296 | expect(problem.issue_link).to eq("http://example.com/mock-errbit") | 295 | expect(problem.issue_link).to eq("http://example.com/mock-errbit") |
297 | expect(problem.issue_type).to eq("mock") | 296 | expect(problem.issue_type).to eq("mock") |
298 | end | 297 | end |
298 | + | ||
299 | + | ||
300 | + context "when rendering views" do | ||
301 | + render_views | ||
302 | + | ||
303 | + it "should save the right body" do | ||
304 | + post :create_issue, app_id: problem.app.id, id: problem.id, format: 'html' | ||
305 | + line = issue_tracker.tracker.output.shift | ||
306 | + expect(line[1]).to include(app_problem_url problem.app, problem) | ||
307 | + end | ||
308 | + end | ||
299 | end | 309 | end |
300 | 310 | ||
301 | context "when app has no issue tracker" do | 311 | context "when app has no issue tracker" do |