mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-23 12:01:46 +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:
parent
3ca75647df
commit
780e64a100
@ -26,7 +26,7 @@ class NewsController < ApplicationController
|
|||||||
before_action :authorize, :except => [:index]
|
before_action :authorize, :except => [:index]
|
||||||
before_action :find_optional_project, :only => :index
|
before_action :find_optional_project, :only => :index
|
||||||
accept_rss_auth :index
|
accept_rss_auth :index
|
||||||
accept_api_auth :index, :show, :create
|
accept_api_auth :index, :show, :create, :destroy
|
||||||
|
|
||||||
helper :watchers
|
helper :watchers
|
||||||
helper :attachments
|
helper :attachments
|
||||||
@ -106,6 +106,9 @@ class NewsController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@news.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
|
||||||
end
|
end
|
||||||
|
|||||||
@ -263,4 +263,24 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
|
|||||||
news = News.find_by(:title => 'News JSON-API with attachments')
|
news = News.find_by(:title => 'News JSON-API with attachments')
|
||||||
assert_equal 2, news.attachments.count
|
assert_equal 2, news.attachments.count
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user