Commit 550448b3 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'cleanup-invite-members-for-task' into 'master'

Invite members for tasks

See merge request gitlab-org/gitlab!74898
parents be1b1384 dc21cfe2
......@@ -92,7 +92,6 @@ class GroupsController < Groups::ApplicationController
if @group.import_state&.in_progress?
redirect_to group_import_path(@group)
else
publish_invite_members_for_task_experiment
render_show_html
end
end
......@@ -380,13 +379,6 @@ class GroupsController < Groups::ApplicationController
def captcha_required?
captcha_enabled? && !params[:parent_id]
end
def publish_invite_members_for_task_experiment
return unless params[:open_modal] == 'invite_members_for_task'
return unless current_user&.can?(:admin_group_member, @group)
experiment(:invite_members_for_task, namespace: @group).publish_to_client
end
end
GroupsController.prepend_mod_with('GroupsController')
......@@ -72,8 +72,6 @@ module Registrations
end
def show_tasks_to_be_done?
return unless experiment(:invite_members_for_task).enabled?
MemberTask.for_members(current_user.members).exists?
end
......
......@@ -83,9 +83,8 @@ module InviteMembersHelper
def show_invite_members_for_task?(source)
return unless current_user
invite_members_for_task_experiment = experiment(:invite_members_for_task).enabled? && params[:open_modal] == 'invite_members_for_task'
invite_for_help_continuous_onboarding = source.is_a?(Project) && experiment(:invite_for_help_continuous_onboarding, namespace: source.namespace).variant.name == 'candidate'
invite_members_for_task_experiment || invite_for_help_continuous_onboarding
params[:open_modal] == 'invite_members_for_task' || invite_for_help_continuous_onboarding
end
def tasks_to_be_done_options
......
......@@ -417,11 +417,9 @@ class Member < ApplicationRecord
def after_accept_invite
post_create_hook
if experiment(:invite_members_for_task).enabled?
run_after_commit_or_now do
if member_task
TasksToBeDone::CreateWorker.perform_async(member_task.id, created_by_id, [user_id.to_i])
end
run_after_commit_or_now do
if member_task
TasksToBeDone::CreateWorker.perform_async(member_task.id, created_by_id, [user_id.to_i])
end
end
end
......
......@@ -117,7 +117,6 @@ module Members
end
def create_tasks_to_be_done
return unless experiment(:invite_members_for_task).enabled?
return if params[:tasks_to_be_done].blank? || params[:tasks_project_id].blank?
valid_members = members.select { |member| member.valid? && member.member_task.valid? }
......
......@@ -65,7 +65,6 @@ module Members
end
def create_member_task
return unless experiment(:invite_members_for_task).enabled?
return unless member.persisted?
return if member_task_attributes.value?(nil)
......
---
name: invite_members_for_task
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69299
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/339747
milestone: '14.5'
type: experiment
group: group::activation
default_enabled: false
......@@ -43,8 +43,8 @@ POST /projects/:id/invitations
| `expires_at` | string | no | A date string in the format YEAR-MONTH-DAY |
| `invite_source` | string | no | The source of the invitation that starts the member creation process. See [this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/327120). |
| `areas_of_focus` | string | no | Areas the inviter wants the member to focus upon. |
| `tasks_to_be_done` | array of strings | no | Tasks the inviter wants the member to focus on. The tasks are added as issues to a specified project. The possible values are: `ci`, `code` and `issues`. If specified, requires `tasks_project_id`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69299) in GitLab 14.5 [with a flag](../administration/feature_flags.md) named `invite_members_for_task`. Disabled by default. |
| `tasks_project_id` | integer | no | The project ID in which to create the task issues. If specified, requires `tasks_to_be_done`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69299) in GitLab 14.5 [with a flag](../administration/feature_flags.md) named `invite_members_for_task`. Disabled by default. |
| `tasks_to_be_done` | array of strings | no | Tasks the inviter wants the member to focus on. The tasks are added as issues to a specified project. The possible values are: `ci`, `code` and `issues`. If specified, requires `tasks_project_id`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69299) in GitLab 14.6 |
| `tasks_project_id` | integer | no | The project ID in which to create the task issues. If specified, requires `tasks_to_be_done`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69299) in GitLab 14.6 |
```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
......
......@@ -99,10 +99,6 @@ RSpec.describe Members::CreateService do
}
end
before do
stub_experiments(invite_members_for_task: true)
end
context 'when passing many user ids' do
it 'creates 2 task issues', :aggregate_failures, :sidekiq_inline do
expect(TasksToBeDone::CreateWorker)
......
......@@ -38,7 +38,7 @@ module Gitlab
end
def invite_members?
invite_members_for_task_experiment_enabled?
user.can?(:admin_group_member, group)
end
end
end
......
......@@ -166,16 +166,6 @@ module Gitlab
link(s_('InProductMarketing|update your preferences'), preference_link)
end
def invite_members_for_task_experiment_enabled?
return unless user.can?(:admin_group_member, group)
experiment(:invite_members_for_task, namespace: group) do |e|
e.candidate { true }
e.record!
e.run
end
end
def validate_series!
raise ArgumentError, "Only #{total_series} series available for this track." unless @series.between?(0, total_series - 1)
end
......
......@@ -62,7 +62,7 @@ module Gitlab
end
def invite_members?
invite_members_for_task_experiment_enabled?
user.can?(:admin_group_member, group)
end
private
......
......@@ -66,7 +66,7 @@ module Gitlab
end
def invite_members?
invite_members_for_task_experiment_enabled?
user.can?(:admin_group_member, group)
end
private
......
......@@ -82,16 +82,6 @@ RSpec.describe GroupsController, factory_default: :keep do
expect(subject).to redirect_to group_import_path(group)
end
end
context 'publishing the invite_members_for_task experiment' do
it 'publishes the experiment data to the client' do
wrapped_experiment(experiment(:invite_members_for_task)) do |e|
expect(e).to receive(:publish_to_client)
end
get :show, params: { id: group.to_param, open_modal: 'invite_members_for_task' }, format: format
end
end
end
describe 'GET #details' do
......
......@@ -101,10 +101,6 @@ RSpec.describe Registrations::WelcomeController do
context 'when tasks to be done are assigned' do
let!(:member1) { create(:group_member, user: user, tasks_to_be_done: %w(ci code)) }
before do
stub_experiments(invite_members_for_task: true)
end
it { is_expected.to redirect_to(issues_dashboard_path(assignee_username: user.username)) }
end
end
......
......@@ -93,22 +93,17 @@ RSpec.describe InviteMembersHelper do
end
end
context 'the invite_members_for_task experiment' do
where(:invite_members_for_task_enabled?, :open_modal_param_present?, :logged_in?, :expected?) do
true | true | true | true
true | true | false | false
true | false | true | false
true | false | false | false
false | true | true | false
false | true | false | false
false | false | true | false
false | false | false | false
context 'inviting members for tasks' do
where(:open_modal_param_present?, :logged_in?, :expected?) do
true | true | true
true | false | false
false | true | false
false | false | false
end
with_them do
before do
allow(helper).to receive(:current_user).and_return(developer) if logged_in?
stub_experiments(invite_members_for_task: true) if invite_members_for_task_enabled?
allow(helper).to receive(:params).and_return({ open_modal: 'invite_members_for_task' }) if open_modal_param_present?
end
......
......@@ -68,7 +68,6 @@ RSpec.describe Emails::InProductMarketing do
with_them do
before do
stub_experiments(invite_members_for_task: :candidate)
group.add_owner(user)
end
......
......@@ -742,7 +742,6 @@ RSpec.describe Group do
let!(:project) { create(:project, group: group) }
before do
stub_experiments(invite_members_for_task: true)
group.add_users([create(:user)], :developer, tasks_to_be_done: %w(ci code), tasks_project_id: project.id)
end
......
......@@ -681,8 +681,6 @@ RSpec.describe Member do
end
it 'schedules a TasksToBeDone::CreateWorker task' do
stub_experiments(invite_members_for_task: true)
member_task = create(:member_task, member: member, project: member.project)
expect(TasksToBeDone::CreateWorker)
......
......@@ -237,7 +237,6 @@ RSpec.describe ProjectTeam do
context 'when `tasks_to_be_done` and `tasks_project_id` are passed' do
before do
stub_experiments(invite_members_for_task: true)
project.team.add_users([user1], :developer, tasks_to_be_done: %w(ci code), tasks_project_id: project.id)
end
......
......@@ -167,10 +167,6 @@ RSpec.describe API::Invitations do
end
context 'with tasks_to_be_done and tasks_project_id in the params' do
before do
stub_experiments(invite_members_for_task: true)
end
let(:project_id) { source_type == 'project' ? source.id : create(:project, namespace: source).id }
context 'when there is 1 invitation' do
......
......@@ -415,10 +415,6 @@ RSpec.describe API::Members do
end
context 'with tasks_to_be_done and tasks_project_id in the params' do
before do
stub_experiments(invite_members_for_task: true)
end
let(:project_id) { source_type == 'project' ? source.id : create(:project, namespace: source).id }
context 'when there is 1 user to add' do
......
......@@ -202,10 +202,6 @@ RSpec.describe Members::CreateService, :aggregate_failures, :clean_gitlab_redis_
{ invite_source: '_invite_source_', tasks_to_be_done: %w(ci code), tasks_project_id: source.id }
end
before do
stub_experiments(invite_members_for_task: true)
end
it 'creates 2 task issues', :aggregate_failures do
expect(TasksToBeDone::CreateWorker)
.to receive(:perform_async)
......
......@@ -301,10 +301,6 @@ RSpec.shared_examples_for "member creation" do
end
context 'when `tasks_to_be_done` and `tasks_project_id` are passed' do
before do
stub_experiments(invite_members_for_task: true)
end
it 'creates a member_task with the correct attributes', :aggregate_failures do
task_project = source.is_a?(Group) ? create(:project, group: source) : source
described_class.new(source, user, :developer, tasks_to_be_done: %w(ci code), tasks_project_id: task_project.id).execute
......@@ -397,10 +393,6 @@ RSpec.shared_examples_for "bulk member creation" do
end
context 'when `tasks_to_be_done` and `tasks_project_id` are passed' do
before do
stub_experiments(invite_members_for_task: true)
end
it 'creates a member_task with the correct attributes', :aggregate_failures do
task_project = source.is_a?(Group) ? create(:project, group: source) : source
members = described_class.add_users(source, [user1], :developer, tasks_to_be_done: %w(ci code), tasks_project_id: task_project.id)
......
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