Skip to content

Commit

Permalink
boot DatabaseNotification model if not booted
Browse files Browse the repository at this point in the history
  • Loading branch information
enniel committed Nov 14, 2018
1 parent 1125deb commit 1b497d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion providers/NotificationsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class NotificationsProvider extends ServiceProvider {
})
this.app.alias('Adonis/Notifications/HasDatabaseNotifications', 'HasDatabaseNotifications')
this.app.bind('Adonis/Notifications/DatabaseNotification', () => {
return require('../src/DatabaseNotification')
const DatabaseNotification = require('../src/DatabaseNotification')
DatabaseNotification._bootIfNotBooted()
return DatabaseNotification
})
this.app.alias('Adonis/Notifications/DatabaseNotification', 'DatabaseNotification')
this.app.bind('Adonis/Notifications/DatabaseMessage', () => {
Expand Down
1 change: 1 addition & 0 deletions test/functional/providers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ test.group('Providers', (group) => {
assert.isDefined(ioc.use('Adonis/Notifications/DatabaseNotification'))
assert.isFalse(ioc._bindings['Adonis/Notifications/DatabaseNotification'].singleton)
assert.equal(ioc._aliases['DatabaseNotification'], 'Adonis/Notifications/DatabaseNotification')
assert.isTrue(ioc.use('Adonis/Notifications/DatabaseNotification').$booted)

assert.isDefined(ioc.use('Adonis/Notifications/DatabaseMessage'))
assert.isFalse(ioc._bindings['Adonis/Notifications/DatabaseMessage'].singleton)
Expand Down

0 comments on commit 1b497d5

Please sign in to comment.