Commit 8b7ad815 authored by Luke Duncalfe's avatar Luke Duncalfe

Move Design Management routes, controllers to FOSS

This change is part of
https://gitlab.com/gitlab-org/gitlab/-/issues/212566 to move all Design
Management code to FOSS.

This change moves the routes and controllers.
parent 9ea5536e
......@@ -21,7 +21,6 @@ class Projects::IssuesController < Projects::ApplicationController
prepend_before_action(only: [:index]) { authenticate_sessionless_user!(:rss) }
prepend_before_action(only: [:calendar]) { authenticate_sessionless_user!(:ics) }
prepend_before_action :authenticate_user!, only: [:new, :export_csv]
# designs is only applicable to EE, but defining a prepend_before_action in EE code would overwrite this
prepend_before_action :store_uri, only: [:new, :show, :designs]
before_action :whitelist_query_limiting, only: [:create, :create_merge_request, :move, :bulk_update]
......
......@@ -13,6 +13,7 @@ resources :issues, concerns: :awardable, constraints: { id: /\d+/ } do
get :realtime_changes
post :create_merge_request
get :discussions, format: :json
get '/designs(/*vueroute)', to: 'issues#designs', as: :designs, format: false
end
collection do
......
......@@ -305,6 +305,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
namespace :design_management do
namespace :designs, path: 'designs/:design_id(/:sha)', constraints: -> (params) { params[:sha].nil? || Gitlab::Git.commit_id?(params[:sha]) } do
resource :raw_image, only: :show
resources :resized_image, only: :show, constraints: -> (params) { DesignManagement::DESIGN_IMAGE_SIZES.include?(params[:id]) }
end
end
draw :issues
draw :merge_requests
......
......@@ -4,7 +4,6 @@ resources :issues, only: [], constraints: { id: /\d+/ } do
member do
get '/descriptions/:version_id/diff', action: :description_diff, as: :description_diff
delete '/descriptions/:version_id', action: :delete_description_version, as: :delete_description_version
get '/designs(/*vueroute)', to: 'issues#designs', as: :designs, format: false
end
collection do
......
......@@ -43,13 +43,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
namespace :design_management do
namespace :designs, path: 'designs/:design_id(/:sha)', constraints: -> (params) { params[:sha].nil? || Gitlab::Git.commit_id?(params[:sha]) } do
resource :raw_image, only: :show
resources :resized_image, only: :show, constraints: -> (params) { DesignManagement::DESIGN_IMAGE_SIZES.include?(params[:id]) }
end
end
resources :subscriptions, only: [:create, :destroy]
resource :threat_monitoring, only: [:show], controller: :threat_monitoring
......
......@@ -169,33 +169,6 @@ describe Projects::IssuesController do
end
end
describe 'GET #designs' do
context 'when project has moved' do
let(:new_project) { create(:project) }
let(:issue) { create(:issue, project: new_project) }
before do
sign_in(user)
project.route.destroy
new_project.redirect_routes.create!(path: project.full_path)
new_project.add_developer(user)
end
it 'redirects from an old issue/designs correctly' do
get :designs,
params: {
namespace_id: project.namespace,
project_id: project,
id: issue
}
expect(response).to redirect_to(designs_project_issue_path(new_project, issue))
expect(response).to have_gitlab_http_status(:found)
end
end
end
describe 'GET #discussions' do
let(:issue) { create(:issue, project: project) }
let!(:discussion) { create(:discussion_note_on_issue, noteable: issue, project: issue.project) }
......
......@@ -41,22 +41,6 @@ describe 'EE-specific project routing' do
end
end
describe Projects::DesignManagement::Designs::RawImagesController, 'routing' do
it 'to #show' do
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/raw_image')).to route_to('projects/design_management/designs/raw_images#show', namespace_id: 'gitlab', project_id: 'gitlabhq', design_id: '1')
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/c6f00aa50b80887ada30a6fe517670be9f8f9ece/raw_image')).to route_to('projects/design_management/designs/raw_images#show', namespace_id: 'gitlab', project_id: 'gitlabhq', design_id: '1', sha: 'c6f00aa50b80887ada30a6fe517670be9f8f9ece')
end
end
describe Projects::DesignManagement::Designs::ResizedImageController, 'routing' do
it 'to #show' do
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/resized_image/v432x230')).to route_to('projects/design_management/designs/resized_image#show', namespace_id: 'gitlab', project_id: 'gitlabhq', design_id: '1', id: 'v432x230')
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/c6f00aa50b80887ada30a6fe517670be9f8f9ece/resized_image/v432x230')).to route_to('projects/design_management/designs/resized_image#show', namespace_id: 'gitlab', project_id: 'gitlabhq', design_id: '1', sha: 'c6f00aa50b80887ada30a6fe517670be9f8f9ece', id: 'v432x230')
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/invalid/resized_image/v432x230')).to route_to('application#route_not_found', unmatched_route: 'gitlab/gitlabhq/-/design_management/designs/1/invalid/resized_image/v432x230')
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/c6f00aa50b80887ada30a6fe517670be9f8f9ece/resized_image/small')).to route_to('application#route_not_found', unmatched_route: 'gitlab/gitlabhq/-/design_management/designs/1/c6f00aa50b80887ada30a6fe517670be9f8f9ece/resized_image/small')
end
end
describe Projects::AutocompleteSourcesController, 'routing' do
it "to #epics" do
expect(get("/gitlab/gitlabhq/-/autocomplete_sources/epics")).to route_to("projects/autocomplete_sources#epics", namespace_id: 'gitlab', project_id: 'gitlabhq')
......
......@@ -14,6 +14,16 @@ describe Projects::DesignManagement::Designs::ResizedImageController do
let(:sha) { design.versions.first.sha }
before do
# TODO these tests are being temporarily skipped unless run in EE,
# as we are in the process of moving Design Management to FOSS in 13.0
# in steps. In the current step the services have not yet been moved,
# and the `design` factory used in this test uses the `:with_smaller_image_versions`
# trait, which calls `GenerateImageVersionsService` to generate the
# smaller image versions.
#
# See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283.
skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
enable_design_management
end
......
......@@ -1719,6 +1719,33 @@ describe Projects::IssuesController do
end
end
describe 'GET #designs' do
context 'when project has moved' do
let(:new_project) { create(:project) }
let(:issue) { create(:issue, project: new_project) }
before do
sign_in(user)
project.route.destroy
new_project.redirect_routes.create!(path: project.full_path)
new_project.add_developer(user)
end
it 'redirects from an old issue/designs correctly' do
get :designs,
params: {
namespace_id: project.namespace,
project_id: project,
id: issue
}
expect(response).to redirect_to(designs_project_issue_path(new_project, issue))
expect(response).to have_gitlab_http_status(:found)
end
end
end
context 'private project with token authentication' do
let(:private_project) { create(:project, :private) }
......
......@@ -380,15 +380,8 @@ describe DesignManagement::Design do
end
end
# TODO these tests are being temporarily skipped unless run in EE,
# as we are in the process of moving Design Management to FOSS in 13.0
# in steps. In the current step the routes have not yet been moved.
#
# See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283.
describe '#note_etag_key' do
it 'returns a correct etag key' do
skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
design = create(:design)
expect(design.note_etag_key).to eq(
......
......@@ -852,4 +852,20 @@ describe 'project routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/serverless", "/gitlab/gitlabhq/-/serverless"
end
end
describe Projects::DesignManagement::Designs::RawImagesController, 'routing' do
it 'to #show' do
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/raw_image')).to route_to('projects/design_management/designs/raw_images#show', namespace_id: 'gitlab', project_id: 'gitlabhq', design_id: '1')
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/c6f00aa50b80887ada30a6fe517670be9f8f9ece/raw_image')).to route_to('projects/design_management/designs/raw_images#show', namespace_id: 'gitlab', project_id: 'gitlabhq', design_id: '1', sha: 'c6f00aa50b80887ada30a6fe517670be9f8f9ece')
end
end
describe Projects::DesignManagement::Designs::ResizedImageController, 'routing' do
it 'to #show' do
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/resized_image/v432x230')).to route_to('projects/design_management/designs/resized_image#show', namespace_id: 'gitlab', project_id: 'gitlabhq', design_id: '1', id: 'v432x230')
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/c6f00aa50b80887ada30a6fe517670be9f8f9ece/resized_image/v432x230')).to route_to('projects/design_management/designs/resized_image#show', namespace_id: 'gitlab', project_id: 'gitlabhq', design_id: '1', sha: 'c6f00aa50b80887ada30a6fe517670be9f8f9ece', id: 'v432x230')
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/invalid/resized_image/v432x230')).to route_to('application#route_not_found', unmatched_route: 'gitlab/gitlabhq/-/design_management/designs/1/invalid/resized_image/v432x230')
expect(get('/gitlab/gitlabhq/-/design_management/designs/1/c6f00aa50b80887ada30a6fe517670be9f8f9ece/resized_image/small')).to route_to('application#route_not_found', unmatched_route: 'gitlab/gitlabhq/-/design_management/designs/1/c6f00aa50b80887ada30a6fe517670be9f8f9ece/resized_image/small')
end
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