redmine_airbrake_backend 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +11 -2
- data/CHANGELOG.md +4 -0
- data/app/controllers/concerns/airbrake_issue_finding.rb +39 -0
- data/app/controllers/concerns/airbrake_issue_handling.rb +3 -32
- data/lib/redmine_airbrake_backend.rb +4 -0
- data/lib/redmine_airbrake_backend/backtrace_element.rb +1 -1
- data/lib/redmine_airbrake_backend/error.rb +3 -3
- data/lib/redmine_airbrake_backend/version.rb +1 -1
- data/redmine_airbrake_backend.gemspec +1 -1
- data/test/test_helper.rb +6 -1
- data/test/unit/notice_test.rb +66 -46
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37936f35cac6d9858dd65014e0e9592a794990c08990b4b7918ae5cab3c92c8e
|
4
|
+
data.tar.gz: 42e2e65994e3302da7e71cd910aac5fefb6ac6d4bbf0f22b091fa1cb2e796894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb04ff49d11b6471db9c9f33fd4882344847dabbaa3ba0708087aa6d4d74cd97516f8ce8392e0064eb3a6304c01af86d8e86c09e550664e815eb168c1247bbaa
|
7
|
+
data.tar.gz: 6d461674d8bc48dc7b22ae4ea1da383ab903b115ec0661843aad58805f98de7ebfb7c171c5840190f53823d8355e44bea25b8608f3be1a85a13c2a6dd1310b73
|
data/.gitlab-ci.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
stages:
|
2
2
|
- build
|
3
|
+
- test
|
3
4
|
- codequality
|
4
5
|
- security
|
5
6
|
|
@@ -7,17 +8,25 @@ build:
|
|
7
8
|
stage: build
|
8
9
|
image: ruby:2.5
|
9
10
|
script:
|
10
|
-
- gem install bundler --no-
|
11
|
+
- gem install bundler --no-document
|
11
12
|
- bundle update
|
12
13
|
artifacts:
|
13
14
|
paths:
|
14
15
|
- Gemfile.lock
|
15
16
|
|
17
|
+
test:
|
18
|
+
stage: test
|
19
|
+
image: ruby:2.5
|
20
|
+
script:
|
21
|
+
- gem install bundler --no-document
|
22
|
+
- bundle update
|
23
|
+
- rake test
|
24
|
+
|
16
25
|
rubocop:
|
17
26
|
stage: codequality
|
18
27
|
image: ruby:2.5
|
19
28
|
script:
|
20
|
-
- gem install rubocop --no-
|
29
|
+
- gem install rubocop --no-document
|
21
30
|
- rubocop
|
22
31
|
|
23
32
|
dependency_scanning:
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Handling for creating / updating issues
|
4
|
+
module AirbrakeIssueFinding
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
include AirbrakeAttachments
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
# Load or initialize issue by project, tracker and airbrake hash or similarity
|
11
|
+
def find_or_initialize_issue(notice)
|
12
|
+
find_issue_by_airbrake_id(notice) || initialize_issue(notice)
|
13
|
+
end
|
14
|
+
|
15
|
+
def find_issue_by_airbrake_id(notice)
|
16
|
+
issue_ids = CustomValue
|
17
|
+
.where(customized_type: Issue.name, custom_field_id: notice_hash_field.id, value: notice.id)
|
18
|
+
.pluck(:customized_id)
|
19
|
+
|
20
|
+
Issue.find_by(id: issue_ids, project_id: @project.id, tracker_id: @tracker.id)
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize_issue(notice)
|
24
|
+
issue = Issue.new(
|
25
|
+
subject: notice.subject,
|
26
|
+
project: @project,
|
27
|
+
tracker: @tracker,
|
28
|
+
author: User.current,
|
29
|
+
category: @category,
|
30
|
+
priority: @priority,
|
31
|
+
description: render_description(notice),
|
32
|
+
assigned_to: @assignee
|
33
|
+
)
|
34
|
+
|
35
|
+
add_attachments_to_issue(issue, notice)
|
36
|
+
|
37
|
+
issue
|
38
|
+
end
|
39
|
+
end
|
@@ -5,6 +5,7 @@ require 'tempfile'
|
|
5
5
|
# Handling for creating / updating issues
|
6
6
|
module AirbrakeIssueHandling
|
7
7
|
extend ActiveSupport::Concern
|
8
|
+
include AirbrakeIssueFinding
|
8
9
|
include AirbrakeAttachments
|
9
10
|
|
10
11
|
private
|
@@ -30,36 +31,6 @@ module AirbrakeIssueHandling
|
|
30
31
|
@issue = nil unless @issue.save
|
31
32
|
end
|
32
33
|
|
33
|
-
# Load or initialize issue by project, tracker and airbrake hash
|
34
|
-
def find_or_initialize_issue(notice)
|
35
|
-
issue_ids = CustomValue
|
36
|
-
.where(customized_type: Issue.name, custom_field_id: notice_hash_field.id, value: notice.id)
|
37
|
-
.pluck(:customized_id)
|
38
|
-
|
39
|
-
issue = Issue.find_by(id: issue_ids, project_id: @project.id, tracker_id: @tracker.id)
|
40
|
-
|
41
|
-
return issue if issue.present?
|
42
|
-
|
43
|
-
initialize_issue(notice)
|
44
|
-
end
|
45
|
-
|
46
|
-
def initialize_issue(notice)
|
47
|
-
issue = Issue.new(
|
48
|
-
subject: notice.subject,
|
49
|
-
project: @project,
|
50
|
-
tracker: @tracker,
|
51
|
-
author: User.current,
|
52
|
-
category: @category,
|
53
|
-
priority: @priority,
|
54
|
-
description: render_description(notice),
|
55
|
-
assigned_to: @assignee
|
56
|
-
)
|
57
|
-
|
58
|
-
add_attachments_to_issue(issue, notice)
|
59
|
-
|
60
|
-
issue
|
61
|
-
end
|
62
|
-
|
63
34
|
def update_occurrences(issue, custom_field_values)
|
64
35
|
return if occurrences_field.blank?
|
65
36
|
|
@@ -97,8 +68,8 @@ module AirbrakeIssueHandling
|
|
97
68
|
def reopen_issue(issue, notice)
|
98
69
|
return if notice.environment_name.blank?
|
99
70
|
|
100
|
-
desc
|
101
|
-
desc
|
71
|
+
desc = "*Issue reopened after occurring again in _#{notice.environment_name}_ environment.*"
|
72
|
+
desc += "\n\n#{render_description(notice)}" if issue_reopen_repeat_description?
|
102
73
|
|
103
74
|
issue.status = issue.tracker.default_status
|
104
75
|
|
@@ -26,9 +26,9 @@ module RedmineAirbrakeBackend
|
|
26
26
|
|
27
27
|
def generate_id
|
28
28
|
h = []
|
29
|
-
h << RedmineAirbrakeBackend.
|
30
|
-
h << RedmineAirbrakeBackend.
|
31
|
-
h += @backtrace.map(&:checksum)
|
29
|
+
h << RedmineAirbrakeBackend.filter(@type)
|
30
|
+
h << RedmineAirbrakeBackend.filter(@message)
|
31
|
+
h += @backtrace.map(&:checksum)
|
32
32
|
|
33
33
|
Digest::MD5.hexdigest(h.compact.join("\n"))
|
34
34
|
end
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.homepage = 'https://gitlab.com/ydkn/redmine_airbrake_backend'
|
17
17
|
spec.license = 'MIT'
|
18
18
|
|
19
|
-
spec.files = `git ls-files`.split(
|
19
|
+
spec.files = `git ls-files`.split("\n")
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
data/test/test_helper.rb
CHANGED
data/test/unit/notice_test.rb
CHANGED
@@ -1,52 +1,72 @@
|
|
1
|
-
|
1
|
+
require_relative '../test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
test 'parse' do
|
5
|
-
api_key = {
|
6
|
-
api_key: 'foobar',
|
7
|
-
project: 'foo'
|
8
|
-
}.to_json
|
9
|
-
xml_data = <<-EOS
|
10
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
11
|
-
<notice version="2.4">
|
12
|
-
<api-key>#{api_key}</api-key>
|
13
|
-
<notifier>
|
14
|
-
<name>Airbrake Notifier</name>
|
15
|
-
<version>3.1.6</version>
|
16
|
-
<url>http://api.airbrake.io</url>
|
17
|
-
</notifier>
|
18
|
-
<error>
|
19
|
-
<class>RuntimeError</class>
|
20
|
-
<message>RuntimeError: I've made a huge mistake</message>
|
21
|
-
<backtrace>
|
22
|
-
<line method="public" file="/testapp/app/models/user.rb" number="53"/>
|
23
|
-
<line method="index" file="/testapp/app/controllers/users_controller.rb" number="14"/>
|
24
|
-
</backtrace>
|
25
|
-
</error>
|
26
|
-
<request>
|
27
|
-
<url>http://example.com</url>
|
28
|
-
<component/>
|
29
|
-
<action/>
|
30
|
-
<cgi-data>
|
31
|
-
<var key="SERVER_NAME">example.org</var>
|
32
|
-
<var key="HTTP_USER_AGENT">Mozilla</var>
|
33
|
-
</cgi-data>
|
34
|
-
</request>
|
35
|
-
<server-environment>
|
36
|
-
<project-root>/testapp</project-root>
|
37
|
-
<environment-name>production</environment-name>
|
38
|
-
<app-version>1.0.0</app-version>
|
39
|
-
</server-environment>
|
40
|
-
</notice>
|
41
|
-
EOS
|
3
|
+
require 'redmine_airbrake_backend/notice'
|
42
4
|
|
43
|
-
|
44
|
-
|
45
|
-
|
5
|
+
class NoticeTest < ActiveSupport::TestCase
|
6
|
+
test 'parse notice request' do
|
7
|
+
params = {
|
8
|
+
"errors" => [{
|
9
|
+
"type" => "OpenURI::HTTPError",
|
10
|
+
"message" => "404 Not Found",
|
11
|
+
"backtrace" => [{
|
12
|
+
"file" => "/usr/local/lib/ruby/2.5.0/open-uri.rb",
|
13
|
+
"line" => 377,
|
14
|
+
"function" => "open_http"
|
15
|
+
}, {
|
16
|
+
"file" => "/usr/local/lib/ruby/2.5.0/open-uri.rb",
|
17
|
+
"line" => 755,
|
18
|
+
"function" => "buffer_open"
|
19
|
+
}, {
|
20
|
+
"file" => "/GEM_ROOT/gems/activesupport-5.2.1/lib/active_support/dependencies.rb",
|
21
|
+
"line" => 287,
|
22
|
+
"function" => "block in require"
|
23
|
+
}, {
|
24
|
+
"file" => "/GEM_ROOT/gems/activesupport-5.2.1/lib/active_support/dependencies.rb",
|
25
|
+
"line" => 253,
|
26
|
+
"function" => "load_dependency"
|
27
|
+
}, {
|
28
|
+
"file" => "/GEM_ROOT/gems/activesupport-5.2.1/lib/active_support/dependencies.rb",
|
29
|
+
"line" => 287,
|
30
|
+
"function" => "require"
|
31
|
+
}, {
|
32
|
+
"file" => "bin/rails",
|
33
|
+
"line" => 4,
|
34
|
+
"function" => "<main>"
|
35
|
+
}]
|
36
|
+
}],
|
37
|
+
"context" => {
|
38
|
+
"rootDirectory" => "/app",
|
39
|
+
"environment" => "production",
|
40
|
+
"hostname" => "foobar.fail",
|
41
|
+
"severity" => "error",
|
42
|
+
"os" => "x86_64-linux-musl",
|
43
|
+
"language" => "ruby/2.5.3",
|
44
|
+
"notifier" => { "name" => "airbrake-ruby", "version" => "2.12.0" },
|
45
|
+
"component" => "MyComponent",
|
46
|
+
"action" => "MyAction"
|
47
|
+
},
|
48
|
+
"environment" => {
|
49
|
+
"program_name" => "bin/rails"
|
50
|
+
},
|
51
|
+
"session" => {},
|
52
|
+
"params" => {
|
53
|
+
"foo" => "bar",
|
54
|
+
"locale" => "en"
|
55
|
+
},
|
56
|
+
"project_id" => "1"
|
57
|
+
}.with_indifferent_access
|
46
58
|
|
47
|
-
|
59
|
+
notice = RedmineAirbrakeBackend::Notice.new(
|
60
|
+
errors: params[:errors].map { |e| RedmineAirbrakeBackend::Error.new(e) },
|
61
|
+
params: params[:params],
|
62
|
+
session: params[:session],
|
63
|
+
context: params[:context],
|
64
|
+
environment: params[:environment]
|
65
|
+
)
|
48
66
|
|
49
|
-
|
50
|
-
|
67
|
+
assert_equal(1, notice.errors.length)
|
68
|
+
assert_equal('OpenURI::HTTPError', notice.errors.first.type)
|
69
|
+
assert_equal('404 Not Found', notice.errors.first.message)
|
70
|
+
assert_equal('a16abb78bf4b40460258c72cdc971ca0', notice.id)
|
51
71
|
end
|
52
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_airbrake_backend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Schwab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- app/controllers/airbrake_project_settings_controller.rb
|
87
87
|
- app/controllers/airbrake_report_controller.rb
|
88
88
|
- app/controllers/concerns/airbrake_attachments.rb
|
89
|
+
- app/controllers/concerns/airbrake_issue_finding.rb
|
89
90
|
- app/controllers/concerns/airbrake_issue_handling.rb
|
90
91
|
- app/controllers/concerns/airbrake_rendering.rb
|
91
92
|
- app/helpers/airbrake_helper.rb
|
@@ -135,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
- !ruby/object:Gem::Version
|
136
137
|
version: '0'
|
137
138
|
requirements: []
|
138
|
-
|
139
|
-
rubygems_version: 2.7.7
|
139
|
+
rubygems_version: 3.0.2
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: This plugin provides the necessary API to use Redmine as a Airbrake backend
|