Commit 4410fc47 authored by Alessio Caiazza's avatar Alessio Caiazza

Merge branch 'dz-scoped-snippets-routing' into 'master'

Make scoped snippet routing a default one

See merge request gitlab-org/gitlab!36091
parents df588c34 46b6d98d
......@@ -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;
},
......
......@@ -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();
......
---
title: Make scoped snippet routing a default one
merge_request: 36091
author:
type: changed
......@@ -178,6 +178,8 @@ Rails.application.routes.draw do
# 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 @@ Rails.application.routes.draw do
draw :api
draw :sidekiq
draw :help
draw :snippets
draw :google_api
draw :import
draw :uploads
......@@ -269,11 +270,8 @@ Rails.application.routes.draw do
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
......
......@@ -346,6 +346,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
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.
......@@ -382,26 +389,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
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
......@@ -511,10 +498,18 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
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.
......
......@@ -17,14 +17,11 @@ resources :snippets, concerns: :awardable do
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_\-]+(?<!\.atom)/ }
......@@ -162,7 +162,7 @@ describe('AwardsHandler', () => {
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');
});
});
......
......@@ -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: '<div>testing</div>',
});
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: '<div>testing</div>',
});
......
......@@ -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({
......
......@@ -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`);
});
});
});
......
......@@ -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');
......
......@@ -14,7 +14,7 @@ RSpec.describe AwardEmojiHelper do
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 @@ RSpec.describe AwardEmojiHelper do
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
......
......@@ -200,7 +200,7 @@ RSpec.describe EventsHelper do
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
......
......@@ -88,7 +88,7 @@ RSpec.describe GitlabRoutingHelper do
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 @@ RSpec.describe GitlabRoutingHelper do
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 @@ RSpec.describe GitlabRoutingHelper do
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 @@ RSpec.describe GitlabRoutingHelper do
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 @@ RSpec.describe GitlabRoutingHelper do
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
......
......@@ -225,7 +225,7 @@ RSpec.describe NotesHelper do
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 @@ RSpec.describe NotesHelper do
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
......
......@@ -14,13 +14,13 @@ RSpec.describe SnippetsHelper do
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 @@ RSpec.describe SnippetsHelper do
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 @@ RSpec.describe SnippetsHelper do
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 @@ RSpec.describe SnippetsHelper do
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 @@ RSpec.describe SnippetsHelper do
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 @@ RSpec.describe SnippetsHelper do
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
......
......@@ -123,11 +123,11 @@ RSpec.describe ::API::Entities::Snippet do
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 @@ RSpec.describe ::API::Entities::Snippet do
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
......@@ -22,7 +22,7 @@ RSpec.describe Gitlab::UrlBuilder do
: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 @@ RSpec.describe Gitlab::UrlBuilder do
: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 @@ RSpec.describe Gitlab::UrlBuilder do
: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 @@ RSpec.describe Gitlab::UrlBuilder do
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 @@ RSpec.describe Gitlab::UrlBuilder do
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
......
......@@ -21,7 +21,7 @@ RSpec.describe PersonalSnippet do
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
......@@ -37,7 +37,7 @@ RSpec.describe ProjectSnippet do
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
......@@ -13,7 +13,7 @@ RSpec.describe SnippetBlobPresenter do
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 @@ RSpec.describe SnippetBlobPresenter do
let(:snippet) { create(:personal_snippet, file_name: 'test.ipynb') }
it 'returns rich notebook content' do
expect(subject.strip).to eq %Q(<div class="file-content" data-endpoint="/snippets/#{snippet.id}/raw" id="js-notebook-viewer"></div>)
expect(subject.strip).to eq %Q(<div class="file-content" data-endpoint="/-/snippets/#{snippet.id}/raw" id="js-notebook-viewer"></div>)
end
end
......@@ -48,7 +48,7 @@ RSpec.describe SnippetBlobPresenter do
let(:snippet) { create(:personal_snippet, file_name: 'openapi.yml') }
it 'returns rich openapi content' do
expect(subject).to eq %Q(<div class="file-content" data-endpoint="/snippets/#{snippet.id}/raw" id="js-openapi-viewer"></div>\n)
expect(subject).to eq %Q(<div class="file-content" data-endpoint="/-/snippets/#{snippet.id}/raw" id="js-openapi-viewer"></div>\n)
end
end
......@@ -131,7 +131,7 @@ RSpec.describe SnippetBlobPresenter do
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 @@ RSpec.describe SnippetBlobPresenter do
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
......
......@@ -23,7 +23,7 @@ RSpec.describe SnippetPresenter do
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 @@ RSpec.describe SnippetPresenter do
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 @@ RSpec.describe SnippetPresenter do
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 @@ RSpec.describe SnippetPresenter do
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
......
......@@ -84,8 +84,8 @@ RSpec.describe API::Snippets do
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
......
......@@ -314,39 +314,39 @@ RSpec.describe 'project routing' do
# 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
......
......@@ -76,39 +76,39 @@ end
# 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment