diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-27 12:08:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-27 12:08:35 +0000 |
commit | 22e9af3c8b8aedf7f46b786be968862b74a2d07e (patch) | |
tree | a10a7d9af40a17fe6cda7b3a681f5e5e2112c16e /spec | |
parent | c8e28a0bb8dd45d91cb72ff2c930bc4a562f1fc7 (diff) | |
download | gitlab-ce-22e9af3c8b8aedf7f46b786be968862b74a2d07e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
58 files changed, 453 insertions, 370 deletions
diff --git a/spec/controllers/acme_challenges_controller_spec.rb b/spec/controllers/acme_challenges_controller_spec.rb index cee06bed27b..be077a4b20d 100644 --- a/spec/controllers/acme_challenges_controller_spec.rb +++ b/spec/controllers/acme_challenges_controller_spec.rb @@ -28,7 +28,7 @@ describe AcmeChallengesController do let(:token) { acme_order.challenge_token } it 'renders not found' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -37,7 +37,7 @@ describe AcmeChallengesController do let(:token) { 'wrongtoken' } it 'renders not found' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index ae7b5784302..c1cfe9f20d2 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -156,7 +156,7 @@ describe ApplicationController do it 'returns 200 response' do get :index, format: requested_format - expect(response).to have_gitlab_http_status 200 + expect(response).to have_gitlab_http_status(:ok) end end @@ -164,7 +164,7 @@ describe ApplicationController do it 'returns 404 response' do get :index - expect(response).to have_gitlab_http_status 404 + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -181,7 +181,7 @@ describe ApplicationController do get :index - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'redirects to login page if not authenticated' do @@ -202,7 +202,7 @@ describe ApplicationController do get :index, format: 'unknown' - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -489,7 +489,7 @@ describe ApplicationController do it 'redirects if the user did not accept the terms' do get :index - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end it 'does not redirect when the user accepted terms' do @@ -497,7 +497,7 @@ describe ApplicationController do get :index - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -581,21 +581,21 @@ describe ApplicationController do it 'renders a 404 without a message' do get :index - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response).to render_template('errors/not_found') end it 'renders a 403 when a message is passed to access denied' do get :index, params: { message: 'None shall pass' } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) expect(response).to render_template('errors/access_denied') end it 'renders a status passed to access denied' do get :index, params: { status: 401 } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end diff --git a/spec/controllers/autocomplete_controller_spec.rb b/spec/controllers/autocomplete_controller_spec.rb index 51f20bae880..1ebbeecc583 100644 --- a/spec/controllers/autocomplete_controller_spec.rb +++ b/spec/controllers/autocomplete_controller_spec.rb @@ -32,7 +32,7 @@ describe AutocompleteController do get(:users, params: { project_id: 'unknown' }) end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end end @@ -61,7 +61,7 @@ describe AutocompleteController do get(:users, params: { group_id: 'unknown' }) end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end end @@ -140,7 +140,7 @@ describe AutocompleteController do get(:users, params: { project_id: project.id }) end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end describe 'GET #users with unknown project' do @@ -148,7 +148,7 @@ describe AutocompleteController do get(:users, params: { project_id: 'unknown' }) end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end describe 'GET #users with inaccessible group' do @@ -157,7 +157,7 @@ describe AutocompleteController do get(:users, params: { group_id: user.namespace.id }) end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end describe 'GET #users with no project' do @@ -372,7 +372,7 @@ describe AutocompleteController do it 'returns empty json' do get :merge_request_target_branches, params: { project_id: project.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_empty end end @@ -383,7 +383,7 @@ describe AutocompleteController do get :merge_request_target_branches, params: { project_id: project.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_empty end end @@ -404,7 +404,7 @@ describe AutocompleteController do get :merge_request_target_branches, params: params - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response).to eq({ 'error' => 'At least one of group_id or project_id must be specified' }) end end @@ -416,7 +416,7 @@ describe AutocompleteController do get :merge_request_target_branches, params: { project_id: project.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to contain_exactly({ 'title' => 'feature' }) end end @@ -433,7 +433,7 @@ describe AutocompleteController do get :merge_request_target_branches, params: { group_id: group.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to contain_exactly({ 'title' => 'feature' }) end end diff --git a/spec/controllers/chaos_controller_spec.rb b/spec/controllers/chaos_controller_spec.rb index bafd4a70862..5812990ce7a 100644 --- a/spec/controllers/chaos_controller_spec.rb +++ b/spec/controllers/chaos_controller_spec.rb @@ -9,7 +9,7 @@ describe ChaosController do get :leakmem - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'call synchronously with params' do @@ -17,7 +17,7 @@ describe ChaosController do get :leakmem, params: { memory_mb: 1, duration_s: 2 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls asynchronously' do @@ -25,7 +25,7 @@ describe ChaosController do get :leakmem, params: { async: 1 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -35,7 +35,7 @@ describe ChaosController do get :cpu_spin - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls synchronously with params' do @@ -43,7 +43,7 @@ describe ChaosController do get :cpu_spin, params: { duration_s: 3 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls asynchronously' do @@ -51,7 +51,7 @@ describe ChaosController do get :cpu_spin, params: { async: 1 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -61,7 +61,7 @@ describe ChaosController do get :db_spin - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls synchronously with params' do @@ -69,7 +69,7 @@ describe ChaosController do get :db_spin, params: { duration_s: 4, interval_s: 5 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls asynchronously' do @@ -77,7 +77,7 @@ describe ChaosController do get :db_spin, params: { async: 1 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -87,7 +87,7 @@ describe ChaosController do get :sleep - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls synchronously with params' do @@ -95,7 +95,7 @@ describe ChaosController do get :sleep, params: { duration_s: 5 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls asynchronously' do @@ -103,7 +103,7 @@ describe ChaosController do get :sleep, params: { async: 1 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -113,7 +113,7 @@ describe ChaosController do get :kill - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls asynchronously' do @@ -121,7 +121,7 @@ describe ChaosController do get :kill, params: { async: 1 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/concerns/metrics_dashboard_spec.rb b/spec/controllers/concerns/metrics_dashboard_spec.rb index 389d264bed3..6ab02057412 100644 --- a/spec/controllers/concerns/metrics_dashboard_spec.rb +++ b/spec/controllers/concerns/metrics_dashboard_spec.rb @@ -72,7 +72,7 @@ describe MetricsDashboard do it 'includes project_blob_path only for project dashboards' do expect(system_dashboard['project_blob_path']).to be_nil - expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/blob/master/.gitlab/dashboards/test.yml") + expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/-/blob/master/.gitlab/dashboards/test.yml") end describe 'project permissions' do diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb index 9937bdf4061..0c1089dc7a8 100644 --- a/spec/controllers/graphql_controller_spec.rb +++ b/spec/controllers/graphql_controller_spec.rb @@ -39,7 +39,7 @@ describe GraphqlController do it 'returns 200 when user can access API' do post :execute - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'returns access denied template when user cannot access API' do @@ -59,7 +59,7 @@ describe GraphqlController do it 'returns 200' do post :execute - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 2ed2b319298..3399ad563a1 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -136,7 +136,7 @@ describe GroupsController do get :activity, params: { id: group.to_param }, format: :json - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['count']).to eq(3) expect(assigns(:projects).limit_value).to be_nil end @@ -151,7 +151,7 @@ describe GroupsController do post :create, params: { group: { name: 'new_group', path: "new_group" } } end.to change { Group.count }.by(1) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end context 'authorization' do @@ -162,7 +162,7 @@ describe GroupsController do post :create, params: { group: { name: 'new_group', path: "new_group" } } end.to change { Group.count }.by(1) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -367,7 +367,7 @@ describe GroupsController do it 'updates the path successfully' do post :update, params: { id: group.to_param, group: { path: 'new_path' } } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(controller).to set_flash[:notice] end @@ -382,7 +382,7 @@ describe GroupsController do it 'updates the project_creation_level successfully' do post :update, params: { id: group.to_param, group: { project_creation_level: ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS } } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(group.reload.project_creation_level).to eq(::Gitlab::Access::MAINTAINER_PROJECT_ACCESS) end @@ -397,7 +397,7 @@ describe GroupsController do post :update, params: { id: group.to_param, group: { name: 'new_name' } } expect(controller).to set_flash[:notice] - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(group.reload.name).to eq('new_name') end @@ -405,7 +405,7 @@ describe GroupsController do post :update, params: { id: group.to_param, group: { path: 'new_path' } } expect(assigns(:group).errors[:base].first).to match(/Docker images in their Container Registry/) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -468,7 +468,7 @@ describe GroupsController do it 'does not redirect' do get :issues, params: { id: group.to_param } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -487,7 +487,7 @@ describe GroupsController do it 'does not redirect' do get :show, params: { id: group.to_param } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -554,13 +554,13 @@ describe GroupsController do it 'does not 404' do post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } } - expect(response).not_to have_gitlab_http_status(404) + expect(response).not_to have_gitlab_http_status(:not_found) end it 'does not redirect to the correct casing' do post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -570,7 +570,7 @@ describe GroupsController do it 'returns not found' do post :update, params: { id: redirect_route.path, group: { path: 'new_path' } } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -580,13 +580,13 @@ describe GroupsController do it 'does not 404' do delete :destroy, params: { id: group.to_param.upcase } - expect(response).not_to have_gitlab_http_status(404) + expect(response).not_to have_gitlab_http_status(:not_found) end it 'does not redirect to the correct casing' do delete :destroy, params: { id: group.to_param.upcase } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -596,7 +596,7 @@ describe GroupsController do it 'returns not found' do delete :destroy, params: { id: redirect_route.path } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -693,7 +693,7 @@ describe GroupsController do end it 'is denied' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -755,13 +755,13 @@ describe GroupsController do it 'is successful' do get :show, params: { id: group.to_param } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'does not allow other formats' do get :show, params: { id: group.to_param }, format: :atom - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -769,7 +769,7 @@ describe GroupsController do it 'is successful' do get :edit, params: { id: group.to_param } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -777,7 +777,7 @@ describe GroupsController do it 'is successful' do get :new - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -786,7 +786,7 @@ describe GroupsController do get :index # Redirects to the dashboard - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -810,7 +810,7 @@ describe GroupsController do it 'deletes the group' do delete :destroy, params: { id: group.to_param } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end diff --git a/spec/controllers/health_check_controller_spec.rb b/spec/controllers/health_check_controller_spec.rb index cbcda5d0dc7..d1de669ad43 100644 --- a/spec/controllers/health_check_controller_spec.rb +++ b/spec/controllers/health_check_controller_spec.rb @@ -101,7 +101,7 @@ describe HealthCheckController, :request_store do it 'supports failure plaintext response' do get :index - expect(response).to have_gitlab_http_status(500) + expect(response).to have_gitlab_http_status(:internal_server_error) expect(response.content_type).to eq 'text/plain' expect(response.body).to include('The server is on fire') end @@ -109,7 +109,7 @@ describe HealthCheckController, :request_store do it 'supports failure json response' do get :index, format: :json - expect(response).to have_gitlab_http_status(500) + expect(response).to have_gitlab_http_status(:internal_server_error) expect(response.content_type).to eq 'application/json' expect(json_response['healthy']).to be false expect(json_response['message']).to include('The server is on fire') @@ -118,7 +118,7 @@ describe HealthCheckController, :request_store do it 'supports failure xml response' do get :index, format: :xml - expect(response).to have_gitlab_http_status(500) + expect(response).to have_gitlab_http_status(:internal_server_error) expect(response.content_type).to eq 'application/xml' expect(xml_response['healthy']).to be false expect(xml_response['message']).to include('The server is on fire') @@ -127,7 +127,7 @@ describe HealthCheckController, :request_store do it 'supports failure responses for specific checks' do get :index, params: { checks: 'email' }, format: :json - expect(response).to have_gitlab_http_status(500) + expect(response).to have_gitlab_http_status(:internal_server_error) expect(response.content_type).to eq 'application/json' expect(json_response['healthy']).to be false expect(json_response['message']).to include('Email is on fire') diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb index 03b6e85b653..69b5605c0e5 100644 --- a/spec/controllers/help_controller_spec.rb +++ b/spec/controllers/help_controller_spec.rb @@ -148,7 +148,7 @@ describe HelpController do context 'for UI Development Kit' do it 'renders found' do get :ui - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb index ac0adcd06a3..9daaa258aa2 100644 --- a/spec/controllers/invites_controller_spec.rb +++ b/spec/controllers/invites_controller_spec.rb @@ -17,7 +17,7 @@ describe InvitesController do get :accept, params: { id: token } member.reload - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(member.user).to eq(user) expect(flash[:notice]).to include 'You have been granted' end @@ -28,7 +28,7 @@ describe InvitesController do get :decline, params: { id: token } expect {member.reload}.to raise_error ActiveRecord::RecordNotFound - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(flash[:notice]).to include 'You have declined the invitation to join' end end diff --git a/spec/controllers/notification_settings_controller_spec.rb b/spec/controllers/notification_settings_controller_spec.rb index 46328148eff..7b19c67cad3 100644 --- a/spec/controllers/notification_settings_controller_spec.rb +++ b/spec/controllers/notification_settings_controller_spec.rb @@ -125,7 +125,7 @@ describe NotificationSettingsController do notification_setting: { level: :participating } } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -195,7 +195,7 @@ describe NotificationSettingsController do notification_setting: { level: :participating } } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/omniauth_callbacks_controller_spec.rb b/spec/controllers/omniauth_callbacks_controller_spec.rb index 8b92976252c..71cdba12147 100644 --- a/spec/controllers/omniauth_callbacks_controller_spec.rb +++ b/spec/controllers/omniauth_callbacks_controller_spec.rb @@ -172,7 +172,7 @@ describe OmniauthCallbacksController, type: :controller, do_not_mock_admin_mode: it 'returns 403' do post provider - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb index bf9680329ce..3ec8e347659 100644 --- a/spec/controllers/passwords_controller_spec.rb +++ b/spec/controllers/passwords_controller_spec.rb @@ -15,7 +15,7 @@ describe PasswordsController do post :create - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(flash[:alert]).to eq _('Password authentication is unavailable.') end end diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index 265f941e146..91f3bfcfa40 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -87,7 +87,7 @@ describe ProfilesController, :request_store do put :update, params: { user: { status: { message: 'Working hard!' } } } expect(user.reload.status.message).to eq('Working hard!') - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end diff --git a/spec/controllers/projects/blame_controller_spec.rb b/spec/controllers/projects/blame_controller_spec.rb index dd7c0f45dc2..ac8394e3cd4 100644 --- a/spec/controllers/projects/blame_controller_spec.rb +++ b/spec/controllers/projects/blame_controller_spec.rb @@ -36,7 +36,7 @@ describe Projects::BlameController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/master") + .to redirect_to("/#{project.full_path}/-/tree/master") end end diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index 78599935910..aa1dcdd9f1d 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -33,7 +33,7 @@ describe Projects::BlobController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/master") + .to redirect_to("/#{project.full_path}/-/tree/master") end end @@ -115,7 +115,7 @@ describe Projects::BlobController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/markdown/doc") + .to redirect_to("/#{project.full_path}/-/tree/markdown/doc") end end end diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index ac39ac626c7..5b59534cb49 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -38,7 +38,7 @@ describe Projects::BranchesController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/merge_branch") + .to redirect_to("/#{project.full_path}/-/tree/merge_branch") end end @@ -48,7 +48,7 @@ describe Projects::BranchesController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/alert('merge');") + .to redirect_to("/#{project.full_path}/-/tree/alert('merge');") end end @@ -93,7 +93,7 @@ describe Projects::BranchesController do } expect(subject) - .to redirect_to("/#{project.full_path}/tree/1-feature-branch") + .to redirect_to("/#{project.full_path}/-/tree/1-feature-branch") end it 'posts a system note' do diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb index a570db12d94..aef8ef1d487 100644 --- a/spec/controllers/projects/raw_controller_spec.rb +++ b/spec/controllers/projects/raw_controller_spec.rb @@ -72,7 +72,7 @@ describe Projects::RawController do env: :raw_blob_request_limit, remote_ip: '0.0.0.0', request_method: 'GET', - path: "/#{project.full_path}/raw/#{file_path}" + path: "/#{project.full_path}/-/raw/#{file_path}" } expect(Gitlab::AuthLogger).to receive(:error).with(attributes).once diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb index 7c9abdf700b..5df05a06f00 100644 --- a/spec/controllers/projects/tree_controller_spec.rb +++ b/spec/controllers/projects/tree_controller_spec.rb @@ -45,7 +45,7 @@ describe Projects::TreeController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/master") + .to redirect_to("/#{project.full_path}/-/tree/master") end end @@ -60,7 +60,7 @@ describe Projects::TreeController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/empty-branch") + .to redirect_to("/#{project.full_path}/-/tree/empty-branch") end end @@ -153,7 +153,7 @@ describe Projects::TreeController do let(:id) { 'master/README.md' } it 'redirects' do - redirect_url = "/#{project.full_path}/blob/master/README.md" + redirect_url = "/#{project.full_path}/-/blob/master/README.md" expect(subject) .to redirect_to(redirect_url) end @@ -181,7 +181,7 @@ describe Projects::TreeController do it 'redirects to the new directory' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/#{branch_name}/#{path}") + .to redirect_to("/#{project.full_path}/-/tree/#{branch_name}/#{path}") expect(flash[:notice]).to eq('The directory has been successfully created.') end end @@ -192,7 +192,7 @@ describe Projects::TreeController do it 'does not allow overwriting of existing files' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/master") + .to redirect_to("/#{project.full_path}/-/tree/master") expect(flash[:alert]).to eq('A file with this name already exists') end end diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 9ae1277de26..a44218a5d2f 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -27,7 +27,7 @@ describe ProjectsController do get :new, params: { namespace_id: group.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('new') end end @@ -36,7 +36,7 @@ describe ProjectsController do it 'responds with status 404' do get :new, params: { namespace_id: group.id } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response).not_to render_template('new') end end @@ -159,7 +159,7 @@ describe ProjectsController do it 'renders a 503' do get :show, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(503) + expect(response).to have_gitlab_http_status(:service_unavailable) end end @@ -264,7 +264,7 @@ describe ProjectsController do get :show, params: { namespace_id: project.namespace, id: project }, format: :git - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_path) end end @@ -331,7 +331,7 @@ describe ProjectsController do id: project.path } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'sets the badge API endpoint' do @@ -371,7 +371,7 @@ describe ProjectsController do end it 'redirects to projects path' do - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(project_path(project)) end end @@ -391,7 +391,7 @@ describe ProjectsController do end it 'returns 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -419,7 +419,7 @@ describe ProjectsController do end it 'redirects to projects path' do - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(project_path(project)) end end @@ -439,7 +439,7 @@ describe ProjectsController do end it 'returns 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -466,7 +466,7 @@ describe ProjectsController do id: project.path } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -486,7 +486,7 @@ describe ProjectsController do id: project.path } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end @@ -521,7 +521,7 @@ describe ProjectsController do expect(assign_repository_path).to include(project.path) end - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -537,7 +537,7 @@ describe ProjectsController do .not_to change { project.reload.path } expect(controller).to set_flash.now[:alert].to(s_('UpdateProject|Cannot rename project because it contains container registry tags!')) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -555,7 +555,7 @@ describe ProjectsController do project: params } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) params.each do |param, value| expect(project.public_send(param)).to eq(value) end @@ -653,7 +653,7 @@ describe ProjectsController do project.reload expect(project.namespace).to eq(new_namespace) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end context 'when new namespace is empty' do @@ -674,7 +674,7 @@ describe ProjectsController do project.reload expect(project.namespace).to eq(old_namespace) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(flash[:alert]).to eq s_('TransferProject|Please select a new namespace for your project.') end end @@ -691,7 +691,7 @@ describe ProjectsController do delete :destroy, params: { namespace_id: project.namespace, id: project } expect { Project.find(orig_id) }.to raise_error(ActiveRecord::RecordNotFound) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(dashboard_projects_path) end @@ -733,7 +733,7 @@ describe ProjectsController do end it 'has http status 200' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'changes the user incoming email token' do @@ -763,7 +763,7 @@ describe ProjectsController do end it 'has http status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'changes the user incoming email token' do @@ -856,7 +856,7 @@ describe ProjectsController do id: project }, format: :js) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -905,7 +905,7 @@ describe ProjectsController do sign_in(user) get :refs, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -928,7 +928,7 @@ describe ProjectsController do it 'returns 404' do post :preview_markdown, params: { namespace_id: private_project.namespace, id: private_project, text: '*Markdown* text' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -973,7 +973,7 @@ describe ProjectsController do end it 'renders JSON body with image links expanded' do - expanded_path = "/#{project_with_repo.full_path}/raw/master/files/images/logo-white.png" + expanded_path = "/#{project_with_repo.full_path}/-/raw/master/files/images/logo-white.png" post :preview_markdown, params: preview_markdown_params @@ -994,7 +994,7 @@ describe ProjectsController do get :show, params: { namespace_id: public_project.namespace, id: public_project } expect(assigns(:project)).to eq(public_project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -1033,13 +1033,13 @@ describe ProjectsController do it 'does not 404' do post :toggle_star, params: { namespace_id: public_project.namespace, id: public_project.path.upcase } - expect(response).not_to have_gitlab_http_status(404) + expect(response).not_to have_gitlab_http_status(:not_found) end it 'does not redirect to the correct casing' do post :toggle_star, params: { namespace_id: public_project.namespace, id: public_project.path.upcase } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -1049,7 +1049,7 @@ describe ProjectsController do it 'returns not found' do post :toggle_star, params: { namespace_id: 'foo', id: 'bar' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -1063,13 +1063,13 @@ describe ProjectsController do it 'does not 404' do delete :destroy, params: { namespace_id: project.namespace, id: project.path.upcase } - expect(response).not_to have_gitlab_http_status(404) + expect(response).not_to have_gitlab_http_status(:not_found) end it 'does not redirect to the correct casing' do delete :destroy, params: { namespace_id: project.namespace, id: project.path.upcase } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -1079,7 +1079,7 @@ describe ProjectsController do it 'returns not found' do delete :destroy, params: { namespace_id: 'foo', id: 'bar' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -1103,7 +1103,7 @@ describe ProjectsController do get action, params: { namespace_id: project.namespace, id: project } expect(flash[:alert]).to eq('This endpoint has been requested too many times. Try again later.') - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -1114,7 +1114,7 @@ describe ProjectsController do it 'returns 302' do get action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -1126,7 +1126,7 @@ describe ProjectsController do it 'returns 404' do get action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1143,7 +1143,7 @@ describe ProjectsController do it 'returns 302' do get action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -1155,7 +1155,7 @@ describe ProjectsController do it 'returns 404' do get action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1172,7 +1172,7 @@ describe ProjectsController do it 'returns 302' do post action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -1184,7 +1184,7 @@ describe ProjectsController do it 'returns 404' do post action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -1196,7 +1196,7 @@ describe ProjectsController do it 'returns 302' do post action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -1208,7 +1208,7 @@ describe ProjectsController do it 'returns 404' do post action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1245,7 +1245,7 @@ describe ProjectsController do it 'redirects to the project page' do get :resolve, params: { id: project.id } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(project_path(project)) end end @@ -1267,14 +1267,14 @@ describe ProjectsController do it 'gives 404 for existing project' do get :resolve, params: { id: project.id } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end it 'gives 404 for non-existing project' do get :resolve, params: { id: '0' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1288,7 +1288,7 @@ describe ProjectsController do it 'gives 404 for private project' do get :resolve, params: { id: project.id } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 214eb35ec9d..792219d830d 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -30,7 +30,7 @@ describe RegistrationsController do it 'renders new template and sets the resource variable' do expect(subject).to render_template(:new) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:resource)).to be_a(User) end end @@ -48,7 +48,7 @@ describe RegistrationsController do it 'renders new template and sets the resource variable' do subject - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(new_user_session_path(anchor: 'register-pane')) end end @@ -200,7 +200,7 @@ describe RegistrationsController do .and_call_original expect(Gitlab::AuthLogger).to receive(:error).with(auth_log_attributes).once expect { post(:create, params: user_params, session: session_params) }.not_to change(User, :count) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.body).to be_empty end end diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index ca7b8a4036a..19786417d76 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -21,13 +21,13 @@ describe SearchController do it 'blocks access without a project_id' do get action, params: params - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'allows access with a project_id' do get action, params: params.merge(project_id: create(:project, :public).id) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -42,13 +42,13 @@ describe SearchController do it 'renders a 403 when no project is given' do get action, params: params - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'renders a 200 when a project was set' do get action, params: params.merge(project_id: project.id) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -57,7 +57,7 @@ describe SearchController do it 'still allows accessing the search page' do get :show - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -195,7 +195,7 @@ describe SearchController do get :count, params: { search: 'hello', scope: 'projects' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to eq({ 'count' => '1' }) end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 1e47df150b4..63797e22b38 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -22,7 +22,7 @@ describe SessionsController do it 'redirects to :omniauth_authorize_path' do get(:new) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to('/saml') end end @@ -31,7 +31,7 @@ describe SessionsController do it 'responds with 200' do get(:new, params: { auto_sign_in: 'false' }) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index c8f9e4256c9..f8fc9a72e00 100644 --- a/spec/controllers/snippets_controller_spec.rb +++ b/spec/controllers/snippets_controller_spec.rb @@ -51,7 +51,7 @@ describe SnippetsController do it 'responds with status 200' do get :new - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end context 'when user is not allowed to create a personal snippet' do @@ -60,7 +60,7 @@ describe SnippetsController do it 'responds with status 404' do get :new - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -90,7 +90,7 @@ describe SnippetsController do it 'responds with status 404' do get :show, params: { id: other_personal_snippet.to_param } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -99,13 +99,13 @@ describe SnippetsController do get :show, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'responds with status 404 when embeddable content is requested' do get :show, params: { id: personal_snippet.to_param }, format: :js - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -131,13 +131,13 @@ describe SnippetsController do get :show, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'responds with status 404 when embeddable content is requested' do get :show, params: { id: personal_snippet.to_param }, format: :js - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -162,14 +162,14 @@ describe SnippetsController do get :show, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'responds with status 200 when embeddable content is requested' do get :show, params: { id: personal_snippet.to_param }, format: :js expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -178,7 +178,7 @@ describe SnippetsController do get :show, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -192,7 +192,7 @@ describe SnippetsController do it 'responds with status 404' do get :show, params: { id: 'doesntexist' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -234,7 +234,7 @@ describe SnippetsController do create_snippet(visibility_level: Snippet::PUBLIC) end.not_to change { Snippet.count } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -496,7 +496,7 @@ describe SnippetsController do it 'responds with status 404' do get :raw, params: { id: other_personal_snippet.to_param } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -507,7 +507,7 @@ describe SnippetsController do it 'responds with status 200' do expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'has expected headers' do @@ -517,7 +517,7 @@ describe SnippetsController do end it "sets #{Gitlab::Workhorse::DETECT_HEADER} header" do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" end end @@ -544,7 +544,7 @@ describe SnippetsController do get :raw, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -569,7 +569,7 @@ describe SnippetsController do get :raw, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end context 'CRLF line ending' do @@ -596,7 +596,7 @@ describe SnippetsController do get :raw, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -610,7 +610,7 @@ describe SnippetsController do it 'responds with status 404' do get :raw, params: { id: 'doesntexist' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -712,7 +712,7 @@ describe SnippetsController do it 'responds with status 404' do delete :destroy, params: { id: snippet.to_param } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb index ff15e685007..69e2c085659 100644 --- a/spec/controllers/uploads_controller_spec.rb +++ b/spec/controllers/uploads_controller_spec.rb @@ -46,7 +46,7 @@ describe UploadsController do it "returns 401 when the user is not logged in" do post :create, params: { model: model, id: snippet.id }, format: :json - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end it "returns 404 when user can't comment on a snippet" do @@ -55,7 +55,7 @@ describe UploadsController do sign_in(user) post :create, params: { model: model, id: private_snippet.id }, format: :json - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -67,7 +67,7 @@ describe UploadsController do it "returns an error without file" do post :create, params: { model: model, id: snippet.id }, format: :json - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end it "returns an error with invalid model" do @@ -78,7 +78,7 @@ describe UploadsController do it "returns 404 status when object not found" do post :create, params: { model: model, id: 9999 }, format: :json - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end context 'with valid image' do @@ -129,7 +129,7 @@ describe UploadsController do it 'returns 401 when the user has no access' do post :create, params: { model: 'user', id: user.id }, format: :json - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end context 'when user is logged in' do @@ -188,7 +188,7 @@ describe UploadsController do post :create, params: { model: model, id: another_user.id, file: txt }, format: :json - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -246,7 +246,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -254,7 +254,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content publicly cached' do @@ -271,7 +271,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content publicly cached' do @@ -296,7 +296,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -316,7 +316,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -338,7 +338,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -361,7 +361,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -369,7 +369,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -386,7 +386,7 @@ describe UploadsController do it "responds with status 404" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -401,7 +401,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -421,7 +421,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -457,7 +457,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -465,7 +465,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -482,7 +482,7 @@ describe UploadsController do it "responds with status 404" do get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -502,7 +502,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content not cached' do @@ -522,7 +522,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content not cached' do @@ -544,7 +544,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -567,7 +567,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -575,7 +575,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content not cached' do @@ -592,7 +592,7 @@ describe UploadsController do it "responds with status 404" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -607,7 +607,7 @@ describe UploadsController do it 'responds with status 200' do get :show, params: { model: 'appearance', mounted_as: 'header_logo', id: appearance.id, filename: 'dk.png' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content publicly cached' do @@ -627,7 +627,7 @@ describe UploadsController do it 'responds with status 200' do get :show, params: { model: 'appearance', mounted_as: 'logo', id: appearance.id, filename: 'dk.png' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content publicly cached' do @@ -648,7 +648,7 @@ describe UploadsController do it 'successfully returns the file' do get :show, params: { model: 'appearance', mounted_as: 'favicon', id: appearance.id, filename: 'dk.png' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header['Content-Disposition']).to end_with 'filename="dk.png"' end end @@ -657,7 +657,7 @@ describe UploadsController do it 'returns a 404' do get :show, params: { model: 'appearance', mounted_as: 'favicon', id: appearance.id, filename: 'bogus.png' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 597d2a185b5..2af398e143d 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -28,7 +28,7 @@ describe UsersController do it 'renders the show template' do get :show, params: { username: user.username } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('show') end end @@ -53,7 +53,7 @@ describe UsersController do it 'renders show' do get :show, params: { username: user.username } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('show') end end @@ -74,7 +74,7 @@ describe UsersController do it 'renders 404' do get :show, params: { username: 'nonexistent' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -130,7 +130,7 @@ describe UsersController do get :calendar, params: { username: public_user.username }, format: :json - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -285,7 +285,7 @@ describe UsersController do context 'format html' do it 'renders snippets page' do get :snippets, params: { username: user.username } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('show') end end @@ -293,7 +293,7 @@ describe UsersController do context 'format json' do it 'response with snippets json data' do get :snippets, params: { username: user.username }, format: :json - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to have_key('html') end end diff --git a/spec/fixtures/authentication/adfs_saml_response.xml b/spec/fixtures/authentication/adfs_saml_response.xml new file mode 100644 index 00000000000..1056d73638c --- /dev/null +++ b/spec/fixtures/authentication/adfs_saml_response.xml @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="jVFQbyEpSfUwqhZtJtarIaGoshwuAQMDwLoiMhzJXsv" Version="2.0" IssueInstant="2020-01-23T06:12:41.896Z" Destination="https://gitlab-example.com/users/auth/saml/callback" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" InResponseTo="feooghajnhofcmogakmlhpkohnmikicnfhdnjlc"> + <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">https://example.com/adfs/services/trust</Issuer> + <samlp:Status> + <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/> + </samlp:Status> + <Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="emmCjammnYdAbMWDuMAJeZvQIMBayeeYqqwvQoDclKE" IssueInstant="2020-01-23T06:12:41.896Z" Version="2.0"> + <Issuer>https://example.com/adfs/services/trust</Issuer> + <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> + <ds:SignedInfo> + <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> + <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/> + <ds:Reference URI="#jVFQbyEpSfUwqhZtJtarIaGoshwuAQMDwLoiMhzJXsv"> + <ds:Transforms> + <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> + <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> + </ds:Transforms> + <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> + <ds:DigestValue>uHuSry39P16Yh7srS32xESmj4Lw</ds:DigestValue> + </ds:Reference> + </ds:SignedInfo> + <ds:SignatureValue>fdghdfggfd=</ds:SignatureValue> + <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"> + <ds:X509Data> + <ds:X509Certificate>dfghjkl</ds:X509Certificate> + </ds:X509Data> + </KeyInfo> + </ds:Signature> + <Subject> + <NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient">example@example.com</NameID> + <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"> + <SubjectConfirmationData InResponseTo="cfeooghajnhofcmogakmlhpkohnmikicnfhdnjlc" NotOnOrAfter="2020-01-23T06:17:41.896Z" Recipient="https://gitlab-example.com/users/auth/saml/callback"/> + </SubjectConfirmation> + </Subject> + <Conditions NotBefore="2020-01-23T06:10:41.818Z" NotOnOrAfter="2020-01-23T07:10:41.818Z"> + <AudienceRestriction> + <Audience>https://gitlab-example.com</Audience> + </AudienceRestriction> + </Conditions> + <AttributeStatement> + <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"> + <AttributeValue>example@example.com</AttributeValue> + </Attribute> + <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"> + <AttributeValue>Example User</AttributeValue> + </Attribute> + <Attribute Name="http://schemas.xmlsoap.org/claims/Group"> + <AttributeValue>Group 1</AttributeValue> + <AttributeValue>Another Group</AttributeValue> + </Attribute> + </AttributeStatement> + <AuthnStatement AuthnInstant="2020-01-23T06:12:41.756Z" SessionIndex="perdkjfskdjfksdiertusfsdfsddeurtherukjdfgkdffg"> + <AuthnContext> + <AuthnContextClassRef>urn:federation:authentication:windows</AuthnContextClassRef> + </AuthnContext> + </AuthnStatement> + </Assertion> +</samlp:Response> diff --git a/spec/frontend/ide/services/index_spec.js b/spec/frontend/ide/services/index_spec.js index d676d7539b6..83a3cfe618b 100644 --- a/spec/frontend/ide/services/index_spec.js +++ b/spec/frontend/ide/services/index_spec.js @@ -97,7 +97,7 @@ describe('IDE services', () => { mock .onGet( - `${relativeUrlRoot}/${TEST_PROJECT_ID}/raw/${TEST_COMMIT_SHA}/${escapeFileUrl( + `${relativeUrlRoot}/${TEST_PROJECT_ID}/-/raw/${TEST_COMMIT_SHA}/${escapeFileUrl( filePath, )}`, ) diff --git a/spec/frontend/repository/components/table/parent_row_spec.js b/spec/frontend/repository/components/table/parent_row_spec.js index 439c7ff080c..360c2e97353 100644 --- a/spec/frontend/repository/components/table/parent_row_spec.js +++ b/spec/frontend/repository/components/table/parent_row_spec.js @@ -32,8 +32,8 @@ describe('Repository parent row component', () => { it.each` path | to - ${'app'} | ${'/tree/master/'} - ${'app/assets'} | ${'/tree/master/app'} + ${'app'} | ${'/-/tree/master/'} + ${'app/assets'} | ${'/-/tree/master/app'} `('renders link in $path to $to', ({ path, to }) => { factory(path); @@ -48,7 +48,7 @@ describe('Repository parent row component', () => { vm.find('td').trigger('click'); expect($router.push).toHaveBeenCalledWith({ - path: '/tree/master/app', + path: '/-/tree/master/app', }); }); @@ -60,7 +60,7 @@ describe('Repository parent row component', () => { vm.find('a').trigger('click'); expect($router.push).not.toHaveBeenCalledWith({ - path: '/tree/master/app', + path: '/-/tree/master/app', }); }); diff --git a/spec/frontend/repository/components/table/row_spec.js b/spec/frontend/repository/components/table/row_spec.js index b60560366a6..b0c97dee414 100644 --- a/spec/frontend/repository/components/table/row_spec.js +++ b/spec/frontend/repository/components/table/row_spec.js @@ -88,7 +88,7 @@ describe('Repository table row component', () => { vm.trigger('click'); if (pushes) { - expect($router.push).toHaveBeenCalledWith({ path: '/tree/master/test' }); + expect($router.push).toHaveBeenCalledWith({ path: '/-/tree/master/test' }); } else { expect($router.push).not.toHaveBeenCalled(); } diff --git a/spec/frontend/repository/router_spec.js b/spec/frontend/repository/router_spec.js index f61a0ccd1e6..1efd74a30c2 100644 --- a/spec/frontend/repository/router_spec.js +++ b/spec/frontend/repository/router_spec.js @@ -4,11 +4,11 @@ import createRouter from '~/repository/router'; describe('Repository router spec', () => { it.each` - path | component | componentName - ${'/'} | ${IndexPage} | ${'IndexPage'} - ${'/tree/master'} | ${TreePage} | ${'TreePage'} - ${'/tree/master/app/assets'} | ${TreePage} | ${'TreePage'} - ${'/tree/123/app/assets'} | ${null} | ${'null'} + path | component | componentName + ${'/'} | ${IndexPage} | ${'IndexPage'} + ${'/-/tree/master'} | ${TreePage} | ${'TreePage'} + ${'/-/tree/master/app/assets'} | ${TreePage} | ${'TreePage'} + ${'/-/tree/123/app/assets'} | ${null} | ${'null'} `('sets component as $componentName for path "$path"', ({ path, component }) => { const router = createRouter('', 'master'); diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index 4996e27c2e6..2d0c4723648 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -56,7 +56,7 @@ describe BlobHelper do stub_feature_flags(web_ide_default: false) link = helper.edit_blob_button(project, 'master', 'README.md') - expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/edit/master/README.md") + expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/-/edit/master/README.md") end it 'returns a link with a Web IDE route' do @@ -69,7 +69,7 @@ describe BlobHelper do stub_feature_flags(web_ide_default: false) link = helper.edit_blob_button(project, 'master', 'README.md', link_opts: { mr_id: 10 }) - expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/edit/master/README.md?mr_id=10") + expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/-/edit/master/README.md?mr_id=10") end end diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb index 2f91ab3afb3..89730a67977 100644 --- a/spec/helpers/markup_helper_spec.rb +++ b/spec/helpers/markup_helper_spec.rb @@ -103,7 +103,7 @@ describe MarkupHelper do let(:requested_path) { 'files/images/README.md' } it 'returns the correct HTML for the image' do - expanded_path = "/#{project.full_path}/raw/master/files/images/#{image_file}" + expanded_path = "/#{project.full_path}/-/raw/master/files/images/#{image_file}" expect(subject.css('a')[0].attr('href')).to eq(expanded_path) expect(subject.css('img')[0].attr('data-src')).to eq(expanded_path) diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb index 8eb40b5975a..d229753a0f0 100644 --- a/spec/helpers/submodule_helper_spec.rb +++ b/spec/helpers/submodule_helper_spec.rb @@ -100,34 +100,34 @@ describe SubmoduleHelper do allow(repo).to receive(:project).and_return(project) stub_url('./') - expect(subject).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/tree/hash"]) + expect(subject).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/-/tree/hash"]) end end context 'submodule on gitlab.com' do it 'detects ssh' do stub_url('git@gitlab.com:gitlab-org/gitlab-foss.git') - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end it 'detects http' do stub_url('http://gitlab.com/gitlab-org/gitlab-foss.git') - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end it 'detects https' do stub_url('https://gitlab.com/gitlab-org/gitlab-foss.git') - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end it 'handles urls with no .git on the end' do stub_url('http://gitlab.com/gitlab-org/gitlab-foss') - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end it 'handles urls with trailing whitespace' do stub_url('http://gitlab.com/gitlab-org/gitlab-foss.git ') - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end it 'returns original with non-standard url' do @@ -171,7 +171,7 @@ describe SubmoduleHelper do stub_url(relative_path) result = subject - expect(result).to eq([expected_path, "#{expected_path}/tree/#{submodule_item.id}"]) + expect(result).to eq([expected_path, "#{expected_path}/-/tree/#{submodule_item.id}"]) end it 'handles project under same group' do diff --git a/spec/javascripts/vue_shared/components/diff_viewer/diff_viewer_spec.js b/spec/javascripts/vue_shared/components/diff_viewer/diff_viewer_spec.js index c743f1f6ad7..6a83790093a 100644 --- a/spec/javascripts/vue_shared/components/diff_viewer/diff_viewer_spec.js +++ b/spec/javascripts/vue_shared/components/diff_viewer/diff_viewer_spec.js @@ -38,11 +38,11 @@ describe('DiffViewer', () => { setTimeout(() => { expect(vm.$el.querySelector('.deleted img').getAttribute('src')).toBe( - `//raw/DEF/${RED_BOX_IMAGE_URL}`, + `//-/raw/DEF/${RED_BOX_IMAGE_URL}`, ); expect(vm.$el.querySelector('.added img').getAttribute('src')).toBe( - `//raw/ABC/${GREEN_BOX_IMAGE_URL}`, + `//-/raw/ABC/${GREEN_BOX_IMAGE_URL}`, ); done(); diff --git a/spec/javascripts/vue_shared/components/pagination/graphql_pagination_spec.js b/spec/javascripts/vue_shared/components/pagination/graphql_pagination_spec.js deleted file mode 100644 index 9e72a0e2480..00000000000 --- a/spec/javascripts/vue_shared/components/pagination/graphql_pagination_spec.js +++ /dev/null @@ -1,73 +0,0 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; -import GraphqlPagination from '~/vue_shared/components/pagination/graphql_pagination.vue'; - -const localVue = createLocalVue(); - -describe('Graphql Pagination component', () => { - let wrapper; - function factory({ hasNextPage = true, hasPreviousPage = true }) { - wrapper = shallowMount(localVue.extend(GraphqlPagination), { - propsData: { - hasNextPage, - hasPreviousPage, - }, - localVue, - }); - } - - afterEach(() => { - wrapper.destroy(); - }); - - describe('without previous page', () => { - beforeEach(() => { - factory({ hasPreviousPage: false }); - }); - - it('renders disabled previous button', () => { - expect(wrapper.find('.js-prev-btn').attributes().disabled).toEqual('true'); - }); - }); - - describe('with previous page', () => { - beforeEach(() => { - factory({ hasPreviousPage: true }); - }); - - it('renders enabled previous button', () => { - expect(wrapper.find('.js-prev-btn').attributes().disabled).toEqual(undefined); - }); - - it('emits previousClicked on click', () => { - wrapper.find('.js-prev-btn').vm.$emit('click'); - - expect(wrapper.emitted().previousClicked.length).toBe(1); - }); - }); - - describe('without next page', () => { - beforeEach(() => { - factory({ hasNextPage: false }); - }); - - it('renders disabled next button', () => { - expect(wrapper.find('.js-next-btn').attributes().disabled).toEqual('true'); - }); - }); - - describe('with next page', () => { - beforeEach(() => { - factory({ hasNextPage: true }); - }); - - it('renders enabled next button', () => { - expect(wrapper.find('.js-next-btn').attributes().disabled).toEqual(undefined); - }); - - it('emits nextClicked on click', () => { - wrapper.find('.js-next-btn').vm.$emit('click'); - - expect(wrapper.emitted().nextClicked.length).toBe(1); - }); - }); -}); diff --git a/spec/lib/banzai/filter/repository_link_filter_spec.rb b/spec/lib/banzai/filter/repository_link_filter_spec.rb index 6945973dfd6..cf73c77ecb8 100644 --- a/spec/lib/banzai/filter/repository_link_filter_spec.rb +++ b/spec/lib/banzai/filter/repository_link_filter_spec.rb @@ -152,7 +152,7 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'rebuilds absolute URL for a file in the repo' do doc = filter(link('/doc/api/README.md')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" end it 'does not modify relative URLs in system notes' do @@ -170,13 +170,13 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'rebuilds relative URL for a file in the repo' do doc = filter(link('doc/api/README.md')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo with leading ./' do doc = filter(link('./doc/api/README.md')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo up one directory' do @@ -184,7 +184,7 @@ describe Banzai::Filter::RepositoryLinkFilter do doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md') expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo up multiple directories' do @@ -192,7 +192,7 @@ describe Banzai::Filter::RepositoryLinkFilter do doc = filter(relative_link, requested_path: 'doc/foo/bar/baz/README.md') expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repository root' do @@ -200,47 +200,47 @@ describe Banzai::Filter::RepositoryLinkFilter do doc = filter(relative_link, requested_path: 'doc/some-file.md') expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/README.md" end it 'rebuilds relative URL for a file in the repo with an anchor' do doc = filter(link('README.md#section')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/README.md#section" + .to eq "/#{project_path}/-/blob/#{ref}/README.md#section" end it 'rebuilds relative URL for a directory in the repo' do doc = filter(link('doc/api/')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/tree/#{ref}/doc/api" + .to eq "/#{project_path}/-/tree/#{ref}/doc/api" end it 'rebuilds relative URL for an image in the repo' do doc = filter(image('files/images/logo-black.png')) expect(doc.at_css('img')['src']) - .to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" + .to eq "/#{project_path}/-/raw/#{ref}/files/images/logo-black.png" end it 'rebuilds relative URL for link to an image in the repo' do doc = filter(link('files/images/logo-black.png')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" + .to eq "/#{project_path}/-/raw/#{ref}/files/images/logo-black.png" end it 'rebuilds relative URL for a video in the repo' do doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video') expect(doc.at_css('video')['src']) - .to eq "/#{project_path}/raw/video/files/videos/intro.mp4" + .to eq "/#{project_path}/-/raw/video/files/videos/intro.mp4" end it 'rebuilds relative URL for audio in the repo' do doc = filter(audio('files/audio/sample.wav'), commit: project.commit('audio'), ref: 'audio') expect(doc.at_css('audio')['src']) - .to eq "/#{project_path}/raw/audio/files/audio/sample.wav" + .to eq "/#{project_path}/-/raw/audio/files/audio/sample.wav" end it 'does not modify relative URL with an anchor only' do @@ -267,7 +267,7 @@ describe Banzai::Filter::RepositoryLinkFilter do allow_any_instance_of(described_class).to receive(:uri_type).and_return(:raw) doc = filter(image(escaped)) - expect(doc.at_css('img')['src']).to eq "/#{project_path}/raw/#{Addressable::URI.escape(ref)}/#{escaped}" + expect(doc.at_css('img')['src']).to eq "/#{project_path}/-/raw/#{Addressable::URI.escape(ref)}/#{escaped}" end context 'when requested path is a file in the repo' do @@ -275,7 +275,7 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'rebuilds URL relative to the containing directory' do doc = filter(link('users.md')) - expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" + expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" end end @@ -284,7 +284,7 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'rebuilds URL relative to the directory' do doc = filter(link('users.md')) - expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" + expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" end end @@ -295,7 +295,7 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'correctly escapes the ref' do doc = filter(link('.gitkeep')) - expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/foo/bar/.gitkeep" + expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/foo/bar/.gitkeep" end end @@ -314,7 +314,7 @@ describe Banzai::Filter::RepositoryLinkFilter do doc = filter(link(path)) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/raw/#{ref_escaped}/files/images/logo-black.png" + .to eq "/#{project_path}/-/raw/#{ref_escaped}/files/images/logo-black.png" end end @@ -325,7 +325,7 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'does not escape the space twice' do doc = filter(link('README.md')) - expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/with%20space/README.md" + expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/with%20space/README.md" end end end diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index 861ef79b2f8..ef9929a9dce 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -31,7 +31,7 @@ describe ExtractsPath do it "log tree path has no escape sequences" do assign_ref_vars - expect(@logs_path).to eq("/#{@project.full_path}/refs/#{ref}/logs_tree/files/ruby/popen.rb") + expect(@logs_path).to eq("/#{@project.full_path}/-/refs/#{ref}/logs_tree/files/ruby/popen.rb") end context 'ref contains %20' do diff --git a/spec/lib/gitlab/auth/saml/auth_hash_spec.rb b/spec/lib/gitlab/auth/saml/auth_hash_spec.rb index 13636a495d1..8b88c16f317 100644 --- a/spec/lib/gitlab/auth/saml/auth_hash_spec.rb +++ b/spec/lib/gitlab/auth/saml/auth_hash_spec.rb @@ -95,6 +95,17 @@ describe Gitlab::Auth::Saml::AuthHash do end end + context 'with ADFS SAML response_object' do + before do + auth_hash_data[:extra][:response_object] = { document: + saml_xml(File.read('spec/fixtures/authentication/adfs_saml_response.xml')) } + end + + it 'can extract authn_context' do + expect(saml_auth_hash.authn_context).to eq 'urn:federation:authentication:windows' + end + end + context 'without response_object' do it 'returns an empty string' do expect(saml_auth_hash.authn_context).to be_nil diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index adf5a232a75..7ecc42ea497 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -258,7 +258,7 @@ FILE describe '#as_json' do it 'includes the blob path for the file' do expect(conflict_file.as_json[:blob_path]) - .to eq("/#{project.full_path}/blob/#{our_commit.oid}/files/ruby/regex.rb") + .to eq("/#{project.full_path}/-/blob/#{our_commit.oid}/files/ruby/regex.rb") end it 'includes the blob icon for the file' do diff --git a/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb b/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb index 9f8542a76c9..7128689e362 100644 --- a/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb @@ -75,8 +75,8 @@ describe Gitlab::DependencyLinker::GodepsJsonLinker do end it 'links GitLab projects' do - expect(subject).to include(link('gitlab.com/group/project/path', 'https://gitlab.com/group/project/tree/master/path')) - expect(subject).to include(link('gitlab.com/group/subgroup/project.git/path', 'https://gitlab.com/group/subgroup/project/tree/master/path')) + expect(subject).to include(link('gitlab.com/group/project/path', 'https://gitlab.com/group/project/-/tree/master/path')) + expect(subject).to include(link('gitlab.com/group/subgroup/project.git/path', 'https://gitlab.com/group/subgroup/project/-/tree/master/path')) end it 'links Golang packages' do diff --git a/spec/lib/gitlab/graphql/representation/submodule_tree_entry_spec.rb b/spec/lib/gitlab/graphql/representation/submodule_tree_entry_spec.rb index 28056a6085d..ed092a846ae 100644 --- a/spec/lib/gitlab/graphql/representation/submodule_tree_entry_spec.rb +++ b/spec/lib/gitlab/graphql/representation/submodule_tree_entry_spec.rb @@ -21,7 +21,7 @@ describe Gitlab::Graphql::Representation::SubmoduleTreeEntry do ) expect(entries.map(&:tree_url)).to contain_exactly( - "https://gitlab.com/gitlab-org/gitlab-grack/tree/645f6c4c82fd3f5e06f67134450a570b795e55a6", + "https://gitlab.com/gitlab-org/gitlab-grack/-/tree/645f6c4c82fd3f5e06f67134450a570b795e55a6", "https://github.com/gitlabhq/gitlab-shell/tree/79bceae69cb5750d6567b223597999bfa91cb3b9", "https://github.com/randx/six/tree/409f37c4f05865e4fb208c771485f211a22c4c2d" ) diff --git a/spec/lib/gitlab/middleware/go_spec.rb b/spec/lib/gitlab/middleware/go_spec.rb index 2b90035d148..99c2a364dfc 100644 --- a/spec/lib/gitlab/middleware/go_spec.rb +++ b/spec/lib/gitlab/middleware/go_spec.rb @@ -241,7 +241,7 @@ describe Gitlab::Middleware::Go do project_url = "http://#{Gitlab.config.gitlab.host}/#{path}" expect(response[0]).to eq(200) expect(response[1]['Content-Type']).to eq('text/html') - expected_body = %{<html><head><meta name="go-import" content="#{Gitlab.config.gitlab.host}/#{path} git #{repository_url}" /><meta name="go-source" content="#{Gitlab.config.gitlab.host}/#{path} #{project_url} #{project_url}/tree/#{branch}{/dir} #{project_url}/blob/#{branch}{/dir}/{file}#L{line}" /></head><body>go get #{Gitlab.config.gitlab.url}/#{path}</body></html>} + expected_body = %{<html><head><meta name="go-import" content="#{Gitlab.config.gitlab.host}/#{path} git #{repository_url}" /><meta name="go-source" content="#{Gitlab.config.gitlab.host}/#{path} #{project_url} #{project_url}/-/tree/#{branch}{/dir} #{project_url}/-/blob/#{branch}{/dir}/{file}#L{line}" /></head><body>go get #{Gitlab.config.gitlab.url}/#{path}</body></html>} expect(response[2].body).to eq([expected_body]) end end diff --git a/spec/lib/gitlab/submodule_links_spec.rb b/spec/lib/gitlab/submodule_links_spec.rb index f0c8825de74..1f2848a29e9 100644 --- a/spec/lib/gitlab/submodule_links_spec.rb +++ b/spec/lib/gitlab/submodule_links_spec.rb @@ -38,7 +38,7 @@ describe Gitlab::SubmoduleLinks do end it 'returns links and caches the by ref' do - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) cache_store = links.instance_variable_get("@cache_store") @@ -49,7 +49,7 @@ describe Gitlab::SubmoduleLinks do let(:ref) { 'signed-commits' } it 'returns links' do - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end end end diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 1ae90cae4b1..c9b41c9d82e 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -189,7 +189,7 @@ describe Key, :mailer do it 'removes key from authorized_file' do key = create(:personal_key) - expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, key.shell_id, key.key) + expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, key.shell_id) key.destroy end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 0b39cfa1243..ee65561cc3e 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -725,7 +725,7 @@ describe Project do let(:project) { create(:project, :repository) } it 'returns the README' do - expect(project.readme_url).to eq("#{project.web_url}/blob/master/README.md") + expect(project.readme_url).to eq("#{project.web_url}/-/blob/master/README.md") end end end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 8b62e332407..845c906129f 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1817,10 +1817,28 @@ describe Repository do end describe '#after_import' do + subject { repository.after_import } + it 'flushes and builds the cache' do expect(repository).to receive(:expire_content_cache) - repository.after_import + subject + end + + it 'calls DetectRepositoryLanguagesWorker' do + expect(DetectRepositoryLanguagesWorker).to receive(:perform_async) + + subject + end + + context 'with a wiki repository' do + let(:repository) { project.wiki.repository } + + it 'does not call DetectRepositoryLanguagesWorker' do + expect(DetectRepositoryLanguagesWorker).not_to receive(:perform_async) + + subject + end end end diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb index 8680e8b9b45..ee7bfd1256d 100644 --- a/spec/presenters/blob_presenter_spec.rb +++ b/spec/presenters/blob_presenter_spec.rb @@ -21,7 +21,7 @@ describe BlobPresenter, :seed_helper do subject { described_class.new(blob) } - it { expect(subject.web_url).to eq("http://localhost/#{project.full_path}/blob/#{blob.commit_id}/#{blob.path}") } + it { expect(subject.web_url).to eq("http://localhost/#{project.full_path}/-/blob/#{blob.commit_id}/#{blob.path}") } end describe '#highlight' do diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb index 6ce6f84cf61..025f083ab27 100644 --- a/spec/presenters/merge_request_presenter_spec.rb +++ b/spec/presenters/merge_request_presenter_spec.rb @@ -334,7 +334,7 @@ describe MergeRequestPresenter do allow(resource).to receive(:target_branch_exists?) { true } is_expected - .to eq("/#{resource.target_project.full_path}/commits/#{resource.target_branch}") + .to eq("/#{resource.target_project.full_path}/-/commits/#{resource.target_branch}") end end @@ -358,7 +358,7 @@ describe MergeRequestPresenter do allow(resource).to receive(:source_branch_exists?) { true } is_expected - .to eq("/#{resource.source_project.full_path}/commits/#{resource.source_branch}") + .to eq("/#{resource.source_project.full_path}/-/commits/#{resource.source_branch}") end end @@ -382,7 +382,7 @@ describe MergeRequestPresenter do allow(resource).to receive(:target_branch_exists?) { true } is_expected - .to eq("/#{resource.target_project.full_path}/tree/#{resource.target_branch}") + .to eq("/#{resource.target_project.full_path}/-/tree/#{resource.target_branch}") end end @@ -496,7 +496,7 @@ describe MergeRequestPresenter do allow(resource).to receive(:source_branch_exists?) { true } is_expected - .to eq("<a href=\"/#{resource.source_project.full_path}/tree/#{resource.source_branch}\">#{resource.source_branch}</a>") + .to eq("<a href=\"/#{resource.source_project.full_path}/-/tree/#{resource.source_branch}\">#{resource.source_branch}</a>") end it 'escapes html, when source_branch does not exist' do diff --git a/spec/presenters/tree_entry_presenter_spec.rb b/spec/presenters/tree_entry_presenter_spec.rb index d74ee5dc28f..0c29fe3e5ff 100644 --- a/spec/presenters/tree_entry_presenter_spec.rb +++ b/spec/presenters/tree_entry_presenter_spec.rb @@ -11,6 +11,6 @@ describe TreeEntryPresenter do let(:presenter) { described_class.new(tree) } describe '.web_url' do - it { expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/tree/#{tree.commit_id}/#{tree.path}") } + it { expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/-/tree/#{tree.commit_id}/#{tree.path}") } end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 62cc6ee086b..6ac7b4af452 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -812,7 +812,7 @@ describe API::Projects do post api('/projects', user), params: project - expect(json_response['readme_url']).to eql("#{Gitlab.config.gitlab.url}/#{json_response['namespace']['full_path']}/somewhere/blob/master/README.md") + expect(json_response['readme_url']).to eql("#{Gitlab.config.gitlab.url}/#{json_response['namespace']['full_path']}/somewhere/-/blob/master/README.md") end it 'sets tag list to a project' do diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index c3a5c0b0caa..d9c398923c5 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -834,7 +834,7 @@ describe 'Git HTTP requests' do Blob.decorate(Gitlab::Git::Blob.find(project.repository, 'master', 'bar/branch-test.txt'), project) end - get "/#{project.full_path}/blob/master/info/refs" + get "/#{project.full_path}/-/blob/master/info/refs" end it "returns the file" do @@ -844,7 +844,7 @@ describe 'Git HTTP requests' do context "when the file does not exist" do before do - get "/#{project.full_path}/blob/master/info/refs" + get "/#{project.full_path}/-/blob/master/info/refs" end it "redirects" do diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 8a1d34b2ecc..a46381fcedf 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -273,16 +273,16 @@ describe 'project routing' do end it 'to #logs_tree' do - expect(get('/gitlab/gitlabhq/refs/stable/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable') - expect(get('/gitlab/gitlabhq/refs/feature%2345/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45') - expect(get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45') - expect(get('/gitlab/gitlabhq/refs/feature@45/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45') - expect(get('/gitlab/gitlabhq/refs/stable/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') - expect(get('/gitlab/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45', path: 'foo/bar/baz') - expect(get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45', path: 'foo/bar/baz') - expect(get('/gitlab/gitlabhq/refs/feature@45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45', path: 'foo/bar/baz') - expect(get('/gitlab/gitlabhq/refs/stable/logs_tree/files.scss')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'files.scss') - assert_routing({ path: "/gitlab/gitlabhq/refs/stable/logs_tree/new%0A%0Aline.txt", + expect(get('/gitlab/gitlabhq/-/refs/stable/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable') + expect(get('/gitlab/gitlabhq/-/refs/feature%2345/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45') + expect(get('/gitlab/gitlabhq/-/refs/feature%2B45/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45') + expect(get('/gitlab/gitlabhq/-/refs/feature@45/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45') + expect(get('/gitlab/gitlabhq/-/refs/stable/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') + expect(get('/gitlab/gitlabhq/-/refs/feature%2345/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45', path: 'foo/bar/baz') + expect(get('/gitlab/gitlabhq/-/refs/feature%2B45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45', path: 'foo/bar/baz') + expect(get('/gitlab/gitlabhq/-/refs/feature@45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45', path: 'foo/bar/baz') + expect(get('/gitlab/gitlabhq/-/refs/stable/logs_tree/files.scss')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'files.scss') + assert_routing({ path: "/gitlab/gitlabhq/-/refs/stable/logs_tree/new%0A%0Aline.txt", method: :get }, { controller: 'projects/refs', action: 'logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -460,9 +460,14 @@ describe 'project routing' do it_behaves_like 'RESTful project resources' do let(:actions) { [:show] } let(:controller) { 'commits' } + let(:controller_path) { '/-/commits' } end it 'to #show' do + expect(get('/gitlab/gitlabhq/-/commits/master.atom')).to route_to('projects/commits#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.atom') + end + + it 'to #show unscoped routing' do expect(get('/gitlab/gitlabhq/commits/master.atom')).to route_to('projects/commits#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.atom') end end @@ -556,11 +561,11 @@ describe 'project routing' do # project_blame GET /:project_id/blame/:id(.:format) blame#show {id: /[^\0]+/, project_id: /[^\/]+/} describe Projects::BlameController, 'routing' do it 'to #show' do - expect(get('/gitlab/gitlabhq/blame/master/app/models/project.rb')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - expect(get('/gitlab/gitlabhq/blame/master/files.scss')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') + expect(get('/gitlab/gitlabhq/-/blame/master/app/models/project.rb')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + expect(get('/gitlab/gitlabhq/-/blame/master/files.scss')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/blame/master/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/blame/master/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/blame', action: 'show', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -571,44 +576,44 @@ describe 'project routing' do # project_blob GET /:project_id/blob/:id(.:format) blob#show {id: /[^\0]+/, project_id: /[^\/]+/} describe Projects::BlobController, 'routing' do it 'to #show' do - expect(get('/gitlab/gitlabhq/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - expect(get('/gitlab/gitlabhq/blob/master/app/models/compare.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/compare.rb') - expect(get('/gitlab/gitlabhq/blob/master/app/models/diff.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/diff.js') - expect(get('/gitlab/gitlabhq/blob/master/files.scss')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') - expect(get('/gitlab/gitlabhq/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/blob/index.js') - expect(get('/gitlab/gitlabhq/blob/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'blob/master/blob/index.js') + expect(get('/gitlab/gitlabhq/-/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + expect(get('/gitlab/gitlabhq/-/blob/master/app/models/compare.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/compare.rb') + expect(get('/gitlab/gitlabhq/-/blob/master/app/models/diff.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/diff.js') + expect(get('/gitlab/gitlabhq/-/blob/master/files.scss')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') + expect(get('/gitlab/gitlabhq/-/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/blob/index.js') + expect(get('/gitlab/gitlabhq/-/blob/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'blob/master/blob/index.js') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/blob/blob/master/blob/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/blob/blob/master/blob/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/blob', action: 'show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: "blob/master/blob/#{newline_file}" }) end - it 'to #show from scope routing' do - expect(get('/gitlab/gitlabhq/-/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + it 'to #show from unscoped routing' do + expect(get('/gitlab/gitlabhq/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') end end # project_tree GET /:project_id/tree/:id(.:format) tree#show {id: /[^\0]+/, project_id: /[^\/]+/} describe Projects::TreeController, 'routing' do it 'to #show' do - expect(get('/gitlab/gitlabhq/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - expect(get('/gitlab/gitlabhq/tree/master/files.scss')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') - expect(get('/gitlab/gitlabhq/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/tree/files') - expect(get('/gitlab/gitlabhq/tree/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'tree/master/tree/files') + expect(get('/gitlab/gitlabhq/-/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + expect(get('/gitlab/gitlabhq/-/tree/master/files.scss')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') + expect(get('/gitlab/gitlabhq/-/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/tree/files') + expect(get('/gitlab/gitlabhq/-/tree/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'tree/master/tree/files') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/tree/master/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/tree/master/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/tree', action: 'show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: "master/#{newline_file}" }) end - it 'to #show from scope routing' do - expect(get('/gitlab/gitlabhq/-/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + it 'to #show from unscoped routing' do + expect(get('/gitlab/gitlabhq/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') end end @@ -616,10 +621,10 @@ describe 'project routing' do # project_files GET /:namespace_id/:project_id/files/*id(.:format) projects/find_file#list {:id=>/(?:[^.]|\.(?!json$))+/, :namespace_id=>/[a-zA-Z.0-9_\-]+/, :project_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/, :format=>/json/} describe Projects::FindFileController, 'routing' do it 'to #show' do - expect(get('/gitlab/gitlabhq/find_file/master')).to route_to('projects/find_file#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master') + expect(get('/gitlab/gitlabhq/-/find_file/master')).to route_to('projects/find_file#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/find_file/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/find_file/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/find_file', action: 'show', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -627,10 +632,10 @@ describe 'project routing' do end it 'to #list' do - expect(get('/gitlab/gitlabhq/files/master.json')).to route_to('projects/find_file#list', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.json') + expect(get('/gitlab/gitlabhq/-/files/master.json')).to route_to('projects/find_file#list', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.json') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/files/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/files/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/find_file', action: 'list', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -640,13 +645,13 @@ describe 'project routing' do describe Projects::BlobController, 'routing' do it 'to #edit' do - expect(get('/gitlab/gitlabhq/edit/master/app/models/project.rb')).to( + expect(get('/gitlab/gitlabhq/-/edit/master/app/models/project.rb')).to( route_to('projects/blob#edit', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')) newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/edit/master/docs/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/edit/master/docs/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/blob', action: 'edit', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -654,13 +659,13 @@ describe 'project routing' do end it 'to #preview' do - expect(post('/gitlab/gitlabhq/preview/master/app/models/project.rb')).to( + expect(post('/gitlab/gitlabhq/-/preview/master/app/models/project.rb')).to( route_to('projects/blob#preview', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')) newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/edit/master/docs/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/edit/master/docs/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/blob', action: 'edit', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -673,12 +678,16 @@ describe 'project routing' do it 'to #show' do newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/raw/master/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/raw/master/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/raw', action: 'show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: "master/#{newline_file}" }) end + + it 'to #show from unscoped routing' do + expect(get('/gitlab/gitlabhq/raw/master/app/models/project.rb')).to route_to('projects/raw#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + end end # project_compare_index GET /:project_id/compare(.:format) compare#index {id: /[^\/]+/, project_id: /[^\/]+/} diff --git a/spec/serializers/blob_entity_spec.rb b/spec/serializers/blob_entity_spec.rb index 7e3a0a87bd5..3cd967ed44c 100644 --- a/spec/serializers/blob_entity_spec.rb +++ b/spec/serializers/blob_entity_spec.rb @@ -23,7 +23,7 @@ describe BlobEntity do mode: "100644", readable_text: true, icon: "file-text-o", - url: "/#{project.full_path}/blob/master/bar/branch-test.txt" + url: "/#{project.full_path}/-/blob/master/bar/branch-test.txt" }) end end diff --git a/spec/serializers/merge_request_poll_widget_entity_spec.rb b/spec/serializers/merge_request_poll_widget_entity_spec.rb index ea9052b4046..0593dd527cc 100644 --- a/spec/serializers/merge_request_poll_widget_entity_spec.rb +++ b/spec/serializers/merge_request_poll_widget_entity_spec.rb @@ -60,7 +60,7 @@ describe MergeRequestPollWidgetEntity do project.add_developer(user) expect(subject[:new_blob_path]) - .to eq("/#{resource.project.full_path}/new/#{resource.source_branch}") + .to eq("/#{resource.project.full_path}/-/new/#{resource.source_branch}") end end diff --git a/spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb b/spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb new file mode 100644 index 00000000000..db9b89f090f --- /dev/null +++ b/spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true +require 'spec_helper' + +describe Ci::CreatePipelineService do + context '.pre/.post stages' do + let_it_be(:user) { create(:admin) } + let_it_be(:project) { create(:project, :repository, creator: user) } + + let(:source) { :push } + let(:service) { described_class.new(project, user, { ref: ref }) } + let(:pipeline) { service.execute(source) } + + let(:config) do + <<~YAML + validate: + stage: .pre + script: echo Hello World + + build: + stage: build + rules: + - if: $CI_COMMIT_BRANCH == "master" + script: echo Hello World + + notify: + stage: .post + script: echo Hello World + YAML + end + + before do + stub_ci_pipeline_yaml_file(config) + end + + context 'when pipeline contains a build except .pre/.post' do + let(:ref) { 'refs/heads/master' } + + it 'creates a pipeline' do + expect(pipeline).to be_persisted + expect(pipeline.stages.map(&:name)).to contain_exactly( + *%w(.pre build .post)) + expect(pipeline.builds.map(&:name)).to contain_exactly( + *%w(validate build notify)) + end + end + + context 'when pipeline does not contain any other build except .pre/.post' do + let(:ref) { 'refs/heads/feature' } + + it 'does not create a pipeline' do + expect(pipeline).not_to be_persisted + + # we can validate a list of stages, as they are assigned + # but not persisted + expect(pipeline.stages.map(&:name)).to contain_exactly( + *%w(.pre .post)) + end + end + end +end diff --git a/spec/services/system_notes/merge_requests_service_spec.rb b/spec/services/system_notes/merge_requests_service_spec.rb index 2a04e888ae0..f5c071502f5 100644 --- a/spec/services/system_notes/merge_requests_service_spec.rb +++ b/spec/services/system_notes/merge_requests_service_spec.rb @@ -253,7 +253,7 @@ describe ::SystemNotes::MergeRequestsService do end it "posts the 'picked merge request' system note" do - expect(subject.note).to eq("picked this merge request into branch [`#{branch_name}`](/#{project.full_path}/tree/#{branch_name}) with commit #{commit_sha}") + expect(subject.note).to eq("picked this merge request into branch [`#{branch_name}`](/#{project.full_path}/-/tree/#{branch_name}) with commit #{commit_sha}") end it 'links the merge request and the cherry-pick commit' do diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb index 474a294ce0d..98040da9d2c 100644 --- a/spec/views/help/index.html.haml_spec.rb +++ b/spec/views/help/index.html.haml_spec.rb @@ -40,7 +40,7 @@ describe 'help/index' do render expect(rendered).to match '8.0.2' - expect(rendered).to have_link('abcdefg', href: %r{https://gitlab.com/gitlab-org/(gitlab|gitlab-foss)/commits/abcdefg}) + expect(rendered).to have_link('abcdefg', href: %r{https://gitlab.com/gitlab-org/(gitlab|gitlab-foss)/-/commits/abcdefg}) end end end |