Skip to content

Commit 5df7c14

Browse files
committed
Do not allow to call Raven.config() more than once
1 parent 95a265a commit 5df7c14

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/raven.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ var Raven = {
5252
* @return {Raven}
5353
*/
5454
config: function(dsn, options) {
55+
if (globalServer) {
56+
logDebug('error', 'Error: Raven has already been configured');
57+
return Raven;
58+
}
5559
if (!dsn) return Raven;
5660

5761
var uri = parseDSN(dsn),

test/raven.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,15 @@ describe('Raven (public API)', function() {
11691169
assert.equal(Raven.config(''), Raven);
11701170
});
11711171

1172+
it('should not set global options more than once', function() {
1173+
this.sinon.spy(window, 'parseDSN');
1174+
this.sinon.stub(window, 'logDebug');
1175+
setupRaven();
1176+
setupRaven();
1177+
assert.isTrue(parseDSN.calledOnce);
1178+
assert.isTrue(logDebug.called);
1179+
});
1180+
11721181
describe('whitelistUrls', function() {
11731182
it('should be false if none are passed', function() {
11741183
Raven.config('//[email protected]/2');

0 commit comments

Comments
 (0)