diff options
Diffstat (limited to 'spec/requests/api/invitations_spec.rb')
-rw-r--r-- | spec/requests/api/invitations_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/requests/api/invitations_spec.rb b/spec/requests/api/invitations_spec.rb index b23ba0021e0..cba4256adc5 100644 --- a/spec/requests/api/invitations_spec.rb +++ b/spec/requests/api/invitations_spec.rb @@ -166,6 +166,38 @@ RSpec.describe API::Invitations do end 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 + it 'creates a member_task with the tasks_to_be_done and the project' do + post invitations_url(source, maintainer), + params: { email: email, access_level: Member::DEVELOPER, tasks_to_be_done: %w(code ci), tasks_project_id: project_id } + + member = source.members.find_by(invite_email: email) + expect(member.tasks_to_be_done).to match_array([:code, :ci]) + expect(member.member_task.project_id).to eq(project_id) + end + end + + context 'when there are multiple invitations' do + it 'creates a member_task with the tasks_to_be_done and the project' do + post invitations_url(source, maintainer), + params: { email: [email, email2].join(','), access_level: Member::DEVELOPER, tasks_to_be_done: %w(code ci), tasks_project_id: project_id } + + members = source.members.where(invite_email: [email, email2]) + members.each do |member| + expect(member.tasks_to_be_done).to match_array([:code, :ci]) + expect(member.member_task.project_id).to eq(project_id) + end + end + end + end + context 'with invite_source considerations', :snowplow do let(:params) { { email: email, access_level: Member::DEVELOPER } } |