Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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