# Loads the default data
# Raises a RecordNotSaved exception if something goes wrong
- def load(lang=nil)
+ def load(lang=nil, options={})
raise DataAlreadyLoaded.new("Some configuration data is already loaded.") unless no_data?
set_language_if_valid(lang)
+ workflow = !(options[:workflow] == false)
Role.transaction do
# Roles
Tracker.create!(:name => l(:default_tracker_feature), :default_status_id => new.id, :is_in_chlog => true, :is_in_roadmap => true, :position => 2)
Tracker.create!(:name => l(:default_tracker_support), :default_status_id => new.id, :is_in_chlog => false, :is_in_roadmap => false, :position => 3)
- # Workflow
- Tracker.all.each { |t|
- IssueStatus.all.each { |os|
- IssueStatus.all.each { |ns|
- WorkflowTransition.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ if workflow
+ # Workflow
+ Tracker.all.each { |t|
+ IssueStatus.all.each { |os|
+ IssueStatus.all.each { |ns|
+ WorkflowTransition.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ }
}
}
- }
- Tracker.all.each { |t|
- [new, in_progress, resolved, feedback].each { |os|
- [in_progress, resolved, feedback, closed].each { |ns|
- WorkflowTransition.create!(:tracker_id => t.id, :role_id => developer.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ Tracker.all.each { |t|
+ [new, in_progress, resolved, feedback].each { |os|
+ [in_progress, resolved, feedback, closed].each { |ns|
+ WorkflowTransition.create!(:tracker_id => t.id, :role_id => developer.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ }
}
}
- }
- Tracker.all.each { |t|
- [new, in_progress, resolved, feedback].each { |os|
- [closed].each { |ns|
- WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ Tracker.all.each { |t|
+ [new, in_progress, resolved, feedback].each { |os|
+ [closed].each { |ns|
+ WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ }
}
+ WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => resolved.id, :new_status_id => feedback.id)
}
- WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => resolved.id, :new_status_id => feedback.id)
- }
+ end
# Enumerations
IssuePriority.create!(:name => l(:default_priority_low), :position => 1)
def test_no_data
assert !Redmine::DefaultData::Loader::no_data?
- Role.where("builtin = 0").delete_all
- Tracker.delete_all
- IssueStatus.delete_all
- Enumeration.delete_all
+ clear_data
assert Redmine::DefaultData::Loader::no_data?
end
def test_load
+ clear_data
+ assert Redmine::DefaultData::Loader::load('en')
+ assert_not_nil DocumentCategory.first
+ assert_not_nil IssuePriority.first
+ assert_not_nil TimeEntryActivity.first
+ assert_not_nil WorkflowTransition.first
+ end
+
+ def test_load_for_all_language
valid_languages.each do |lang|
+ clear_data
begin
- Role.where("builtin = 0").delete_all
- Tracker.delete_all
- IssueStatus.delete_all
- Enumeration.delete_all
- assert Redmine::DefaultData::Loader::load(lang)
+ assert Redmine::DefaultData::Loader::load(lang, :workflow => false)
assert_not_nil DocumentCategory.first
assert_not_nil IssuePriority.first
assert_not_nil TimeEntryActivity.first
end
end
end
+
+ def clear_data
+ Role.where("builtin = 0").delete_all
+ Tracker.delete_all
+ IssueStatus.delete_all
+ Enumeration.delete_all
+ WorkflowRule.delete_all
+ end
end