##// END OF EJS Templates
Refactor the hardcoded event actions (notifiables) to use a class...
Eric Davis -
r4106:244e94de8075
parent child
Show More
@@ -0,0 +1,19
1 module Redmine
2 class Notifiable
3 CoreNotifications = [
4 'issue_added',
5 'issue_updated',
6 'news_added',
7 'document_added',
8 'file_added',
9 'message_posted',
10 'wiki_content_added',
11 'wiki_content_updated'
12 ]
13
14 # TODO: Plugin API for adding a new notification?
15 def self.all
16 CoreNotifications
17 end
18 end
19 end
@@ -0,0 +1,38
1 # redMine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require File.dirname(__FILE__) + '/../../../test_helper'
19
20 class Redmine::NotifiableTest < ActiveSupport::TestCase
21 def setup
22 end
23
24 def test_included_core_notifications
25 assert_equal 8, Redmine::Notifiable::CoreNotifications.length
26 Redmine::Notifiable::CoreNotifications.length
27
28 %w(issue_added issue_updated news_added document_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
29 assert Redmine::Notifiable::CoreNotifications.include?(notifiable), "missing #{notifiable}"
30 end
31 end
32
33 def test_all_should_include_all_of_the_core_notifications
34 Redmine::Notifiable::CoreNotifications.each do |notifiable|
35 assert Redmine::Notifiable.all.include?(notifiable), "missing #{notifiable} in #all"
36 end
37 end
38 end
@@ -26,7 +26,7 class SettingsController < ApplicationController
26 end
26 end
27
27
28 def edit
28 def edit
29 @notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted wiki_content_added wiki_content_updated)
29 @notifiables = Redmine::Notifiable.all
30 if request.post? && params[:settings] && params[:settings].is_a?(Hash)
30 if request.post? && params[:settings] && params[:settings].is_a?(Hash)
31 settings = (params[:settings] || {}).dup.symbolize_keys
31 settings = (params[:settings] || {}).dup.symbolize_keys
32 settings.each do |name, value|
32 settings.each do |name, value|
@@ -8,6 +8,7 require 'redmine/core_ext'
8 require 'redmine/themes'
8 require 'redmine/themes'
9 require 'redmine/hook'
9 require 'redmine/hook'
10 require 'redmine/plugin'
10 require 'redmine/plugin'
11 require 'redmine/notifiable'
11 require 'redmine/wiki_formatting'
12 require 'redmine/wiki_formatting'
12 require 'redmine/scm/base'
13 require 'redmine/scm/base'
13
14
General Comments 0
You need to be logged in to leave comments. Login now