Skip to content

Commit

Permalink
Project Copier: tweaks to initialization (#4270)
Browse files Browse the repository at this point in the history
* Add more fields to EXCLUDE_ATTRIBUTES

* add tests for the EXCLUDE_ATTRIBUTES functionality

* remove unused attribute

* fix default_array declaration

* refactor project_copier exclude_attributes tests

* refactor project_copier exclude_attributes tests

---------

Co-authored-by: tooyosi <[email protected]>
  • Loading branch information
lcjohnso and Tooyosi authored Mar 12, 2024
1 parent b91a4c2 commit 23605b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/project_copier.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
class ProjectCopier
attr_reader :project_to_copy, :user

EXCLUDE_ATTRIBUTES = %i[classifications_count launched_row_order beta_row_order].freeze
EXCLUDE_ATTRIBUTES = %i[
classifications_count
classifiers_count
launch_date
completeness
activity
lock_version
launched_row_order
beta_row_order
].freeze

INCLUDE_ASSOCIATIONS = [
:tutorials,
:pages,
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/project_copier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
expect(copied_project.configuration['source_project_id']).to be(project.id)
end

it 'does not copy over excluded attributes' do
project_with_excluded_keys = create(:full_project, classifications_count: 3, classifiers_count: 2, launch_date: Date.yesterday, completeness: 0.5, activity: 1, lock_version: 8)
other_copied_project = described_class.new(project_with_excluded_keys.id, copyist.id).copy
ProjectCopier::EXCLUDE_ATTRIBUTES.each do |attr|
expect(other_copied_project[attr]).not_to eq(project_with_excluded_keys[attr])
end
end

it 'creates Talk roles for the new project and its owner' do
allow(TalkAdminCreateWorker).to receive(:perform_async)
copied_project
Expand Down

0 comments on commit 23605b0

Please sign in to comment.