diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-10-25 13:57:51 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-10-25 13:57:51 +0300 |
commit | ba27abec815e476481b976175c67273c1cbb6e57 (patch) | |
tree | ae3cb12e2147a48fbebabd383b03c06078f28467 | |
parent | dd3b451d78e3db1e2b79229677d5af95b025bbc7 (diff) | |
parent | ed545d9f754374c7a5fe98a81544f0d1cdc88cf0 (diff) |
Merge branch 'show-commit-status-from-source-project' into 'master'
Show commits from source project. Be consistent with pipeline
## What does this MR do?
Show commits from source project instead of target project.
## Why was this MR needed?
To be consistent.
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- Tests
- [x] Added for this feature/bug
## What are the relevant issue numbers?
Closes #3596
See merge request !6658
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | app/models/merge_request_diff.rb | 8 | ||||
-rw-r--r-- | app/views/projects/merge_requests/show/_commits.html.haml | 2 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 3 | ||||
-rw-r--r-- | spec/views/projects/merge_requests/_commits.html.haml_spec.rb | 38 |
5 files changed, 47 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f2bec867f..2e25f0b2ceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ Please view this file on the master branch, on stable branches it's out of date. - Add visibility level to project repository - Fix robots.txt disallowing access to groups starting with "s" (Matt Harrison) - Close open merge request without source project (Katarzyna Kobierska Ula Budziszewska) + - Fix showing commits from source project for merge request !6658 - Fix that manual jobs would no longer block jobs in the next stage. !6604 - Add configurable email subject suffix (Fu Xu) - Use defined colour for a language when available !6748 (nilsding) diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index b8a10b7968e..dd65a9a8b86 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -299,8 +299,10 @@ class MergeRequestDiff < ActiveRecord::Base end def keep_around_commits - repository.keep_around(start_commit_sha) - repository.keep_around(head_commit_sha) - repository.keep_around(base_commit_sha) + [repository, merge_request.source_project.repository].each do |repo| + repo.keep_around(start_commit_sha) + repo.keep_around(head_commit_sha) + repo.keep_around(base_commit_sha) + end end end diff --git a/app/views/projects/merge_requests/show/_commits.html.haml b/app/views/projects/merge_requests/show/_commits.html.haml index 0b05785430b..61020516bcf 100644 --- a/app/views/projects/merge_requests/show/_commits.html.haml +++ b/app/views/projects/merge_requests/show/_commits.html.haml @@ -3,4 +3,4 @@ Most recent commits displayed first %ol#commits-list.list-unstyled - = render "projects/commits/commits", project: @merge_request.project + = render "projects/commits/commits", project: @merge_request.source_project diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 3155eff9ee1..1067ff7bb4d 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1286,7 +1286,8 @@ describe MergeRequest, models: true do let(:project) { create(:project) } let(:user) { create(:user) } let(:fork_project) { create(:project, forked_from_project: project, namespace: user.namespace) } - let(:merge_request) do + + let!(:merge_request) do create(:closed_merge_request, source_project: fork_project, target_project: project) diff --git a/spec/views/projects/merge_requests/_commits.html.haml_spec.rb b/spec/views/projects/merge_requests/_commits.html.haml_spec.rb new file mode 100644 index 00000000000..6f70b3daf8e --- /dev/null +++ b/spec/views/projects/merge_requests/_commits.html.haml_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe 'projects/merge_requests/show/_commits.html.haml' do + include Devise::Test::ControllerHelpers + + let(:user) { create(:user) } + let(:target_project) { create(:project) } + + let(:source_project) do + create(:project, forked_from_project: target_project) + end + + let(:merge_request) do + create(:merge_request, :simple, + source_project: source_project, + target_project: target_project, + author: user) + end + + before do + controller.prepend_view_path('app/views/projects') + + assign(:merge_request, merge_request) + assign(:commits, merge_request.commits) + end + + it 'shows commits from source project' do + render + + commit = source_project.commit(merge_request.source_branch) + href = namespace_project_commit_path( + source_project.namespace, + source_project, + commit) + + expect(rendered).to have_link(Commit.truncate_sha(commit.sha), href: href) + end +end |