Fix Originality report creation fk violations
Fixes PLAT-3257 Test Plan: - Verify you can successfully create an originality report with an attachment on a different shard than the report. - Run through a simple workflow of the plagiarism detection platform to verify all works as before when attachment is on the same shard or a second shard. Change-Id: I0c42d3ec5634e269c896b46bc8111f95bbaca903 Reviewed-on: https://gerrit.instructure.com/146144 Reviewed-by: Rob Orton <rob@instructure.com> Reviewed-by: Nathan Mills <nathanm@instructure.com> QA-Review: August Thornton <august@instructure.com> Tested-by: Jenkins Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
parent
80e5dc21de
commit
06a764452a
|
@ -0,0 +1,31 @@
|
|||
#
|
||||
# Copyright (C) 2018 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
class RemoveAttachmentForeignKeyFromOriginalityReports < ActiveRecord::Migration[5.1]
|
||||
tag :predeploy
|
||||
|
||||
def up
|
||||
remove_foreign_key :originality_reports, column: :attachment_id
|
||||
remove_foreign_key :originality_reports, column: :originality_report_attachment_id
|
||||
end
|
||||
|
||||
def down
|
||||
add_foreign_key :originality_reports, :attachments, column: :attachment_id
|
||||
add_foreign_key :originality_reports, :attachments, column: :originality_report_attachment_id
|
||||
end
|
||||
end
|
|
@ -285,6 +285,32 @@ describe OriginalityReport do
|
|||
end.not_to change(OriginalityReport, :count)
|
||||
end
|
||||
|
||||
context 'with sharding' do
|
||||
specs_require_sharding
|
||||
|
||||
let(:new_shard) { Shard.create! }
|
||||
let(:new_shard_attachment) { new_shard.activate { attachment_model } }
|
||||
let(:submission) { submission_model }
|
||||
|
||||
it 'allows cross-shard attachment associations' do
|
||||
report = OriginalityReport.create!(
|
||||
submission: submission,
|
||||
originality_score: 50,
|
||||
attachment: new_shard_attachment
|
||||
)
|
||||
expect(report.attachment).to eq new_shard_attachment
|
||||
end
|
||||
|
||||
it 'allows cross-shard report attachment associations' do
|
||||
report = OriginalityReport.create!(
|
||||
submission: submission,
|
||||
originality_score: 50,
|
||||
originality_report_attachment: new_shard_attachment
|
||||
)
|
||||
expect(report.originality_report_attachment).to eq new_shard_attachment
|
||||
end
|
||||
end
|
||||
|
||||
context 'when lti link is present' do
|
||||
let!(:link) do
|
||||
Lti::Link.create!(
|
||||
|
|
Loading…
Reference in New Issue