Skip to content

Commit

Permalink
Merge branch 'development' into fix-for-broken-v1-api-doc-link
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpinto1 authored Dec 16, 2024
2 parents 4fe0792 + 2d707d5 commit d72cd71
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

- Refactor Plan.deep_copy(plan) [#3469](https://github.com/DMPRoadmap/roadmap/pull/3469)
- Fixed a bug in the deep copy of plans where the old identifier was being copied into the new plan. We now copy the generated id of the new plan to the identifier field.
- Fixed bar chart click function in the Usage dashboard (GitHub issue #3443)

Expand Down
4 changes: 1 addition & 3 deletions app/models/plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,9 @@ def self.deep_copy(plan)
plan_copy.save!
# Copy newly generated Id to the identifier
plan_copy.identifier = plan_copy.id.to_s
plan.save!
plan.answers.each do |answer|
answer_copy = Answer.deep_copy(answer)
answer_copy.plan_id = plan_copy.id
answer_copy.save!
plan_copy.answers << answer_copy
end
plan.guidance_groups.each do |guidance_group|
plan_copy.guidance_groups << guidance_group if guidance_group.present?
Expand Down
4 changes: 4 additions & 0 deletions spec/models/plan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@
expect(subject.title).to include(plan.title)
end

it "copies the new plan's id to its identifer" do
expect(subject.identifier).to eql(subject.id.to_s)
end

it 'persists the record' do
expect(subject).to be_persisted
end
Expand Down

0 comments on commit d72cd71

Please sign in to comment.