]> source.dussan.org Git - redmine.git/commitdiff
Skip workflow creation in tests for each locale.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 31 Dec 2016 12:53:38 +0000 (12:53 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 31 Dec 2016 12:53:38 +0000 (12:53 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@16115 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/default_data/loader.rb
test/unit/default_data_test.rb

index 0fdfad61f08d0fd642325f3a3668e2b0734584ce..0d36dbba8f5ccdc7f98354c185fabd39019821de 100644 (file)
@@ -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)
index c22e9341f5a3031d1a1ccf3476b5460e7cf47a85..e60702940a58ff4d7f03137a289b743d47916d1e 100644 (file)
@@ -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