Commit 835127cd authored by Sean McGivern's avatar Sean McGivern

Fix approvers dropdown when creating MR from a fork

The `users_select_tag` helper defaults to using `@project`, which in this case
is the source project, not the target project. Explicitly use the target project
to get the right list of users.
parent 970f41cf
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
.col-sm-10 .col-sm-10
- author = issuable.author || current_user - author = issuable.author || current_user
- skip_users = issuable.all_approvers_including_groups + [author] - skip_users = issuable.all_approvers_including_groups + [author]
= users_select_tag("merge_request[approver_ids]", multiple: true, class: 'input-large', email_user: true, skip_users: skip_users) = users_select_tag("merge_request[approver_ids]", multiple: true, class: 'input-large', email_user: true, skip_users: skip_users, project: issuable.target_project)
.help-block .help-block
This merge request must be approved by these users. This merge request must be approved by these users.
You can override the project settings by setting your own list of approvers. You can override the project settings by setting your own list of approvers.
- skip_groups = issuable.overall_approver_groups.pluck(:group_id) - skip_groups = issuable.overall_approver_groups.pluck(:group_id)
= groups_select_tag('merge_request[approver_group_ids]', multiple: true, data: { skip_groups: skip_groups, all_available: true }, class: 'input-large') = groups_select_tag('merge_request[approver_group_ids]', multiple: true, data: { skip_groups: skip_groups, all_available: true, project: issuable.target_project }, class: 'input-large')
.help-block .help-block
This merge request must be approved by members of these groups. This merge request must be approved by members of these groups.
You can override the project settings by setting your own list of approvers. You can override the project settings by setting your own list of approvers.
......
---
title: Fix approvers dropdown when creating a merge request from a fork
merge_request:
author:
...@@ -2,15 +2,15 @@ require 'rails_helper' ...@@ -2,15 +2,15 @@ require 'rails_helper'
feature 'Merge request approvals', js: true, feature: true do feature 'Merge request approvals', js: true, feature: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, approvals_before_merge: 1) } let(:project) { create(:project, :public, approvals_before_merge: 1) }
context 'when editing an MR with a different author' do context 'when editing an MR with a different author' do
let(:author) { create(:user) } let(:author) { create(:user) }
let(:merge_request) { create(:merge_request, author: author, source_project: project) } let(:merge_request) { create(:merge_request, author: author, source_project: project) }
before do before do
project.team << [user, :developer] project.add_developer(user)
project.team << [author, :developer] project.add_developer(author)
login_as(user) login_as(user)
visit edit_namespace_project_merge_request_path(project.namespace, project, merge_request) visit edit_namespace_project_merge_request_path(project.namespace, project, merge_request)
...@@ -27,16 +27,20 @@ feature 'Merge request approvals', js: true, feature: true do ...@@ -27,16 +27,20 @@ feature 'Merge request approvals', js: true, feature: true do
end end
end end
context 'when creating an MR' do context 'when creating an MR from a fork' do
let(:other_user) { create(:user) } let(:other_user) { create(:user) }
let(:non_member) { create(:user) } let(:non_member) { create(:user) }
let(:forked_project) { create(:project, :public, creator: user) }
before do before do
project.team << [user, :developer] create(:forked_project_link, forked_to_project: forked_project, forked_from_project: project)
project.team << [other_user, :developer]
forked_project.add_developer(nuser)
project.add_developer(user)
project.add_developer(other_user)
login_as(user) login_as(user)
visit new_namespace_project_merge_request_path(project.namespace, project, merge_request: { target_branch: 'master', source_branch: 'feature' }) visit new_namespace_project_merge_request_path(forked_project.namespace, forked_project, merge_request: { target_branch: 'master', source_branch: 'feature' })
find('#s2id_merge_request_approver_ids .select2-input').click find('#s2id_merge_request_approver_ids .select2-input').click
end end
...@@ -59,8 +63,8 @@ feature 'Merge request approvals', js: true, feature: true do ...@@ -59,8 +63,8 @@ feature 'Merge request approvals', js: true, feature: true do
let(:other_user) { create(:user) } let(:other_user) { create(:user) }
before do before do
project.team << [user, :developer] project.add_developer(user)
project.team << [other_user, :developer] project.add_developer(other_user)
login_as(user) login_as(user)
end end
...@@ -114,7 +118,7 @@ feature 'Merge request approvals', js: true, feature: true do ...@@ -114,7 +118,7 @@ feature 'Merge request approvals', js: true, feature: true do
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
before do before do
project.team << [user, :developer] project.add_developer(user)
login_as(user) login_as(user)
end end
...@@ -199,8 +203,7 @@ feature 'Merge request approvals', js: true, feature: true do ...@@ -199,8 +203,7 @@ feature 'Merge request approvals', js: true, feature: true do
let(:group) { create :group } let(:group) { create :group }
before do before do
project.team << [user, :developer] project.add_developer(user)
group.add_developer(other_user) group.add_developer(other_user)
group.add_developer(user) group.add_developer(user)
...@@ -300,7 +303,7 @@ feature 'Merge request approvals', js: true, feature: true do ...@@ -300,7 +303,7 @@ feature 'Merge request approvals', js: true, feature: true do
end end
before do before do
project.team << [user, :developer] project.add_developer(user)
login_as(user) login_as(user)
visit new_namespace_project_merge_request_path(project.namespace, project, merge_request: { target_branch: 'master', source_branch: 'feature' }) visit new_namespace_project_merge_request_path(project.namespace, project, merge_request: { target_branch: 'master', source_branch: 'feature' })
......
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