gitlab-org--gitlab-foss/spec/models
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
..
ci Fix commit_spec: invalid validation 2016-03-14 13:20:35 +01:00
concerns Restrict access for confidential issues on milestone view 2016-03-17 20:55:59 -03:00
hooks web hooks to webhooks 2016-03-10 14:48:29 -05:00
members Tag model specs 2015-12-09 10:50:51 +01:00
project_services Suppress e-mails on failed builds if allow_failure is set 2016-01-07 10:45:39 -08:00
abuse_report_spec.rb Clearify who deletes the user 2016-03-15 21:09:25 +01:00
appearance_spec.rb Branded login page also in CE 2016-02-26 15:50:51 +01:00
application_setting_spec.rb Validate email addresses using Devise.email_regexp 2016-02-09 18:15:35 +01:00
blob_spec.rb Add a Blob model that wraps Gitlab::Git::Blob 2016-02-18 22:45:30 -05:00
broadcast_message_spec.rb Move BroadcastMessage#status to a helper since it's presentational 2016-01-13 11:49:59 -05:00
build_spec.rb Fix review comments 2016-03-14 13:33:26 +01:00
commit_range_spec.rb Tag model specs 2015-12-09 10:50:51 +01:00
commit_spec.rb Restrict access to references for confidential issues 2016-03-17 20:55:59 -03:00
commit_status_spec.rb Annotate models 2016-01-06 13:09:55 +00:00
deploy_key_spec.rb Tag model specs 2015-12-09 10:50:51 +01:00
deploy_keys_project_spec.rb Tag model specs 2015-12-09 10:50:51 +01:00
email_spec.rb Validate email addresses using Devise.email_regexp 2016-02-09 18:15:35 +01:00
event_spec.rb Restrict access to confidential issues on activity feed 2016-03-17 20:56:00 -03:00
external_issue_spec.rb Update ExternalIssue regex for JIRA integration 2016-01-26 15:55:40 -05:00
external_wiki_service_spec.rb Annotate models 2016-01-06 13:09:55 +00:00
forked_project_link_spec.rb
generic_commit_status_spec.rb Annotate models 2016-01-06 13:09:55 +00:00
global_milestone_spec.rb Fix Error 500 when global milestones have slashes 2015-12-22 13:15:32 -08:00
group_spec.rb Use ILIKE/LIKE for searching groups 2016-03-11 15:25:21 -05:00
identity_spec.rb Codestyle changes 2016-01-12 12:29:10 -02:00
issue_spec.rb Incorporate review 2016-03-15 20:21:11 +01:00
jira_issue_spec.rb Backport JIRA service 2015-12-18 14:19:48 -06:00
key_spec.rb Fixed Rubocop offenses 2015-12-15 00:53:52 -02:00
label_link_spec.rb Tag model specs 2015-12-09 10:50:51 +01:00
label_spec.rb Add cross project references support for label model 2016-03-03 10:41:11 +01:00
member_spec.rb Validate email addresses using Devise.email_regexp 2016-02-09 18:15:35 +01:00
merge_request_spec.rb Merge branch 'fix-mr-source-sha' into 'master' 2016-03-18 12:28:43 +00:00
milestone_spec.rb Restrict access for confidential issues on milestone view 2016-03-17 20:55:59 -03:00
namespace_spec.rb Corrected spec title for Namespace.search 2016-03-11 15:25:24 -05:00
note_spec.rb Merge branch 'rs-note-active-spec' into 'master' 2016-03-14 12:53:15 -04:00
project_group_link_spec.rb Bring ProjectGroupLink model and migrations from EE 2016-03-11 17:47:05 +01:00
project_security_spec.rb Tag model specs 2015-12-09 10:50:51 +01:00
project_snippet_spec.rb Remove Snippet#expires_at 2016-03-05 18:12:17 -05:00
project_spec.rb Ignore eager loading in Project.search UNION 2016-03-15 16:46:17 +01:00
project_team_spec.rb Bring shared project feature tests from EE 2016-03-12 14:45:14 +01:00
project_wiki_spec.rb Add Banzai::Filter::GollumTagsFilter for parsing Gollum's tags in HTML 2016-01-14 12:09:31 -02:00
protected_branch_spec.rb Tag model specs 2015-12-09 10:50:51 +01:00
release_spec.rb Annotate models 2015-11-13 19:22:46 +01:00
repository_spec.rb Added tests for Repository#build_cache 2016-03-17 21:45:43 +01:00
service_spec.rb Annotate models 2016-01-06 13:09:55 +00:00
snippet_spec.rb Use ILIKE/LIKE for searching snippets 2016-03-11 15:25:21 -05:00
spam_log_spec.rb Refactor Admin::SpamLogsController to block user before destroying 2016-02-02 11:25:44 -02:00
todo_spec.rb Does not raise an error when Todo is already marked as done 2016-02-23 10:43:29 -03:00
tree_spec.rb Prioritize previewable over plain README files 2016-01-25 11:27:07 -02:00
user_spec.rb Merge branch 'master' into 4009-external-users 2016-03-15 19:16:16 +01:00
wiki_page_spec.rb Fix old version warning when viewing wiki latest version via version_id 2016-01-29 14:17:00 -02:00