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,
2121 tags : { } ,
2222 extra : { }
2323 } ,
24- authQueryString ;
24+ authQueryString ,
25+ isRavenInstalled = false ;
2526
2627/*
2728 * The core Raven singleton
@@ -121,8 +122,9 @@ var Raven = {
121122 * @return {Raven }
122123 */
123124 install : function ( ) {
124- if ( isSetup ( ) ) {
125+ if ( isSetup ( ) && ! isRavenInstalled ) {
125126 TraceKit . report . subscribe ( handleStackInfo ) ;
127+ isRavenInstalled = true ;
126128 }
127129
128130 return Raven ;
@@ -216,6 +218,7 @@ var Raven = {
216218 */
217219 uninstall : function ( ) {
218220 TraceKit . report . uninstall ( ) ;
221+ isRavenInstalled = false ;
219222
220223 return Raven ;
221224 } ,
Original file line number Diff line number Diff line change @@ -1247,6 +1247,14 @@ describe('Raven (public API)', function() {
12471247 assert . isTrue ( TraceKit . report . subscribe . calledOnce ) ;
12481248 assert . equal ( TraceKit . report . subscribe . lastCall . args [ 0 ] , handleStackInfo ) ;
12491249 } ) ;
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+ } ) ;
12501258 } ) ;
12511259
12521260 describe ( '.wrap' , function ( ) {
@@ -1392,6 +1400,13 @@ describe('Raven (public API)', function() {
13921400 Raven . uninstall ( ) ;
13931401 assert . isTrue ( TraceKit . report . uninstall . calledOnce ) ;
13941402 } ) ;
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+ } ) ;
13951410 } ) ;
13961411
13971412 describe ( '.setUserContext' , function ( ) {
You can’t perform that action at this time.
0 commit comments