Fix that "Successful deletion" notice is not displayed after deleting some types of content (#33116).

Patch by Yuichi HARADA.


git-svn-id: http://svn.redmine.org/redmine/trunk@19641 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2020-04-04 00:43:28 +00:00
parent a24834fa77
commit 6e781f6479
8 changed files with 27 additions and 3 deletions

View File

@@ -83,6 +83,7 @@ class DocumentsController < ApplicationController
def destroy def destroy
@document.destroy if request.delete? @document.destroy if request.delete?
flash[:notice] = l(:notice_successful_delete)
redirect_to project_documents_path(@project) redirect_to project_documents_path(@project)
end end

View File

@@ -448,7 +448,10 @@ class IssuesController < ApplicationController
end end
end end
respond_to do |format| respond_to do |format|
format.html {redirect_back_or_default _project_issues_path(@project)} format.html {
flash[:notice] = l(:notice_successful_delete)
redirect_back_or_default _project_issues_path(@project)
}
format.api {render_api_ok} format.api {render_api_ok}
end end
end end

View File

@@ -115,7 +115,10 @@ class NewsController < ApplicationController
def destroy def destroy
@news.destroy @news.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to project_news_index_path(@project) } format.html {
flash[:notice] = l(:notice_successful_delete)
redirect_to project_news_index_path(@project)
}
format.api { render_api_ok } format.api { render_api_ok }
end end
end end

View File

@@ -284,7 +284,10 @@ class WikiController < ApplicationController
end end
@page.destroy @page.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to project_wiki_index_path(@project) } format.html {
flash[:notice] = l(:notice_successful_delete)
redirect_to project_wiki_index_path(@project)
}
format.api { render_api_ok } format.api { render_api_ok }
end end
end end

View File

@@ -240,6 +240,7 @@ class DocumentsControllerTest < Redmine::ControllerTest
} }
end end
assert_redirected_to '/projects/ecookbook/documents' assert_redirected_to '/projects/ecookbook/documents'
assert_equal 'Successful deletion.', flash[:notice]
assert_nil Document.find_by_id(1) assert_nil Document.find_by_id(1)
end end

View File

@@ -7509,6 +7509,7 @@ class IssuesControllerTest < Redmine::ControllerTest
delete(:destroy, :params => {:id => 2}) delete(:destroy, :params => {:id => 2})
end end
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 'Successful deletion.', flash[:notice]
assert_nil Issue.find_by_id(2) assert_nil Issue.find_by_id(2)
end end
@@ -7588,6 +7589,7 @@ class IssuesControllerTest < Redmine::ControllerTest
end end
end end
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 'Successful deletion.', flash[:notice]
assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
assert_nil TimeEntry.find_by_id([1, 2]) assert_nil TimeEntry.find_by_id([1, 2])
end end
@@ -7609,6 +7611,7 @@ class IssuesControllerTest < Redmine::ControllerTest
end end
end end
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 'Successful deletion.', flash[:notice]
assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
assert_nil TimeEntry.find(1).issue_id assert_nil TimeEntry.find(1).issue_id
assert_nil TimeEntry.find(2).issue_id assert_nil TimeEntry.find(2).issue_id
@@ -7630,6 +7633,7 @@ class IssuesControllerTest < Redmine::ControllerTest
end end
end end
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 'Successful deletion.', flash[:notice]
assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
assert_equal 2, TimeEntry.find(1).issue_id assert_equal 2, TimeEntry.find(1).issue_id
assert_equal 2, TimeEntry.find(2).issue_id assert_equal 2, TimeEntry.find(2).issue_id
@@ -7654,6 +7658,7 @@ class IssuesControllerTest < Redmine::ControllerTest
} }
) )
assert_response 302 assert_response 302
assert_equal 'Successful deletion.', flash[:notice]
end end
end end
assert_equal 3, target.time_entries.count assert_equal 3, target.time_entries.count
@@ -7730,6 +7735,7 @@ class IssuesControllerTest < Redmine::ControllerTest
) )
end end
assert_redirected_to :controller => 'issues', :action => 'index' assert_redirected_to :controller => 'issues', :action => 'index'
assert_equal 'Successful deletion.', flash[:notice]
assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6)) assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
end end
@@ -7750,6 +7756,7 @@ class IssuesControllerTest < Redmine::ControllerTest
) )
end end
assert_response 302 assert_response 302
assert_equal 'Successful deletion.', flash[:notice]
end end
def test_destroy_invalid_should_respond_with_404 def test_destroy_invalid_should_respond_with_404
@@ -7770,6 +7777,7 @@ class IssuesControllerTest < Redmine::ControllerTest
delete(:destroy, :params => {:id => issue.id}) delete(:destroy, :params => {:id => issue.id})
end end
assert_response 302 assert_response 302
assert_equal 'Successful deletion.', flash[:notice]
end end
def test_destroy_without_permission_on_tracker_should_be_denied def test_destroy_without_permission_on_tracker_should_be_denied

View File

@@ -243,6 +243,7 @@ class NewsControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2 @request.session[:user_id] = 2
delete(:destroy, :params => {:id => 1}) delete(:destroy, :params => {:id => 1})
assert_redirected_to '/projects/ecookbook/news' assert_redirected_to '/projects/ecookbook/news'
assert_equal 'Successful deletion.', flash[:notice]
assert_nil News.find_by_id(1) assert_nil News.find_by_id(1)
end end
end end

View File

@@ -914,6 +914,7 @@ class WikiControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2 @request.session[:user_id] = 2
delete :destroy, :params => {:project_id => 1, :id => 'Child_2'} delete :destroy, :params => {:project_id => 1, :id => 'Child_2'}
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 'Successful deletion.', flash[:notice]
end end
def test_destroy_parent_should_ask_confirmation def test_destroy_parent_should_ask_confirmation
@@ -935,6 +936,7 @@ class WikiControllerTest < Redmine::ControllerTest
delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'nullify'} delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'nullify'}
end end
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 'Successful deletion.', flash[:notice]
assert_nil WikiPage.find_by_id(2) assert_nil WikiPage.find_by_id(2)
end end
@@ -944,6 +946,7 @@ class WikiControllerTest < Redmine::ControllerTest
delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'destroy'} delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'destroy'}
end end
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 'Successful deletion.', flash[:notice]
assert_nil WikiPage.find_by_id(2) assert_nil WikiPage.find_by_id(2)
assert_nil WikiPage.find_by_id(5) assert_nil WikiPage.find_by_id(5)
end end
@@ -954,6 +957,7 @@ class WikiControllerTest < Redmine::ControllerTest
delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1} delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1}
end end
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 'Successful deletion.', flash[:notice]
assert_nil WikiPage.find_by_id(2) assert_nil WikiPage.find_by_id(2)
assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
end end