@@ -53,7 +53,7 module SettingsHelper | |||||
53 | check_box_tag( |
|
53 | check_box_tag( | |
54 | "settings[#{setting}][]", |
|
54 | "settings[#{setting}][]", | |
55 | value, |
|
55 | value, | |
56 |
|
|
56 | setting_values.include?(value), | |
57 | :id => nil |
|
57 | :id => nil | |
58 | ) + text.to_s, |
|
58 | ) + text.to_s, | |
59 | :class => (options[:inline] ? 'inline' : 'block') |
|
59 | :class => (options[:inline] ? 'inline' : 'block') |
@@ -126,7 +126,12 class Project < ActiveRecord::Base | |||||
126 | self.enabled_module_names = Setting.default_projects_modules |
|
126 | self.enabled_module_names = Setting.default_projects_modules | |
127 | end |
|
127 | end | |
128 | if !initialized.key?('trackers') && !initialized.key?('tracker_ids') |
|
128 | if !initialized.key?('trackers') && !initialized.key?('tracker_ids') | |
129 | self.trackers = Tracker.sorted.all |
|
129 | default = Setting.default_projects_tracker_ids | |
|
130 | if default.is_a?(Array) | |||
|
131 | self.trackers = Tracker.where(:id => default.map(&:to_i)).sorted.all | |||
|
132 | else | |||
|
133 | self.trackers = Tracker.sorted.all | |||
|
134 | end | |||
130 | end |
|
135 | end | |
131 | end |
|
136 | end | |
132 |
|
137 |
@@ -6,6 +6,9 | |||||
6 | <p><%= setting_multiselect(:default_projects_modules, |
|
6 | <p><%= setting_multiselect(:default_projects_modules, | |
7 | Redmine::AccessControl.available_project_modules.collect {|m| [l_or_humanize(m, :prefix => "project_module_"), m.to_s]}) %></p> |
|
7 | Redmine::AccessControl.available_project_modules.collect {|m| [l_or_humanize(m, :prefix => "project_module_"), m.to_s]}) %></p> | |
8 |
|
8 | |||
|
9 | <p><%= setting_multiselect(:default_projects_tracker_ids, | |||
|
10 | Tracker.sorted.all.collect {|t| [t.name, t.id.to_s]}) %></p> | |||
|
11 | ||||
9 | <p><%= setting_check_box :sequential_project_identifiers %></p> |
|
12 | <p><%= setting_check_box :sequential_project_identifiers %></p> | |
10 |
|
13 | |||
11 | <p><%= setting_select :new_project_user_role_id, |
|
14 | <p><%= setting_select :new_project_user_role_id, |
@@ -179,6 +179,9 default_projects_modules: | |||||
179 | - boards |
|
179 | - boards | |
180 | - calendar |
|
180 | - calendar | |
181 | - gantt |
|
181 | - gantt | |
|
182 | default_projects_tracker_ids: | |||
|
183 | serialized: true | |||
|
184 | default: | |||
182 | # Role given to a non-admin user who creates a project |
|
185 | # Role given to a non-admin user who creates a project | |
183 | new_project_user_role_id: |
|
186 | new_project_user_role_id: | |
184 | format: int |
|
187 | format: int |
@@ -87,7 +87,15 class ActiveSupport::TestCase | |||||
87 | end |
|
87 | end | |
88 |
|
88 | |||
89 | def with_settings(options, &block) |
|
89 | def with_settings(options, &block) | |
90 | saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].is_a?(Symbol) ? Setting[k] : Setting[k].dup; h} |
|
90 | saved_settings = options.keys.inject({}) do |h, k| | |
|
91 | h[k] = case Setting[k] | |||
|
92 | when Symbol, false, true, nil | |||
|
93 | Setting[k] | |||
|
94 | else | |||
|
95 | Setting[k].dup | |||
|
96 | end | |||
|
97 | h | |||
|
98 | end | |||
91 | options.each {|k, v| Setting[k] = v} |
|
99 | options.each {|k, v| Setting[k] = v} | |
92 | yield |
|
100 | yield | |
93 | ensure |
|
101 | ensure |
@@ -74,9 +74,30 class ProjectTest < ActiveSupport::TestCase | |||||
74 | with_settings :default_projects_modules => ['issue_tracking', 'repository'] do |
|
74 | with_settings :default_projects_modules => ['issue_tracking', 'repository'] do | |
75 | assert_equal ['issue_tracking', 'repository'], Project.new.enabled_module_names |
|
75 | assert_equal ['issue_tracking', 'repository'], Project.new.enabled_module_names | |
76 | end |
|
76 | end | |
|
77 | end | |||
|
78 | ||||
|
79 | def test_default_trackers_should_match_default_tracker_ids_setting | |||
|
80 | with_settings :default_projects_tracker_ids => ['1', '3'] do | |||
|
81 | assert_equal Tracker.find(1, 3).sort, Project.new.trackers.sort | |||
|
82 | end | |||
|
83 | end | |||
77 |
|
84 | |||
78 | assert_equal Tracker.all.sort, Project.new.trackers.sort |
|
85 | def test_default_trackers_should_be_all_trackers_with_blank_setting | |
79 | assert_equal Tracker.find(1, 3).sort, Project.new(:tracker_ids => [1, 3]).trackers.sort |
|
86 | with_settings :default_projects_tracker_ids => nil do | |
|
87 | assert_equal Tracker.all.sort, Project.new.trackers.sort | |||
|
88 | end | |||
|
89 | end | |||
|
90 | ||||
|
91 | def test_default_trackers_should_be_empty_with_empty_setting | |||
|
92 | with_settings :default_projects_tracker_ids => [] do | |||
|
93 | assert_equal [], Project.new.trackers | |||
|
94 | end | |||
|
95 | end | |||
|
96 | ||||
|
97 | def test_default_trackers_should_not_replace_initialized_trackers | |||
|
98 | with_settings :default_projects_tracker_ids => ['1', '3'] do | |||
|
99 | assert_equal Tracker.find(1, 2).sort, Project.new(:tracker_ids => [1, 2]).trackers.sort | |||
|
100 | end | |||
80 | end |
|
101 | end | |
81 |
|
102 | |||
82 | def test_update |
|
103 | def test_update |
General Comments 0
You need to be logged in to leave comments.
Login now