Avoid a TypeError when initializing MergeRequest JS class with no arg

Without this sane default you would get the following error when you
tried to instantiate a new MergeRequest object with no argument (i.e.
`new MergeRequest();`):

TypeError: undefined is not an object (evaluating 'this.opts.action')

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2016-06-15 10:32:57 +02:00
parent d8563bd6c2
commit 8aed815b6e
No known key found for this signature in database
GPG Key ID: 46DF07E5CD9E96AB
2 changed files with 2 additions and 2 deletions

View File

@ -9,7 +9,7 @@ class @MergeRequest
# Options:
# action - String, current controller action
#
constructor: (@opts) ->
constructor: (@opts = {}) ->
this.$el = $('.merge-request')
this.$('.show-all-commits').on 'click', =>

View File

@ -6,7 +6,7 @@ describe 'MergeRequest', ->
beforeEach ->
fixture.load('merge_requests_show.html')
@merge = new MergeRequest({})
@merge = new MergeRequest()
it 'modifies the Markdown field', ->
spyOn(jQuery, 'ajax').and.stub()