gitlab-org--gitlab-foss/spec
Douwe Maan dadd28e317 Merge branch 'fix-mr-source-sha' into 'master'
Fix MergeRequest#source_sha when there is no diff

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/14170

### Overview

This MR fixes an unhandled Exception when visiting the page of an open Merge Request  without diff.

### Description

`MergeRequest#source_sha` is expected to return the sha of the source branch last commit. But when an open Merge Request has no diff (e.g. all commits have already been merged to the target branch), `merge_request.source_sha` incorrectly returns `nil`.

This was without consequences before – but since !2217 was merged (a few days ago), it makes `Gitlab::Git::Commit.between` raise an "Unexpected nil argument" exception. This can be reproduced when visiting the http://localhost:3000/gitlab-org/gitlab-test/merge_requests/2 page on a fresh local Gitlab setup.

This MR fixes the crash, by making sure that `source_sha` returns a
correct result even when there is no diff available. I also added tests.

@DouweM I believe you wrote most of this code in the first place ; does this looks correct to you, or is there a better way to resolve this issue maybe?

See merge request !3135
2016-03-18 12:28:43 +00:00
..
config Don't load all of GitLab in mail_room 2016-02-26 18:48:13 -08:00
controllers Restrict access to confidential issues 2016-03-17 20:55:38 -03:00
factories Merge branch 'fix-mr-source-sha' into 'master' 2016-03-18 12:28:43 +00:00
features Merge branch 'issue-fade-load' into 'master' 2016-03-18 12:25:09 +00:00
finders Bring shared project feature tests from EE 2016-03-12 14:45:14 +01:00
fixtures Add support for keyword arguments in label reference method 2016-03-03 10:41:11 +01:00
helpers Revert "Merge branch 'avatar-cropping' into 'master' " 2016-03-15 14:55:40 +01:00
initializers
javascripts Change js-quick-submit behavior to expect the class on the form 2016-03-02 15:11:15 -05:00
lib Merge branch 'confidential-issues' into 'master' 2016-03-18 12:04:56 +00:00
mailers Improving the original label-subscribing implementation 2016-03-15 18:22:02 +01:00
models Merge branch 'fix-mr-source-sha' into 'master' 2016-03-18 12:28:43 +00:00
requests Restrict access to confidential issues through API 2016-03-17 20:55:59 -03:00
routing Remove Profile::KeysController#new action 2016-03-03 16:13:59 -05:00
services Restrict access for confidential issues on autocomplete 2016-03-17 20:55:59 -03:00
support Restrict access to references for confidential issues 2016-03-17 20:55:59 -03:00
tasks/gitlab
views
workers Specs for the DeleteUserService 2016-03-15 22:19:51 +01:00
factories_spec.rb
rails_helper.rb
spec_helper.rb Original implementation to allow users to subscribe to labels 2016-03-15 17:25:37 +01:00
teaspoon_env.rb