Commit 7b18e8c7 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch '13525-sane-defaults-for-merge-request-js-class-constructor' into 'master'

Avoid a TypeError when initializing MergeRequest JS class with no arg

## What does this MR do?

Avoid a TypeError when initializing MergeRequest JS class with no arg.

## Are there points in the code the reviewer needs to double check?

No.

## Why was this MR needed?

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')

## What are the relevant issue numbers?

Fixes #13525.

## Does this MR meet the acceptance criteria?

- [x] No CHANGELOG since it's a trivial internal change
- [x] Tests
  - [x] Added for this feature/bug
  - [ ] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !4667
parents 280c95fc 8aed815b
...@@ -9,7 +9,7 @@ class @MergeRequest ...@@ -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', -> ...@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment