check_box_tag(
"settings[#{setting}][]",
value,
- Setting.send(setting).include?(value),
+ setting_values.include?(value),
:id => nil
) + text.to_s,
:class => (options[:inline] ? 'inline' : 'block')
self.enabled_module_names = Setting.default_projects_modules
end
if !initialized.key?('trackers') && !initialized.key?('tracker_ids')
- self.trackers = Tracker.sorted.all
+ default = Setting.default_projects_tracker_ids
+ if default.is_a?(Array)
+ self.trackers = Tracker.where(:id => default.map(&:to_i)).sorted.all
+ else
+ self.trackers = Tracker.sorted.all
+ end
end
end
<p><%= setting_multiselect(:default_projects_modules,
Redmine::AccessControl.available_project_modules.collect {|m| [l_or_humanize(m, :prefix => "project_module_"), m.to_s]}) %></p>
+<p><%= setting_multiselect(:default_projects_tracker_ids,
+ Tracker.sorted.all.collect {|t| [t.name, t.id.to_s]}) %></p>
+
<p><%= setting_check_box :sequential_project_identifiers %></p>
<p><%= setting_select :new_project_user_role_id,
- boards
- calendar
- gantt
+default_projects_tracker_ids:
+ serialized: true
+ default:
# Role given to a non-admin user who creates a project
new_project_user_role_id:
format: int
end
def with_settings(options, &block)
- saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].is_a?(Symbol) ? Setting[k] : Setting[k].dup; h}
+ saved_settings = options.keys.inject({}) do |h, k|
+ h[k] = case Setting[k]
+ when Symbol, false, true, nil
+ Setting[k]
+ else
+ Setting[k].dup
+ end
+ h
+ end
options.each {|k, v| Setting[k] = v}
yield
ensure
with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
assert_equal ['issue_tracking', 'repository'], Project.new.enabled_module_names
end
+ end
+
+ def test_default_trackers_should_match_default_tracker_ids_setting
+ with_settings :default_projects_tracker_ids => ['1', '3'] do
+ assert_equal Tracker.find(1, 3).sort, Project.new.trackers.sort
+ end
+ end
- assert_equal Tracker.all.sort, Project.new.trackers.sort
- assert_equal Tracker.find(1, 3).sort, Project.new(:tracker_ids => [1, 3]).trackers.sort
+ def test_default_trackers_should_be_all_trackers_with_blank_setting
+ with_settings :default_projects_tracker_ids => nil do
+ assert_equal Tracker.all.sort, Project.new.trackers.sort
+ end
+ end
+
+ def test_default_trackers_should_be_empty_with_empty_setting
+ with_settings :default_projects_tracker_ids => [] do
+ assert_equal [], Project.new.trackers
+ end
+ end
+
+ def test_default_trackers_should_not_replace_initialized_trackers
+ with_settings :default_projects_tracker_ids => ['1', '3'] do
+ assert_equal Tracker.find(1, 2).sort, Project.new(:tracker_ids => [1, 2]).trackers.sort
+ end
end
def test_update