diff --git a/lib/project_copier.rb b/lib/project_copier.rb index 3edd513ea..e6f458917 100644 --- a/lib/project_copier.rb +++ b/lib/project_copier.rb @@ -11,7 +11,7 @@ class ProjectCopier launched_row_order beta_row_order ].freeze - + INCLUDE_ASSOCIATIONS = [ :tutorials, :pages, @@ -61,7 +61,7 @@ def copy_project copied_project = project_to_copy.deep_clone include: INCLUDE_ASSOCIATIONS, except: EXCLUDE_ATTRIBUTES copied_project.owner = user - copied_project.display_name += ' (copy)' if user == project_to_copy.owner + copied_project.display_name += " (copy: #{Time.now.utc.strftime('%Y-%m-%d %H:%M:%S')})" copied_project.assign_attributes(launch_approved: false, live: false) # reset the project's configuration but record the source project id diff --git a/spec/lib/project_copier_spec.rb b/spec/lib/project_copier_spec.rb index 46cf657f8..407efa56b 100644 --- a/spec/lib/project_copier_spec.rb +++ b/spec/lib/project_copier_spec.rb @@ -16,13 +16,9 @@ expect(copied_project.owner).to eq(copyist) end - it 'renames a project when the owner is copying their own project' do - new_copy = described_class.new(project.id, project.owner.id).copy - expect(new_copy.display_name).to include('(copy)') - end - - it 'has matching attributes' do - expect(copied_project.display_name).to eq(project.display_name) + it 'appends copy and current timestamp to display_name' do + allow(Time).to receive(:now).and_return(Time.utc(2024, 5, 17, 12, 0, 0)) + expect(copied_project.display_name).to eq("#{project.display_name} (copy: 2024-05-17 12:00:00)") end it 'resets the live attribute' do