diff options
Diffstat (limited to 'spec')
25 files changed, 252 insertions, 157 deletions
diff --git a/spec/controllers/projects/deploy_keys_controller_spec.rb b/spec/controllers/projects/deploy_keys_controller_spec.rb index 25e3e8e37a9..a97f9ebf36b 100644 --- a/spec/controllers/projects/deploy_keys_controller_spec.rb +++ b/spec/controllers/projects/deploy_keys_controller_spec.rb @@ -19,10 +19,10 @@ describe Projects::DeployKeysController do end context 'when html requested' do - it 'redirects to project settings with the correct anchor' do + it 'redirects to project ci / cd settings with the correct anchor' do get :index, params: params - expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-deploy-keys-settings')) + expect(response).to redirect_to(project_settings_ci_cd_path(project, anchor: 'js-deploy-keys-settings')) end end @@ -87,13 +87,13 @@ describe Projects::DeployKeysController do it 'creates a new deploy key for the project' do expect { post :create, params: create_params }.to change(project.deploy_keys, :count).by(1) - expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-deploy-keys-settings')) + expect(response).to redirect_to(project_settings_ci_cd_path(project, anchor: 'js-deploy-keys-settings')) end it 'redirects to project settings with the correct anchor' do post :create, params: create_params - expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-deploy-keys-settings')) + expect(response).to redirect_to(project_settings_ci_cd_path(project, anchor: 'js-deploy-keys-settings')) end context 'when the deploy key is invalid' do @@ -153,7 +153,7 @@ describe Projects::DeployKeysController do expect(DeployKeysProject.where(project_id: project.id, deploy_key_id: deploy_key.id).count).to eq(1) expect(response).to have_gitlab_http_status(:found) - expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) + expect(response).to redirect_to(namespace_project_settings_ci_cd_path(anchor: 'js-deploy-keys-settings')) end it 'returns 404' do @@ -175,7 +175,7 @@ describe Projects::DeployKeysController do expect(DeployKeysProject.where(project_id: project.id, deploy_key_id: deploy_key.id).count).to eq(1) expect(response).to have_gitlab_http_status(:found) - expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) + expect(response).to redirect_to(namespace_project_settings_ci_cd_path(anchor: 'js-deploy-keys-settings')) end end end @@ -216,7 +216,7 @@ describe Projects::DeployKeysController do put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } expect(response).to have_gitlab_http_status(:found) - expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) + expect(response).to redirect_to(namespace_project_settings_ci_cd_path(anchor: 'js-deploy-keys-settings')) expect { DeployKey.find(deploy_key.id) }.to raise_error(ActiveRecord::RecordNotFound) end @@ -239,7 +239,7 @@ describe Projects::DeployKeysController do end.to change { DeployKey.count }.by(-1) expect(response).to have_gitlab_http_status(:found) - expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) + expect(response).to redirect_to(namespace_project_settings_ci_cd_path(anchor: 'js-deploy-keys-settings')) expect { DeployKey.find(deploy_key.id) }.to raise_error(ActiveRecord::RecordNotFound) end diff --git a/spec/features/projects/deploy_keys_spec.rb b/spec/features/projects/deploy_keys_spec.rb index 0f3e7646673..03b7c54faf6 100644 --- a/spec/features/projects/deploy_keys_spec.rb +++ b/spec/features/projects/deploy_keys_spec.rb @@ -17,9 +17,9 @@ describe 'Project deploy keys', :js do end it 'removes association between project and deploy key' do - visit project_settings_repository_path(project) + visit project_settings_ci_cd_path(project) - page.within(find('.deploy-keys')) do + page.within(find('.qa-deploy-keys-settings')) do expect(page).to have_selector('.deploy-key', count: 1) accept_confirm { find('.ic-remove').click } diff --git a/spec/features/projects/settings/ci_cd_settings_spec.rb b/spec/features/projects/settings/ci_cd_settings_spec.rb index e69ee31e582..8b9b1ac00c3 100644 --- a/spec/features/projects/settings/ci_cd_settings_spec.rb +++ b/spec/features/projects/settings/ci_cd_settings_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' -describe 'Projects > Settings > CI/CD settings' do - let(:project) { create(:project_empty_repo) } - let(:user) { create(:user) } - let(:role) { :maintainer } +describe 'Projects > Settings > CI / CD settings' do + let_it_be(:project) { create(:project_empty_repo) } + let_it_be(:user) { create(:user) } + let_it_be(:role) { :maintainer } context 'Deploy tokens' do let!(:deploy_token) { create(:deploy_token, projects: [project]) } @@ -21,4 +21,92 @@ describe 'Projects > Settings > CI/CD settings' do let(:entity_type) { 'project' } end end + + context 'Deploy Keys', :js do + let_it_be(:private_deploy_key) { create(:deploy_key, title: 'private_deploy_key', public: false) } + let_it_be(:public_deploy_key) { create(:another_deploy_key, title: 'public_deploy_key', public: true) } + let(:new_ssh_key) { attributes_for(:key)[:key] } + + before do + project.add_role(user, role) + sign_in(user) + end + + it 'get list of keys' do + project.deploy_keys << private_deploy_key + project.deploy_keys << public_deploy_key + + visit project_settings_ci_cd_path(project) + + expect(page).to have_content('private_deploy_key') + expect(page).to have_content('public_deploy_key') + end + + it 'add a new deploy key' do + visit project_settings_ci_cd_path(project) + + fill_in 'deploy_key_title', with: 'new_deploy_key' + fill_in 'deploy_key_key', with: new_ssh_key + check 'deploy_key_deploy_keys_projects_attributes_0_can_push' + click_button 'Add key' + + expect(page).to have_content('new_deploy_key') + expect(page).to have_content('Write access allowed') + end + + it 'edit an existing deploy key' do + project.deploy_keys << private_deploy_key + visit project_settings_ci_cd_path(project) + + find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click + + fill_in 'deploy_key_title', with: 'updated_deploy_key' + check 'deploy_key_deploy_keys_projects_attributes_0_can_push' + click_button 'Save changes' + + expect(page).to have_content('updated_deploy_key') + expect(page).to have_content('Write access allowed') + end + + it 'edit an existing public deploy key to be writable' do + project.deploy_keys << public_deploy_key + visit project_settings_ci_cd_path(project) + + find('.deploy-key', text: public_deploy_key.title).find('.ic-pencil').click + + check 'deploy_key_deploy_keys_projects_attributes_0_can_push' + click_button 'Save changes' + + expect(page).to have_content('public_deploy_key') + expect(page).to have_content('Write access allowed') + end + + it 'edit a deploy key from projects user has access to' do + project2 = create(:project_empty_repo) + project2.add_role(user, role) + project2.deploy_keys << private_deploy_key + + visit project_settings_ci_cd_path(project) + + find('.js-deployKeys-tab-available_project_keys').click + + find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click + + fill_in 'deploy_key_title', with: 'updated_deploy_key' + click_button 'Save changes' + + find('.js-deployKeys-tab-available_project_keys').click + + expect(page).to have_content('updated_deploy_key') + end + + it 'remove an existing deploy key' do + project.deploy_keys << private_deploy_key + visit project_settings_ci_cd_path(project) + + accept_confirm { find('.deploy-key', text: private_deploy_key.title).find('.ic-remove').click } + + expect(page).not_to have_content(private_deploy_key.title) + end + end end diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index d750234d9ad..9030cd6a648 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -25,89 +25,6 @@ describe 'Projects > Settings > Repository settings' do context 'for maintainer' do let(:role) { :maintainer } - context 'Deploy Keys', :js do - let(:private_deploy_key) { create(:deploy_key, title: 'private_deploy_key', public: false) } - let(:public_deploy_key) { create(:another_deploy_key, title: 'public_deploy_key', public: true) } - let(:new_ssh_key) { attributes_for(:key)[:key] } - - it 'get list of keys' do - project.deploy_keys << private_deploy_key - project.deploy_keys << public_deploy_key - - visit project_settings_repository_path(project) - - expect(page).to have_content('private_deploy_key') - expect(page).to have_content('public_deploy_key') - end - - it 'add a new deploy key' do - visit project_settings_repository_path(project) - - fill_in 'deploy_key_title', with: 'new_deploy_key' - fill_in 'deploy_key_key', with: new_ssh_key - check 'deploy_key_deploy_keys_projects_attributes_0_can_push' - click_button 'Add key' - - expect(page).to have_content('new_deploy_key') - expect(page).to have_content('Write access allowed') - end - - it 'edit an existing deploy key' do - project.deploy_keys << private_deploy_key - visit project_settings_repository_path(project) - - find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click - - fill_in 'deploy_key_title', with: 'updated_deploy_key' - check 'deploy_key_deploy_keys_projects_attributes_0_can_push' - click_button 'Save changes' - - expect(page).to have_content('updated_deploy_key') - expect(page).to have_content('Write access allowed') - end - - it 'edit an existing public deploy key to be writable' do - project.deploy_keys << public_deploy_key - visit project_settings_repository_path(project) - - find('.deploy-key', text: public_deploy_key.title).find('.ic-pencil').click - - check 'deploy_key_deploy_keys_projects_attributes_0_can_push' - click_button 'Save changes' - - expect(page).to have_content('public_deploy_key') - expect(page).to have_content('Write access allowed') - end - - it 'edit a deploy key from projects user has access to' do - project2 = create(:project_empty_repo) - project2.add_role(user, role) - project2.deploy_keys << private_deploy_key - - visit project_settings_repository_path(project) - - find('.js-deployKeys-tab-available_project_keys').click - - find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click - - fill_in 'deploy_key_title', with: 'updated_deploy_key' - click_button 'Save changes' - - find('.js-deployKeys-tab-available_project_keys').click - - expect(page).to have_content('updated_deploy_key') - end - - it 'remove an existing deploy key' do - project.deploy_keys << private_deploy_key - visit project_settings_repository_path(project) - - accept_confirm { find('.deploy-key', text: private_deploy_key.title).find('.ic-remove').click } - - expect(page).not_to have_content(private_deploy_key.title) - end - end - context 'remote mirror settings' do let(:user2) { create(:user) } diff --git a/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb b/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb index cd9299150b2..ac7788ba1fa 100644 --- a/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb +++ b/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb @@ -20,7 +20,7 @@ describe "User interacts with deploy keys", :js do click_button("Enable") expect(page).not_to have_selector(".fa-spinner") - expect(current_path).to eq(project_settings_repository_path(project)) + expect(current_path).to eq(project_settings_ci_cd_path(project)) find(".js-deployKeys-tab-enabled_keys").click @@ -96,7 +96,7 @@ describe "User interacts with deploy keys", :js do click_button("Add key") - expect(current_path).to eq(project_settings_repository_path(project)) + expect(current_path).to eq(project_settings_ci_cd_path(project)) page.within(".deploy-keys") do expect(page).to have_content(DEPLOY_KEY_TITLE) diff --git a/spec/helpers/award_emoji_helper_spec.rb b/spec/helpers/award_emoji_helper_spec.rb index 975f32edd42..3dee466a80c 100644 --- a/spec/helpers/award_emoji_helper_spec.rb +++ b/spec/helpers/award_emoji_helper_spec.rb @@ -64,7 +64,7 @@ describe AwardEmojiHelper do it 'returns correct url' do @project = issue.project - expected_url = "/#{@project.namespace.path}/#{@project.path}/issues/#{issue.iid}/toggle_award_emoji" + expected_url = "/#{@project.namespace.path}/#{@project.path}/-/issues/#{issue.iid}/toggle_award_emoji" expect(subject).to eq(expected_url) end diff --git a/spec/helpers/boards_helper_spec.rb b/spec/helpers/boards_helper_spec.rb index e731b95586f..f5e5285554c 100644 --- a/spec/helpers/boards_helper_spec.rb +++ b/spec/helpers/boards_helper_spec.rb @@ -11,7 +11,7 @@ describe BoardsHelper do @project = project @board = create(:board, project: @project) - expect(build_issue_link_base).to eq("/#{@project.namespace.path}/#{@project.path}/issues") + expect(build_issue_link_base).to eq("/#{@project.namespace.path}/#{@project.path}/-/issues") end end diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index 062fa8f106e..61229127770 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -110,7 +110,7 @@ describe EventsHelper do it 'returns a project issue url' do event.target = create(:note_on_issue, note: 'nice work') - expect(subject).to eq("#{project_base_url}/issues/#{event.note_target.iid}#note_#{event.target.id}") + expect(subject).to eq("#{project_base_url}/-/issues/#{event.note_target.iid}#note_#{event.target.id}") end it 'returns a merge request url' do diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb index a39110d0aa7..7971eb8849d 100644 --- a/spec/helpers/issuables_helper_spec.rb +++ b/spec/helpers/issuables_helper_spec.rb @@ -183,8 +183,8 @@ describe IssuablesHelper do @project = issue.project expected_data = { - endpoint: "/#{@project.full_path}/issues/#{issue.iid}", - updateEndpoint: "/#{@project.full_path}/issues/#{issue.iid}.json", + endpoint: "/#{@project.full_path}/-/issues/#{issue.iid}", + updateEndpoint: "/#{@project.full_path}/-/issues/#{issue.iid}.json", canUpdate: true, canDestroy: true, issuableRef: "##{issue.iid}", diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index a394812f8f0..dad740d3b80 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -200,7 +200,7 @@ describe IssuesHelper do shared_examples 'successfully displays link to issue and with css class' do |action| it 'returns link' do - link = "<a class=\"#{css_class}\" href=\"/#{new_issue.project.full_path}/issues/#{new_issue.iid}\">(#{action})</a>" + link = "<a class=\"#{css_class}\" href=\"/#{new_issue.project.full_path}/-/issues/#{new_issue.iid}\">(#{action})</a>" expect(helper.issue_closed_link(issue, user, css_class: css_class)).to match(link) end diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb index 322390c3840..ec70041d51f 100644 --- a/spec/helpers/labels_helper_spec.rb +++ b/spec/helpers/labels_helper_spec.rb @@ -56,7 +56,7 @@ describe LabelsHelper do context 'without subject' do it "uses the label's project" do - expect(link_to_label(label_presenter)).to match %r{<a.*href="/#{label.project.full_path}/issues\?label_name%5B%5D=#{label.name}".*>.*</a>}m + expect(link_to_label(label_presenter)).to match %r{<a.*href="/#{label.project.full_path}/-/issues\?label_name%5B%5D=#{label.name}".*>.*</a>}m end end @@ -65,7 +65,7 @@ describe LabelsHelper do let(:subject) { build(:project, namespace: namespace, name: 'bar3') } it 'links to project issues page' do - expect(link_to_label(label_presenter)).to match %r{<a.*href="/foo3/bar3/issues\?label_name%5B%5D=#{label.name}".*>.*</a>}m + expect(link_to_label(label_presenter)).to match %r{<a.*href="/foo3/bar3/-/issues\?label_name%5B%5D=#{label.name}".*>.*</a>}m end end @@ -78,15 +78,7 @@ describe LabelsHelper do end context 'with a type argument' do - ['issue', :issue].each do |type| - context "set to #{type}" do - it 'links to correct page' do - expect(link_to_label(label_presenter, type: type)).to match %r{<a.*href="/#{label.project.full_path}/#{type.to_s.pluralize}\?label_name%5B%5D=#{label.name}".*>.*</a>}m - end - end - end - - ['merge_request', :merge_request].each do |type| + ['issue', :issue, 'merge_request', :merge_request].each do |type| context "set to #{type}" do it 'links to correct page' do expect(link_to_label(label_presenter, type: type)).to match %r{<a.*href="/#{label.project.full_path}/-/#{type.to_s.pluralize}\?label_name%5B%5D=#{label.name}".*>.*</a>}m diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb index 1dc7f4e98ab..f074a918e7f 100644 --- a/spec/helpers/notes_helper_spec.rb +++ b/spec/helpers/notes_helper_spec.rb @@ -272,7 +272,7 @@ describe NotesHelper do let(:note) { create(:note_on_issue, noteable: issue, project: project) } it 'returns the noteable url with an anchor to the note' do - expect(noteable_note_url(note)).to match("/#{project.namespace.path}/#{project.path}/issues/#{issue.iid}##{dom_id(note)}") + expect(noteable_note_url(note)).to match("/#{project.namespace.path}/#{project.path}/-/issues/#{issue.iid}##{dom_id(note)}") end end diff --git a/spec/javascripts/diffs/mock_data/diff_discussions.js b/spec/javascripts/diffs/mock_data/diff_discussions.js index a9b00634104..dc25dd1647a 100644 --- a/spec/javascripts/diffs/mock_data/diff_discussions.js +++ b/spec/javascripts/diffs/mock_data/diff_discussions.js @@ -64,7 +64,7 @@ export default { resolve_path: '/gitlab-org/gitlab-test/-/merge_requests/20/discussions/6b232e05bea388c6b043ccc243ba505faac04ea8/resolve', resolve_with_issue_path: - '/gitlab-org/gitlab-test/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', + '/gitlab-org/gitlab-test/-/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', }, { id: '1753', @@ -117,7 +117,7 @@ export default { resolve_path: '/gitlab-org/gitlab-test/-/merge_requests/20/discussions/6b232e05bea388c6b043ccc243ba505faac04ea8/resolve', resolve_with_issue_path: - '/gitlab-org/gitlab-test/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', + '/gitlab-org/gitlab-test/-/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', }, { id: '1754', @@ -160,7 +160,7 @@ export default { resolve_path: '/gitlab-org/gitlab-test/-/merge_requests/20/discussions/6b232e05bea388c6b043ccc243ba505faac04ea8/resolve', resolve_with_issue_path: - '/gitlab-org/gitlab-test/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', + '/gitlab-org/gitlab-test/-/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', }, { id: '1755', @@ -203,7 +203,7 @@ export default { resolve_path: '/gitlab-org/gitlab-test/-/merge_requests/20/discussions/6b232e05bea388c6b043ccc243ba505faac04ea8/resolve', resolve_with_issue_path: - '/gitlab-org/gitlab-test/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', + '/gitlab-org/gitlab-test/-/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', }, { id: '1756', @@ -246,7 +246,7 @@ export default { resolve_path: '/gitlab-org/gitlab-test/-/merge_requests/20/discussions/6b232e05bea388c6b043ccc243ba505faac04ea8/resolve', resolve_with_issue_path: - '/gitlab-org/gitlab-test/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', + '/gitlab-org/gitlab-test/-/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', }, ], individual_note: false, @@ -255,7 +255,7 @@ export default { resolve_path: '/gitlab-org/gitlab-test/-/merge_requests/20/discussions/6b232e05bea388c6b043ccc243ba505faac04ea8/resolve', resolve_with_issue_path: - '/gitlab-org/gitlab-test/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', + '/gitlab-org/gitlab-test/-/issues/new?discussion_to_resolve=6b232e05bea388c6b043ccc243ba505faac04ea8&merge_request_to_resolve_discussions_of=20', diff_file: { submodule: false, submodule_link: null, diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js index fdd6f4e6470..f11d4f5ac33 100644 --- a/spec/javascripts/issue_show/components/app_spec.js +++ b/spec/javascripts/issue_show/components/app_spec.js @@ -40,17 +40,19 @@ describe('Issuable output', () => { const IssuableDescriptionComponent = Vue.extend(issuableApp); mock = new MockAdapter(axios); - mock.onGet('/gitlab-org/gitlab-shell/issues/9/realtime_changes/realtime_changes').reply(() => { - const res = Promise.resolve([200, REALTIME_REQUEST_STACK[realtimeRequestCount]]); - realtimeRequestCount += 1; - return res; - }); + mock + .onGet('/gitlab-org/gitlab-shell/-/issues/9/realtime_changes/realtime_changes') + .reply(() => { + const res = Promise.resolve([200, REALTIME_REQUEST_STACK[realtimeRequestCount]]); + realtimeRequestCount += 1; + return res; + }); vm = new IssuableDescriptionComponent({ propsData: { canUpdate: true, canDestroy: true, - endpoint: '/gitlab-org/gitlab-shell/issues/9/realtime_changes', + endpoint: '/gitlab-org/gitlab-shell/-/issues/9/realtime_changes', updateEndpoint: gl.TEST_HOST, issuableRef: '#1', initialTitleHtml: '', diff --git a/spec/javascripts/vue_mr_widget/mock_data.js b/spec/javascripts/vue_mr_widget/mock_data.js index 048a5f88c99..d11756d712a 100644 --- a/spec/javascripts/vue_mr_widget/mock_data.js +++ b/spec/javascripts/vue_mr_widget/mock_data.js @@ -216,7 +216,7 @@ export default { remove_wip_path: '/root/acets-app/-/merge_requests/22/remove_wip', cancel_auto_merge_path: '/root/acets-app/-/merge_requests/22/cancel_auto_merge', create_issue_to_resolve_discussions_path: - '/root/acets-app/issues/new?merge_request_to_resolve_discussions_of=22', + '/root/acets-app/-/issues/new?merge_request_to_resolve_discussions_of=22', merge_path: '/root/acets-app/-/merge_requests/22/merge', cherry_pick_in_fork_path: '/root/acets-app/forks?continue%5Bnotice%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+has+been+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.+Try+to+revert+this+commit+again.&continue%5Bnotice_now%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+is+being+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.&continue%5Bto%5D=%2Froot%2Facets-app%2Fmerge_requests%2F22&namespace_key=1', diff --git a/spec/lib/gitlab/ci/pipeline/chain/build/associations_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/build/associations_spec.rb new file mode 100644 index 00000000000..542a2462b59 --- /dev/null +++ b/spec/lib/gitlab/ci/pipeline/chain/build/associations_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Ci::Pipeline::Chain::Build::Associations do + let(:project) { create(:project, :repository) } + let(:user) { create(:user, developer_projects: [project]) } + let(:pipeline) { Ci::Pipeline.new } + let(:step) { described_class.new(pipeline, command) } + + let(:command) do + Gitlab::Ci::Pipeline::Chain::Command.new( + source: :push, + origin_ref: 'master', + checkout_sha: project.commit.id, + after_sha: nil, + before_sha: nil, + trigger_request: nil, + schedule: nil, + merge_request: nil, + project: project, + current_user: user, + bridge: bridge) + end + + context 'when a bridge is passed in to the pipeline creation' do + let(:bridge) { create(:ci_bridge) } + + it 'links the pipeline to the upstream bridge job' do + step.perform! + + expect(pipeline.source_pipeline).to be_present + expect(pipeline.source_pipeline).to be_valid + expect(pipeline.source_pipeline).to have_attributes( + source_pipeline: bridge.pipeline, source_project: bridge.project, + source_bridge: bridge, project: project + ) + end + + it 'never breaks the chain' do + step.perform! + + expect(step.break?).to eq(false) + end + end + + context 'when a bridge is not passed in to the pipeline creation' do + let(:bridge) { nil } + + it 'leaves the source pipeline empty' do + step.perform! + + expect(pipeline.source_pipeline).to be_nil + end + + it 'never breaks the chain' do + step.perform! + + expect(step.break?).to eq(false) + end + end +end diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index 49011b100ab..11bbf444b1d 100644 --- a/spec/lib/gitlab/url_builder_spec.rb +++ b/spec/lib/gitlab/url_builder_spec.rb @@ -20,7 +20,7 @@ describe Gitlab::UrlBuilder do url = described_class.build(issue) - expect(url).to eq "#{Settings.gitlab['url']}/#{issue.project.full_path}/issues/#{issue.iid}" + expect(url).to eq "#{Settings.gitlab['url']}/#{issue.project.full_path}/-/issues/#{issue.iid}" end end @@ -107,7 +107,7 @@ describe Gitlab::UrlBuilder do url = described_class.build(note) - expect(url).to eq "#{Settings.gitlab['url']}/#{issue.project.full_path}/issues/#{issue.iid}#note_#{note.id}" + expect(url).to eq "#{Settings.gitlab['url']}/#{issue.project.full_path}/-/issues/#{issue.iid}#note_#{note.id}" end end diff --git a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb index defebcee9c6..7f1c6224b7d 100644 --- a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb +++ b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb @@ -33,9 +33,9 @@ describe GitlabIssueTrackerService do end it 'gives the correct path' do - expect(service.project_url).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/issues") - expect(service.new_issue_url).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/issues/new") - expect(service.issue_url(432)).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/issues/432") + expect(service.project_url).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/-/issues") + expect(service.new_issue_url).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/-/issues/new") + expect(service.issue_url(432)).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/-/issues/432") end end @@ -45,9 +45,9 @@ describe GitlabIssueTrackerService do end it 'gives the correct path' do - expect(service.issue_tracker_path).to eq("/gitlab/root/#{project.full_path}/issues") - expect(service.new_issue_path).to eq("/gitlab/root/#{project.full_path}/issues/new") - expect(service.issue_path(432)).to eq("/gitlab/root/#{project.full_path}/issues/432") + expect(service.issue_tracker_path).to eq("/gitlab/root/#{project.full_path}/-/issues") + expect(service.new_issue_path).to eq("/gitlab/root/#{project.full_path}/-/issues/new") + expect(service.issue_path(432)).to eq("/gitlab/root/#{project.full_path}/-/issues/432") end end end diff --git a/spec/presenters/issue_presenter_spec.rb b/spec/presenters/issue_presenter_spec.rb index 1eb674d1f8f..4a4caef9d28 100644 --- a/spec/presenters/issue_presenter_spec.rb +++ b/spec/presenters/issue_presenter_spec.rb @@ -17,7 +17,7 @@ describe IssuePresenter do describe '#web_url' do it 'returns correct path' do - expect(presenter.web_url).to eq("http://localhost/#{group.name}/#{project.name}/issues/#{issue.iid}") + expect(presenter.web_url).to eq("http://localhost/#{group.name}/#{project.name}/-/issues/#{issue.iid}") end end @@ -37,7 +37,7 @@ describe IssuePresenter do describe '#issue_path' do it 'returns correct path' do - expect(presenter.issue_path).to eq("/#{group.name}/#{project.name}/issues/#{issue.iid}") + expect(presenter.issue_path).to eq("/#{group.name}/#{project.name}/-/issues/#{issue.iid}") end end end diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb index 025f083ab27..f184e767f8c 100644 --- a/spec/presenters/merge_request_presenter_spec.rb +++ b/spec/presenters/merge_request_presenter_spec.rb @@ -128,11 +128,11 @@ describe MergeRequestPresenter do subject { described_class.new(resource, current_user: user).closing_issues_links } it 'presents closing issues links' do - is_expected.to match("#{project.full_path}/issues/#{issue_a.iid}") + is_expected.to match("#{project.full_path}/-/issues/#{issue_a.iid}") end it 'does not present related issues links' do - is_expected.not_to match("#{project.full_path}/issues/#{issue_b.iid}") + is_expected.not_to match("#{project.full_path}/-/issues/#{issue_b.iid}") end it 'appends status when closing issue is already closed' do @@ -148,11 +148,11 @@ describe MergeRequestPresenter do end it 'presents related issues links' do - is_expected.to match("#{project.full_path}/issues/#{issue_b.iid}") + is_expected.to match("#{project.full_path}/-/issues/#{issue_b.iid}") end it 'does not present closing issues links' do - is_expected.not_to match("#{project.full_path}/issues/#{issue_a.iid}") + is_expected.not_to match("#{project.full_path}/-/issues/#{issue_a.iid}") end it 'appends status when mentioned issue is already closed' do @@ -275,7 +275,7 @@ describe MergeRequestPresenter do project.add_maintainer(user) is_expected - .to eq("/#{resource.project.full_path}/issues/new?merge_request_to_resolve_discussions_of=#{resource.iid}") + .to eq("/#{resource.project.full_path}/-/issues/new?merge_request_to_resolve_discussions_of=#{resource.iid}") end end diff --git a/spec/requests/api/releases_spec.rb b/spec/requests/api/releases_spec.rb index 12fd9f431e5..f9e7253a88b 100644 --- a/spec/requests/api/releases_spec.rb +++ b/spec/requests/api/releases_spec.rb @@ -78,7 +78,7 @@ describe API::Releases do issue_uri = URI.parse(links['issues_url']) expect(mr_uri.path).to eq("#{path_base}/-/merge_requests") - expect(issue_uri.path).to eq("#{path_base}/issues") + expect(issue_uri.path).to eq("#{path_base}/-/issues") expect(mr_uri.query).to eq(expected_query) expect(issue_uri.query).to eq(expected_query) end diff --git a/spec/services/ci/create_cross_project_pipeline_service_spec.rb b/spec/services/ci/create_cross_project_pipeline_service_spec.rb index 51cf18f8d87..09d44bcea0a 100644 --- a/spec/services/ci/create_cross_project_pipeline_service_spec.rb +++ b/spec/services/ci/create_cross_project_pipeline_service_spec.rb @@ -109,7 +109,7 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do expect(pipeline.source_bridge).to be_a ::Ci::Bridge end - it 'updates bridge status when downstream pipeline gets proceesed' do + it 'updates bridge status when downstream pipeline gets processed' do pipeline = service.execute(bridge) expect(pipeline.reload).to be_pending @@ -128,6 +128,37 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do end end + context 'when downstream pipeline has yaml configuration error' do + before do + stub_ci_pipeline_yaml_file(YAML.dump(job: { invalid: 'yaml' })) + end + + it 'creates only one new pipeline' do + expect { service.execute(bridge) } + .to change { Ci::Pipeline.count }.by(1) + end + + it 'creates a new pipeline in a downstream project' do + pipeline = service.execute(bridge) + + expect(pipeline.user).to eq bridge.user + expect(pipeline.project).to eq downstream_project + expect(bridge.sourced_pipelines.first.pipeline).to eq pipeline + expect(pipeline.triggered_by_pipeline).to eq upstream_pipeline + expect(pipeline.source_bridge).to eq bridge + expect(pipeline.source_bridge).to be_a ::Ci::Bridge + end + + it 'does not update bridge status when downstream pipeline gets processed' do + pipeline = service.execute(bridge) + + expect(pipeline.reload).to be_failed + # TODO: This should change to failed once #198354 gets fixed. + # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25706 + expect(bridge.reload).to be_pending + end + end + context 'when downstream project is the same as the job project' do let(:trigger) do { trigger: { project: upstream_project.full_path } } @@ -173,7 +204,7 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do expect(pipeline.source_bridge).to be_a ::Ci::Bridge end - it 'updates bridge status when downstream pipeline gets proceesed' do + it 'updates bridge status when downstream pipeline gets processed' do pipeline = service.execute(bridge) expect(pipeline.reload).to be_pending diff --git a/spec/services/ci/create_pipeline_service/custom_config_content_spec.rb b/spec/services/ci/create_pipeline_service/custom_config_content_spec.rb index 33cd6e164b0..2657f1d300a 100644 --- a/spec/services/ci/create_pipeline_service/custom_config_content_spec.rb +++ b/spec/services/ci/create_pipeline_service/custom_config_content_spec.rb @@ -4,18 +4,22 @@ require 'spec_helper' describe Ci::CreatePipelineService do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:admin) } + let(:upstream_pipeline) { create(:ci_pipeline) } let(:ref) { 'refs/heads/master' } let(:service) { described_class.new(project, user, { ref: ref }) } context 'custom config content' do let(:bridge) do - double(:bridge, yaml_for_downstream: <<~YML - rspec: - script: rspec - custom: - script: custom - YML - ) + create(:ci_bridge, status: 'running', pipeline: upstream_pipeline, project: upstream_pipeline.project).tap do |bridge| + allow(bridge).to receive(:yaml_for_downstream).and_return( + <<~YML + rspec: + script: rspec + custom: + script: custom + YML + ) + end end subject { service.execute(:push, bridge: bridge) } diff --git a/spec/services/error_tracking/issue_details_service_spec.rb b/spec/services/error_tracking/issue_details_service_spec.rb index 9f217deda21..66b8988f8e3 100644 --- a/spec/services/error_tracking/issue_details_service_spec.rb +++ b/spec/services/error_tracking/issue_details_service_spec.rb @@ -27,7 +27,7 @@ describe ErrorTracking::IssueDetailsService do create(:sentry_issue, issue: gitlab_issue, sentry_issue_identifier: detailed_error.id) expect(result[:issue].gitlab_issue).to include( - "http", "/#{project.full_path}/issues/#{gitlab_issue.iid}" + "http", "/#{project.full_path}/-/issues/#{gitlab_issue.iid}" ) end diff --git a/spec/views/admin/application_settings/integrations.html.haml_spec.rb b/spec/views/admin/application_settings/integrations.html.haml_spec.rb index e51cbb9fbfe..392d43ef2d4 100644 --- a/spec/views/admin/application_settings/integrations.html.haml_spec.rb +++ b/spec/views/admin/application_settings/integrations.html.haml_spec.rb @@ -11,7 +11,6 @@ describe 'admin/application_settings/integrations.html.haml' do before do assign(:application_setting, app_settings) allow(Gitlab::Sourcegraph).to receive(:feature_available?).and_return(sourcegraph_flag) - allow(License).to receive(:feature_available?).with(:elastic_search).and_return(false) if defined?(License) end context 'when sourcegraph feature is enabled' do |