From: Jean-Philippe Lang Date: Sat, 31 Dec 2016 12:53:38 +0000 (+0000) Subject: Skip workflow creation in tests for each locale. X-Git-Tag: 3.4.0~473 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f2bf5aa25c482eb48d24135a19cb6f4455bf263f;p=redmine.git Skip workflow creation in tests for each locale. git-svn-id: http://svn.redmine.org/redmine/trunk@16115 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/lib/redmine/default_data/loader.rb b/lib/redmine/default_data/loader.rb index 0fdfad61f..0d36dbba8 100644 --- a/lib/redmine/default_data/loader.rb +++ b/lib/redmine/default_data/loader.rb @@ -34,9 +34,10 @@ module Redmine # 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 @@ -139,31 +140,33 @@ module Redmine 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) diff --git a/test/unit/default_data_test.rb b/test/unit/default_data_test.rb index c22e9341f..e60702940 100644 --- a/test/unit/default_data_test.rb +++ b/test/unit/default_data_test.rb @@ -23,21 +23,24 @@ class DefaultDataTest < ActiveSupport::TestCase 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 @@ -46,4 +49,12 @@ class DefaultDataTest < ActiveSupport::TestCase 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