redmine_airbrake_backend 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +42 -0
  3. data/.rubocop.yml +13 -0
  4. data/CHANGELOG.md +8 -0
  5. data/Gemfile +3 -1
  6. data/README.md +0 -4
  7. data/Rakefile +2 -1
  8. data/app/controllers/airbrake_controller.rb +32 -137
  9. data/app/controllers/airbrake_notice_controller.rb +8 -6
  10. data/app/controllers/airbrake_project_settings_controller.rb +6 -4
  11. data/app/controllers/airbrake_report_controller.rb +2 -0
  12. data/app/controllers/concerns/airbrake_attachments.rb +56 -0
  13. data/app/controllers/concerns/airbrake_issue_handling.rb +109 -0
  14. data/app/controllers/concerns/airbrake_rendering.rb +16 -0
  15. data/app/helpers/airbrake_helper.rb +35 -23
  16. data/app/models/airbrake_project_setting.rb +2 -0
  17. data/bin/rails +3 -3
  18. data/config/routes.rb +2 -0
  19. data/db/migrate/20130708102357_create_airbrake_project_settings.rb +3 -0
  20. data/db/migrate/20131003151228_add_reopen_repeat_description.rb +3 -0
  21. data/lib/redmine_airbrake_backend.rb +3 -0
  22. data/lib/redmine_airbrake_backend/backtrace_element.rb +6 -4
  23. data/lib/redmine_airbrake_backend/engine.rb +27 -25
  24. data/lib/redmine_airbrake_backend/error.rb +2 -0
  25. data/lib/redmine_airbrake_backend/ios_report.rb +33 -28
  26. data/lib/redmine_airbrake_backend/notice.rb +43 -27
  27. data/lib/redmine_airbrake_backend/patches/issue_category.rb +10 -5
  28. data/lib/redmine_airbrake_backend/patches/issue_priority.rb +10 -5
  29. data/lib/redmine_airbrake_backend/patches/project.rb +10 -5
  30. data/lib/redmine_airbrake_backend/patches/projects_helper.rb +16 -11
  31. data/lib/redmine_airbrake_backend/patches/tracker.rb +10 -5
  32. data/lib/redmine_airbrake_backend/version.rb +3 -1
  33. data/lib/tasks/test.rake +11 -9
  34. data/redmine_airbrake_backend.gemspec +10 -6
  35. data/test/unit/notice_test.rb +1 -1
  36. metadata +24 -5
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'redmine_airbrake_backend/error'
2
4
 
3
5
  module RedmineAirbrakeBackend
@@ -7,32 +9,18 @@ module RedmineAirbrakeBackend
7
9
  attr_reader :errors, :params, :session, :context, :environment, :application, :attachments
8
10
 
9
11
  def initialize(options)
10
- # Errors
11
- @errors = options[:errors].compact
12
-
13
- # Params
14
- @params = options[:params]
15
-
16
- # Session
17
- @session = options[:session]
12
+ # Set instance variables from options
13
+ instance_variables_from_options(options, %i[errors params session environment application])
14
+ instance_variables_from_options(options, %i[attachments], ensure_array: true)
18
15
 
19
16
  # Context
20
- @context = options[:context].reject { |k, v| ['notifier'].include?(k) }
21
-
22
- # Environment
23
- @environment = options[:environment]
24
-
25
- # Application
26
- @application = options[:application]
27
-
28
- # Attachments
29
- @attachments = (options[:attachments].presence || []).compact
17
+ @context = context_from_options(options)
30
18
 
31
19
  # Environment name
32
- @environment_name = options[:context][:environment].presence rescue nil
20
+ @environment_name = environment_name_from_options(options)
33
21
 
34
22
  # Type
35
- @type = options[:type] || (options[:context][:language].split('/', 2).first.downcase rescue nil)
23
+ @type = type_from_options(options)
36
24
 
37
25
  # Error ID
38
26
  @id = generate_id
@@ -43,21 +31,49 @@ module RedmineAirbrakeBackend
43
31
 
44
32
  private
45
33
 
34
+ def instance_variables_from_options(options, keys, opts = {})
35
+ keys.each do |key|
36
+ value = options[key]
37
+
38
+ value = value.compact if value.is_a?(Array) || value.is_a?(Hash)
39
+ value = Array(value) if opts[:ensure_array]
40
+
41
+ instance_variable_set("@#{key}", value)
42
+ end
43
+ end
44
+
45
+ def context_from_options(options)
46
+ options[:context].reject { |k, _| ['notifier'].include?(k) }
47
+ end
48
+
49
+ def environment_name_from_options(options)
50
+ return nil if options[:context].blank?
51
+
52
+ options[:context][:environment].presence
53
+ end
54
+
55
+ def type_from_options(options)
56
+ return options[:type] if options[:type].present?
57
+
58
+ return nil if options[:context].blank? || options[:context][:language].blank?
59
+
60
+ options[:context][:language].strip.split('/', 2).first.downcase
61
+ end
62
+
46
63
  def generate_id
47
64
  Digest::MD5.hexdigest(@errors.map(&:id).join("\n"))
48
65
  end
49
66
 
50
67
  def generate_subject
51
68
  error = @errors.first
52
- s = ''
53
69
 
54
- if error.type.blank? || error.message.starts_with?("#{error.type}:")
55
- s = "[#{@id[0..7]}] #{error.message}"
56
- else
57
- s = "[#{@id[0..7]}] #{error.type}: #{error.message}"
58
- end
70
+ subject = if error.type.blank? || error.message.starts_with?("#{error.type}:")
71
+ "[#{@id[0..7]}] #{error.message}"
72
+ else
73
+ "[#{@id[0..7]}] #{error.type}: #{error.message}"
74
+ end
59
75
 
60
- s[0..254].strip
76
+ subject[0..254].strip
61
77
  end
62
78
  end
63
79
  end
@@ -1,11 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/concern'
2
4
 
3
- module RedmineAirbrakeBackend::Patches
4
- module IssueCategory
5
- extend ActiveSupport::Concern
5
+ module RedmineAirbrakeBackend
6
+ module Patches
7
+ # Patches for IssueCategory
8
+ module IssueCategory
9
+ extend ActiveSupport::Concern
6
10
 
7
- included do
8
- has_many :airbrake_project_settings, foreign_key: :category_id, dependent: :nullify
11
+ included do
12
+ has_many :airbrake_project_settings, foreign_key: :category_id, dependent: :nullify
13
+ end
9
14
  end
10
15
  end
11
16
  end
@@ -1,11 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/concern'
2
4
 
3
- module RedmineAirbrakeBackend::Patches
4
- module IssuePriority
5
- extend ActiveSupport::Concern
5
+ module RedmineAirbrakeBackend
6
+ module Patches
7
+ # Patches for IssuePriority
8
+ module IssuePriority
9
+ extend ActiveSupport::Concern
6
10
 
7
- included do
8
- has_many :airbrake_project_settings, dependent: :nullify
11
+ included do
12
+ has_many :airbrake_project_settings, dependent: :nullify
13
+ end
9
14
  end
10
15
  end
11
16
  end
@@ -1,11 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/concern'
2
4
 
3
- module RedmineAirbrakeBackend::Patches
4
- module Project
5
- extend ActiveSupport::Concern
5
+ module RedmineAirbrakeBackend
6
+ module Patches
7
+ # Patches for Project
8
+ module Project
9
+ extend ActiveSupport::Concern
6
10
 
7
- included do
8
- has_one :airbrake_settings, class_name: AirbrakeProjectSetting.name, dependent: :destroy
11
+ included do
12
+ has_one :airbrake_settings, class_name: AirbrakeProjectSetting.name, dependent: :destroy
13
+ end
9
14
  end
10
15
  end
11
16
  end
@@ -1,25 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/concern'
2
4
 
3
- module RedmineAirbrakeBackend::Patches
4
- module ProjectsHelper
5
- extend ActiveSupport::Concern
5
+ module RedmineAirbrakeBackend
6
+ module Patches
7
+ # Patches for ProjectsHelper
8
+ module ProjectsHelper
9
+ extend ActiveSupport::Concern
6
10
 
7
- included do
8
- alias_method_chain :project_settings_tabs, :airbrake_backend_tab
9
- end
11
+ included do
12
+ alias_method_chain :project_settings_tabs, :airbrake_backend_tab
13
+ end
10
14
 
11
- # add airbrake tab to project settings
12
- def project_settings_tabs_with_airbrake_backend_tab
13
- tabs = project_settings_tabs_without_airbrake_backend_tab
15
+ # add airbrake tab to project settings
16
+ def project_settings_tabs_with_airbrake_backend_tab
17
+ tabs = project_settings_tabs_without_airbrake_backend_tab
14
18
 
15
- tabs.push(
19
+ tabs.push(
16
20
  name: 'airbrake',
17
21
  action: :manage_airbrake,
18
22
  partial: 'projects/settings/airbrake',
19
23
  label: :project_module_airbrake
20
24
  )
21
25
 
22
- tabs.select { |tab| User.current.allowed_to?(tab[:action], @project) }
26
+ tabs.select { |tab| User.current.allowed_to?(tab[:action], @project) }
27
+ end
23
28
  end
24
29
  end
25
30
  end
@@ -1,11 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/concern'
2
4
 
3
- module RedmineAirbrakeBackend::Patches
4
- module Tracker
5
- extend ActiveSupport::Concern
5
+ module RedmineAirbrakeBackend
6
+ module Patches
7
+ # Patches for Tracker
8
+ module Tracker
9
+ extend ActiveSupport::Concern
6
10
 
7
- included do
8
- has_many :airbrake_project_settings, dependent: :nullify
11
+ included do
12
+ has_many :airbrake_project_settings, dependent: :nullify
13
+ end
9
14
  end
10
15
  end
11
16
  end
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RedmineAirbrakeBackend
2
4
  # Version of this gem
3
- VERSION = '1.2.1'
5
+ VERSION = '1.2.2'
4
6
  end
data/lib/tasks/test.rake CHANGED
@@ -1,30 +1,32 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :redmine do
2
4
  namespace :airbrake_backend do
3
5
  desc 'Runs the plugin tests.'
4
6
  task :test do
5
- Rake::Task["redmine:airbrake_backend:test:units"].invoke
6
- Rake::Task["redmine:airbrake_backend:test:functionals"].invoke
7
- Rake::Task["redmine:airbrake_backend:test:integration"].invoke
7
+ Rake::Task['redmine:airbrake_backend:test:units'].invoke
8
+ Rake::Task['redmine:airbrake_backend:test:functionals'].invoke
9
+ Rake::Task['redmine:airbrake_backend:test:integration'].invoke
8
10
  end
9
11
 
10
12
  namespace :test do
11
13
  desc 'Runs the plugin unit tests.'
12
- Rake::TestTask.new :units => "db:test:prepare" do |t|
13
- t.libs << "test"
14
+ Rake::TestTask.new units: 'db:test:prepare' do |t|
15
+ t.libs << 'test'
14
16
  t.verbose = true
15
17
  t.pattern = "#{RedmineAirbrakeBackend.directory}/test/unit/**/*_test.rb"
16
18
  end
17
19
 
18
20
  desc 'Runs the plugin functional tests.'
19
- Rake::TestTask.new :functionals => "db:test:prepare" do |t|
20
- t.libs << "test"
21
+ Rake::TestTask.new functionals: 'db:test:prepare' do |t|
22
+ t.libs << 'test'
21
23
  t.verbose = true
22
24
  t.pattern = "#{RedmineAirbrakeBackend.directory}/test/functional/**/*_test.rb"
23
25
  end
24
26
 
25
27
  desc 'Runs the plugin integration tests.'
26
- Rake::TestTask.new :integration => "db:test:prepare" do |t|
27
- t.libs << "test"
28
+ Rake::TestTask.new integration: 'db:test:prepare' do |t|
29
+ t.libs << 'test'
28
30
  t.verbose = true
29
31
  t.pattern = "#{RedmineAirbrakeBackend.directory}/test/integration/**/*_test.rb"
30
32
  end
@@ -1,19 +1,22 @@
1
- # coding: utf-8
2
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
3
4
 
4
5
  require 'redmine_airbrake_backend/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
8
+ spec.required_ruby_version = '>= 2.4.0'
9
+
7
10
  spec.name = 'redmine_airbrake_backend'
8
11
  spec.version = RedmineAirbrakeBackend::VERSION
9
12
  spec.authors = ['Florian Schwab']
10
13
  spec.email = ['me@ydkn.de']
11
- spec.description = %q(Plugin which adds Airbrake support to Redmine)
12
- spec.summary = %q(This plugin provides the necessary API to use Redmine as a Airbrake backend)
13
- spec.homepage = 'https://github.com/ydkn/redmine_airbrake_backend'
14
+ spec.description = 'Plugin which adds Airbrake support to Redmine'
15
+ spec.summary = 'This plugin provides the necessary API to use Redmine as a Airbrake backend'
16
+ spec.homepage = 'https://gitlab.com/ydkn/redmine_airbrake_backend'
14
17
  spec.license = 'MIT'
15
18
 
16
- spec.files = `git ls-files`.split($/)
19
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
21
  spec.require_paths = ['lib']
19
22
 
@@ -21,4 +24,5 @@ Gem::Specification.new do |spec|
21
24
 
22
25
  spec.add_development_dependency 'bundler'
23
26
  spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'rubocop'
24
28
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require File.expand_path('../test_helper', __dir__)
2
2
 
3
3
  class NoticeTest < ActiveSupport::TestCase
4
4
  test 'parse' do
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.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Schwab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-29 00:00:00.000000000 Z
11
+ date: 2018-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Plugin which adds Airbrake support to Redmine
56
70
  email:
57
71
  - me@ydkn.de
@@ -60,6 +74,8 @@ extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
62
76
  - ".gitignore"
77
+ - ".gitlab-ci.yml"
78
+ - ".rubocop.yml"
63
79
  - CHANGELOG.md
64
80
  - Gemfile
65
81
  - LICENSE.txt
@@ -69,6 +85,9 @@ files:
69
85
  - app/controllers/airbrake_notice_controller.rb
70
86
  - app/controllers/airbrake_project_settings_controller.rb
71
87
  - app/controllers/airbrake_report_controller.rb
88
+ - app/controllers/concerns/airbrake_attachments.rb
89
+ - app/controllers/concerns/airbrake_issue_handling.rb
90
+ - app/controllers/concerns/airbrake_rendering.rb
72
91
  - app/helpers/airbrake_helper.rb
73
92
  - app/models/airbrake_project_setting.rb
74
93
  - app/views/airbrake/issue_description/_section.erb
@@ -97,7 +116,7 @@ files:
97
116
  - redmine_airbrake_backend.gemspec
98
117
  - test/test_helper.rb
99
118
  - test/unit/notice_test.rb
100
- homepage: https://github.com/ydkn/redmine_airbrake_backend
119
+ homepage: https://gitlab.com/ydkn/redmine_airbrake_backend
101
120
  licenses:
102
121
  - MIT
103
122
  metadata: {}
@@ -109,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
128
  requirements:
110
129
  - - ">="
111
130
  - !ruby/object:Gem::Version
112
- version: '0'
131
+ version: 2.4.0
113
132
  required_rubygems_version: !ruby/object:Gem::Requirement
114
133
  requirements:
115
134
  - - ">="
@@ -117,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
136
  version: '0'
118
137
  requirements: []
119
138
  rubyforge_project:
120
- rubygems_version: 2.7.3
139
+ rubygems_version: 2.7.7
121
140
  signing_key:
122
141
  specification_version: 4
123
142
  summary: This plugin provides the necessary API to use Redmine as a Airbrake backend