Skip to content

Commit

Permalink
updates for redmine 2.3 / rails 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jkraemer committed May 10, 2013
1 parent a213dfd commit 257102e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
2 changes: 0 additions & 2 deletions app/helpers/notices_helper.rb

This file was deleted.

15 changes: 4 additions & 11 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
ActionController::Routing::Routes.draw do |map|

map.with_options(:controller => 'notices', :method => :post) do |m|
m.connect 'notices', :action => 'index' # API v1 (hoptoad)
m.connect 'notifier_api/v2/notices', :action => 'index_v2' # API v2 (hoptoad / airbrake, xml based)
end
# API v1 (hoptoad)
post 'notices', :to => 'notices#index'

if Rails.env == 'test'
# route without the :method => :post requirement since otherwise the route is
# not recognized in the functional test. dont know why though...
map.connect '/notices/index_v2', :controller => 'notices', :action => 'index_v2'
end
# API v2 (hoptoad / airbrake, xml based)
post 'notifier_api/v2/notices', :to => 'notices#index_v2'

end
21 changes: 9 additions & 12 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
require 'redmine'
require 'dispatcher'
Redmine::Plugin.register :redmine_hoptoad_server do
name 'Redmine Hoptoad Server plugin'
author 'Jan Schulz-Hofen, Planio GmbH'
description 'Turns Redmine into an Airbrake / Hoptoad compatible server, i.e. an API provider which can be used with the Airbrake gem / hoptoad_notifier plugin. See http://github.com/yeah/redmine_hoptoad_server'
version '0.0.1'
end

begin
gem 'nokogiri'
require 'nokogiri'
rescue LoadError
Rails.logger.error "Nokogiri gem not found, parsing hoptoad API v2 requests will be sub-optimal"
end

Dispatcher.to_prepare do
Issue.send(:include, RedmineHoptoadServer::Patches::IssuePatch) unless Issue.include?(RedmineHoptoadServer::Patches::IssuePatch)
IssueObserver.send(:include, RedmineHoptoadServer::Patches::IssueObserverPatch) unless IssueObserver.include?(RedmineHoptoadServer::Patches::IssueObserverPatch)
Rails.configuration.to_prepare do
require_dependency 'redmine_hoptoad_server/patches/issue_patch'
require_dependency 'redmine_hoptoad_server/patches/issue_observer_patch'
end

Redmine::Plugin.register :redmine_hoptoad_server do
name 'Redmine Hoptoad Server plugin'
author 'Jan Schulz-Hofen, Planio GmbH'
description 'Turns Redmine into a Hoptoad server, i.e. an API provider which can be used with the hoptoad_notifier. See http://github.com/yeah/redmine_hoptoad_server'
version '0.0.1'
end
4 changes: 4 additions & 0 deletions lib/redmine_hoptoad_server/patches/issue_observer_patch.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_dependency 'issue_observer'

module RedmineHoptoadServer
module Patches
module IssueObserverPatch
Expand All @@ -15,3 +17,5 @@ def after_create_with_notify_switch(issue)
end
end
end

IssueObserver.send(:include, RedmineHoptoadServer::Patches::IssueObserverPatch) unless IssueObserver.included_modules.include?(RedmineHoptoadServer::Patches::IssueObserverPatch)
4 changes: 4 additions & 0 deletions lib/redmine_hoptoad_server/patches/issue_patch.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_dependency 'issue'

module RedmineHoptoadServer
module Patches
module IssuePatch
Expand All @@ -12,3 +14,5 @@ def skip_notification?
end
end
end

Issue.send(:include, RedmineHoptoadServer::Patches::IssuePatch) unless Issue.included_modules.include?(RedmineHoptoadServer::Patches::IssuePatch)
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Load the normal Rails helper
require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')

# Ensure that we are using the temporary fixture path
Engines::Testing.set_fixture_path
Expand Down

0 comments on commit 257102e

Please sign in to comment.