Skip to content

Commit

Permalink
fix(rum-core): avoid creating multiple transactions in startTransacti…
Browse files Browse the repository at this point in the history
…on (#296)
  • Loading branch information
jahtalab authored and vigneshshanmugam committed Jun 18, 2019
1 parent 0116f68 commit 70c3fb4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ class TransactionService {

if (!tr) {
tr = this.createTransaction(name, type, perfOptions)
}

if (tr.canReuse()) {
} else if (tr.canReuse()) {
/*
* perfOptions could also have `canReuse:true` in which case we
* allow a redefinition until there's a call that doesn't have that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,10 @@ describe('TransactionService', function() {
done()
})
})

it('should createTransaction once per startTransaction', function() {
spyOn(transactionService, 'createTransaction').and.callThrough()
transactionService.startTransaction('test-name', 'test-type')
expect(transactionService.createTransaction).toHaveBeenCalledTimes(1)
})
})

0 comments on commit 70c3fb4

Please sign in to comment.