don't call notifications if notifications has no url
This commit is contained in:
@@ -12,10 +12,7 @@ describe 'NotificationsHandler', ->
|
||||
notificationUrl = "notification.sharelatex.testing"
|
||||
|
||||
beforeEach ->
|
||||
@request =
|
||||
post: sinon.stub().callsArgWith(1)
|
||||
del: sinon.stub().callsArgWith(1)
|
||||
get: sinon.stub()
|
||||
@request = sinon.stub().callsArgWith(1)
|
||||
@handler = SandboxedModule.require modulePath, requires:
|
||||
"settings-sharelatex": apis:{notifications:{url:notificationUrl}}
|
||||
"request":@request
|
||||
@@ -26,18 +23,19 @@ describe 'NotificationsHandler', ->
|
||||
describe "getUserNotifications", ->
|
||||
it 'should get unread notifications', (done)->
|
||||
stubbedNotifications = [{_id: notification_id, user_id: user_id}]
|
||||
@request.get.callsArgWith(1, null, {statusCode:200}, stubbedNotifications)
|
||||
@request.callsArgWith(1, null, {statusCode:200}, stubbedNotifications)
|
||||
@handler.getUserNotifications user_id, (err, unreadNotifications)=>
|
||||
stubbedNotifications.should.deep.equal unreadNotifications
|
||||
getOpts =
|
||||
uri: "#{notificationUrl}/user/#{user_id}"
|
||||
json:true
|
||||
timeout:1000
|
||||
@request.get.calledWith(getOpts).should.equal true
|
||||
method: "GET"
|
||||
@request.calledWith(getOpts).should.equal true
|
||||
done()
|
||||
|
||||
it 'should return empty arrays if there are no notifications', ->
|
||||
@request.get.callsArgWith(1, null, {statusCode:200}, null)
|
||||
@request.callsArgWith(1, null, {statusCode:200}, null)
|
||||
@handler.getUserNotifications user_id, (err, unreadNotifications)=>
|
||||
unreadNotifications.length.should.equal 0
|
||||
|
||||
@@ -52,7 +50,8 @@ describe 'NotificationsHandler', ->
|
||||
json:
|
||||
key:@key
|
||||
timeout:1000
|
||||
@request.del.calledWith(opts).should.equal true
|
||||
method: "DELETE"
|
||||
@request.calledWith(opts).should.equal true
|
||||
done()
|
||||
|
||||
|
||||
@@ -64,7 +63,7 @@ describe 'NotificationsHandler', ->
|
||||
|
||||
it "should post the message over", (done)->
|
||||
@handler.createNotification user_id, @key, @templateKey, @messageOpts, =>
|
||||
args = @request.post.args[0][0]
|
||||
args = @request.args[0][0]
|
||||
args.uri.should.equal "#{notificationUrl}/user/#{user_id}"
|
||||
args.timeout.should.equal 1000
|
||||
expectedJson = {key:@key, templateKey:@templateKey, messageOpts:@messageOpts}
|
||||
|
||||
Reference in New Issue
Block a user