spec: Manually create a delayed job in a fixture file
Having a delayed job with an id of 1 causes a conflict later when inst-jobs automatically creates a job also with an id of 1. As a workaround, manually create one with an id of 2. fixes INTEROP-6439 Change-Id: I3a8842bf0073972293cc83c3bfd263ab1fa57053 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/256383 Reviewed-by: Wagner Goncalves <wagner.goncalves@instructure.com> QA-Review: Tucker Mcknight <tmcknight@instructure.com> Product-Review: Tucker Mcknight <tmcknight@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
parent
a4c4abf86c
commit
43982889b5
|
@ -0,0 +1,37 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Copyright (C) 2020 - 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/>.
|
||||
#
|
||||
|
||||
module CdcFixtures
|
||||
def self.create_job
|
||||
# The model-generator can successfully auto-create a delayed job model.
|
||||
# However, this causes a problem when a PluginSetting model is created.
|
||||
# When a PluginSetting is created, it also creates a delayed job (the
|
||||
# inst-jobs gem does this automatically), and that job gets an id of 1
|
||||
# for some reason, even though a job with id=1 already exists. The new job
|
||||
# id doesn't get auto-incremented to 2.
|
||||
# I couldn't figure out why that was happening, so this is a workaround.
|
||||
# Manually create a delayed job here, with an id of 2, so that the
|
||||
# other job created along with the PluginSetting can use id 1.
|
||||
return Delayed::Backend::ActiveRecord::Job.new(
|
||||
id: 2,
|
||||
run_at: Time.zone.now,
|
||||
)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue