File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ var _Raven = window.Raven,
21
21
tags : { } ,
22
22
extra : { }
23
23
} ,
24
- authQueryString ;
24
+ authQueryString ,
25
+ isRavenInstalled = false ;
25
26
26
27
/*
27
28
* The core Raven singleton
@@ -121,8 +122,9 @@ var Raven = {
121
122
* @return {Raven }
122
123
*/
123
124
install : function ( ) {
124
- if ( isSetup ( ) ) {
125
+ if ( isSetup ( ) && ! isRavenInstalled ) {
125
126
TraceKit . report . subscribe ( handleStackInfo ) ;
127
+ isRavenInstalled = true ;
126
128
}
127
129
128
130
return Raven ;
@@ -216,6 +218,7 @@ var Raven = {
216
218
*/
217
219
uninstall : function ( ) {
218
220
TraceKit . report . uninstall ( ) ;
221
+ isRavenInstalled = false ;
219
222
220
223
return Raven ;
221
224
} ,
Original file line number Diff line number Diff line change @@ -1247,6 +1247,14 @@ describe('Raven (public API)', function() {
1247
1247
assert . isTrue ( TraceKit . report . subscribe . calledOnce ) ;
1248
1248
assert . equal ( TraceKit . report . subscribe . lastCall . args [ 0 ] , handleStackInfo ) ;
1249
1249
} ) ;
1250
+
1251
+ it ( 'should not register itself more than once' , function ( ) {
1252
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
1253
+ this . sinon . stub ( TraceKit . report , 'subscribe' ) ;
1254
+ Raven . install ( ) ;
1255
+ Raven . install ( ) ;
1256
+ assert . isTrue ( TraceKit . report . subscribe . calledOnce ) ;
1257
+ } ) ;
1250
1258
} ) ;
1251
1259
1252
1260
describe ( '.wrap' , function ( ) {
@@ -1392,6 +1400,13 @@ describe('Raven (public API)', function() {
1392
1400
Raven . uninstall ( ) ;
1393
1401
assert . isTrue ( TraceKit . report . uninstall . calledOnce ) ;
1394
1402
} ) ;
1403
+
1404
+ it ( 'should set isRavenInstalled flag to false' , function ( ) {
1405
+ isRavenInstalled = true ;
1406
+ this . sinon . stub ( TraceKit . report , 'uninstall' ) ;
1407
+ Raven . uninstall ( ) ;
1408
+ assert . isFalse ( isRavenInstalled ) ;
1409
+ } ) ;
1395
1410
} ) ;
1396
1411
1397
1412
describe ( '.setUserContext' , function ( ) {
You can’t perform that action at this time.
0 commit comments