From 637ec7e883647baa3cffdd8ea27d56246e522f85 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 12 Sep 2015 12:48:51 +0000 Subject: [PATCH] Merged r14508 (#20512). git-svn-id: http://svn.redmine.org/redmine/branches/3.1-stable@14556 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/project.rb | 2 +- test/unit/project_test.rb | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 4a54b2210..aacb01c15 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 4d6979fe6..c76272e7b 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -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 -- 2.39.5