diff --git a/app/assets/javascripts/snippets/components/edit.vue b/app/assets/javascripts/snippets/components/edit.vue index 71ba4e0c183b0ad65b08886282f284a8a8ed1d17..95d2bb0698b782e582385ad737c5c22ffc4d5baa 100644 --- a/app/assets/javascripts/snippets/components/edit.vue +++ b/app/assets/javascripts/snippets/components/edit.vue @@ -95,7 +95,7 @@ export default { }, cancelButtonHref() { if (this.newSnippet) { - return this.projectPath ? `/${this.projectPath}/snippets` : `/snippets`; + return this.projectPath ? `/${this.projectPath}/-/snippets` : `/-/snippets`; } return this.snippet.webUrl; }, diff --git a/app/assets/javascripts/snippets/components/snippet_header.vue b/app/assets/javascripts/snippets/components/snippet_header.vue index 707e2b0ea30b0cebe545fa0428bb915a3d70fe76..bd06ef2cfc9cac8b549cd5b1cb6bc2ceb9de3fd0 100644 --- a/app/assets/javascripts/snippets/components/snippet_header.vue +++ b/app/assets/javascripts/snippets/components/snippet_header.vue @@ -91,8 +91,8 @@ export default { condition: this.canCreateSnippet, text: __('New snippet'), href: this.snippet.project - ? `${this.snippet.project.webUrl}/snippets/new` - : '/snippets/new', + ? `${this.snippet.project.webUrl}/-/snippets/new` + : '/-/snippets/new', variant: 'success', category: 'secondary', cssClass: 'ml-2', @@ -130,7 +130,9 @@ export default { }, methods: { redirectToSnippets() { - window.location.pathname = `${this.snippet.project?.fullPath || 'dashboard'}/snippets`; + window.location.pathname = this.snippet.project + ? `${this.snippet.project.fullPath}/-/snippets` + : 'dashboard/snippets'; }, closeDeleteModal() { this.$refs.deleteModal.hide(); diff --git a/changelogs/unreleased/dz-scoped-snippets-routing.yml b/changelogs/unreleased/dz-scoped-snippets-routing.yml new file mode 100644 index 0000000000000000000000000000000000000000..4d0ef4214ba200a2f8b2d2766588f4c62d42c7d2 --- /dev/null +++ b/changelogs/unreleased/dz-scoped-snippets-routing.yml @@ -0,0 +1,5 @@ +--- +title: Make scoped snippet routing a default one +merge_request: 36091 +author: +type: changed diff --git a/config/routes.rb b/config/routes.rb index dd84bc859bb0401fff08f72076aa886987744a81..fa84b5e50c74576f6569d19ede5ae9779cadec02 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -178,6 +178,8 @@ # in case we decide to move away from doorkeeper-openid_connect get 'jwks' => 'doorkeeper/openid_connect/discovery#keys' + draw :snippets + # Product analytics collector match '/collector/i', to: ProductAnalytics::CollectorApp.new, via: :all end @@ -258,7 +260,6 @@ draw :api draw :sidekiq draw :help - draw :snippets draw :google_api draw :import draw :uploads @@ -269,11 +270,8 @@ draw :user draw :project - # Serve snippet routes under /-/snippets. - # To ensure an old unscoped routing is used for the UI we need to - # add prefix 'as' to the scope routing and place it below original routing. # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/210024 - scope '-', as: :scoped do + scope as: 'deprecated' do draw :snippets end diff --git a/config/routes/project.rb b/config/routes/project.rb index 7605d63fdbdfcba1616fc2e16c7e4636bf476d10..8aa0fd041109b3a44604d1c41bbc041479574225 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -344,6 +344,13 @@ namespace :import do resource :jira, only: [:show], controller: :jira end + + resources :snippets, concerns: :awardable, constraints: { id: /\d+/ } do + member do + get :raw + post :mark_as_spam + end + end end # End of the /-/ scope. @@ -380,26 +387,6 @@ end end - resources :snippets, concerns: :awardable, constraints: { id: /\d+/ } do # rubocop: disable Cop/PutProjectRoutesUnderScope - member do - get :raw - post :mark_as_spam - end - end - - # Serve snippet routes under /-/snippets. - # To ensure an old unscoped routing is used for the UI we need to - # add prefix 'as' to the scope routing and place it below original routing. - # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/29572 - scope '-', as: :scoped do - resources :snippets, concerns: :awardable, constraints: { id: /\d+/ } do # rubocop: disable Cop/PutProjectRoutesUnderScope - member do - get :raw - post :mark_as_spam - end - end - end - namespace :prometheus do resources :alerts, constraints: { id: /\d+/ }, only: [:index, :create, :show, :update, :destroy] do # rubocop: disable Cop/PutProjectRoutesUnderScope post :notify, on: :collection @@ -509,10 +496,18 @@ end # Deprecated unscoped routing. - # Issue https://gitlab.com/gitlab-org/gitlab/issues/118849 scope as: 'deprecated' do + # Issue https://gitlab.com/gitlab-org/gitlab/issues/118849 draw :pipelines draw :repository + + # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/29572 + resources :snippets, concerns: :awardable, constraints: { id: /\d+/ } do # rubocop: disable Cop/PutProjectRoutesUnderScope + member do + get :raw + post :mark_as_spam + end + end end # All new routes should go under /-/ scope. diff --git a/config/routes/snippets.rb b/config/routes/snippets.rb index 1ea9a6431d819c92a887b53b5feaeff8495c65f5..7bb82da49105e530c7fb065e535c4dbcadf2bf15 100644 --- a/config/routes/snippets.rb +++ b/config/routes/snippets.rb @@ -17,14 +17,11 @@ end end -# Use this /-/ scope for all new snippet routes. -scope path: '-' do - get '/snippets/:snippet_id/raw/:ref/*path', - to: 'snippets/blobs#raw', - as: :snippet_blob_raw, - format: false, - constraints: { snippet_id: /\d+/ } -end +get '/snippets/:snippet_id/raw/:ref/*path', + to: 'snippets/blobs#raw', + as: :snippet_blob_raw, + format: false, + constraints: { snippet_id: /\d+/ } get '/s/:username', to: redirect('users/%{username}/snippets'), constraints: { username: /[a-zA-Z.0-9_\-]+(? { describe('::getAwardUrl', () => { it('returns the url for request', () => { - expect(awardsHandler.getAwardUrl()).toBe('http://test.host/snippets/1/toggle_award_emoji'); + expect(awardsHandler.getAwardUrl()).toBe('http://test.host/-/snippets/1/toggle_award_emoji'); }); }); diff --git a/spec/frontend/blob/viewer/index_spec.js b/spec/frontend/blob/viewer/index_spec.js index 7239f59c6fae035a6fc748c62f2624c39569fe49..97ac42a10bfba1d8dbab2574103f9f3fa3cbdeb1 100644 --- a/spec/frontend/blob/viewer/index_spec.js +++ b/spec/frontend/blob/viewer/index_spec.js @@ -24,11 +24,11 @@ describe('Blob viewer', () => { blob = new BlobViewer(); - mock.onGet('http://test.host/snippets/1.json?viewer=rich').reply(200, { + mock.onGet('http://test.host/-/snippets/1.json?viewer=rich').reply(200, { html: '
testing
', }); - mock.onGet('http://test.host/snippets/1.json?viewer=simple').reply(200, { + mock.onGet('http://test.host/-/snippets/1.json?viewer=simple').reply(200, { html: '
testing
', }); diff --git a/spec/frontend/snippets/components/edit_spec.js b/spec/frontend/snippets/components/edit_spec.js index 0148439d74c993e4041a5de427e7fd42867a3a82..4eb624ebf3420d3a7913c4a9e86764aab8cc3511 100644 --- a/spec/frontend/snippets/components/edit_spec.js +++ b/spec/frontend/snippets/components/edit_spec.js @@ -183,7 +183,7 @@ describe('Snippet Edit app', () => { it.each` isNew | status | expectation - ${true} | ${`new`} | ${`/snippets`} + ${true} | ${`new`} | ${`/-/snippets`} ${false} | ${`existing`} | ${newlyEditedSnippetUrl} `('sets correct href for the cancel button on a $status snippet', ({ isNew, expectation }) => { createComponent({ diff --git a/spec/frontend/snippets/components/snippet_header_spec.js b/spec/frontend/snippets/components/snippet_header_spec.js index 0825da92118be6822b4b63c3ba3b943ce48df9bd..0b991e7a5d4955f6b098117cf766c98f00eef85e 100644 --- a/spec/frontend/snippets/components/snippet_header_spec.js +++ b/spec/frontend/snippets/components/snippet_header_spec.js @@ -199,7 +199,7 @@ describe('Snippet header component', () => { }, }).then(() => { expect(wrapper.vm.closeDeleteModal).toHaveBeenCalled(); - expect(window.location.pathname).toBe(`${fullPath}/snippets`); + expect(window.location.pathname).toBe(`${fullPath}/-/snippets`); }); }); }); diff --git a/spec/frontend/snippets_spec.js b/spec/frontend/snippets_spec.js index 5b391606371bce5a84f1e34650c97d5336c059da..6c39ff0da27b5523dec9ddf1f33db16b1e4af238 100644 --- a/spec/frontend/snippets_spec.js +++ b/spec/frontend/snippets_spec.js @@ -7,7 +7,7 @@ describe('Snippets', () => { let shareBtn; let scriptTag; - const snippetUrl = 'http://test.host/snippets/1'; + const snippetUrl = 'http://test.host/-/snippets/1'; beforeEach(() => { loadHTMLFixture('snippets/show.html'); diff --git a/spec/helpers/award_emoji_helper_spec.rb b/spec/helpers/award_emoji_helper_spec.rb index 51e0a1b9721477fb2e573d68be6893a787db40d2..74ebdad3e8f62702a94bd5b3dd40989b91440a5a 100644 --- a/spec/helpers/award_emoji_helper_spec.rb +++ b/spec/helpers/award_emoji_helper_spec.rb @@ -14,7 +14,7 @@ subject { helper.toggle_award_url(note) } it 'returns correct url' do - expected_url = "/snippets/#{note.noteable.id}/notes/#{note.id}/toggle_award_emoji" + expected_url = "/-/snippets/#{note.noteable.id}/notes/#{note.id}/toggle_award_emoji" expect(subject).to eq(expected_url) end @@ -38,7 +38,7 @@ let(:awardable) { snippet } it 'returns correct url' do - expected_url = "/snippets/#{snippet.id}/toggle_award_emoji" + expected_url = "/-/snippets/#{snippet.id}/toggle_award_emoji" expect(subject).to eq(expected_url) end diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index 4ca31405c1ee85e3e690bd41a34f040807de2d5e..c629643e24892aeda91cb9c35bf12744598e7527 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -200,7 +200,7 @@ it 'returns a project snippet note url' do event.target = create(:note_on_project_snippet, note: 'keep going') - expect(subject).to eq("#{project_base_url}/snippets/#{event.note_target.id}#note_#{event.target.id}") + expect(subject).to eq("#{project_base_url}/-/snippets/#{event.note_target.id}#note_#{event.target.id}") end it 'returns a project issue url' do diff --git a/spec/helpers/gitlab_routing_helper_spec.rb b/spec/helpers/gitlab_routing_helper_spec.rb index 901296c9d80140349f52f6e600c3103647defd5a..888806c4a455d1f1047d10d40f5bd265557ffb1f 100644 --- a/spec/helpers/gitlab_routing_helper_spec.rb +++ b/spec/helpers/gitlab_routing_helper_spec.rb @@ -88,7 +88,7 @@ it 'returns snippet preview markdown path for a personal snippet' do @snippet = create(:personal_snippet) - expect(preview_markdown_path(nil)).to eq("/snippets/preview_markdown") + expect(preview_markdown_path(nil)).to eq("/-/snippets/preview_markdown") end it 'returns project preview markdown path for a project snippet' do @@ -153,31 +153,31 @@ describe '#gitlab_snippet_path' do it 'returns the personal snippet path' do - expect(gitlab_snippet_path(personal_snippet)).to eq("/snippets/#{personal_snippet.id}") + expect(gitlab_snippet_path(personal_snippet)).to eq("/-/snippets/#{personal_snippet.id}") end it 'returns the project snippet path' do - expect(gitlab_snippet_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/snippets/#{project_snippet.id}") + expect(gitlab_snippet_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/-/snippets/#{project_snippet.id}") end end describe '#gitlab_snippet_url' do it 'returns the personal snippet url' do - expect(gitlab_snippet_url(personal_snippet)).to eq("http://test.host/snippets/#{personal_snippet.id}") + expect(gitlab_snippet_url(personal_snippet)).to eq("http://test.host/-/snippets/#{personal_snippet.id}") end it 'returns the project snippet url' do - expect(gitlab_snippet_url(project_snippet)).to eq("http://test.host/#{project_snippet.project.full_path}/snippets/#{project_snippet.id}") + expect(gitlab_snippet_url(project_snippet)).to eq("http://test.host/#{project_snippet.project.full_path}/-/snippets/#{project_snippet.id}") end end describe '#gitlab_raw_snippet_path' do it 'returns the raw personal snippet path' do - expect(gitlab_raw_snippet_path(personal_snippet)).to eq("/snippets/#{personal_snippet.id}/raw") + expect(gitlab_raw_snippet_path(personal_snippet)).to eq("/-/snippets/#{personal_snippet.id}/raw") end it 'returns the raw project snippet path' do - expect(gitlab_raw_snippet_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/snippets/#{project_snippet.id}/raw") + expect(gitlab_raw_snippet_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/-/snippets/#{project_snippet.id}/raw") end end @@ -207,6 +207,16 @@ end end + describe '#gitlab_raw_snippet_url' do + it 'returns the raw personal snippet url' do + expect(gitlab_raw_snippet_url(personal_snippet)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/raw") + end + + it 'returns the raw project snippet url' do + expect(gitlab_raw_snippet_url(project_snippet)).to eq("http://test.host/#{project_snippet.project.full_path}/-/snippets/#{project_snippet.id}/raw") + end + end + describe '#gitlab_raw_snippet_blob_url' do let(:blob) { snippet.blobs.first } let(:ref) { 'snippet-test-ref' } @@ -247,59 +257,59 @@ describe '#gitlab_raw_snippet_url' do it 'returns the raw personal snippet url' do - expect(gitlab_raw_snippet_url(personal_snippet)).to eq("http://test.host/snippets/#{personal_snippet.id}/raw") + expect(gitlab_raw_snippet_url(personal_snippet)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/raw") end it 'returns the raw project snippet url' do - expect(gitlab_raw_snippet_url(project_snippet)).to eq("http://test.host/#{project_snippet.project.full_path}/snippets/#{project_snippet.id}/raw") + expect(gitlab_raw_snippet_url(project_snippet)).to eq("http://test.host/#{project_snippet.project.full_path}/-/snippets/#{project_snippet.id}/raw") end end describe '#gitlab_snippet_notes_path' do it 'returns the notes path for the personal snippet' do - expect(gitlab_snippet_notes_path(personal_snippet)).to eq("/snippets/#{personal_snippet.id}/notes") + expect(gitlab_snippet_notes_path(personal_snippet)).to eq("/-/snippets/#{personal_snippet.id}/notes") end end describe '#gitlab_snippet_notes_url' do it 'returns the notes url for the personal snippet' do - expect(gitlab_snippet_notes_url(personal_snippet)).to eq("http://test.host/snippets/#{personal_snippet.id}/notes") + expect(gitlab_snippet_notes_url(personal_snippet)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/notes") end end describe '#gitlab_snippet_note_path' do it 'returns the note path for the personal snippet' do - expect(gitlab_snippet_note_path(personal_snippet, note)).to eq("/snippets/#{personal_snippet.id}/notes/#{note.id}") + expect(gitlab_snippet_note_path(personal_snippet, note)).to eq("/-/snippets/#{personal_snippet.id}/notes/#{note.id}") end end describe '#gitlab_snippet_note_url' do it 'returns the note url for the personal snippet' do - expect(gitlab_snippet_note_url(personal_snippet, note)).to eq("http://test.host/snippets/#{personal_snippet.id}/notes/#{note.id}") + expect(gitlab_snippet_note_url(personal_snippet, note)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/notes/#{note.id}") end end describe '#gitlab_toggle_award_emoji_snippet_note_path' do it 'returns the note award emoji path for the personal snippet' do - expect(gitlab_toggle_award_emoji_snippet_note_path(personal_snippet, note)).to eq("/snippets/#{personal_snippet.id}/notes/#{note.id}/toggle_award_emoji") + expect(gitlab_toggle_award_emoji_snippet_note_path(personal_snippet, note)).to eq("/-/snippets/#{personal_snippet.id}/notes/#{note.id}/toggle_award_emoji") end end describe '#gitlab_toggle_award_emoji_snippet_note_url' do it 'returns the note award emoji url for the personal snippet' do - expect(gitlab_toggle_award_emoji_snippet_note_url(personal_snippet, note)).to eq("http://test.host/snippets/#{personal_snippet.id}/notes/#{note.id}/toggle_award_emoji") + expect(gitlab_toggle_award_emoji_snippet_note_url(personal_snippet, note)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/notes/#{note.id}/toggle_award_emoji") end end describe '#gitlab_toggle_award_emoji_snippet_path' do it 'returns the award emoji path for the personal snippet' do - expect(gitlab_toggle_award_emoji_snippet_path(personal_snippet)).to eq("/snippets/#{personal_snippet.id}/toggle_award_emoji") + expect(gitlab_toggle_award_emoji_snippet_path(personal_snippet)).to eq("/-/snippets/#{personal_snippet.id}/toggle_award_emoji") end end describe '#gitlab_toggle_award_emoji_snippet_url' do it 'returns the award url for the personal snippet' do - expect(gitlab_toggle_award_emoji_snippet_url(personal_snippet)).to eq("http://test.host/snippets/#{personal_snippet.id}/toggle_award_emoji") + expect(gitlab_toggle_award_emoji_snippet_url(personal_snippet)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/toggle_award_emoji") end end @@ -309,7 +319,7 @@ end it 'returns the project snippets dashboard path' do - expect(gitlab_dashboard_snippets_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/snippets") + expect(gitlab_dashboard_snippets_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/-/snippets") end end end diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb index f29f947ba465ff652580ce809bf76412ff8620cd..19dcd698c0b2a8654cda5fe265364aa736987bcf 100644 --- a/spec/helpers/notes_helper_spec.rb +++ b/spec/helpers/notes_helper_spec.rb @@ -225,7 +225,7 @@ it 'return snippet notes path for personal snippet' do @snippet = create(:personal_snippet) - expect(helper.notes_url).to eq("/snippets/#{@snippet.id}/notes") + expect(helper.notes_url).to eq("/-/snippets/#{@snippet.id}/notes") end it 'return project notes path for project snippet' do @@ -250,7 +250,7 @@ it 'return snippet notes path for personal snippet' do note = create(:note_on_personal_snippet) - expect(helper.note_url(note)).to eq("/snippets/#{note.noteable.id}/notes/#{note.id}") + expect(helper.note_url(note)).to eq("/-/snippets/#{note.noteable.id}/notes/#{note.id}") end it 'return project notes path for project snippet' do diff --git a/spec/helpers/snippets_helper_spec.rb b/spec/helpers/snippets_helper_spec.rb index 8fc54f17e71444c9e4611f6e28fd6ff5a918c53c..7878f8772994c71a9cc170882b46060722492423 100644 --- a/spec/helpers/snippets_helper_spec.rb +++ b/spec/helpers/snippets_helper_spec.rb @@ -14,13 +14,13 @@ it 'returns view raw button of embedded snippets for personal snippets' do @snippet = create(:personal_snippet, :public) - expect(subject).to eq(download_link("http://test.host/snippets/#{@snippet.id}/raw")) + expect(subject).to eq(download_link("http://test.host/-/snippets/#{@snippet.id}/raw")) end it 'returns view raw button of embedded snippets for project snippets' do @snippet = create(:project_snippet, :public) - expect(subject).to eq(download_link("http://test.host/#{@snippet.project.path_with_namespace}/snippets/#{@snippet.id}/raw")) + expect(subject).to eq(download_link("http://test.host/#{@snippet.project.path_with_namespace}/-/snippets/#{@snippet.id}/raw")) end def download_link(url) @@ -34,13 +34,13 @@ def download_link(url) it 'returns download button of embedded snippets for personal snippets' do @snippet = create(:personal_snippet, :public) - expect(subject).to eq(download_link("http://test.host/snippets/#{@snippet.id}/raw")) + expect(subject).to eq(download_link("http://test.host/-/snippets/#{@snippet.id}/raw")) end it 'returns download button of embedded snippets for project snippets' do @snippet = create(:project_snippet, :public) - expect(subject).to eq(download_link("http://test.host/#{@snippet.project.path_with_namespace}/snippets/#{@snippet.id}/raw")) + expect(subject).to eq(download_link("http://test.host/#{@snippet.project.path_with_namespace}/-/snippets/#{@snippet.id}/raw")) end def download_link(url) @@ -56,7 +56,7 @@ def download_link(url) context 'public' do it 'returns a script tag with the snippet full url' do - expect(subject).to eq(script_embed("http://test.host/snippets/#{snippet.id}")) + expect(subject).to eq(script_embed("http://test.host/-/snippets/#{snippet.id}")) end end end @@ -65,7 +65,7 @@ def download_link(url) let(:snippet) { public_project_snippet } it 'returns a script tag with the snippet full url' do - expect(subject).to eq(script_embed("http://test.host/#{snippet.project.path_with_namespace}/snippets/#{snippet.id}")) + expect(subject).to eq(script_embed("http://test.host/#{snippet.project.path_with_namespace}/-/snippets/#{snippet.id}")) end end @@ -81,7 +81,7 @@ def script_embed(url) let(:snippet) { public_personal_snippet } it 'returns the download button' do - expect(subject).to eq(download_link("/snippets/#{snippet.id}/raw")) + expect(subject).to eq(download_link("/-/snippets/#{snippet.id}/raw")) end end @@ -89,7 +89,7 @@ def script_embed(url) let(:snippet) { public_project_snippet } it 'returns the download button' do - expect(subject).to eq(download_link("/#{snippet.project.path_with_namespace}/snippets/#{snippet.id}/raw")) + expect(subject).to eq(download_link("/#{snippet.project.path_with_namespace}/-/snippets/#{snippet.id}/raw")) end end diff --git a/spec/lib/api/entities/snippet_spec.rb b/spec/lib/api/entities/snippet_spec.rb index bcb8c364392e020cf222aeef0140726492c3e3be..068851f7f6cccb8d627260689627f27a8cbdfe6f 100644 --- a/spec/lib/api/entities/snippet_spec.rb +++ b/spec/lib/api/entities/snippet_spec.rb @@ -123,11 +123,11 @@ it_behaves_like 'common attributes' it 'returns snippet web_url attribute' do - expect(subject[:web_url]).to match("/snippets/#{snippet.id}") + expect(subject[:web_url]).to match("/-/snippets/#{snippet.id}") end it 'returns snippet raw_url attribute' do - expect(subject[:raw_url]).to match("/snippets/#{snippet.id}/raw") + expect(subject[:raw_url]).to match("/-/snippets/#{snippet.id}/raw") end end @@ -137,11 +137,11 @@ it_behaves_like 'common attributes' it 'returns snippet web_url attribute' do - expect(subject[:web_url]).to match("#{snippet.project.full_path}/snippets/#{snippet.id}") + expect(subject[:web_url]).to match("#{snippet.project.full_path}/-/snippets/#{snippet.id}") end it 'returns snippet raw_url attribute' do - expect(subject[:raw_url]).to match("#{snippet.project.full_path}/snippets/#{snippet.id}/raw") + expect(subject[:raw_url]).to match("#{snippet.project.full_path}/-/snippets/#{snippet.id}/raw") end end end diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index a16ff252bc119c9376ea152c2476dc1088733f54..b58b5a8466230200ef0eaf9e409d6159d4932484 100644 --- a/spec/lib/gitlab/url_builder_spec.rb +++ b/spec/lib/gitlab/url_builder_spec.rb @@ -22,7 +22,7 @@ :issue | ->(issue) { "/#{issue.project.full_path}/-/issues/#{issue.iid}" } :merge_request | ->(merge_request) { "/#{merge_request.project.full_path}/-/merge_requests/#{merge_request.iid}" } :project_milestone | ->(milestone) { "/#{milestone.project.full_path}/-/milestones/#{milestone.iid}" } - :project_snippet | ->(snippet) { "/#{snippet.project.full_path}/snippets/#{snippet.id}" } + :project_snippet | ->(snippet) { "/#{snippet.project.full_path}/-/snippets/#{snippet.id}" } :project_wiki | ->(wiki) { "/#{wiki.container.full_path}/-/wikis/home" } :ci_build | ->(build) { "/#{build.project.full_path}/-/jobs/#{build.id}" } :design | ->(design) { "/#{design.project.full_path}/-/design_management/designs/#{design.id}/raw_image" } @@ -31,7 +31,7 @@ :group_milestone | ->(milestone) { "/groups/#{milestone.group.full_path}/-/milestones/#{milestone.iid}" } :user | ->(user) { "/#{user.full_path}" } - :personal_snippet | ->(snippet) { "/snippets/#{snippet.id}" } + :personal_snippet | ->(snippet) { "/-/snippets/#{snippet.id}" } :wiki_page | ->(wiki_page) { "#{wiki_page.wiki.wiki_base_path}/#{wiki_page.slug}" } :note_on_commit | ->(note) { "/#{note.project.full_path}/-/commit/#{note.commit_id}#note_#{note.id}" } @@ -47,10 +47,10 @@ :discussion_note_on_merge_request | ->(note) { "/#{note.project.full_path}/-/merge_requests/#{note.noteable.iid}#note_#{note.id}" } :legacy_diff_note_on_merge_request | ->(note) { "/#{note.project.full_path}/-/merge_requests/#{note.noteable.iid}#note_#{note.id}" } - :note_on_project_snippet | ->(note) { "/#{note.project.full_path}/snippets/#{note.noteable_id}#note_#{note.id}" } - :discussion_note_on_project_snippet | ->(note) { "/#{note.project.full_path}/snippets/#{note.noteable_id}#note_#{note.id}" } - :discussion_note_on_personal_snippet | ->(note) { "/snippets/#{note.noteable_id}#note_#{note.id}" } - :note_on_personal_snippet | ->(note) { "/snippets/#{note.noteable_id}#note_#{note.id}" } + :note_on_project_snippet | ->(note) { "/#{note.project.full_path}/-/snippets/#{note.noteable_id}#note_#{note.id}" } + :discussion_note_on_project_snippet | ->(note) { "/#{note.project.full_path}/-/snippets/#{note.noteable_id}#note_#{note.id}" } + :discussion_note_on_personal_snippet | ->(note) { "/-/snippets/#{note.noteable_id}#note_#{note.id}" } + :note_on_personal_snippet | ->(note) { "/-/snippets/#{note.noteable_id}#note_#{note.id}" } end with_them do @@ -98,7 +98,7 @@ it 'returns a raw snippet URL if requested' do url = subject.build(snippet, raw: true) - expect(url).to eq "#{Gitlab.config.gitlab.url}/snippets/#{snippet.id}/raw" + expect(url).to eq "#{Gitlab.config.gitlab.url}/-/snippets/#{snippet.id}/raw" end it 'returns a raw snippet blob URL if requested' do @@ -114,7 +114,7 @@ it 'returns a raw snippet URL if requested' do url = subject.build(snippet, raw: true) - expect(url).to eq "#{Gitlab.config.gitlab.url}/#{snippet.project.full_path}/snippets/#{snippet.id}/raw" + expect(url).to eq "#{Gitlab.config.gitlab.url}/#{snippet.project.full_path}/-/snippets/#{snippet.id}/raw" end it 'returns a raw snippet blob URL if requested' do diff --git a/spec/models/personal_snippet_spec.rb b/spec/models/personal_snippet_spec.rb index 10d70fed1eea37ab1cf845e89045788e05500329..2236c9dfed73a4e08b7ff3eafbd28977b56e5994 100644 --- a/spec/models/personal_snippet_spec.rb +++ b/spec/models/personal_snippet_spec.rb @@ -21,7 +21,7 @@ let_it_be(:container) { create(:personal_snippet, :repository) } let(:stubbed_container) { build_stubbed(:personal_snippet) } let(:expected_full_path) { "@snippets/#{container.id}" } - let(:expected_web_url_path) { "snippets/#{container.id}" } - let(:expected_repo_url_path) { expected_web_url_path } + let(:expected_web_url_path) { "-/snippets/#{container.id}" } + let(:expected_repo_url_path) { "snippets/#{container.id}" } end end diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb index 464b9b1da8427f1cd68dba81449f425747f9f780..3bcbf6b9e1b7e65ac526cad9276eb146aa308e16 100644 --- a/spec/models/project_snippet_spec.rb +++ b/spec/models/project_snippet_spec.rb @@ -37,7 +37,7 @@ let_it_be(:container) { create(:project_snippet, :repository) } let(:stubbed_container) { build_stubbed(:project_snippet) } let(:expected_full_path) { "#{container.project.full_path}/@snippets/#{container.id}" } - let(:expected_web_url_path) { "#{container.project.full_path}/snippets/#{container.id}" } - let(:expected_repo_url_path) { expected_web_url_path } + let(:expected_web_url_path) { "#{container.project.full_path}/-/snippets/#{container.id}" } + let(:expected_repo_url_path) { "#{container.project.full_path}/snippets/#{container.id}" } end end diff --git a/spec/presenters/snippet_blob_presenter_spec.rb b/spec/presenters/snippet_blob_presenter_spec.rb index 7464c0ac15b10b848c8ac3bd12368ba062eb7257..00bdb982147757294e4886b984f1b76c9ec6fba2 100644 --- a/spec/presenters/snippet_blob_presenter_spec.rb +++ b/spec/presenters/snippet_blob_presenter_spec.rb @@ -13,7 +13,7 @@ subject { described_class.new(snippet.blob).rich_data } context 'with PersonalSnippet' do - let(:raw_url) { "http://127.0.0.1:3000/snippets/#{snippet.id}/raw" } + let(:raw_url) { "http://127.0.0.1:3000/-/snippets/#{snippet.id}/raw" } let(:snippet) { build(:personal_snippet) } it 'returns nil when the snippet blob is binary' do @@ -40,7 +40,7 @@ let(:snippet) { create(:personal_snippet, file_name: 'test.ipynb') } it 'returns rich notebook content' do - expect(subject.strip).to eq %Q(
) + expect(subject.strip).to eq %Q(
) end end @@ -48,7 +48,7 @@ let(:snippet) { create(:personal_snippet, file_name: 'openapi.yml') } it 'returns rich openapi content' do - expect(subject).to eq %Q(
\n) + expect(subject).to eq %Q(
\n) end end @@ -131,7 +131,7 @@ let(:snippet) { project_snippet } it 'returns the raw path' do - expect(subject).to eq "/#{snippet.project.full_path}/snippets/#{snippet.id}/raw" + expect(subject).to eq "/#{snippet.project.full_path}/-/snippets/#{snippet.id}/raw" end end @@ -139,7 +139,7 @@ let(:snippet) { personal_snippet } it 'returns the raw path' do - expect(subject).to eq "/snippets/#{snippet.id}/raw" + expect(subject).to eq "/-/snippets/#{snippet.id}/raw" end end end diff --git a/spec/presenters/snippet_presenter_spec.rb b/spec/presenters/snippet_presenter_spec.rb index 98c291bdd02d9e2f76ae92d931777de272fec8a6..681564ed2b07a699ad8d773ef1b85a3f93cfd0c4 100644 --- a/spec/presenters/snippet_presenter_spec.rb +++ b/spec/presenters/snippet_presenter_spec.rb @@ -23,7 +23,7 @@ let(:snippet) { personal_snippet } it 'returns snippet web url' do - expect(subject).to match "/snippets/#{snippet.id}" + expect(subject).to match "/-/snippets/#{snippet.id}" end end @@ -31,7 +31,7 @@ let(:snippet) { project_snippet } it 'returns snippet web url' do - expect(subject).to match "/#{project.full_path}/snippets/#{snippet.id}" + expect(subject).to match "/#{project.full_path}/-/snippets/#{snippet.id}" end end end @@ -43,7 +43,7 @@ let(:snippet) { personal_snippet } it 'returns snippet web url' do - expect(subject).to match "/snippets/#{snippet.id}/raw" + expect(subject).to match "/-/snippets/#{snippet.id}/raw" end end @@ -51,7 +51,7 @@ let(:snippet) { project_snippet } it 'returns snippet web url' do - expect(subject).to match "/#{project.full_path}/snippets/#{snippet.id}/raw" + expect(subject).to match "/#{project.full_path}/-/snippets/#{snippet.id}/raw" end end end diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index e676eb94337396b1127432dc0ba7a435ebd08fe7..6c0b71c286345796a51180d27005da91488b40dd 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -84,8 +84,8 @@ public_snippet.id, public_snippet_other.id) expect(json_response.map { |snippet| snippet['web_url']} ).to contain_exactly( - "http://localhost/snippets/#{public_snippet.id}", - "http://localhost/snippets/#{public_snippet_other.id}") + "http://localhost/-/snippets/#{public_snippet.id}", + "http://localhost/-/snippets/#{public_snippet_other.id}") expect(json_response[0]['files'].first).to eq snippet_blob_file(public_snippet_other.blobs.first) expect(json_response[1]['files'].first).to eq snippet_blob_file(public_snippet.blobs.first) end diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 87091da0c84cab374b752c246649325f08e3731a..028a5782c6e4fdcb1b7118ea19645052488588dc 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -314,39 +314,39 @@ # DELETE /:project_id/snippets/:id(.:format) snippets#destroy describe SnippetsController, 'routing' do it 'to #raw' do - expect(get('/gitlab/gitlabhq/snippets/1/raw')).to route_to('projects/snippets#raw', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') + expect(get('/gitlab/gitlabhq/-/snippets/1/raw')).to route_to('projects/snippets#raw', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') end it 'to #index' do - expect(get('/gitlab/gitlabhq/snippets')).to route_to('projects/snippets#index', namespace_id: 'gitlab', project_id: 'gitlabhq') + expect(get('/gitlab/gitlabhq/-/snippets')).to route_to('projects/snippets#index', namespace_id: 'gitlab', project_id: 'gitlabhq') end it 'to #create' do - expect(post('/gitlab/gitlabhq/snippets')).to route_to('projects/snippets#create', namespace_id: 'gitlab', project_id: 'gitlabhq') + expect(post('/gitlab/gitlabhq/-/snippets')).to route_to('projects/snippets#create', namespace_id: 'gitlab', project_id: 'gitlabhq') end it 'to #new' do - expect(get('/gitlab/gitlabhq/snippets/new')).to route_to('projects/snippets#new', namespace_id: 'gitlab', project_id: 'gitlabhq') + expect(get('/gitlab/gitlabhq/-/snippets/new')).to route_to('projects/snippets#new', namespace_id: 'gitlab', project_id: 'gitlabhq') end it 'to #edit' do - expect(get('/gitlab/gitlabhq/snippets/1/edit')).to route_to('projects/snippets#edit', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') + expect(get('/gitlab/gitlabhq/-/snippets/1/edit')).to route_to('projects/snippets#edit', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') end it 'to #show' do - expect(get('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') + expect(get('/gitlab/gitlabhq/-/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') end it 'to #update' do - expect(put('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#update', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') + expect(put('/gitlab/gitlabhq/-/snippets/1')).to route_to('projects/snippets#update', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') end it 'to #destroy' do - expect(delete('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') + expect(delete('/gitlab/gitlabhq/-/snippets/1')).to route_to('projects/snippets#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') end - it 'to #show from scope routing' do - expect(get('/gitlab/gitlabhq/-/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') + it 'to #show from unscope routing' do + expect(get('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') end end diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index 1218ae307812a8819b96f6f10acbd7ae45e7cbb9..024d4d467a77e363bcc858181916801f34b9c8d5 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -76,39 +76,39 @@ # DELETE /snippets/:id(.:format) snippets#destroy RSpec.describe SnippetsController, "routing" do it "to #raw" do - expect(get("/snippets/1/raw")).to route_to('snippets#raw', id: '1') + expect(get("/-/snippets/1/raw")).to route_to('snippets#raw', id: '1') end it "to #index" do - expect(get("/snippets")).to route_to('snippets#index') + expect(get("/-/snippets")).to route_to('snippets#index') end it "to #create" do - expect(post("/snippets")).to route_to('snippets#create') + expect(post("/-/snippets")).to route_to('snippets#create') end it "to #new" do - expect(get("/snippets/new")).to route_to('snippets#new') + expect(get("/-/snippets/new")).to route_to('snippets#new') end it "to #edit" do - expect(get("/snippets/1/edit")).to route_to('snippets#edit', id: '1') + expect(get("/-/snippets/1/edit")).to route_to('snippets#edit', id: '1') end it "to #show" do - expect(get("/snippets/1")).to route_to('snippets#show', id: '1') + expect(get("/-/snippets/1")).to route_to('snippets#show', id: '1') end it "to #update" do - expect(put("/snippets/1")).to route_to('snippets#update', id: '1') + expect(put("/-/snippets/1")).to route_to('snippets#update', id: '1') end it "to #destroy" do - expect(delete("/snippets/1")).to route_to('snippets#destroy', id: '1') + expect(delete("/-/snippets/1")).to route_to('snippets#destroy', id: '1') end - it 'to #show from scope routing' do - expect(get("/-/snippets/1")).to route_to('snippets#show', id: '1') + it 'to #show from unscoped routing' do + expect(get("/snippets/1")).to route_to('snippets#show', id: '1') end end