Commit d202326e authored by Shinya Maeda's avatar Shinya Maeda

Merge branch '290311-remove-support-for-release-notes-in-create-tag-api-2' into 'master'

Add feature flag removing support for release notes in tags API [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!63392
parents 9f42733a 8b990f78
---
name: remove_release_notes_from_tags_api
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/63392
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/290311
milestone: '14.0'
type: development
group: group::release
default_enabled: false
......@@ -61,6 +61,8 @@ module API
optional :release_description, type: String, desc: 'Specifying release notes stored in the GitLab database (deprecated in GitLab 11.7)'
end
post ':id/repository/tags', :release_orchestration do
deprecate_release_notes unless params[:release_description].blank?
authorize_admin_tag
result = ::Tags::CreateService.new(user_project, current_user)
......@@ -119,6 +121,7 @@ module API
requires :description, type: String, desc: 'Release notes with markdown support'
end
post ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS, feature_category: :release_orchestration do
deprecate_release_notes
authorize_create_release!
##
......@@ -151,6 +154,7 @@ module API
requires :description, type: String, desc: 'Release notes with markdown support'
end
put ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS, feature_category: :release_orchestration do
deprecate_release_notes
authorize_update_release!
result = ::Releases::UpdateService
......@@ -177,6 +181,12 @@ module API
def release
@release ||= user_project.releases.find_by_tag(params[:tag])
end
def deprecate_release_notes
return unless Feature.enabled?(:remove_release_notes_from_tags_api, user_project, default_enabled: :yaml)
render_api_error!("Release notes modification via tags API is deprecated, see https://gitlab.com/gitlab-org/gitlab/-/issues/290311", 400)
end
end
end
end
......@@ -358,8 +358,17 @@ RSpec.describe API::Tags do
expect(json_response['message']).to eq('Target foo is invalid')
end
context 'lightweight tags with release notes' do
it 'creates a new tag' do
context 'when release_description is passed' do
it 'returns error' do
post api(route, current_user), params: { tag_name: tag_name, ref: 'master', release_description: 'Wow' }
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["message"]).to eq("Release notes modification via tags API is deprecated, see https://gitlab.com/gitlab-org/gitlab/-/issues/290311")
end
it 'creates a new tag with release if feature is enabled' do
stub_feature_flags(remove_release_notes_from_tags_api: false)
post api(route, current_user), params: { tag_name: tag_name, ref: 'master', release_description: 'Wow' }
expect(response).to have_gitlab_http_status(:created)
......@@ -445,6 +454,10 @@ RSpec.describe API::Tags do
let(:route) { "/projects/#{project_id}/repository/tags/#{tag_name}/release" }
let(:description) { 'Awesome release!' }
before do
stub_feature_flags(remove_release_notes_from_tags_api: false)
end
shared_examples_for 'repository new release' do
it 'creates description for existing git tag' do
post api(route, user), params: { description: description }
......@@ -455,6 +468,15 @@ RSpec.describe API::Tags do
expect(json_response['description']).to eq(description)
end
it 'returns error if feature is removed' do
stub_feature_flags(remove_release_notes_from_tags_api: true)
post api(route, user), params: { description: description }
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["message"]).to eq("Release notes modification via tags API is deprecated, see https://gitlab.com/gitlab-org/gitlab/-/issues/290311")
end
context 'when tag does not exist' do
let(:tag_name) { 'unknown' }
......@@ -502,6 +524,10 @@ RSpec.describe API::Tags do
let(:description) { 'Awesome release!' }
let(:new_description) { 'The best release!' }
before do
stub_feature_flags(remove_release_notes_from_tags_api: false)
end
shared_examples_for 'repository update release' do
context 'on tag with existing release' do
let!(:release) do
......@@ -519,6 +545,15 @@ RSpec.describe API::Tags do
expect(json_response['tag_name']).to eq(tag_name)
expect(json_response['description']).to eq(new_description)
end
it 'returns error if feature is removed' do
stub_feature_flags(remove_release_notes_from_tags_api: true)
put api(route, current_user), params: { description: new_description }
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["message"]).to eq("Release notes modification via tags API is deprecated, see https://gitlab.com/gitlab-org/gitlab/-/issues/290311")
end
end
context 'when tag does not exist' do
......
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