Skip to content

Commit

Permalink
Update error message copy
Browse files Browse the repository at this point in the history
These updates are based on the feedbacks from Kati Tirbhowan and from
discussions in the team.

This might change in future based on the feedback.
  • Loading branch information
syed-ali-tw committed Aug 16, 2024
1 parent 50c2162 commit 16eff9b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
15 changes: 12 additions & 3 deletions app/controllers/homepage_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ 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
rescue GdsApi::HTTPErrorResponse => e
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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
"<a href=\"#{Plek.external_url_for('support.service')}/technical_fault_report/new\">please raise a support ticket</a>"
end
end
8 changes: 4 additions & 4 deletions test/functional/homepage_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\"#{Plek.external_url_for('support.service')}/technical_fault_report/new\">please raise a support ticket</a>", flash[:danger]
end

should "render edit template" do
Expand Down Expand Up @@ -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 <a href=\"#{Plek.external_url_for('support.service')}/technical_fault_report/new\">please raise a support ticket</a>", flash[:danger]
end
end

Expand Down Expand Up @@ -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 <a href=\"#{Plek.external_url_for('support.service')}/technical_fault_report/new\">please raise a support ticket</a>", flash[:danger]
assert_redirected_to show_popular_links_path
end
end
Expand Down Expand Up @@ -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 <a href=\"#{Plek.external_url_for('support.service')}/technical_fault_report/new\">please raise a support ticket</a>", flash[:danger]
assert_redirected_to show_popular_links_path
end
end
Expand Down

0 comments on commit 16eff9b

Please sign in to comment.