fire global announcement live events

closes MBL-6063

test plan:
- I'm not sure how these things are tested, but
- create an account notification
- check that a live event was fired off

Change-Id: I2d041183fc4da859a9c7f2ab9a28f1572a02ccfb
Reviewed-on: https://gerrit.instructure.com/93222
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
QA-Review: Benjamin Christian Nelson <bcnelson@instructure.com>
Product-Review: Cameron Sutter <csutter@instructure.com>
This commit is contained in:
Cameron Sutter 2016-10-19 11:38:34 -06:00
parent a444b5fab8
commit b46d6e3bb3
4 changed files with 33 additions and 1 deletions

View File

@ -11,7 +11,8 @@ class LiveEventsObserver < ActiveRecord::Observer
:assignment,
:submission,
:attachment,
:user_account_association
:user_account_association,
:account_notification
def after_update(obj)
changes = obj.changes
@ -76,6 +77,8 @@ class LiveEventsObserver < ActiveRecord::Observer
if attachment_eligible?(obj)
Canvas::LiveEvents.attachment_created(obj)
end
when AccountNotification
Canvas::LiveEvents.account_notification_created(obj)
end
end
end

View File

@ -410,3 +410,14 @@ by `asset_type` and `asset_id`.
| `context_type` | The type of context the attachment is used in. |
| `context_id` | The id of the context the attachment is used in. |
| `content_type` | The content type of the attachment. |
#### `account_notification_created`
| Field | Description |
| ----- | ----------- |
| `account_notification_id` | The Canvas id of the account notification. |
| `subject` | The subject of the notification. |
| `message` | The message to be sent in the notification. |
| `icon` | The icon to display with the message. Defaults to warning. |
| `start_at` | When to send out the notification. |
| `end_at` | When to expire the notification. |

View File

@ -48,6 +48,17 @@ module Canvas::LiveEvents
})
end
def self.account_notification_created(notification)
post_event_stringified('account_notification_created', {
account_notification_id: notification.id,
subject: LiveEvents.truncate(notification.subject),
message: LiveEvents.truncate(notification.message),
icon: notification.icon,
start_at: notification.start_at,
end_at: notification.end_at,
})
end
def self.group_membership_created(membership)
post_event_stringified('group_membership_created', {
group_membership_id: membership.global_id,

View File

@ -170,4 +170,11 @@ describe LiveEventsObserver do
user_with_pseudonym(account: Account.default, username: 'bobbo', active_all: true)
end
end
describe "account_notification" do
it "posts create events" do
Canvas::LiveEvents.expects(:account_notification_created).once
account_notification
end
end
end