Commit c4e48d27 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-merge-request-assignee-list' into 'master'

Use the user list from the target project in a merge request

### What does this MR do?

This MR derives the assignable users from the target project.

### Why was this MR needed?

In a merge request, the assignable users uses the list from the forked project, not the target project where the merge request will be going. For example, if I fork a project from the gitlab-org namespace into my personal namespace, make some changes, and then create a merge request, the only users I see are me. I think it makes more sense to show all the users in gitlab-org. This is a regression caused by 1c2711f7.

### What are the relevant issue numbers?

Closes #1535

See merge request !682
parents c2490601 7a7ce701
......@@ -5,6 +5,7 @@ v 7.12.0 (unreleased)
- Disabled expansion of top/bottom blobs for new file diffs
- Update Asciidoctor gem to version 1.5.2. (Jakub Jirutka)
- Fix resolving of relative links to repository files in AsciiDoc documents. (Jakub Jirutka)
- Use the user list from the target project in a merge request (Stan Hu)
v 7.11.1
- no changes
......
......@@ -10,6 +10,7 @@ module SelectsHelper
any_user = opts[:any_user] || false
email_user = opts[:email_user] || false
first_user = opts[:first_user] && current_user ? current_user.username : false
project = opts[:project] || @project
html = {
class: css_class,
......@@ -21,8 +22,8 @@ module SelectsHelper
}
unless opts[:scope] == :all
if @project
html['data-project-id'] = @project.id
if project
html['data-project-id'] = project.id
elsif @group
html['data-group-id'] = @group.id
end
......
......@@ -46,7 +46,7 @@
.col-sm-10
= users_select_tag("#{issuable.class.model_name.param_key}[assignee_id]",
placeholder: 'Select a user', class: 'custom-form-control', null_user: true,
selected: issuable.assignee_id)
selected: issuable.assignee_id, project: @target_project || @project)
 
= link_to 'Assign to me', '#', class: 'btn assign-to-me-link'
.form-group
......
......@@ -9,7 +9,7 @@
none
.issuable-context-selectbox
- if can?(current_user, :modify_merge_request, @merge_request)
= users_select_tag('merge_request[assignee_id]', placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: @merge_request.assignee_id, null_user: true)
= users_select_tag('merge_request[assignee_id]', placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: @merge_request.assignee_id, project: @target_project, null_user: true)
%div.prepend-top-20.clearfix
.issuable-context-title
......
......@@ -38,3 +38,15 @@ Feature: Project Forked Merge Requests
Given I visit project "Forked Shop" merge requests page
And I click link "New Merge Request"
Then the target repository should be the original repository
@javascript
Scenario: I see the users in the target project for a new merge request
Given I logout
And I sign in as an admin
And I have a project forked off of "Shop" called "Forked Shop"
Then I visit project "Forked Shop" merge requests page
And I click link "New Merge Request"
And I fill out a "Merge Request On Forked Project" merge request
When I click "Assign to" dropdown"
Then I should see the target project ID in the input selector
And I should see the users from the target project ID
......@@ -128,6 +128,21 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
page.should have_select("merge_request_target_project_id", selected: @project.path_with_namespace)
end
step 'I click "Assign to" dropdown"' do
first('.ajax-users-select').click
end
step 'I should see the target project ID in the input selector' do
expect(page).to have_selector("input[data-project-id=\"#{@project.id}\"]")
end
step 'I should see the users from the target project ID' do
expect(page).to have_selector('.user-result', visible: true, count: 2)
users = page.all('.user-name')
users[0].text.should == 'Unassigned'
users[1].text.should == @project.users.first.name
end
# Verify a link is generated against the correct project
def verify_commit_link(container_div, container_project)
# This should force a wait for the javascript to execute
......
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