diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /spec/requests/api/members_spec.rb | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'spec/requests/api/members_spec.rb')
-rw-r--r-- | spec/requests/api/members_spec.rb | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/spec/requests/api/members_spec.rb b/spec/requests/api/members_spec.rb index a1daf86de31..7f4345faabb 100644 --- a/spec/requests/api/members_spec.rb +++ b/spec/requests/api/members_spec.rb @@ -81,14 +81,22 @@ RSpec.describe API::Members do expect(json_response.map { |u| u['id'] }).to match_array [maintainer.id, developer.id] end - it 'finds members with query string' do - get api(members_url, developer), params: { query: maintainer.username } + context 'with cross db check disabled' do + around do |example| + allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/343305') do + example.run + end + end - expect(response).to have_gitlab_http_status(:ok) - expect(response).to include_pagination_headers - expect(json_response).to be_an Array - expect(json_response.count).to eq(1) - expect(json_response.first['username']).to eq(maintainer.username) + it 'finds members with query string' do + get api(members_url, developer), params: { query: maintainer.username } + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.count).to eq(1) + expect(json_response.first['username']).to eq(maintainer.username) + end end it 'finds members with the given user_ids' do @@ -406,6 +414,38 @@ RSpec.describe API::Members 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 user to add' do + it 'creates a member_task with the correct attributes' do + post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), + params: { user_id: stranger.id, access_level: Member::DEVELOPER, tasks_to_be_done: %w(code ci), tasks_project_id: project_id } + + member = source.members.find_by(user_id: stranger.id) + 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 users to add' do + it 'creates a member_task with the correct attributes' do + post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), + params: { user_id: [developer.id, stranger.id].join(','), access_level: Member::DEVELOPER, tasks_to_be_done: %w(code ci), tasks_project_id: project_id } + + members = source.members.where(user_id: [developer.id, stranger.id]) + 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 + it "returns 409 if member already exists" do post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), params: { user_id: maintainer.id, access_level: Member::MAINTAINER } |