diff --git a/app/controllers/homepage_controller.rb b/app/controllers/homepage_controller.rb index 533be5d55..3195b4027 100644 --- a/app/controllers/homepage_controller.rb +++ b/app/controllers/homepage_controller.rb @@ -28,11 +28,12 @@ def update render "homepage/popular_links/edit" rescue StandardError => e Rails.logger.error "Error #{e.class} #{e.message}" - flash[:danger] = "Due to an application error, the edition couldn't be saved." + flash[:danger] = "Due to an application error, the edition couldn't be saved. #{try_again_message} #{raise_support_error_message}" render "homepage/popular_links/edit" end def publish + flash[:danger] = "Due to an application error, the edition couldn't be published. #{try_again_message} #{raise_support_error_message}" @latest_popular_links.publish_latest flash[:success] = "Popular links successfully published.".html_safe @@ -40,7 +41,7 @@ def publish flash[:danger] = rescue_already_published_error(e) rescue StandardError => e Rails.logger.error "Error #{e.class} #{e.message}" - flash[:danger] = "Due to an application error, the edition couldn't be published." + flash[:danger] = "Due to an application error, the edition couldn't be published. #{try_again_message} #{raise_support_error_message}" ensure redirect_to show_popular_links_path end @@ -74,7 +75,7 @@ def cannot_delete_published_error_message end def application_error_message - "Due to an application error, the draft couldn't be deleted.".html_safe + "Due to an application error, the draft couldn't be deleted. #{try_again_message} #{raise_support_error_message}".html_safe end def rescue_already_published_error(error) @@ -109,4 +110,12 @@ def remove_leading_and_trailing_url_spaces(links) end link_items end + + def raise_support_error_message + "If the problem persists #{support_link}" + end + + def support_link + "please raise a support ticket" + end end diff --git a/test/functional/homepage_controller_test.rb b/test/functional/homepage_controller_test.rb index 21676b5b7..f984b99ee 100644 --- a/test/functional/homepage_controller_test.rb +++ b/test/functional/homepage_controller_test.rb @@ -130,7 +130,7 @@ class HomepageControllerTest < ActionController::TestCase "5" => { "title" => "title5", "url" => "/url5" }, "6" => { "title" => "title6", "url" => "/url6" } } } - assert_equal "Due to an application error, the edition couldn't be saved.", flash[:danger] + assert_equal "Due to an application error, the edition couldn't be saved. Please wait for a few minutes and try again. If the problem persists please raise a support ticket", flash[:danger] end should "render edit template" do @@ -223,7 +223,7 @@ class HomepageControllerTest < ActionController::TestCase should "alert 'application error'" do post :publish, params: { id: @popular_links.id } - assert_equal "Due to an application error, the edition couldn't be published.", flash[:danger] + assert_equal "Due to an application error, the edition couldn't be published. Please wait for a few minutes and try again. If the problem persists please raise a support ticket", flash[:danger] end end @@ -300,7 +300,7 @@ class HomepageControllerTest < ActionController::TestCase delete :destroy, params: { id: @popular_links.id } - assert_equal "Due to an application error, the draft couldn't be deleted.", flash[:danger] + assert_equal "Due to an application error, the draft couldn't be deleted. Please wait for a few minutes and try again. If the problem persists please raise a support ticket", flash[:danger] assert_redirected_to show_popular_links_path end end @@ -328,7 +328,7 @@ class HomepageControllerTest < ActionController::TestCase delete :destroy, params: { id: @popular_links.id } - assert_equal "Due to an application error, the draft couldn't be deleted.", flash[:danger] + assert_equal "Due to an application error, the draft couldn't be deleted. Please wait for a few minutes and try again. If the problem persists please raise a support ticket", flash[:danger] assert_redirected_to show_popular_links_path end end