Find branches in all projects in the fork network
This commit is contained in:
parent
70716a1292
commit
7c00b53812
3 changed files with 25 additions and 3 deletions
|
@ -120,10 +120,13 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
|
||||||
end
|
end
|
||||||
|
|
||||||
def selected_target_project
|
def selected_target_project
|
||||||
if @project.id.to_s == params[:target_project_id] || @project.forked_project_link.nil?
|
if @project.id.to_s == params[:target_project_id] || !@project.forked?
|
||||||
@project
|
@project
|
||||||
|
elsif params[:target_project_id].present?
|
||||||
|
MergeRequestTargetProjectFinder.new(current_user: current_user, source_project: @project)
|
||||||
|
.execute.find(params[:target_project_id])
|
||||||
else
|
else
|
||||||
@project.forked_project_link.forked_from_project
|
@project.forked_from_project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class MergeRequestTargetProjectFinder
|
class MergeRequestTargetProjectFinder
|
||||||
attr_reader :current_user, :source_project
|
attr_reader :current_user, :source_project
|
||||||
|
|
||||||
def initialize(current_user: nil, source_project:, params: {})
|
def initialize(current_user: nil, source_project:)
|
||||||
@current_user = current_user
|
@current_user = current_user
|
||||||
@source_project = source_project
|
@source_project = source_project
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,6 +44,25 @@ feature 'Creating a merge request from a fork', :js do
|
||||||
expect { click_button 'Submit merge request' }
|
expect { click_button 'Submit merge request' }
|
||||||
.to change { target_project.merge_requests.reload.size }.by(1)
|
.to change { target_project.merge_requests.reload.size }.by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'updates the branches when selecting a new target project' do
|
||||||
|
target_project_member = target_project.owner
|
||||||
|
CreateBranchService.new(target_project, target_project_member)
|
||||||
|
.execute('a-brand-new-branch-to-test', 'master')
|
||||||
|
|
||||||
|
visit project_new_merge_request_path(source_project)
|
||||||
|
|
||||||
|
first('.js-target-project').click
|
||||||
|
find('.dropdown-target-project .dropdown-content a', text: target_project.full_path).click
|
||||||
|
|
||||||
|
wait_for_requests
|
||||||
|
|
||||||
|
first('.js-target-branch').click
|
||||||
|
|
||||||
|
within('.dropdown-target-branch .dropdown-content') do
|
||||||
|
expect(page).to have_content('a-brand-new-branch-to-test')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'creating to the source of a fork' do
|
context 'creating to the source of a fork' do
|
||||||
|
|
Loading…
Reference in a new issue