diff options
-rw-r--r-- | app/controllers/news_controller.rb | 7 | ||||
-rw-r--r-- | test/integration/api_test/news_test.rb | 20 |
2 files changed, 25 insertions, 2 deletions
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 6c1e7f1bd..3ea0abea7 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -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 diff --git a/test/integration/api_test/news_test.rb b/test/integration/api_test/news_test.rb index 48a0b1025..0ec7824d2 100644 --- a/test/integration/api_test/news_test.rb +++ b/test/integration/api_test/news_test.rb @@ -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 |