mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Fix module stub in incorrect scope
This commit is contained in:
parent
be6fa346d5
commit
136fd84810
1 changed files with 14 additions and 13 deletions
|
@ -24,21 +24,16 @@ describe "RateLimiter", ->
|
||||||
@RedisWrapper =
|
@RedisWrapper =
|
||||||
client: sinon.stub().returns(@rclient)
|
client: sinon.stub().returns(@rclient)
|
||||||
|
|
||||||
@limiterFn = sinon.stub()
|
|
||||||
@RollingRateLimiter = (opts) =>
|
|
||||||
return @limiterFn
|
|
||||||
|
|
||||||
@limiter = SandboxedModule.require modulePath, requires:
|
|
||||||
"rolling-rate-limiter": @RollingRateLimiter
|
|
||||||
"settings-sharelatex":@settings
|
|
||||||
"logger-sharelatex" : @logger = {log:sinon.stub(), err:sinon.stub()}
|
|
||||||
"./RedisWrapper": @RedisWrapper
|
|
||||||
|
|
||||||
@endpointName = "compiles"
|
@endpointName = "compiles"
|
||||||
@subject = "some-project-id"
|
@subject = "some-project-id"
|
||||||
@timeInterval = 20
|
@timeInterval = 20
|
||||||
@throttleLimit = 5
|
@throttleLimit = 5
|
||||||
|
|
||||||
|
@requires =
|
||||||
|
"settings-sharelatex":@settings
|
||||||
|
"logger-sharelatex" : @logger = {log:sinon.stub(), err:sinon.stub()}
|
||||||
|
"./RedisWrapper": @RedisWrapper
|
||||||
|
|
||||||
@details =
|
@details =
|
||||||
endpointName: @endpointName
|
endpointName: @endpointName
|
||||||
subjectName: @subject
|
subjectName: @subject
|
||||||
|
@ -52,7 +47,9 @@ describe "RateLimiter", ->
|
||||||
describe 'when action is permitted', ->
|
describe 'when action is permitted', ->
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@limiterFn = sinon.stub().callsArgWith(1, null, 0, 22)
|
@requires["rolling-rate-limiter"] = (opts) =>
|
||||||
|
return sinon.stub().callsArgWith(1, null, 0, 22)
|
||||||
|
@limiter = SandboxedModule.require modulePath, requires: @requires
|
||||||
|
|
||||||
it 'should not produce and error', (done) ->
|
it 'should not produce and error', (done) ->
|
||||||
@limiter.addCount {}, (err, should) ->
|
@limiter.addCount {}, (err, should) ->
|
||||||
|
@ -67,7 +64,9 @@ describe "RateLimiter", ->
|
||||||
describe 'when action is not permitted', ->
|
describe 'when action is not permitted', ->
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@limiterFn = sinon.stub().callsArgWith(1, null, 4000, 0)
|
@requires["rolling-rate-limiter"] = (opts) =>
|
||||||
|
return sinon.stub().callsArgWith(1, null, 4000, 0)
|
||||||
|
@limiter = SandboxedModule.require modulePath, requires: @requires
|
||||||
|
|
||||||
it 'should not produce and error', (done) ->
|
it 'should not produce and error', (done) ->
|
||||||
@limiter.addCount {}, (err, should) ->
|
@limiter.addCount {}, (err, should) ->
|
||||||
|
@ -82,7 +81,9 @@ describe "RateLimiter", ->
|
||||||
describe 'when limiter produces an error', ->
|
describe 'when limiter produces an error', ->
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@limiterFn = sinon.stub().callsArgWith(1, new Error('woops'))
|
@requires["rolling-rate-limiter"] = (opts) =>
|
||||||
|
return sinon.stub().callsArgWith(1, new Error('woops'))
|
||||||
|
@limiter = SandboxedModule.require modulePath, requires: @requires
|
||||||
|
|
||||||
it 'should produce and error', (done) ->
|
it 'should produce and error', (done) ->
|
||||||
@limiter.addCount {}, (err, should) ->
|
@limiter.addCount {}, (err, should) ->
|
||||||
|
|
Loading…
Reference in a new issue