diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-07 06:18:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-07 06:18:52 +0300 |
commit | 9d20ce8c998506a1e27c55bbf99cd4c0595185af (patch) | |
tree | 961f5ef4fe5dc03b097d2708b62f974856d770b4 /spec | |
parent | 5ced7473bbf692832c48de1d3f72f0ace3b2d82c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/projects/members/effective_access_level_finder_spec.rb | 33 | ||||
-rw-r--r-- | spec/lib/atlassian/jira_connect/client_spec.rb | 22 | ||||
-rw-r--r-- | spec/lib/gitlab/project_authorizations_spec.rb | 26 | ||||
-rw-r--r-- | spec/requests/api/members_spec.rb | 29 | ||||
-rw-r--r-- | spec/services/projects/create_service_spec.rb | 35 |
5 files changed, 41 insertions, 104 deletions
diff --git a/spec/finders/projects/members/effective_access_level_finder_spec.rb b/spec/finders/projects/members/effective_access_level_finder_spec.rb index 446b0f8f9a2..bec327835f6 100644 --- a/spec/finders/projects/members/effective_access_level_finder_spec.rb +++ b/spec/finders/projects/members/effective_access_level_finder_spec.rb @@ -12,34 +12,15 @@ RSpec.describe Projects::Members::EffectiveAccessLevelFinder, '#execute' do let_it_be(:project) { create(:project) } shared_examples_for 'includes access level of the owner of the project' do - context 'when personal_project_owner_with_owner_access feature flag is enabled' do - it 'includes access level of the owner of the project as Owner' do - expect(subject).to( - contain_exactly( - hash_including( - 'user_id' => project.namespace.owner.id, - 'access_level' => Gitlab::Access::OWNER - ) - ) - ) - end - end - - context 'when personal_project_owner_with_owner_access feature flag is disabled' do - before do - stub_feature_flags(personal_project_owner_with_owner_access: false) - end - - it 'includes access level of the owner of the project as Maintainer' do - expect(subject).to( - contain_exactly( - hash_including( - 'user_id' => project.namespace.owner.id, - 'access_level' => Gitlab::Access::MAINTAINER - ) + it 'includes access level of the owner of the project as Owner' do + expect(subject).to( + contain_exactly( + hash_including( + 'user_id' => project.namespace.owner.id, + 'access_level' => Gitlab::Access::OWNER ) ) - end + ) end end diff --git a/spec/lib/atlassian/jira_connect/client_spec.rb b/spec/lib/atlassian/jira_connect/client_spec.rb index 9201d1c5dcb..dd3130c78bf 100644 --- a/spec/lib/atlassian/jira_connect/client_spec.rb +++ b/spec/lib/atlassian/jira_connect/client_spec.rb @@ -127,11 +127,19 @@ RSpec.describe Atlassian::JiraConnect::Client do end end + context 'the response is 202 accepted' do + let(:response) { double(code: 202, parsed_response: :foo) } + + it 'yields to the block' do + expect(processed).to eq [:data, :foo] + end + end + context 'the response is 400 bad request' do let(:response) { double(code: 400, parsed_response: errors) } it 'extracts the errors messages' do - expect(processed).to eq('errorMessages' => %w(X Y)) + expect(processed).to eq('errorMessages' => %w(X Y), 'responseCode' => 400) end end @@ -139,7 +147,7 @@ RSpec.describe Atlassian::JiraConnect::Client do let(:response) { double(code: 401, parsed_response: nil) } it 'reports that our JWT is wrong' do - expect(processed).to eq('errorMessages' => ['Invalid JWT']) + expect(processed).to eq('errorMessages' => ['Invalid JWT'], 'responseCode' => 401) end end @@ -147,7 +155,7 @@ RSpec.describe Atlassian::JiraConnect::Client do let(:response) { double(code: 403, parsed_response: nil) } it 'reports that the App is misconfigured' do - expect(processed).to eq('errorMessages' => ['App does not support foo']) + expect(processed).to eq('errorMessages' => ['App does not support foo'], 'responseCode' => 403) end end @@ -155,7 +163,7 @@ RSpec.describe Atlassian::JiraConnect::Client do let(:response) { double(code: 413, parsed_response: errors) } it 'extracts the errors messages' do - expect(processed).to eq('errorMessages' => ['Data too large', 'X', 'Y']) + expect(processed).to eq('errorMessages' => ['Data too large', 'X', 'Y'], 'responseCode' => 413) end end @@ -163,7 +171,7 @@ RSpec.describe Atlassian::JiraConnect::Client do let(:response) { double(code: 429, parsed_response: nil) } it 'reports that we exceeded the rate limit' do - expect(processed).to eq('errorMessages' => ['Rate limit exceeded']) + expect(processed).to eq('errorMessages' => ['Rate limit exceeded'], 'responseCode' => 429) end end @@ -171,7 +179,7 @@ RSpec.describe Atlassian::JiraConnect::Client do let(:response) { double(code: 503, parsed_response: nil) } it 'reports that the service is unavailable' do - expect(processed).to eq('errorMessages' => ['Service unavailable']) + expect(processed).to eq('errorMessages' => ['Service unavailable'], 'responseCode' => 503) end end @@ -179,7 +187,7 @@ RSpec.describe Atlassian::JiraConnect::Client do let(:response) { double(code: 1000, parsed_response: :something) } it 'reports that this was unanticipated' do - expect(processed).to eq('errorMessages' => ['Unknown error'], 'response' => :something) + expect(processed).to eq('errorMessages' => ['Unknown error'], 'responseCode' => 1000, 'response' => :something) end end end diff --git a/spec/lib/gitlab/project_authorizations_spec.rb b/spec/lib/gitlab/project_authorizations_spec.rb index 8630762e06f..640cf9be453 100644 --- a/spec/lib/gitlab/project_authorizations_spec.rb +++ b/spec/lib/gitlab/project_authorizations_spec.rb @@ -34,28 +34,12 @@ RSpec.describe Gitlab::ProjectAuthorizations do .to include(owned_project.id, other_project.id, group_project.id) end - context 'when personal_project_owner_with_owner_access feature flag is enabled' do - it 'includes the correct access levels' do - mapping = map_access_levels(authorizations) - - expect(mapping[owned_project.id]).to eq(Gitlab::Access::OWNER) - expect(mapping[other_project.id]).to eq(Gitlab::Access::REPORTER) - expect(mapping[group_project.id]).to eq(Gitlab::Access::DEVELOPER) - end - end - - context 'when personal_project_owner_with_owner_access feature flag is disabled' do - before do - stub_feature_flags(personal_project_owner_with_owner_access: false) - end - - it 'includes the correct access levels' do - mapping = map_access_levels(authorizations) + it 'includes the correct access levels' do + mapping = map_access_levels(authorizations) - expect(mapping[owned_project.id]).to eq(Gitlab::Access::MAINTAINER) - expect(mapping[other_project.id]).to eq(Gitlab::Access::REPORTER) - expect(mapping[group_project.id]).to eq(Gitlab::Access::DEVELOPER) - end + expect(mapping[owned_project.id]).to eq(Gitlab::Access::OWNER) + expect(mapping[other_project.id]).to eq(Gitlab::Access::REPORTER) + expect(mapping[group_project.id]).to eq(Gitlab::Access::DEVELOPER) end end diff --git a/spec/requests/api/members_spec.rb b/spec/requests/api/members_spec.rb index 5c867b4580b..561d81f9860 100644 --- a/spec/requests/api/members_spec.rb +++ b/spec/requests/api/members_spec.rb @@ -675,30 +675,13 @@ RSpec.describe API::Members do end context 'adding owner to project' do - context 'when personal_project_owner_with_owner_access feature flag is enabled' do - it 'returns created status' do - expect do - post api("/projects/#{project.id}/members", maintainer), - params: { user_id: stranger.id, access_level: Member::OWNER } - - expect(response).to have_gitlab_http_status(:created) - end.to change { project.members.count }.by(1) - end - end - - context 'when personal_project_owner_with_owner_access feature flag is disabled' do - before do - stub_feature_flags(personal_project_owner_with_owner_access: false) - end - - it 'returns created status' do - expect do - post api("/projects/#{project.id}/members", maintainer), - params: { user_id: stranger.id, access_level: Member::OWNER } + it 'returns created status' do + expect do + post api("/projects/#{project.id}/members", maintainer), + params: { user_id: stranger.id, access_level: Member::OWNER } - expect(response).to have_gitlab_http_status(:bad_request) - end.not_to change { project.members.count } - end + expect(response).to have_gitlab_http_status(:created) + end.to change { project.members.count }.by(1) end end diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index 03f66256487..96a50b26871 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -116,34 +116,15 @@ RSpec.describe Projects::CreateService, '#execute' do end context 'user namespace' do - context 'when personal_project_owner_with_owner_access feature flag is enabled' do - it 'creates a project in user namespace' do - project = create_project(user, opts) - - expect(project).to be_valid - expect(project.first_owner).to eq(user) - expect(project.team.maintainers).not_to include(user) - expect(project.team.owners).to contain_exactly(user) - expect(project.namespace).to eq(user.namespace) - expect(project.project_namespace).to be_in_sync_with_project(project) - end - end - - context 'when personal_project_owner_with_owner_access feature flag is disabled' do - before do - stub_feature_flags(personal_project_owner_with_owner_access: false) - end - - it 'creates a project in user namespace' do - project = create_project(user, opts) + it 'creates a project in user namespace' do + project = create_project(user, opts) - expect(project).to be_valid - expect(project.first_owner).to eq(user) - expect(project.team.maintainers).to contain_exactly(user) - expect(project.team.owners).to contain_exactly(user) - expect(project.namespace).to eq(user.namespace) - expect(project.project_namespace).to be_in_sync_with_project(project) - end + expect(project).to be_valid + expect(project.first_owner).to eq(user) + expect(project.team.maintainers).not_to include(user) + expect(project.team.owners).to contain_exactly(user) + expect(project.namespace).to eq(user.namespace) + expect(project.project_namespace).to be_in_sync_with_project(project) end end |