redmine_airbrake_backend 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/app/models/airbrake_project_setting.rb +2 -7
- data/lib/redmine_airbrake_backend.rb +5 -0
- data/lib/redmine_airbrake_backend/engine.rb +23 -6
- data/lib/redmine_airbrake_backend/notice.rb +6 -6
- data/lib/redmine_airbrake_backend/patches/issue_category.rb +11 -0
- data/lib/redmine_airbrake_backend/patches/issue_priority.rb +11 -0
- data/lib/redmine_airbrake_backend/patches/project.rb +11 -0
- data/lib/redmine_airbrake_backend/patches/projects_helper.rb +24 -0
- data/lib/redmine_airbrake_backend/patches/tracker.rb +11 -0
- data/lib/redmine_airbrake_backend/version.rb +1 -1
- data/lib/tasks/test.rake +33 -0
- data/test/test_helper.rb +1 -0
- data/test/unit/notice_test.rb +54 -0
- metadata +13 -4
- data/lib/redmine_airbrake_backend/project_helper_patch.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 618ee3d3d8ec581efd20a70331dcf0c95fc35f07
|
4
|
+
data.tar.gz: 387de8062df6128c399eb18431bf66b2c610ee39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e234cb1fd3984a9dc85465466efc9cc806572b8dbce306531e59825b4e97e5aaf63469844ada49c584ff4da1a5870472f4bc67221c5efaf665b9a0658301a318
|
7
|
+
data.tar.gz: f4e8f815ad22df7e3060df447af795c6d20619ac96c8f48a653d32403cdd4909ade75b26c80251f62daabfa5465e0686608fca8d820a5f53a932b11ebaf12c88
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
redmine_airbrake_backend (0.3.
|
4
|
+
redmine_airbrake_backend (0.3.3)
|
5
5
|
hpricot
|
6
6
|
htmlentities
|
7
7
|
rails
|
@@ -34,7 +34,7 @@ GEM
|
|
34
34
|
thread_safe (~> 0.1)
|
35
35
|
tzinfo (~> 0.3.37)
|
36
36
|
arel (4.0.0)
|
37
|
-
atomic (1.1.
|
37
|
+
atomic (1.1.14)
|
38
38
|
builder (3.1.4)
|
39
39
|
erubis (2.7.0)
|
40
40
|
hike (1.2.3)
|
@@ -46,7 +46,7 @@ GEM
|
|
46
46
|
treetop (~> 1.4.8)
|
47
47
|
mime-types (1.25)
|
48
48
|
minitest (4.7.5)
|
49
|
-
multi_json (1.
|
49
|
+
multi_json (1.8.0)
|
50
50
|
polyglot (0.3.3)
|
51
51
|
rack (1.5.2)
|
52
52
|
rack-test (0.6.2)
|
@@ -75,7 +75,7 @@ GEM
|
|
75
75
|
activesupport (>= 3.0)
|
76
76
|
sprockets (~> 2.8)
|
77
77
|
thor (0.18.1)
|
78
|
-
thread_safe (0.1.
|
78
|
+
thread_safe (0.1.3)
|
79
79
|
atomic
|
80
80
|
tilt (1.4.1)
|
81
81
|
treetop (1.4.15)
|
@@ -1,17 +1,12 @@
|
|
1
|
+
require 'redmine/safe_attributes'
|
2
|
+
|
1
3
|
class AirbrakeProjectSetting < ActiveRecord::Base
|
2
4
|
include Redmine::SafeAttributes
|
3
5
|
|
4
6
|
belongs_to :project
|
5
|
-
Project.has_one :airbrake_settings, class_name: AirbrakeProjectSetting.name, dependent: :destroy
|
6
|
-
|
7
7
|
belongs_to :tracker
|
8
|
-
Tracker.has_many :airbrake_project_settings, dependent: :nullify
|
9
|
-
|
10
8
|
belongs_to :category, class_name: IssueCategory.name
|
11
|
-
IssueCategory.has_many :airbrake_project_settings, dependent: :nullify
|
12
|
-
|
13
9
|
belongs_to :priority, class_name: IssuePriority.name
|
14
|
-
IssuePriority.has_many :airbrake_project_settings, dependent: :nullify
|
15
10
|
|
16
11
|
validates_presence_of :project_id
|
17
12
|
|
@@ -2,16 +2,33 @@ require 'redmine_airbrake_backend/version'
|
|
2
2
|
|
3
3
|
module RedmineAirbrakeBackend
|
4
4
|
class Engine < ::Rails::Engine
|
5
|
-
initializer 'redmine_airbrake_backend.register_redmine_plugin', after:
|
6
|
-
|
5
|
+
initializer 'redmine_airbrake_backend.register_redmine_plugin', after: 'load_config_initializers' do |app|
|
6
|
+
register_redmine_plugin
|
7
|
+
end
|
8
|
+
|
9
|
+
initializer 'redmine_airbrake_backend.apply_patches', after: 'redmine_airbrake_backend.register_redmine_plugin' do |app|
|
10
|
+
ActionDispatch::Callbacks.to_prepare do
|
11
|
+
require_dependency 'redmine_airbrake_backend/patches/project'
|
12
|
+
require_dependency 'redmine_airbrake_backend/patches/tracker'
|
13
|
+
require_dependency 'redmine_airbrake_backend/patches/issue_category'
|
14
|
+
require_dependency 'redmine_airbrake_backend/patches/issue_priority'
|
15
|
+
require_dependency 'redmine_airbrake_backend/patches/projects_helper'
|
16
|
+
|
17
|
+
RedmineAirbrakeBackend::Engine.apply_patch(Project, RedmineAirbrakeBackend::Patches::Project)
|
18
|
+
RedmineAirbrakeBackend::Engine.apply_patch(Tracker, RedmineAirbrakeBackend::Patches::Tracker)
|
19
|
+
RedmineAirbrakeBackend::Engine.apply_patch(IssueCategory, RedmineAirbrakeBackend::Patches::IssueCategory)
|
20
|
+
RedmineAirbrakeBackend::Engine.apply_patch(IssuePriority, RedmineAirbrakeBackend::Patches::IssuePriority)
|
21
|
+
RedmineAirbrakeBackend::Engine.apply_patch(ProjectsHelper, RedmineAirbrakeBackend::Patches::ProjectsHelper)
|
22
|
+
end
|
23
|
+
end
|
7
24
|
|
8
|
-
|
9
|
-
|
25
|
+
def apply_patch(clazz, patch)
|
26
|
+
clazz.send(:include, patch) unless clazz.included_modules.include?(patch)
|
10
27
|
end
|
11
28
|
|
12
29
|
private
|
13
30
|
|
14
|
-
def
|
31
|
+
def register_redmine_plugin
|
15
32
|
Redmine::Plugin.register :redmine_airbrake_backend do
|
16
33
|
name 'Airbrake Backend'
|
17
34
|
author 'Florian Schwab'
|
@@ -20,7 +37,7 @@ module RedmineAirbrakeBackend
|
|
20
37
|
url 'https://github.com/ydkn/redmine_airbrake_backend'
|
21
38
|
version ::RedmineAirbrakeBackend::VERSION
|
22
39
|
requires_redmine :version_or_higher => '2.3.2'
|
23
|
-
directory
|
40
|
+
directory RedmineAirbrakeBackend.directory
|
24
41
|
|
25
42
|
project_module :airbrake do
|
26
43
|
permission :manage_airbrake, {airbrake: [:update]}
|
@@ -25,16 +25,16 @@ module RedmineAirbrakeBackend
|
|
25
25
|
doc = Hpricot::XML(xml_data)
|
26
26
|
|
27
27
|
raise NoticeInvalid if (notice = doc.at('notice')).blank?
|
28
|
-
raise NoticeInvalid if (version = notice.attributes['version']).blank?
|
29
|
-
raise UnsupportedVersion unless SUPPORTED_API_VERSIONS.include?(version)
|
28
|
+
raise NoticeInvalid.new('no version') if (version = notice.attributes['version']).blank?
|
29
|
+
raise UnsupportedVersion.new(version) unless SUPPORTED_API_VERSIONS.include?(version)
|
30
30
|
|
31
31
|
params = JSON.parse(notice.at('api-key').inner_text).symbolize_keys rescue nil
|
32
|
-
raise NoticeInvalid if params.blank?
|
32
|
+
raise NoticeInvalid.new('no or invalid api-key') if params.blank?
|
33
33
|
|
34
|
-
raise NoticeInvalid if (notifier = convert_element(notice.at('notifier'))).blank?
|
34
|
+
raise NoticeInvalid.new('no notifier') if (notifier = convert_element(notice.at('notifier'))).blank?
|
35
35
|
|
36
|
-
raise NoticeInvalid if (error = convert_element(notice.at('error'))).blank?
|
37
|
-
raise NoticeInvalid if error[:message].blank?
|
36
|
+
raise NoticeInvalid.new('no error') if (error = convert_element(notice.at('error'))).blank?
|
37
|
+
raise NoticeInvalid.new('no message') if error[:message].blank?
|
38
38
|
|
39
39
|
error[:backtrace] = format_backtrace(error[:backtrace])
|
40
40
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module RedmineAirbrakeBackend::Patches
|
4
|
+
module ProjectsHelper
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
alias_method_chain :project_settings_tabs, :airbrake_backend_tab
|
9
|
+
end
|
10
|
+
|
11
|
+
def project_settings_tabs_with_airbrake_backend_tab
|
12
|
+
tabs = project_settings_tabs_without_airbrake_backend_tab
|
13
|
+
|
14
|
+
tabs.push({
|
15
|
+
:name => 'airbrake',
|
16
|
+
:action => :manage_airbrake,
|
17
|
+
:partial => 'projects/settings/airbrake',
|
18
|
+
:label => :project_module_airbrake
|
19
|
+
})
|
20
|
+
|
21
|
+
tabs.select{|tab| User.current.allowed_to?(tab[:action], @project)}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/tasks/test.rake
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
namespace :redmine do
|
2
|
+
namespace :airbrake_backend do
|
3
|
+
desc 'Runs the plugin tests.'
|
4
|
+
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
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :test do
|
11
|
+
desc 'Runs the plugin unit tests.'
|
12
|
+
Rake::TestTask.new :units => "db:test:prepare" do |t|
|
13
|
+
t.libs << "test"
|
14
|
+
t.verbose = true
|
15
|
+
t.pattern = "#{RedmineAirbrakeBackend.directory}/test/unit/**/*_test.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Runs the plugin functional tests.'
|
19
|
+
Rake::TestTask.new :functionals => "db:test:prepare" do |t|
|
20
|
+
t.libs << "test"
|
21
|
+
t.verbose = true
|
22
|
+
t.pattern = "#{RedmineAirbrakeBackend.directory}/test/functional/**/*_test.rb"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Runs the plugin integration tests.'
|
26
|
+
Rake::TestTask.new :integration => "db:test:prepare" do |t|
|
27
|
+
t.libs << "test"
|
28
|
+
t.verbose = true
|
29
|
+
t.pattern = "#{RedmineAirbrakeBackend.directory}/test/integration/**/*_test.rb"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path('./test/test_helper')
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
class NoticeTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test 'parse' do
|
6
|
+
api_key = {
|
7
|
+
api_key: 'foobar',
|
8
|
+
project: 'foo'
|
9
|
+
}.to_json
|
10
|
+
xml_data = <<-EOS
|
11
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
12
|
+
<notice version="2.4">
|
13
|
+
<api-key>#{api_key}</api-key>
|
14
|
+
<notifier>
|
15
|
+
<name>Airbrake Notifier</name>
|
16
|
+
<version>3.1.6</version>
|
17
|
+
<url>http://api.airbrake.io</url>
|
18
|
+
</notifier>
|
19
|
+
<error>
|
20
|
+
<class>RuntimeError</class>
|
21
|
+
<message>RuntimeError: I've made a huge mistake</message>
|
22
|
+
<backtrace>
|
23
|
+
<line method="public" file="/testapp/app/models/user.rb" number="53"/>
|
24
|
+
<line method="index" file="/testapp/app/controllers/users_controller.rb" number="14"/>
|
25
|
+
</backtrace>
|
26
|
+
</error>
|
27
|
+
<request>
|
28
|
+
<url>http://example.com</url>
|
29
|
+
<component/>
|
30
|
+
<action/>
|
31
|
+
<cgi-data>
|
32
|
+
<var key="SERVER_NAME">example.org</var>
|
33
|
+
<var key="HTTP_USER_AGENT">Mozilla</var>
|
34
|
+
</cgi-data>
|
35
|
+
</request>
|
36
|
+
<server-environment>
|
37
|
+
<project-root>/testapp</project-root>
|
38
|
+
<environment-name>production</environment-name>
|
39
|
+
<app-version>1.0.0</app-version>
|
40
|
+
</server-environment>
|
41
|
+
</notice>
|
42
|
+
EOS
|
43
|
+
|
44
|
+
notice = RedmineAirbrakeBackend::Notice.parse(prepare_xml(xml_data))
|
45
|
+
assert notice
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def prepare_xml(xml_data)
|
51
|
+
xml_data.split("\n").map{|l| l.strip}.join('')
|
52
|
+
end
|
53
|
+
|
54
|
+
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: 0.3.
|
4
|
+
version: 0.3.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: 2013-09-
|
11
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -108,9 +108,16 @@ files:
|
|
108
108
|
- lib/redmine_airbrake_backend.rb
|
109
109
|
- lib/redmine_airbrake_backend/engine.rb
|
110
110
|
- lib/redmine_airbrake_backend/notice.rb
|
111
|
-
- lib/redmine_airbrake_backend/
|
111
|
+
- lib/redmine_airbrake_backend/patches/issue_category.rb
|
112
|
+
- lib/redmine_airbrake_backend/patches/issue_priority.rb
|
113
|
+
- lib/redmine_airbrake_backend/patches/project.rb
|
114
|
+
- lib/redmine_airbrake_backend/patches/projects_helper.rb
|
115
|
+
- lib/redmine_airbrake_backend/patches/tracker.rb
|
112
116
|
- lib/redmine_airbrake_backend/version.rb
|
117
|
+
- lib/tasks/test.rake
|
113
118
|
- redmine_airbrake_backend.gemspec
|
119
|
+
- test/test_helper.rb
|
120
|
+
- test/unit/notice_test.rb
|
114
121
|
homepage: https://github.com/ydkn/redmine_airbrake_backend
|
115
122
|
licenses:
|
116
123
|
- MIT
|
@@ -135,4 +142,6 @@ rubygems_version: 2.0.3
|
|
135
142
|
signing_key:
|
136
143
|
specification_version: 4
|
137
144
|
summary: This plugin provides the necessary API to use Redmine as a Airbrake backend
|
138
|
-
test_files:
|
145
|
+
test_files:
|
146
|
+
- test/test_helper.rb
|
147
|
+
- test/unit/notice_test.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
::ProjectsHelper.module_eval %Q{
|
2
|
-
alias_method :project_settings_tabs_original_airbrake, :project_settings_tabs
|
3
|
-
|
4
|
-
def project_settings_tabs
|
5
|
-
tabs = project_settings_tabs_original_airbrake
|
6
|
-
|
7
|
-
tabs.push({
|
8
|
-
:name => 'airbrake',
|
9
|
-
:action => :manage_airbrake,
|
10
|
-
:partial => 'projects/settings/airbrake',
|
11
|
-
:label => :project_module_airbrake
|
12
|
-
})
|
13
|
-
|
14
|
-
tabs.select{|tab| User.current.allowed_to?(tab[:action], @project)}
|
15
|
-
end
|
16
|
-
}
|