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:
parent
d8563bd6c2
commit
8aed815b6e
|
@ -9,7 +9,7 @@ class @MergeRequest
|
||||||
# Options:
|
# Options:
|
||||||
# action - String, current controller action
|
# action - String, current controller action
|
||||||
#
|
#
|
||||||
constructor: (@opts) ->
|
constructor: (@opts = {}) ->
|
||||||
this.$el = $('.merge-request')
|
this.$el = $('.merge-request')
|
||||||
|
|
||||||
this.$('.show-all-commits').on 'click', =>
|
this.$('.show-all-commits').on 'click', =>
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe 'MergeRequest', ->
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
fixture.load('merge_requests_show.html')
|
fixture.load('merge_requests_show.html')
|
||||||
@merge = new MergeRequest({})
|
@merge = new MergeRequest()
|
||||||
|
|
||||||
it 'modifies the Markdown field', ->
|
it 'modifies the Markdown field', ->
|
||||||
spyOn(jQuery, 'ajax').and.stub()
|
spyOn(jQuery, 'ajax').and.stub()
|
||||||
|
|
Loading…
Reference in New Issue