# 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
# 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