1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-24 09:21:12 +00:00

REST API for deleting news (#13468).

Patch by Takenori TAKAKI.


git-svn-id: http://svn.redmine.org/redmine/trunk@18442 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2019-09-09 08:57:29 +00:00
parent 3ca75647df
commit 780e64a100
2 changed files with 25 additions and 2 deletions

View File

@ -26,7 +26,7 @@ class NewsController < ApplicationController
before_action :authorize, :except => [:index]
before_action :find_optional_project, :only => :index
accept_rss_auth :index
accept_api_auth :index, :show, :create
accept_api_auth :index, :show, :create, :destroy
helper :watchers
helper :attachments
@ -106,6 +106,9 @@ class NewsController < ApplicationController
def destroy
@news.destroy
redirect_to project_news_index_path(@project)
respond_to do |format|
format.html { redirect_to project_news_index_path(@project) }
format.api { render_api_ok }
end
end
end

View File

@ -263,4 +263,24 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
news = News.find_by(:title => 'News JSON-API with attachments')
assert_equal 2, news.attachments.count
end
test "DELETE /news/:id.xml" do
assert_difference('News.count', -1) do
delete '/news/1.xml', :headers => credentials('jsmith')
assert_response :no_content
assert_equal '', response.body
end
assert_nil News.find_by_id(1)
end
test "DELETE /news/:id.json" do
assert_difference('News.count', -1) do
delete '/news/1.json', :headers => credentials('jsmith')
assert_response :no_content
assert_equal '', response.body
end
assert_nil News.find_by_id(6)
end
end