Commit 6cb19c235400ed6ed566078f7afdcaabac0e28dd
Exists in
master
and in
1 other branch
Merge pull request #827 from stevecrozz/issue_tracker_templates
Refs #785 add md and txt issue tracker templates
Showing
6 changed files
with
92 additions
and
41 deletions
Show diff stats
app/controllers/problems_controller.rb
@@ -61,7 +61,7 @@ class ProblemsController < ApplicationController | @@ -61,7 +61,7 @@ class ProblemsController < ApplicationController | ||
61 | end | 61 | end |
62 | 62 | ||
63 | def create_issue | 63 | def create_issue |
64 | - body = render_to_string "issue_trackers/issue", layout: false, formats: [:txt] | 64 | + body = render_to_string "issue_trackers/issue", layout: false, formats: [:md] |
65 | title = "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}" | 65 | title = "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}" |
66 | 66 | ||
67 | 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) |
app/helpers/hash_helper.rb
@@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
1 | +[See this exception on Errbit](<%= app_problem_url problem.app, problem %>) | ||
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 | +<% if notice.env_vars.present? %> | ||
35 | +## Environment ## | ||
36 | +| Key | Value | | ||
37 | +|------------|------------| | ||
38 | +<% notice.env_vars.each do |key, val| %>| <%= key %> | <%= val %> | | ||
39 | +<% end %> | ||
40 | +<% end %> | ||
41 | +<% end %> |
app/views/issue_trackers/issue.txt.erb
1 | -[See this exception on Errbit](<%= app_problem_url problem.app, problem %> "See this exception on Errbit") | 1 | +Errbit link: <%= app_problem_url problem.app, problem %> |
2 | <% if notice = problem.notices.first %> | 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 | -``` | 3 | +<% notice.message %> |
22 | 4 | ||
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 %>** | 5 | +Summary |
6 | +------- | ||
7 | +<% if notice.request['url'].present? %> | ||
8 | +URL: <%= notice.request['url'] %> | ||
31 | <% end %> | 9 | <% 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> | 10 | +Where: <%= notice.where %> |
11 | +Occured: <%= notice.created_at.to_s(:micro) %> | ||
12 | +Similar: <%= (notice.problem.notices_count - 1).to_s %> | ||
13 | +Params: <%= pretty_hash notice.params %> | ||
14 | +Session: <%= pretty_hash notice.session %> | ||
15 | +Env: <%= pretty_hash notice.env_vars %> | ||
16 | + | ||
17 | +Backtrace | ||
18 | +--------- | ||
19 | +<% notice.backtrace_lines.each do |line| %><%= sprintf('%5d: %s **%s', line.number, line.file_relative, line.method) %> | ||
42 | <% end %> | 20 | <% end %> |
43 | -</table> | ||
44 | <% end %> | 21 | <% end %> |
45 | - |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +describe "issue_trackers/issue.md.erb", type: 'view' do | ||
2 | + let(:problem) { | ||
3 | + problem = Fabricate(:problem) | ||
4 | + Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) | ||
5 | + problem | ||
6 | + } | ||
7 | + | ||
8 | + before do | ||
9 | + allow(view).to receive(:problem).and_return(problem) | ||
10 | + end | ||
11 | + | ||
12 | + it "has the problem url" do | ||
13 | + render | ||
14 | + expect(rendered).to match(app_problem_url problem.app, problem) | ||
15 | + end | ||
16 | +end |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +describe "issue_trackers/issue.txt.erb", type: 'view' do | ||
2 | + let(:problem) { | ||
3 | + problem = Fabricate(:problem) | ||
4 | + Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) | ||
5 | + problem | ||
6 | + } | ||
7 | + | ||
8 | + before do | ||
9 | + allow(view).to receive(:problem).and_return(problem) | ||
10 | + end | ||
11 | + | ||
12 | + it "has the problem url" do | ||
13 | + render | ||
14 | + expect(rendered).to match(app_problem_url problem.app, problem) | ||
15 | + end | ||
16 | +end |