From ed74bc036b3203bb14c3fbb986c077f2958d004d Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 4 Apr 2024 16:44:53 +0300 Subject: [PATCH 1/1] Fix browse elements timeouts --- app/views/nodes/timeout.html.erb | 5 +++++ app/views/old_nodes/timeout.html.erb | 5 +++++ app/views/old_relations/timeout.html.erb | 5 +++++ app/views/old_ways/timeout.html.erb | 5 +++++ app/views/relations/timeout.html.erb | 5 +++++ app/views/ways/timeout.html.erb | 5 +++++ config/locales/en.yml | 15 +++++++++++++++ test/controllers/nodes_controller_test.rb | 11 +++++++++++ test/controllers/old_nodes_controller_test.rb | 11 +++++++++++ test/controllers/old_relations_controller_test.rb | 11 +++++++++++ test/controllers/old_ways_controller_test.rb | 11 +++++++++++ test/controllers/relations_controller_test.rb | 11 +++++++++++ test/controllers/ways_controller_test.rb | 11 +++++++++++ 13 files changed, 111 insertions(+) create mode 100644 app/views/nodes/timeout.html.erb create mode 100644 app/views/old_nodes/timeout.html.erb create mode 100644 app/views/old_relations/timeout.html.erb create mode 100644 app/views/old_ways/timeout.html.erb create mode 100644 app/views/relations/timeout.html.erb create mode 100644 app/views/ways/timeout.html.erb diff --git a/app/views/nodes/timeout.html.erb b/app/views/nodes/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/nodes/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/app/views/old_nodes/timeout.html.erb b/app/views/old_nodes/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/old_nodes/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/app/views/old_relations/timeout.html.erb b/app/views/old_relations/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/old_relations/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/app/views/old_ways/timeout.html.erb b/app/views/old_ways/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/old_ways/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/app/views/relations/timeout.html.erb b/app/views/relations/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/relations/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/app/views/ways/timeout.html.erb b/app/views/ways/timeout.html.erb new file mode 100644 index 000000000..61415c650 --- /dev/null +++ b/app/views/ways/timeout.html.erb @@ -0,0 +1,5 @@ +<% set_title(t("browse.timeout.title")) %> + +<%= render "sidebar_header", :title => t("browse.timeout.title") %> + +

<%= t ".sorry", :id => params[:id] %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index faf9a8985..06a60f977 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -403,15 +403,30 @@ en: introduction: "Click on the map to find nearby features." nearby: "Nearby features" enclosing: "Enclosing features" + nodes: + timeout: + sorry: "Sorry, the data for the node with the id %{id}, took too long to retrieve." old_nodes: not_found: sorry: "Sorry, node #%{id} version %{version} could not be found." + timeout: + sorry: "Sorry, the history of the node with the id %{id}, took too long to retrieve." + ways: + timeout: + sorry: "Sorry, the data for the way with the id %{id}, took too long to retrieve." old_ways: not_found: sorry: "Sorry, way #%{id} version %{version} could not be found." + timeout: + sorry: "Sorry, the history of the way with the id %{id}, took too long to retrieve." + relations: + timeout: + sorry: "Sorry, the data for the relation with the id %{id}, took too long to retrieve." old_relations: not_found: sorry: "Sorry, relation #%{id} version %{version} could not be found." + timeout: + sorry: "Sorry, the history of the relation with the id %{id}, took too long to retrieve." changeset_comments: feeds: comment: diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index 5bb08ea71..a29432723 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb @@ -90,4 +90,15 @@ class NodesControllerTest < ActionDispatch::IntegrationTest assert_select ".secondary-actions a", :text => "View History", :count => 1 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 1 end + + def test_show_timeout + node = create(:node) + with_settings(:web_timeout => -1) do + get node_path(node) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the node with the id #{node.id}")}/ + end end diff --git a/test/controllers/old_nodes_controller_test.rb b/test/controllers/old_nodes_controller_test.rb index bb4dffdc6..abaf30d62 100644 --- a/test/controllers/old_nodes_controller_test.rb +++ b/test/controllers/old_nodes_controller_test.rb @@ -218,6 +218,17 @@ class OldNodesControllerTest < ActionDispatch::IntegrationTest assert_select "#sidebar_content", /node #0 version 0 could not be found/ end + def test_show_timeout + node = create(:node, :with_history) + with_settings(:web_timeout => -1) do + get old_node_path(node, 1) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the node with the id #{node.id}")}/ + end + private def create_redacted_node diff --git a/test/controllers/old_relations_controller_test.rb b/test/controllers/old_relations_controller_test.rb index a766f8b8d..f5de706cf 100644 --- a/test/controllers/old_relations_controller_test.rb +++ b/test/controllers/old_relations_controller_test.rb @@ -177,6 +177,17 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest assert_select "#sidebar_content", /relation #0 version 0 could not be found/ end + def test_show_timeout + relation = create(:relation, :with_history) + with_settings(:web_timeout => -1) do + get old_relation_path(relation, 1) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the relation with the id #{relation.id}")}/ + end + private def create_redacted_relation diff --git a/test/controllers/old_ways_controller_test.rb b/test/controllers/old_ways_controller_test.rb index 6455343cf..fcc2281b8 100644 --- a/test/controllers/old_ways_controller_test.rb +++ b/test/controllers/old_ways_controller_test.rb @@ -182,6 +182,17 @@ class OldWaysControllerTest < ActionDispatch::IntegrationTest assert_select "#sidebar_content", /way #0 version 0 could not be found/ end + def test_show_timeout + way = create(:way, :with_history) + with_settings(:web_timeout => -1) do + get old_way_path(way, 1) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the way with the id #{way.id}")}/ + end + private def create_redacted_way diff --git a/test/controllers/relations_controller_test.rb b/test/controllers/relations_controller_test.rb index 926d95026..bdcbd2fd7 100644 --- a/test/controllers/relations_controller_test.rb +++ b/test/controllers/relations_controller_test.rb @@ -36,4 +36,15 @@ class RelationsControllerTest < ActionDispatch::IntegrationTest sidebar_browse_check :relation_path, member.id, "browse/feature" assert_select "a[href='#{relation_path relation}']", :count => 1 end + + def test_show_timeout + relation = create(:relation) + with_settings(:web_timeout => -1) do + get relation_path(relation) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the relation with the id #{relation.id}")}/ + end end diff --git a/test/controllers/ways_controller_test.rb b/test/controllers/ways_controller_test.rb index e198f7cf6..995004cb4 100644 --- a/test/controllers/ways_controller_test.rb +++ b/test/controllers/ways_controller_test.rb @@ -36,4 +36,15 @@ class WaysControllerTest < ActionDispatch::IntegrationTest sidebar_browse_check :way_path, member.id, "browse/feature" assert_select "a[href='#{relation_path relation}']", :count => 1 end + + def test_show_timeout + way = create(:way) + with_settings(:web_timeout => -1) do + get way_path(way) + end + assert_response :error + assert_template :layout => "map" + assert_dom "h2", "Timeout Error" + assert_dom "p", /#{Regexp.quote("the way with the id #{way.id}")}/ + end end -- 2.39.5