Add `sis_batch_id` to NOP fields for update

`sis_batch_id` is updated even when no other field is changed on a sis
batch import. Add `sis_batch_id` to the list of fields that will not
trigger a live-events stream update.

Test Plan:
  * Specs

closes RECNVS-239

Change-Id: I15f0b82dbbe1dc47885d3f2ce05932ba66f96c97
Reviewed-on: https://gerrit.instructure.com/137963
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Jonathan Featherstone <jfeatherstone@instructure.com>
QA-Review: Jonathan Featherstone <jfeatherstone@instructure.com>
This commit is contained in:
Jonathan Featherstone 2018-01-15 14:25:32 -07:00
parent 18896f628e
commit 89e7d3eda7
2 changed files with 12 additions and 1 deletions

View File

@ -34,9 +34,10 @@ class LiveEventsObserver < ActiveRecord::Observer
:account_notification,
:course_section
NOP_UPDATE_FIELDS = [ "updated_at", "sis_batch_id" ].freeze
def after_update(obj)
changes = obj.changes
return nil if changes.except("updated_at").empty?
return nil if changes.except(*NOP_UPDATE_FIELDS).empty?
obj.class.connection.after_transaction_commit do
case obj

View File

@ -27,6 +27,16 @@ describe LiveEventsObserver do
expect(Canvas::LiveEvents).to receive(:user_updated).never
@user.save!
end
it "doesn't post events for NOP fields" do
account_model
course_model(name: "CS101", account: @account)
sis = @account.sis_batches.create
@course.name = "CS101"
@course.sis_batch_id = sis.id
expect(Canvas::LiveEvents).to receive(:course_updated).never
@course.save!
end
it "does post event for actual change" do
user_model(name: "Joey Joe Joe")