]> source.dussan.org Git - redmine.git/commitdiff
Merged r14508 (#20512).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 12 Sep 2015 12:48:51 +0000 (12:48 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 12 Sep 2015 12:48:51 +0000 (12:48 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.1-stable@14556 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb
test/unit/project_test.rb

index 4a54b221085f81cf57060f8fc93352f363a26d87..aacb01c15dc5a32ebf67ff08dc4a5e7c27f9fcdf 100644 (file)
@@ -751,7 +751,7 @@ class Project < ActiveRecord::Base
     # clear unique attributes
     attributes = project.attributes.dup.except('id', 'name', 'identifier', 'status', 'parent_id', 'lft', 'rgt')
     copy = Project.new(attributes)
-    copy.enabled_modules = project.enabled_modules
+    copy.enabled_module_names = project.enabled_module_names
     copy.trackers = project.trackers
     copy.custom_values = project.custom_values.collect {|v| v.clone}
     copy.issue_custom_fields = project.issue_custom_fields
index 4d6979fe6e7a08737dba5af768aba64fd867228c..c76272e7b8bf30b38656043acca86915d516efd5 100644 (file)
@@ -723,13 +723,26 @@ class ProjectTest < ActiveSupport::TestCase
 
     # Duplicated attributes
     assert_equal source_project.description, copied_project.description
-    assert_equal source_project.enabled_modules, copied_project.enabled_modules
     assert_equal source_project.trackers, copied_project.trackers
 
     # Default attributes
     assert_equal 1, copied_project.status
   end
 
+  def test_copy_from_should_copy_enabled_modules
+    source = Project.generate!
+    source.enabled_module_names = %w(issue_tracking wiki)
+
+    copy = Project.copy_from(source)
+    copy.name = 'Copy'
+    copy.identifier = 'copy'
+    assert_difference 'EnabledModule.count', 2 do
+      copy.save!
+    end
+    assert_equal 2, copy.reload.enabled_modules.count
+    assert_equal 2, source.reload.enabled_modules.count
+  end
+
   def test_activities_should_use_the_system_activities
     project = Project.find(1)
     assert_equal project.activities.to_a, TimeEntryActivity.where(:active => true).to_a