spec: Throw a ForeignKeyNotSatisfied if an assignment doesn't exist
When creating an AssignmentOverride for the CDC schema tests, it currently fills in 1 for assignment_id. Any required integer field is auto-filled with a 1, so we're assuming that an assignment exists with an ID of 1. This isn't a safe assumption, so look for an actual assignment instead, and throw a ForeignKeyNotSatisfied error if there isn't one yet. (ForeignKeyNotSatisfied will push this model to the back of the queue and try to create it later, after other models have been created.) Change-Id: I6dea6e5e6e0c553a3ba261f47565fc1dda95ce7f Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/248890 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Evan Battaglia <ebattaglia@instructure.com> QA-Review: Tucker Mcknight <tmcknight@instructure.com> Product-Review: Tucker Mcknight <tmcknight@instructure.com>
This commit is contained in:
parent
1adcb0bc1e
commit
f9fa2d57a0
|
@ -17,12 +17,18 @@
|
|||
#
|
||||
|
||||
module CdcFixtures
|
||||
class ForeignKeyNotSatisfied < StandardError
|
||||
end
|
||||
|
||||
def self.create_assignment_override
|
||||
assignment = Assignment.first
|
||||
raise CdcFixtures::ForeignKeyNotSatisfied unless assignment
|
||||
|
||||
AssignmentOverride.new({
|
||||
workflow_state: 'default',
|
||||
title: 'default',
|
||||
set_id: 1,
|
||||
assignment_id: 1
|
||||
assignment_id: assignment.id
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue