Commit 0ed0eb01 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'cwq/tag_branch_same_name' into 'master'

fix new MR form erroneously selects tag as source when branch of same name exists

See merge request !9535
parents 21c6743c 4d6e377c
...@@ -402,7 +402,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -402,7 +402,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
if params[:ref].present? if params[:ref].present?
@ref = params[:ref] @ref = params[:ref]
@commit = @repository.commit(@ref) @commit = @repository.commit("refs/heads/#{@ref}")
end end
render layout: false render layout: false
...@@ -413,7 +413,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -413,7 +413,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
if params[:ref].present? if params[:ref].present?
@ref = params[:ref] @ref = params[:ref]
@commit = @target_project.commit(@ref) @commit = @target_project.commit("refs/heads/#{@ref}")
end end
render layout: false render layout: false
......
---
title: "Fixes an issue in the new merge request form, where a tag would be selected instead of a branch when they have the same names"
merge_request: 9535
author: Weiqing Chu
...@@ -12,6 +12,33 @@ feature 'Create New Merge Request', feature: true, js: true do ...@@ -12,6 +12,33 @@ feature 'Create New Merge Request', feature: true, js: true do
login_as user login_as user
end end
it 'selects the source branch sha when a tag with the same name exists' do
visit namespace_project_merge_requests_path(project.namespace, project)
click_link 'New Merge Request'
expect(page).to have_content('Source branch')
expect(page).to have_content('Target branch')
first('.js-source-branch').click
first('.dropdown-source-branch .dropdown-content a', text: 'v1.1.0').click
expect(page).to have_content "b83d6e3"
end
it 'selects the target branch sha when a tag with the same name exists' do
visit namespace_project_merge_requests_path(project.namespace, project)
click_link 'New Merge Request'
expect(page).to have_content('Source branch')
expect(page).to have_content('Target branch')
first('.js-target-branch').click
first('.dropdown-target-branch .dropdown-content a', text: 'v1.1.0').click
expect(page).to have_content "b83d6e3"
end
it 'generates a diff for an orphaned branch' do it 'generates a diff for an orphaned branch' do
visit namespace_project_merge_requests_path(project.namespace, project) visit namespace_project_merge_requests_path(project.namespace, project)
......
...@@ -53,6 +53,7 @@ describe "Compare", js: true do ...@@ -53,6 +53,7 @@ describe "Compare", js: true do
dropdown = find(".js-compare-#{dropdown_type}-dropdown") dropdown = find(".js-compare-#{dropdown_type}-dropdown")
dropdown.find(".compare-dropdown-toggle").click dropdown.find(".compare-dropdown-toggle").click
dropdown.fill_in("Filter by Git revision", with: selection) dropdown.fill_in("Filter by Git revision", with: selection)
find_link(selection, visible: true).click wait_for_ajax
dropdown.find_all("a[data-ref=\"#{selection}\"]", visible: true).last.click
end end
end end
...@@ -37,7 +37,8 @@ module TestEnv ...@@ -37,7 +37,8 @@ module TestEnv
'conflict-too-large' => '39fa04f', 'conflict-too-large' => '39fa04f',
'deleted-image-test' => '6c17798', 'deleted-image-test' => '6c17798',
'wip' => 'b9238ee', 'wip' => 'b9238ee',
'csv' => '3dd0896' 'csv' => '3dd0896',
'v1.1.0' => 'b83d6e3'
}.freeze }.freeze
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily # gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
......
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