fix moving outcomes via csv import
closes OUT-3426 flag = none Test plan: - save the sample data at the bottom of http://canvas.docker/doc/api/file.outcomes_csv.html to a csv file - on the account outcomes page, import the file's outcomes into the account - update the file with a second group d,group,Child group 2,child group description,G-1.2,,,active,a, - update the outcome to belong to the new group c,outcome,...,active,d,3,... - verify that update completes successfully and outcome has moved to theh newly created "Child group 2" Change-Id: Ie8f26497bb58bf513b2fc6734be213601e2442b4 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/221207 Tested-by: Jenkins Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Frank Murphy <fmurphy@instructure.com> QA-Review: Pat Renner <prenner@instructure.com> Product-Review: Michael Brewer-Davis <mbd@instructure.com>
This commit is contained in:
parent
66315ea980
commit
17eaae6e8d
|
@ -273,15 +273,17 @@ module Outcomes
|
|||
where(workflow_state: 'deleted')
|
||||
resurrect.update_all(workflow_state: 'active')
|
||||
|
||||
# add new parents before removing old to avoid deleting last link
|
||||
# to an aligned outcome
|
||||
existing_parent_ids = existing_links.pluck(:associated_asset_id)
|
||||
new_parents = parents.reject { |p| existing_parent_ids.include?(p.id) }
|
||||
new_parents.each { |p| p.add_outcome(outcome) }
|
||||
|
||||
kill = existing_links.
|
||||
where.not(associated_asset_id: next_parent_ids).
|
||||
where(associated_asset_type: 'LearningOutcomeGroup').
|
||||
where(workflow_state: 'active')
|
||||
kill.destroy_all
|
||||
|
||||
existing_parent_ids = existing_links.pluck(:associated_asset_id)
|
||||
new_parents = parents.reject { |p| existing_parent_ids.include?(p.id) }
|
||||
new_parents.each { |p| p.add_outcome(outcome) }
|
||||
end
|
||||
|
||||
def outcome_import_id
|
||||
|
|
|
@ -415,7 +415,15 @@ RSpec.describe Outcomes::Import do
|
|||
it 'reassigns parents of existing outcome' do
|
||||
parent1.add_outcome(existing_outcome)
|
||||
importer.import_outcome(**outcome_attributes, parent_guids: 'parent2')
|
||||
expect(parent1.child_outcome_links.active.map(&:content)).to be_empty
|
||||
expect(parent1.child_outcome_links.active.map(&:content)).to be_empty
|
||||
expect(parent2.child_outcome_links.active.map(&:content)).to include existing_outcome
|
||||
end
|
||||
|
||||
it 'reassigns parents of an aligned outcome' do
|
||||
outcome_with_rubric(outcome: existing_outcome)
|
||||
parent1.add_outcome(existing_outcome)
|
||||
importer.import_outcome(**outcome_attributes, parent_guids: 'parent2')
|
||||
expect(parent1.child_outcome_links.active.map(&:content)).to be_empty
|
||||
expect(parent2.child_outcome_links.active.map(&:content)).to include existing_outcome
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue