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
@document.destroy if request.delete?
flash[:notice] = l(:notice_successful_delete)
redirect_to project_documents_path(@project)
end

View File

@@ -448,7 +448,10 @@ class IssuesController < ApplicationController
end
end
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}
end
end

View File

@@ -115,7 +115,10 @@ class NewsController < ApplicationController
def destroy
@news.destroy
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 }
end
end

View File

@@ -284,7 +284,10 @@ class WikiController < ApplicationController
end
@page.destroy
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 }
end
end

View File

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

View File

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

View File

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