gitlab-org--gitlab-foss/spec/factories
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 Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
abuse_reports.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
appearances.rb Branded login page also in CE 2016-02-26 15:50:51 +01:00
broadcast_messages.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
commit_statuses.rb Update commit status factory to reflect recent changes 2016-01-26 15:23:57 +01:00
deploy_keys_projects.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
emails.rb Remove unused another_email factory 2016-03-06 16:34:43 -05:00
events.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
forked_project_links.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
group_members.rb
groups.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
identities.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
issues.rb Restrict access to confidential issues 2016-03-17 20:55:38 -03:00
keys.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
label_links.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
labels.rb Improving the original label-subscribing implementation 2016-03-15 18:22:02 +01:00
lfs_objects.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
lfs_objects_projects.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
merge_requests.rb Fix MergeRequest#source_sha when there is no diff 2016-03-16 14:02:04 +01:00
milestones.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
namespaces.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
notes.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
personal_snippets.rb Simplify the various Snippet factories 2016-03-08 16:40:27 -05:00
project_group_links.rb Bring ProjectGroupLink model and migrations from EE 2016-03-11 17:47:05 +01:00
project_hooks.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
project_members.rb Add traits for each access_level to ProjectMember factory 2016-03-06 16:53:22 -05:00
project_snippets.rb Simplify the various Snippet factories 2016-03-08 16:40:27 -05:00
projects.rb Annotate models 2016-01-06 13:09:55 +00:00
protected_branches.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
releases.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
sent_notifications.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
service_hooks.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
services.rb Remove unnecessary attribute definitions from Service factory 2016-03-06 16:55:17 -05:00
snippets.rb Simplify the various Snippet factories 2016-03-08 16:40:27 -05:00
spam_logs.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
system_hooks.rb Move all factory definitions to their own file 2016-03-04 15:26:51 -05:00
todos.rb Rename Tasks to Todos 2016-02-20 12:39:27 -02:00
users.rb Revert "Merge branch 'avatar-cropping' into 'master' " 2016-03-15 14:55:40 +01:00