Commit 845e1e2f authored by Nathan Friend's avatar Nathan Friend Committed by Douglas Barbosa Alexandre

Add backend route for release show page

This commit adds the backend route for the dedicated release show page.
This page is hidden behind a `release_show_page` feature flag which is
disabled by default.
parent 2e18b6f9
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
class Projects::ReleasesController < Projects::ApplicationController class Projects::ReleasesController < Projects::ApplicationController
# Authorize # Authorize
before_action :require_non_empty_project, except: [:index] before_action :require_non_empty_project, except: [:index]
before_action :release, only: %i[edit update] before_action :release, only: %i[edit show update]
before_action :authorize_read_release! before_action :authorize_read_release!
before_action do before_action do
push_frontend_feature_flag(:release_issue_summary, project) push_frontend_feature_flag(:release_issue_summary, project)
push_frontend_feature_flag(:release_evidence_collection, project, default_enabled: true) push_frontend_feature_flag(:release_evidence_collection, project, default_enabled: true)
push_frontend_feature_flag(:release_show_page, project)
end end
before_action :authorize_update_release!, only: %i[edit update] before_action :authorize_update_release!, only: %i[edit update]
before_action :authorize_read_release_evidence!, only: [:evidence] before_action :authorize_read_release_evidence!, only: [:evidence]
...@@ -29,6 +30,16 @@ class Projects::ReleasesController < Projects::ApplicationController ...@@ -29,6 +30,16 @@ class Projects::ReleasesController < Projects::ApplicationController
end end
end end
def show
return render_404 unless Feature.enabled?(:release_show_page, project)
respond_to do |format|
format.html do
render :show
end
end
end
protected protected
def releases def releases
...@@ -37,7 +48,9 @@ class Projects::ReleasesController < Projects::ApplicationController ...@@ -37,7 +48,9 @@ class Projects::ReleasesController < Projects::ApplicationController
def edit def edit
respond_to do |format| respond_to do |format|
format.html { render 'edit' } format.html do
render :edit
end
end end
end end
......
- add_to_breadcrumbs _("Releases"), project_releases_path(@project)
- page_title @release.name
#js-show-release-page{ data: { project_id: @project.id, tag_name: @release.tag } }
...@@ -166,7 +166,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -166,7 +166,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
resources :releases, only: [:index, :edit], param: :tag, constraints: { tag: %r{[^/]+} } do resources :releases, only: [:index, :show, :edit], param: :tag, constraints: { tag: %r{[^/]+} } do
member do member do
get :evidence get :evidence
end end
......
...@@ -127,13 +127,13 @@ describe Projects::ReleasesController do ...@@ -127,13 +127,13 @@ describe Projects::ReleasesController do
sign_in(user) sign_in(user)
end end
let!(:release) { create(:release, project: project) } let(:release) { create(:release, project: project) }
let(:tag) { CGI.escape(release.tag) } let(:tag) { CGI.escape(release.tag) }
it_behaves_like 'successful request' it_behaves_like 'successful request'
context 'when tag name contains slash' do context 'when tag name contains slash' do
let!(:release) { create(:release, project: project, tag: 'awesome/v1.0') } let(:release) { create(:release, project: project, tag: 'awesome/v1.0') }
let(:tag) { CGI.escape(release.tag) } let(:tag) { CGI.escape(release.tag) }
it_behaves_like 'successful request' it_behaves_like 'successful request'
...@@ -145,7 +145,6 @@ describe Projects::ReleasesController do ...@@ -145,7 +145,6 @@ describe Projects::ReleasesController do
end end
context 'when release does not exist' do context 'when release does not exist' do
let!(:release) { }
let(:tag) { 'non-existent-tag' } let(:tag) { 'non-existent-tag' }
it_behaves_like 'not found' it_behaves_like 'not found'
...@@ -158,6 +157,47 @@ describe Projects::ReleasesController do ...@@ -158,6 +157,47 @@ describe Projects::ReleasesController do
end end
end end
describe 'GET #show' do
subject do
get :show, params: { namespace_id: project.namespace, project_id: project, tag: tag }
end
before do
sign_in(user)
end
let(:release) { create(:release, project: project) }
let(:tag) { CGI.escape(release.tag) }
it_behaves_like 'successful request'
context 'when tag name contains slash' do
let(:release) { create(:release, project: project, tag: 'awesome/v1.0') }
let(:tag) { CGI.escape(release.tag) }
it_behaves_like 'successful request'
it 'is accesible at a URL encoded path' do
expect(project_release_path(project, release))
.to eq("/#{project.namespace.path}/#{project.name}/-/releases/awesome%252Fv1.0")
end
end
context 'when feature flag `release_show_page` is disabled' do
before do
stub_feature_flags(release_show_page: false)
end
it_behaves_like 'not found'
end
context 'when release does not exist' do
let(:tag) { 'non-existent-tag' }
it_behaves_like 'not found'
end
end
describe 'GET #evidence' do describe 'GET #evidence' do
let_it_be(:tag_name) { "v1.1.0-evidence" } let_it_be(:tag_name) { "v1.1.0-evidence" }
let!(:release) { create(:release, :with_evidence, project: project, tag: tag_name) } let!(:release) { create(:release, :with_evidence, project: project, tag: tag_name) }
......
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