##// END OF EJS Templates
Revert r6104 "Merged r6098 from trunk."...
Jean-Baptiste Barth -
r5985:102c9afadfd6
parent child
Show More
@@ -43,7 +43,7 class Attachment < ActiveRecord::Base
43 "LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id"}
43 "LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id"}
44
44
45 cattr_accessor :storage_path
45 cattr_accessor :storage_path
46 @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files"
46 @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{RAILS_ROOT}/files"
47
47
48 def validate
48 def validate
49 if self.filesize > Setting.attachment_max_size.to_i.kilobytes
49 if self.filesize > Setting.attachment_max_size.to_i.kilobytes
@@ -544,27 +544,7 class Project < ActiveRecord::Base
544 def enabled_module_names
544 def enabled_module_names
545 enabled_modules.collect(&:name)
545 enabled_modules.collect(&:name)
546 end
546 end
547
547
548 # Enable a specific module
549 #
550 # Examples:
551 # project.enable_module!(:issue_tracking)
552 # project.enable_module!("issue_tracking")
553 def enable_module!(name)
554 enabled_modules << EnabledModule.new(:name => name.to_s) unless module_enabled?(name)
555 end
556
557 # Disable a module if it exists
558 #
559 # Examples:
560 # project.disable_module!(:issue_tracking)
561 # project.disable_module!("issue_tracking")
562 # project.disable_module!(project.enabled_modules.first)
563 def disable_module!(target)
564 target = enabled_modules.detect{|mod| target.to_s == mod.name} unless enabled_modules.include?(target)
565 target.destroy unless target.blank?
566 end
567
568 safe_attributes 'name',
548 safe_attributes 'name',
569 'description',
549 'description',
570 'homepage',
550 'homepage',
@@ -75,7 +75,7 class Setting < ActiveRecord::Base
75 TIS-620)
75 TIS-620)
76
76
77 cattr_accessor :available_settings
77 cattr_accessor :available_settings
78 @@available_settings = YAML::load(File.open("#{Rails.root}/config/settings.yml"))
78 @@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml"))
79 Redmine::Plugin.all.each do |plugin|
79 Redmine::Plugin.all.each do |plugin|
80 next unless plugin.settings
80 next unless plugin.settings
81 @@available_settings["plugin_#{plugin.id}"] = {'default' => plugin.settings[:default], 'serialized' => true}
81 @@available_settings["plugin_#{plugin.id}"] = {'default' => plugin.settings[:default], 'serialized' => true}
@@ -14,7 +14,7 class RedminePluginControllerGenerator < ControllerGenerator
14 end
14 end
15
15
16 def destination_root
16 def destination_root
17 File.join(Rails.root, plugin_path)
17 File.join(RAILS_ROOT, plugin_path)
18 end
18 end
19
19
20 def manifest
20 def manifest
@@ -14,7 +14,7 class RedminePluginModelGenerator < ModelGenerator
14 end
14 end
15
15
16 def destination_root
16 def destination_root
17 File.join(Rails.root, plugin_path)
17 File.join(RAILS_ROOT, plugin_path)
18 end
18 end
19
19
20 def manifest
20 def manifest
@@ -56,11 +56,11 module Redmine
56 def month_name(month)
56 def month_name(month)
57 ::I18n.t('date.month_names')[month]
57 ::I18n.t('date.month_names')[month]
58 end
58 end
59
59
60 def valid_languages
60 def valid_languages
61 @@valid_languages ||= Dir.glob(File.join(Rails.root, 'config', 'locales', '*.yml')).collect {|f| File.basename(f).split('.').first}.collect(&:to_sym)
61 @@valid_languages ||= Dir.glob(File.join(RAILS_ROOT, 'config', 'locales', '*.yml')).collect {|f| File.basename(f).split('.').first}.collect(&:to_sym)
62 end
62 end
63
63
64 def find_language(lang)
64 def find_language(lang)
65 @@languages_lookup = valid_languages.inject({}) {|k, v| k[v.to_s.downcase] = v; k }
65 @@languages_lookup = valid_languages.inject({}) {|k, v| k[v.to_s.downcase] = v; k }
66 @@languages_lookup[lang.to_s.downcase]
66 @@languages_lookup[lang.to_s.downcase]
@@ -1,16 +1,16
1 # Redmine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -69,7 +69,7 module Redmine #:nodoc:
69 p.name(id.to_s.humanize) if p.name.nil?
69 p.name(id.to_s.humanize) if p.name.nil?
70 # Adds plugin locales if any
70 # Adds plugin locales if any
71 # YAML translation files should be found under <plugin>/config/locales/
71 # YAML translation files should be found under <plugin>/config/locales/
72 ::I18n.load_path += Dir.glob(File.join(Rails.root, 'vendor', 'plugins', id.to_s, 'config', 'locales', '*.yml'))
72 ::I18n.load_path += Dir.glob(File.join(RAILS_ROOT, 'vendor', 'plugins', id.to_s, 'config', 'locales', '*.yml'))
73 registered_plugins[id] = p
73 registered_plugins[id] = p
74 end
74 end
75
75
@@ -204,7 +204,7 module Redmine
204 end
204 end
205 if Rails.env == 'development'
205 if Rails.env == 'development'
206 # Capture stderr when running in dev environment
206 # Capture stderr when running in dev environment
207 cmd = "#{cmd} 2>>#{Rails.root}/log/scm.stderr.log"
207 cmd = "#{cmd} 2>>#{RAILS_ROOT}/log/scm.stderr.log"
208 end
208 end
209 begin
209 begin
210 if RUBY_VERSION < '1.9'
210 if RUBY_VERSION < '1.9'
@@ -14,7 +14,7 module Redmine
14
14
15 def self.revision
15 def self.revision
16 revision = nil
16 revision = nil
17 entries_path = "#{Rails.root}/.svn/entries"
17 entries_path = "#{RAILS_ROOT}/.svn/entries"
18 if File.readable?(entries_path)
18 if File.readable?(entries_path)
19 begin
19 begin
20 f = File.open(entries_path, 'r')
20 f = File.open(entries_path, 'r')
@@ -1,16 +1,16
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -20,7 +20,7 module Redmine
20 module MyPage
20 module MyPage
21 module Block
21 module Block
22 def self.additional_blocks
22 def self.additional_blocks
23 @@additional_blocks ||= Dir.glob("#{Rails.root}/vendor/plugins/*/app/views/my/blocks/_*.{rhtml,erb}").inject({}) do |h,file|
23 @@additional_blocks ||= Dir.glob("#{RAILS_ROOT}/vendor/plugins/*/app/views/my/blocks/_*.{rhtml,erb}").inject({}) do |h,file|
24 name = File.basename(file).split('.').first.gsub(/^_/, '')
24 name = File.basename(file).split('.').first.gsub(/^_/, '')
25 h[name] = name.to_sym
25 h[name] = name.to_sym
26 h
26 h
@@ -7,7 +7,7 task :extract_fixtures => :environment do
7 ActiveRecord::Base.establish_connection
7 ActiveRecord::Base.establish_connection
8 (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
8 (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
9 i = "000"
9 i = "000"
10 File.open("#{Rails.root}/#{table_name}.yml", 'w' ) do |file|
10 File.open("#{RAILS_ROOT}/#{table_name}.yml", 'w' ) do |file|
11 data = ActiveRecord::Base.connection.select_all(sql % table_name)
11 data = ActiveRecord::Base.connection.select_all(sql % table_name)
12 file.write data.inject({}) { |hash, record|
12 file.write data.inject({}) { |hash, record|
13 # cast extracted values
13 # cast extracted values
@@ -19,5 +19,4 task :extract_fixtures => :environment do
19 }.to_yaml
19 }.to_yaml
20 end
20 end
21 end
21 end
22 end
22 end
23
@@ -1,7 +1,7
1 desc 'Generates a configuration file for cookie store sessions.'
1 desc 'Generates a configuration file for cookie store sessions.'
2
2
3 file 'config/initializers/session_store.rb' do
3 file 'config/initializers/session_store.rb' do
4 path = File.join(Rails.root, 'config', 'initializers', 'session_store.rb')
4 path = File.join(RAILS_ROOT, 'config', 'initializers', 'session_store.rb')
5 secret = ActiveSupport::SecureRandom.hex(40)
5 secret = ActiveSupport::SecureRandom.hex(40)
6 File.open(path, 'w') do |f|
6 File.open(path, 'w') do |f|
7 f.write <<"EOF"
7 f.write <<"EOF"
@@ -1,9 +1,9
1 ---
1 ---
2 repositories_001:
2 repositories_001:
3 project_id: 1
3 project_id: 1
4 url: file:///<%= Rails.root %>/tmp/test/subversion_repository
4 url: file:///<%= RAILS_ROOT.gsub(%r{config\/\.\.}, '') %>/tmp/test/subversion_repository
5 id: 10
5 id: 10
6 root_url: file:///<%= Rails.root %>/tmp/test/subversion_repository
6 root_url: file:///<%= RAILS_ROOT.gsub(%r{config\/\.\.}, '') %>/tmp/test/subversion_repository
7 password: ""
7 password: ""
8 login: ""
8 login: ""
9 type: Subversion
9 type: Subversion
@@ -32,7 +32,7 class ApplicationControllerTest < ActionController::TestCase
32
32
33 # check that all language files are valid
33 # check that all language files are valid
34 def test_localization
34 def test_localization
35 lang_files_count = Dir["#{Rails.root}/config/locales/*.yml"].size
35 lang_files_count = Dir["#{RAILS_ROOT}/config/locales/*.yml"].size
36 assert_equal lang_files_count, valid_languages.size
36 assert_equal lang_files_count, valid_languages.size
37 valid_languages.each do |lang|
37 valid_languages.each do |lang|
38 assert set_language_if_valid(lang)
38 assert set_language_if_valid(lang)
@@ -32,7 +32,7 class AttachmentsControllerTest < ActionController::TestCase
32 @controller = AttachmentsController.new
32 @controller = AttachmentsController.new
33 @request = ActionController::TestRequest.new
33 @request = ActionController::TestRequest.new
34 @response = ActionController::TestResponse.new
34 @response = ActionController::TestResponse.new
35 Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
35 Attachment.storage_path = "#{RAILS_ROOT}/test/fixtures/files"
36 User.current = nil
36 User.current = nil
37 end
37 end
38
38
@@ -78,13 +78,11 class ActiveSupport::TestCase
78
78
79 # Use a temporary directory for attachment related tests
79 # Use a temporary directory for attachment related tests
80 def set_tmp_attachments_directory
80 def set_tmp_attachments_directory
81 Dir.mkdir "#{Rails.root}/tmp/test" unless File.directory?("#{Rails.root}/tmp/test")
81 Dir.mkdir "#{RAILS_ROOT}/tmp/test" unless File.directory?("#{RAILS_ROOT}/tmp/test")
82 unless File.directory?("#{Rails.root}/tmp/test/attachments")
82 Dir.mkdir "#{RAILS_ROOT}/tmp/test/attachments" unless File.directory?("#{RAILS_ROOT}/tmp/test/attachments")
83 Dir.mkdir "#{Rails.root}/tmp/test/attachments"
83 Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments"
84 end
85 Attachment.storage_path = "#{Rails.root}/tmp/test/attachments"
86 end
84 end
87
85
88 def with_settings(options, &block)
86 def with_settings(options, &block)
89 saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].dup; h}
87 saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].dup; h}
90 options.each {|k, v| Setting[k] = v}
88 options.each {|k, v| Setting[k] = v}
@@ -1,16 +1,16
1 # Redmine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -20,10 +20,10 require File.expand_path('../../../../test_helper', __FILE__)
20 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
20 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
21
21
22 fixtures :issues
22 fixtures :issues
23
23
24 # Some hooks that are manually registered in these tests
24 # Some hooks that are manually registered in these tests
25 class TestHook < Redmine::Hook::ViewListener; end
25 class TestHook < Redmine::Hook::ViewListener; end
26
26
27 class TestHook1 < TestHook
27 class TestHook1 < TestHook
28 def view_layouts_base_html_head(context)
28 def view_layouts_base_html_head(context)
29 'Test hook 1 listener.'
29 'Test hook 1 listener.'
@@ -35,13 +35,13 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
35 'Test hook 2 listener.'
35 'Test hook 2 listener.'
36 end
36 end
37 end
37 end
38
38
39 class TestHook3 < TestHook
39 class TestHook3 < TestHook
40 def view_layouts_base_html_head(context)
40 def view_layouts_base_html_head(context)
41 "Context keys: #{context.keys.collect(&:to_s).sort.join(', ')}."
41 "Context keys: #{context.keys.collect(&:to_s).sort.join(', ')}."
42 end
42 end
43 end
43 end
44
44
45 class TestLinkToHook < TestHook
45 class TestLinkToHook < TestHook
46 def view_layouts_base_html_head(context)
46 def view_layouts_base_html_head(context)
47 link_to('Issues', :controller => 'issues')
47 link_to('Issues', :controller => 'issues')
@@ -51,54 +51,54 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
51 class TestHookHelperController < ActionController::Base
51 class TestHookHelperController < ActionController::Base
52 include Redmine::Hook::Helper
52 include Redmine::Hook::Helper
53 end
53 end
54
54
55 class TestHookHelperView < ActionView::Base
55 class TestHookHelperView < ActionView::Base
56 include Redmine::Hook::Helper
56 include Redmine::Hook::Helper
57 end
57 end
58
58
59 Redmine::Hook.clear_listeners
59 Redmine::Hook.clear_listeners
60
60
61 def setup
61 def setup
62 @hook_module = Redmine::Hook
62 @hook_module = Redmine::Hook
63 end
63 end
64
64
65 def teardown
65 def teardown
66 @hook_module.clear_listeners
66 @hook_module.clear_listeners
67 end
67 end
68
68
69 def test_clear_listeners
69 def test_clear_listeners
70 assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size
70 assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size
71 @hook_module.add_listener(TestHook1)
71 @hook_module.add_listener(TestHook1)
72 @hook_module.add_listener(TestHook2)
72 @hook_module.add_listener(TestHook2)
73 assert_equal 2, @hook_module.hook_listeners(:view_layouts_base_html_head).size
73 assert_equal 2, @hook_module.hook_listeners(:view_layouts_base_html_head).size
74
74
75 @hook_module.clear_listeners
75 @hook_module.clear_listeners
76 assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size
76 assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size
77 end
77 end
78
78
79 def test_add_listener
79 def test_add_listener
80 assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size
80 assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size
81 @hook_module.add_listener(TestHook1)
81 @hook_module.add_listener(TestHook1)
82 assert_equal 1, @hook_module.hook_listeners(:view_layouts_base_html_head).size
82 assert_equal 1, @hook_module.hook_listeners(:view_layouts_base_html_head).size
83 end
83 end
84
84
85 def test_call_hook
85 def test_call_hook
86 @hook_module.add_listener(TestHook1)
86 @hook_module.add_listener(TestHook1)
87 assert_equal ['Test hook 1 listener.'], hook_helper.call_hook(:view_layouts_base_html_head)
87 assert_equal ['Test hook 1 listener.'], hook_helper.call_hook(:view_layouts_base_html_head)
88 end
88 end
89
89
90 def test_call_hook_with_context
90 def test_call_hook_with_context
91 @hook_module.add_listener(TestHook3)
91 @hook_module.add_listener(TestHook3)
92 assert_equal ['Context keys: bar, controller, foo, project, request.'],
92 assert_equal ['Context keys: bar, controller, foo, project, request.'],
93 hook_helper.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a')
93 hook_helper.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a')
94 end
94 end
95
95
96 def test_call_hook_with_multiple_listeners
96 def test_call_hook_with_multiple_listeners
97 @hook_module.add_listener(TestHook1)
97 @hook_module.add_listener(TestHook1)
98 @hook_module.add_listener(TestHook2)
98 @hook_module.add_listener(TestHook2)
99 assert_equal ['Test hook 1 listener.', 'Test hook 2 listener.'], hook_helper.call_hook(:view_layouts_base_html_head)
99 assert_equal ['Test hook 1 listener.', 'Test hook 2 listener.'], hook_helper.call_hook(:view_layouts_base_html_head)
100 end
100 end
101
101
102 # Context: Redmine::Hook::Helper.call_hook default_url
102 # Context: Redmine::Hook::Helper.call_hook default_url
103 def test_call_hook_default_url_options
103 def test_call_hook_default_url_options
104 @hook_module.add_listener(TestLinkToHook)
104 @hook_module.add_listener(TestLinkToHook)
@@ -111,27 +111,27 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
111 @hook_module.add_listener(TestHook3)
111 @hook_module.add_listener(TestHook3)
112 assert_match /project/i, hook_helper.call_hook(:view_layouts_base_html_head)[0]
112 assert_match /project/i, hook_helper.call_hook(:view_layouts_base_html_head)[0]
113 end
113 end
114
114
115 def test_call_hook_from_controller_with_controller_added_to_context
115 def test_call_hook_from_controller_with_controller_added_to_context
116 @hook_module.add_listener(TestHook3)
116 @hook_module.add_listener(TestHook3)
117 assert_match /controller/i, hook_helper.call_hook(:view_layouts_base_html_head)[0]
117 assert_match /controller/i, hook_helper.call_hook(:view_layouts_base_html_head)[0]
118 end
118 end
119
119
120 def test_call_hook_from_controller_with_request_added_to_context
120 def test_call_hook_from_controller_with_request_added_to_context
121 @hook_module.add_listener(TestHook3)
121 @hook_module.add_listener(TestHook3)
122 assert_match /request/i, hook_helper.call_hook(:view_layouts_base_html_head)[0]
122 assert_match /request/i, hook_helper.call_hook(:view_layouts_base_html_head)[0]
123 end
123 end
124
124
125 def test_call_hook_from_view_with_project_added_to_context
125 def test_call_hook_from_view_with_project_added_to_context
126 @hook_module.add_listener(TestHook3)
126 @hook_module.add_listener(TestHook3)
127 assert_match /project/i, view_hook_helper.call_hook(:view_layouts_base_html_head)
127 assert_match /project/i, view_hook_helper.call_hook(:view_layouts_base_html_head)
128 end
128 end
129
129
130 def test_call_hook_from_view_with_controller_added_to_context
130 def test_call_hook_from_view_with_controller_added_to_context
131 @hook_module.add_listener(TestHook3)
131 @hook_module.add_listener(TestHook3)
132 assert_match /controller/i, view_hook_helper.call_hook(:view_layouts_base_html_head)
132 assert_match /controller/i, view_hook_helper.call_hook(:view_layouts_base_html_head)
133 end
133 end
134
134
135 def test_call_hook_from_view_with_request_added_to_context
135 def test_call_hook_from_view_with_request_added_to_context
136 @hook_module.add_listener(TestHook3)
136 @hook_module.add_listener(TestHook3)
137 assert_match /request/i, view_hook_helper.call_hook(:view_layouts_base_html_head)
137 assert_match /request/i, view_hook_helper.call_hook(:view_layouts_base_html_head)
@@ -146,27 +146,27 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
146
146
147 def test_call_hook_should_not_change_the_default_url_for_email_notifications
147 def test_call_hook_should_not_change_the_default_url_for_email_notifications
148 issue = Issue.find(1)
148 issue = Issue.find(1)
149
149
150 ActionMailer::Base.deliveries.clear
150 ActionMailer::Base.deliveries.clear
151 Mailer.deliver_issue_add(issue)
151 Mailer.deliver_issue_add(issue)
152 mail = ActionMailer::Base.deliveries.last
152 mail = ActionMailer::Base.deliveries.last
153
153
154 @hook_module.add_listener(TestLinkToHook)
154 @hook_module.add_listener(TestLinkToHook)
155 hook_helper.call_hook(:view_layouts_base_html_head)
155 hook_helper.call_hook(:view_layouts_base_html_head)
156
156
157 ActionMailer::Base.deliveries.clear
157 ActionMailer::Base.deliveries.clear
158 Mailer.deliver_issue_add(issue)
158 Mailer.deliver_issue_add(issue)
159 mail2 = ActionMailer::Base.deliveries.last
159 mail2 = ActionMailer::Base.deliveries.last
160
160
161 assert_equal mail.body, mail2.body
161 assert_equal mail.body, mail2.body
162 end
162 end
163
163
164 def hook_helper
164 def hook_helper
165 @hook_helper ||= TestHookHelperController.new
165 @hook_helper ||= TestHookHelperController.new
166 end
166 end
167
167
168 def view_hook_helper
168 def view_hook_helper
169 @view_hook_helper ||= TestHookHelperView.new(Rails.root.to_s + '/app/views')
169 @view_hook_helper ||= TestHookHelperView.new(RAILS_ROOT + '/app/views')
170 end
170 end
171 end
171 end
172
172
@@ -597,54 +597,6 class ProjectTest < ActiveSupport::TestCase
597 end
597 end
598 end
598 end
599
599
600 context "enabled_modules" do
601 setup do
602 @project = Project.find(1)
603 end
604
605 should "define module by names and preserve ids" do
606 # Remove one module
607 modules = @project.enabled_modules.slice(0..-2)
608 assert modules.any?
609 assert_difference 'EnabledModule.count', -1 do
610 @project.enabled_module_names = modules.collect(&:name)
611 end
612 @project.reload
613 # Ids should be preserved
614 assert_equal @project.enabled_module_ids.sort, modules.collect(&:id).sort
615 end
616
617 should "enable a module" do
618 @project.enabled_module_names = []
619 @project.reload
620 assert_equal [], @project.enabled_module_names
621 #with string
622 @project.enable_module!("issue_tracking")
623 assert_equal ["issue_tracking"], @project.enabled_module_names
624 #with symbol
625 @project.enable_module!(:gantt)
626 assert_equal ["issue_tracking", "gantt"], @project.enabled_module_names
627 #don't add a module twice
628 @project.enable_module!("issue_tracking")
629 assert_equal ["issue_tracking", "gantt"], @project.enabled_module_names
630 end
631
632 should "disable a module" do
633 #with string
634 assert @project.enabled_module_names.include?("issue_tracking")
635 @project.disable_module!("issue_tracking")
636 assert ! @project.reload.enabled_module_names.include?("issue_tracking")
637 #with symbol
638 assert @project.enabled_module_names.include?("gantt")
639 @project.disable_module!(:gantt)
640 assert ! @project.reload.enabled_module_names.include?("gantt")
641 #with EnabledModule object
642 first_module = @project.enabled_modules.first
643 @project.disable_module!(first_module)
644 assert ! @project.reload.enabled_module_names.include?(first_module.name)
645 end
646 end
647
648 def test_enabled_module_names_should_not_recreate_enabled_modules
600 def test_enabled_module_names_should_not_recreate_enabled_modules
649 project = Project.find(1)
601 project = Project.find(1)
650 # Remove one module
602 # Remove one module
General Comments 0
You need to be logged in to leave comments. Login now