cdc: improve reliability of fixture creation
Change-Id: I4c458ab1a79ffba18eaec2bf732727f125650d62 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277645 Reviewed-by: Jacob Burroughs <jburroughs@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
9075b1d8b2
commit
42bffa8b21
|
@ -26,11 +26,10 @@ module CdcFixtures
|
|||
assignment = Assignment.first
|
||||
raise CdcFixtures::ForeignKeyNotSatisfied unless assignment
|
||||
|
||||
AssignmentOverride.new({
|
||||
workflow_state: 'default',
|
||||
title: 'default',
|
||||
set_id: 1,
|
||||
assignment_id: assignment.id
|
||||
})
|
||||
AssignmentOverride.new(id: 1,
|
||||
workflow_state: 'default',
|
||||
title: 'default',
|
||||
set_id: 1,
|
||||
assignment_id: assignment.id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,13 +20,12 @@
|
|||
|
||||
module CdcFixtures
|
||||
def self.create_blackout_date
|
||||
BlackoutDate.new({
|
||||
context_type: 'Account',
|
||||
context_id: 1,
|
||||
start_date: Time.zone.today,
|
||||
end_date: Time.zone.today,
|
||||
event_title: 'default',
|
||||
root_account_id: 1
|
||||
})
|
||||
BlackoutDate.new(id: 1,
|
||||
context_type: 'Account',
|
||||
context_id: 1,
|
||||
start_date: Time.zone.today,
|
||||
end_date: Time.zone.today,
|
||||
event_title: 'default',
|
||||
root_account_id: 1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
# 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,
|
||||
queue: 'test',
|
||||
)
|
||||
end
|
||||
end
|
|
@ -21,6 +21,6 @@
|
|||
module CdcFixtures
|
||||
def self.create_profile
|
||||
Course.find_or_create_by!(id: 1)
|
||||
Profile.new(context_id: 1, context_type: 'Course', root_account_id: 1)
|
||||
Profile.new(id: 1, context_id: 1, context_type: 'Course', root_account_id: 1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,18 +20,23 @@
|
|||
|
||||
module CdcFixtures
|
||||
def self.create_web_conference
|
||||
ps = PluginSetting.find_or_create_by(name: 'adobe_connect')
|
||||
ps.settings = {}
|
||||
ps.disabled = false
|
||||
ps.save!
|
||||
# the model-generator may have created a record with id 1 already, but
|
||||
# bypassing the sequence, so it'll try to create with id 1 and fail.
|
||||
# just let it try twice
|
||||
PluginSetting.unique_constraint_retry do
|
||||
ps = PluginSetting.where(name: 'adobe_connect').first_or_initialize
|
||||
ps.settings = {}
|
||||
ps.disabled = false
|
||||
ps.save! if ps.changed?
|
||||
end
|
||||
|
||||
return WebConference.new({
|
||||
title: 'default',
|
||||
conference_type: 'AdobeConnect',
|
||||
context_id: 1,
|
||||
context_type: 'Course',
|
||||
user_id: 1,
|
||||
root_account_id: 1,
|
||||
})
|
||||
WebConference.new(
|
||||
title: 'default',
|
||||
conference_type: 'AdobeConnect',
|
||||
context_id: 1,
|
||||
context_type: 'Course',
|
||||
user_id: 1,
|
||||
root_account_id: 1,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,12 +20,13 @@
|
|||
|
||||
module CdcFixtures
|
||||
def self.create_wiki_page
|
||||
Wiki.new.save!(validate: false)
|
||||
WikiPage.new({
|
||||
wiki_id: 1,
|
||||
workflow_state: 'default',
|
||||
context_id: 1,
|
||||
context_type: 'Course'
|
||||
})
|
||||
wiki = Wiki.where(id: 1).first_or_initialize
|
||||
wiki.save!(validate: false) if wiki.new_record?
|
||||
|
||||
WikiPage.new(id: 1,
|
||||
wiki_id: 1,
|
||||
workflow_state: 'default',
|
||||
context_id: 1,
|
||||
context_type: 'Course')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue