Commit c2fc5a4b authored by Phil Hughes's avatar Phil Hughes

Merge branch '219270-issue-invite-members' into 'master'

Add invite member to assignee dropdown in issues/merge requests

See merge request gitlab-org/gitlab!33210
parents 26e9be96 64a113e8
......@@ -40,4 +40,13 @@
- data['max-select'] = dropdown_options[:data][:'max-select'] if dropdown_options[:data][:'max-select']
- options[:data].merge!(data)
- if experiment_enabled?(:invite_members_version_a) && can_import_members?
- options[:dropdown_class] += ' dropdown-extended-height'
- options[:footer_content] = true
= dropdown_tag(title, options: options) do
%ul.dropdown-footer-list
%li
= link_to _('Invite Members'), project_project_members_path(@project), title: _('Invite Members'), :"data-is-link" => true
- else
= dropdown_tag(title, options: options)
......@@ -3,6 +3,10 @@
require 'spec_helper'
RSpec.describe 'projects/merge_requests/show.html.haml' do
before do
allow(view).to receive(:experiment_enabled?).and_return(false)
end
include_context 'merge request show action'
context 'when merge request is created by a GitLab team member' do
......
......@@ -47,6 +47,9 @@ module Gitlab
},
upgrade_link_in_user_menu_a: {
tracking_category: 'Growth::Expansion::Experiment::UpgradeLinkInUserMenuA'
},
invite_members_version_a: {
tracking_category: 'Growth::Expansion::Experiment::InviteMembersVersionA'
}
}.freeze
......
......@@ -12118,6 +12118,9 @@ msgstr ""
msgid "Invite \"%{trimmed}\" by email"
msgstr ""
msgid "Invite Members"
msgstr ""
msgid "Invite group"
msgstr ""
......
......@@ -7,12 +7,13 @@ describe 'Issue Sidebar' do
let(:group) { create(:group, :nested) }
let(:project) { create(:project, :public, namespace: group) }
let!(:user) { create(:user)}
let!(:user) { create(:user) }
let!(:label) { create(:label, project: project, title: 'bug') }
let(:issue) { create(:labeled_issue, project: project, labels: [label]) }
let!(:xss_label) { create(:label, project: project, title: '<script>alert("xss");</script>') }
before do
stub_feature_flags(save_issuable_health_status: false)
sign_in(user)
end
......@@ -20,6 +21,48 @@ describe 'Issue Sidebar' do
let(:user2) { create(:user) }
let(:issue2) { create(:issue, project: project, author: user2) }
context 'when invite_members_version_a experiment is enabled' do
before do
stub_experiment_for_user(invite_members_version_a: true)
end
context 'when user can not see invite members' do
before do
project.add_developer(user)
visit_issue(project, issue2)
find('.block.assignee .edit-link').click
wait_for_requests
end
it 'does not see link to invite members' do
page.within '.dropdown-menu-user' do
expect(page).not_to have_link('Invite Members')
end
end
end
context 'when user can see invite members' do
before do
project.add_maintainer(user)
visit_issue(project, issue2)
find('.block.assignee .edit-link').click
wait_for_requests
end
it 'sees link to invite members' do
page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite Members', href: project_project_members_path(project))
end
end
end
end
context 'when invite_members_version_a experiment is not enabled' do
context 'when user is a developer' do
before do
project.add_developer(user)
visit_issue(project, issue2)
......@@ -79,6 +122,25 @@ describe 'Issue Sidebar' do
end
end
context 'when user is a maintainer' do
before do
project.add_maintainer(user)
visit_issue(project, issue2)
find('.block.assignee .edit-link').click
wait_for_requests
end
it 'shows author in assignee dropdown and no invite link' do
page.within '.dropdown-menu-user' do
expect(page).not_to have_link('Invite Members')
end
end
end
end
end
context 'as a allowed user' do
before do
project.add_developer(user)
......
......@@ -20,6 +20,7 @@ describe 'Merge request > User edits assignees sidebar', :js do
let(:sidebar_assignee_dropdown_item) { sidebar_assignee_block.find(".dropdown-menu li[data-user-id=\"#{assignee.id}\"]") }
let(:sidebar_assignee_dropdown_tooltip) { sidebar_assignee_dropdown_item.find('a')['data-title'] || '' }
context 'when invite_members_version_a experiment is not enabled' do
before do
stub_const('Autocomplete::UsersFinder::LIMIT', users_find_limit)
......@@ -51,6 +52,12 @@ describe 'Merge request > User edits assignees sidebar', :js do
it "shows assignee tooltip '#{expected_tooltip}" do
expect(sidebar_assignee_dropdown_tooltip).to eql(expected_tooltip)
end
it 'does not show invite link' do
page.within '.dropdown-menu-user' do
expect(page).not_to have_link('Invite Members')
end
end
end
end
......@@ -65,4 +72,48 @@ describe 'Merge request > User edits assignees sidebar', :js do
it_behaves_like 'when assigned', expected_tooltip: 'Cannot merge'
end
end
context 'when invite_members_version_a experiment is enabled' do
let_it_be(:user) { create(:user) }
before do
stub_experiment_for_user(invite_members_version_a: true)
sign_in(user)
end
context 'when user can not see invite members' do
before do
project.add_developer(user)
visit project_merge_request_path(project, merge_request)
find('.block.assignee .edit-link').click
wait_for_requests
end
it 'does not see link to invite members' do
page.within '.dropdown-menu-user' do
expect(page).not_to have_link('Invite Members')
end
end
end
context 'when user can see invite members' do
before do
project.add_maintainer(user)
visit project_merge_request_path(project, merge_request)
find('.block.assignee .edit-link').click
wait_for_requests
end
it 'sees link to invite members' do
page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite Members', href: project_project_members_path(project))
end
end
end
end
end
......@@ -3,6 +3,10 @@
require 'spec_helper'
describe 'projects/merge_requests/show.html.haml' do
before do
allow(view).to receive(:experiment_enabled?).and_return(false)
end
include_context 'merge request show action'
describe 'merge request assignee sidebar' do
......
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