Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/canvas/live_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ def self.get_attachment_data(attachment)
folder_id: attachment.global_folder_id,
unlock_at: attachment.unlock_at,
lock_at: attachment.lock_at,
locked: attachment.locked,
updated_at: attachment.updated_at
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/canvas/live_events_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def self.after_update(obj, changes)
Canvas::LiveEvents.assignment_override_updated(obj)
when Attachment
if attachment_eligible?(obj)
if %w[display_name lock_at unlock_at folder_id].any? { |field| changes[field] }
if %w[display_name lock_at unlock_at folder_id locked].any? { |field| changes[field] }
Canvas::LiveEvents.attachment_updated(obj, changes["display_name"]&.first)
elsif changes["file_state"] && obj.file_state == "deleted"
# Attachments are often soft deleted rather than destroyed
Expand Down
15 changes: 15 additions & 0 deletions spec/observers/live_events_observer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@
attachment.touch
end
end

context "if the attachment is published" do
it "posts attachment_updated event" do
attachment.update(locked: true)
expect(Canvas::LiveEvents).to receive(:attachment_updated)
attachment.publish!
end
end

context "if the attachment is unpublished" do
it "posts attachment_updated event" do
expect(Canvas::LiveEvents).to receive(:attachment_updated)
attachment.update(locked: true)
end
end
end

describe "conversation" do
Expand Down