fix duplicated LiveEvent when locking a quiz

refs QUIZ-9877
flag = none

when a quiz is initially locked, the live-event
blueprint_restrictions_updated is sent twice.
(after_create and after_update)
the after_create event does not contain
restrictions yet and conflicts with the
other LE that does. This causes initial
lockings to not be propagated to Quiz_API.

subsequent lockings/unlockings work as
intented.

this PS removes a the useless after_create
callback.

test plan:
- setup a Blueprint course
- add a new quiz to the course
  (make sure the quiz was not locked before)
- lock the quiz
- observe that `one` blueprint_restrictions_updated
  live event is sent, with the correct data.
- subsequent lockings/unlockings should work as
  usual.

Change-Id: I48c1a09af506708945ca3b49858f632f720c0e42
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/299442
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Ricardo Oliveira <ricardo.oliveira@instructure.com>
Product-Review: Marissa Pio Roda <marissa.pioroda@instructure.com>
Reviewed-by: Dustin Cowles <dustin.cowles@instructure.com>
This commit is contained in:
Jorge Arteaga 2022-08-23 16:04:14 -04:00
parent 320fc01b23
commit e967c70a8b
2 changed files with 3 additions and 15 deletions

View File

@ -93,8 +93,6 @@ module Canvas::LiveEventsCallbacks
Canvas::LiveEvents.master_template_created(obj)
when MasterCourses::ChildSubscription
Canvas::LiveEvents.blueprint_subscription_created(obj)
when MasterCourses::MasterContentTag
Canvas::LiveEvents.blueprint_restrictions_updated(obj) if obj.quiz_lti_content?
end
end

View File

@ -654,14 +654,9 @@ describe LiveEventsObserver do
allow_any_instance_of(Assignment).to receive(:quiz_lti?).and_return(true)
end
it "posts a blueprint_restrictions_updated event after create" do
expect(Canvas::LiveEvents).to receive(:blueprint_restrictions_updated).once
MasterCourses::MasterContentTag.create!(@master_content_tag_params)
end
context "when the restrictions field change" do
it "posts a blueprint_restrictions_updated event after update" do
expect(Canvas::LiveEvents).to receive(:blueprint_restrictions_updated).twice
expect(Canvas::LiveEvents).to receive(:blueprint_restrictions_updated).once
master_content_tag = MasterCourses::MasterContentTag.create!(@master_content_tag_params)
updated_restrictions =
@ -672,7 +667,7 @@ describe LiveEventsObserver do
context "when the use_default_restrictions field change" do
it "posts a blueprint_restrictions_updated event after update" do
expect(Canvas::LiveEvents).to receive(:blueprint_restrictions_updated).twice
expect(Canvas::LiveEvents).to receive(:blueprint_restrictions_updated).once
master_content_tag = MasterCourses::MasterContentTag.create!(@master_content_tag_params)
master_content_tag.update!(use_default_restrictions: false)
end
@ -680,7 +675,7 @@ describe LiveEventsObserver do
context "when restriction-related fields do not change" do
it "does not post a blueprint_restrictions_updated event after update" do
expect(Canvas::LiveEvents).to receive(:blueprint_restrictions_updated).once
expect(Canvas::LiveEvents).not_to receive(:blueprint_restrictions_updated)
master_content_tag = MasterCourses::MasterContentTag.create!(@master_content_tag_params)
master_content_tag.update!(migration_id: "mastercourse_1_3_d0d68ef2dc33bc0af9ca51a6679e4779")
end
@ -688,11 +683,6 @@ describe LiveEventsObserver do
end
context "when the master_content_tag is not associated with a New Quiz" do
it "does not post a blueprint_restrictions_updated event after create" do
expect(Canvas::LiveEvents).not_to receive(:blueprint_restrictions_updated)
MasterCourses::MasterContentTag.create!(@master_content_tag_params)
end
it "does not post a blueprint_restrictions_updated event after update" do
expect(Canvas::LiveEvents).not_to receive(:blueprint_restrictions_updated)
master_content_tag = MasterCourses::MasterContentTag.create!(@master_content_tag_params)