diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-15 03:10:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-15 03:10:32 +0300 |
commit | 0a977c1034dbc147771db52e9fbc8ede43eb7e0c (patch) | |
tree | 7e9f63fbb6bcfd509abb2bec6221ac1a51d567c8 /spec | |
parent | db2275b561bace34d90b901226d7f46d33e4cbd9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/middleware/go_spec.rb | 22 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 78 |
2 files changed, 6 insertions, 94 deletions
diff --git a/spec/lib/gitlab/middleware/go_spec.rb b/spec/lib/gitlab/middleware/go_spec.rb index e795577d203..bc1d53b2ccb 100644 --- a/spec/lib/gitlab/middleware/go_spec.rb +++ b/spec/lib/gitlab/middleware/go_spec.rb @@ -32,7 +32,7 @@ RSpec.describe Gitlab::Middleware::Go do shared_examples 'go-get=1' do |enabled_protocol:| context 'with simple 2-segment project path' do - let!(:project) { create(:project, :public, :repository) } + let!(:project) { create(:project, :private, :repository) } context 'with subpackages' do let(:path) { "#{project.full_path}/subpackage" } @@ -51,16 +51,6 @@ RSpec.describe Gitlab::Middleware::Go do end end - context 'with nonexistent path' do - let(:path) { 'nonexistent-group/nonexistent-project' } - - it 'responses not found' do - status_code, _headers, body = go - expect(status_code).to eq(404) - expect(body).to match_array(['']) - end - end - context 'with a nested project path' do let(:group) { create(:group, :nested) } let!(:project) { create(:project, :public, :repository, namespace: group) } @@ -78,10 +68,8 @@ RSpec.describe Gitlab::Middleware::Go do end shared_examples 'unauthorized' do - it 'returns unauthorized' do - status_code, _headers, body = go - expect(status_code).to eq(404) - expect(body).to match_array(['']) + it 'returns the 2-segment group path' do + expect_response_with_path(go, enabled_protocol, group.full_path, project.default_branch) end end @@ -153,7 +141,7 @@ RSpec.describe Gitlab::Middleware::Go do expect(Gitlab::Auth).to receive(:find_for_git_client).and_raise(Gitlab::Auth::IpBlacklisted) response = go - expect(response[0]).to eq(404) + expect(response[0]).to eq(403) expect(response[1]['Content-Length']).to be_nil expect(response[2]).to eq(['']) end @@ -170,7 +158,7 @@ RSpec.describe Gitlab::Middleware::Go do expect(Gitlab::Auth).to receive(:find_for_git_client).and_raise(Gitlab::Auth::MissingPersonalAccessTokenError) response = go - expect(response[0]).to eq(404) + expect(response[0]).to eq(401) expect(response[1]['Content-Length']).to be_nil expect(response[2]).to eq(['']) end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index b16fa4df6c1..32518b867cb 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -5416,82 +5416,6 @@ RSpec.describe MergeRequest, factory_default: :keep do subject(:suggested_reviewer_users) { merge_request.suggested_reviewer_users } - shared_examples 'blank suggestions' do - it 'returns an empty relation' do - expect(suggested_reviewer_users).to be_empty - end - end - - context 'when predictions is nil' do - it_behaves_like 'blank suggestions' - end - - context 'when predictions is not nil' do - before do - merge_request.build_predictions - end - - context 'when predictions is a non hash' do - before do - merge_request.build_predictions - merge_request.predictions.suggested_reviewers = 1 - end - - it_behaves_like 'blank suggestions' - end - - context 'when predictions is an empty hash' do - before do - merge_request.predictions.suggested_reviewers = {} - end - - it_behaves_like 'blank suggestions' - end - - context 'when suggests a user who is not a member' do - let_it_be(:non_member) { create(:user) } - - before do - merge_request.predictions.suggested_reviewers = { 'reviewers' => [non_member.username] } - end - - it_behaves_like 'blank suggestions' - end - - context 'when suggests users who are members' do - let_it_be(:first_member) { create(:user) } - let_it_be(:second_member) { create(:user) } - - before_all do - project.add_developer(first_member) - project.add_developer(second_member) - end - - before do - merge_request.predictions.suggested_reviewers = { - 'reviewers' => [ - second_member.username, - first_member.username - ] - } - end - - context 'when a user is inactive' do - before do - second_member.deactivate - end - - it 'returns only active users' do - expect(suggested_reviewer_users).to eq([first_member]) - end - end - - context 'when all users are active' do - it 'returns users in correct suggested order' do - expect(suggested_reviewer_users).to eq([second_member, first_member]) - end - end - end - end + it { is_expected.to be_empty } end end |