Announce MasterMigration completed on LiveEvents
closes QUIZ-9360 flag=none Test Plan: - specs pass Change-Id: I6ac5e69e7bbb80624d9813a48ba3d03ad3ee154f Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/287605 QA-Review: Jorge Arteaga <jorge.arteaga@instructure.com> Product-Review: Jorge Arteaga <jorge.arteaga@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Alex Slaughter <aslaughter@instructure.com>
This commit is contained in:
parent
08965f67ca
commit
2628d3675e
|
@ -51,7 +51,8 @@ class LiveEventsObserver < ActiveRecord::Observer
|
|||
:user_account_association,
|
||||
:user,
|
||||
:wiki_page,
|
||||
"MasterCourses::MasterTemplate"
|
||||
"MasterCourses::MasterTemplate",
|
||||
"MasterCourses::MasterMigration"
|
||||
|
||||
NOP_UPDATE_FIELDS = ["updated_at", "sis_batch_id"].freeze
|
||||
def after_update(obj)
|
||||
|
|
|
@ -984,6 +984,18 @@ module Canvas::LiveEvents
|
|||
}
|
||||
end
|
||||
|
||||
def self.master_migration_completed(master_migration)
|
||||
post_event_stringified("master_migration_completed", master_migration_completed_data(master_migration))
|
||||
end
|
||||
|
||||
def self.master_migration_completed_data(master_migration)
|
||||
{
|
||||
master_migration_id: master_migration.id,
|
||||
master_template_id: master_migration.master_template_id,
|
||||
root_account_id: master_migration.root_account_id
|
||||
}
|
||||
end
|
||||
|
||||
def self.heartbeat
|
||||
data = {
|
||||
environment: Canvas.environment,
|
||||
|
|
|
@ -188,6 +188,10 @@ module Canvas::LiveEventsCallbacks
|
|||
Canvas::LiveEvents.outcome_calculation_method_updated(obj)
|
||||
when OutcomeFriendlyDescription
|
||||
Canvas::LiveEvents.outcome_friendly_description_updated(obj)
|
||||
when MasterCourses::MasterMigration
|
||||
if changes["workflow_state"] && obj.workflow_state == "completed"
|
||||
Canvas::LiveEvents.master_migration_completed(obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2000,6 +2000,25 @@ describe Canvas::LiveEvents do
|
|||
end
|
||||
end
|
||||
|
||||
describe "master migration" do
|
||||
before do
|
||||
@course = course_model
|
||||
@master_template = MasterCourses::MasterTemplate.create!(course: @course)
|
||||
@master_migration = MasterCourses::MasterMigration.create!(master_template: @master_template)
|
||||
end
|
||||
|
||||
context "completed" do
|
||||
it "triggers an master_migration_completed live event" do
|
||||
expect_event("master_migration_completed", {
|
||||
master_template_id: @master_template.id.to_s,
|
||||
master_migration_id: @master_migration.id.to_s,
|
||||
root_account_id: @master_migration.root_account_id.to_s
|
||||
}).once
|
||||
Canvas::LiveEvents.master_migration_completed(@master_migration)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "heartbeat" do
|
||||
context "when database region is not set (local/open source)" do
|
||||
it "sets region to not_configured" do
|
||||
|
|
|
@ -609,4 +609,22 @@ describe LiveEventsObserver do
|
|||
MasterCourses::MasterTemplate.create!(course: @course)
|
||||
end
|
||||
end
|
||||
|
||||
describe "MasterCourses::MasterMigration" do
|
||||
it "posts update events when the migration completes" do
|
||||
course_model
|
||||
master_template = MasterCourses::MasterTemplate.create!(course: @course)
|
||||
master_migration = MasterCourses::MasterMigration.create!(master_template: master_template)
|
||||
expect(Canvas::LiveEvents).to receive(:master_migration_completed).once
|
||||
master_migration.update(workflow_state: "completed")
|
||||
end
|
||||
|
||||
it "does not post update events when the migration updates for other reasons" do
|
||||
course_model
|
||||
master_template = MasterCourses::MasterTemplate.create!(course: @course)
|
||||
master_migration = MasterCourses::MasterMigration.create!(master_template: master_template)
|
||||
expect(Canvas::LiveEvents).not_to receive(:master_migration_completed)
|
||||
master_migration.update(workflow_state: "exports_failed")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue