Commit 8fa58c71 authored by Fatih Acet's avatar Fatih Acet

Merge branch...

Merge branch '25836-changing-from-version-in-diff-comparison-does-not-preserve-to-version' into 'master'

Resolve changing "from" version in diff comparison does not preserve "to" version

Closes #25836

See merge request !8328
parents b23fd4e9 139ff578
......@@ -98,7 +98,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@start_version = @comparable_diffs.find { |diff| diff.head_commit_sha == @start_sha }
unless @start_version
render_404
@start_sha = @merge_request_diff.head_commit_sha
@start_version = @merge_request_diff
end
end
......
......@@ -19,7 +19,7 @@
%ul
- @merge_request_diffs.each do |merge_request_diff|
%li
= link_to merge_request_version_path(@project, @merge_request, merge_request_diff), class: ('is-active' if merge_request_diff == @merge_request_diff) do
= link_to merge_request_version_path(@project, @merge_request, merge_request_diff, @start_sha), class: ('is-active' if merge_request_diff == @merge_request_diff) do
%strong
- if merge_request_diff.latest?
latest version
......
......@@ -81,4 +81,52 @@ feature 'Merge Request versions', js: true, feature: true do
expect(page).to have_content '8 changed files'
end
end
describe 'compare with same version' do
before do
page.within '.mr-version-compare-dropdown' do
find('.btn-default').click
click_link 'version 1'
end
end
it 'should have 0 chages between versions' do
page.within '.mr-version-compare-dropdown' do
expect(page).to have_content 'version 1'
end
page.within '.mr-version-dropdown' do
find('.btn-default').click
find(:link, 'version 1').trigger('click')
end
expect(page).to have_content '0 changed files'
end
end
describe 'compare with newer version' do
before do
page.within '.mr-version-compare-dropdown' do
find('.btn-default').click
click_link 'version 2'
end
end
it 'should set the compared versions to be the same' do
page.within '.mr-version-compare-dropdown' do
expect(page).to have_content 'version 2'
end
page.within '.mr-version-dropdown' do
find('.btn-default').click
find(:link, 'version 1').trigger('click')
end
page.within '.mr-version-compare-dropdown' do
expect(page).to have_content 'version 1'
end
expect(page).to have_content '0 changed files'
end
end
end
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