- <% if @feature.visible? %>
+<% if @feature.visible? %>
+
<%= link_to(t("browse.download_xml"), :controller => "api/#{@type.pluralize}", :action => :show) %>
+
+<% end %>
+
+ <% if @feature.version > 1 %>
+ <%= link_to "<< #{t('browse.version')} #1", :controller => "old_#{@type.pluralize}", :action => :show, :version => 1 %>
·
<% end %>
- <%= link_to(t("browse.view_history"), :action => "#{@type}_history") %>
+ <%= link_to t("browse.view_history"), :action => "#{@type}_history" %>
+ <% if @feature.version > 1 %>
+ ·
+ <%= link_to "#{t('browse.version')} ##{@feature.version} >>", :controller => "old_#{@type.pluralize}", :action => :show, :version => @feature.version %>
+ <% end %>
diff --git a/app/views/old_nodes/not_found.html.erb b/app/views/old_nodes/not_found.html.erb
new file mode 100644
index 000000000..1ee5d9d3f
--- /dev/null
+++ b/app/views/old_nodes/not_found.html.erb
@@ -0,0 +1,7 @@
+<% set_title(t("browse.not_found.title")) %>
+
+<%= render "sidebar_header", :title => t("browse.not_found.title") %>
+
+
+
<%= t ".sorry", :id => params[:id], :version => params[:version] %>
+
diff --git a/app/views/old_nodes/show.html.erb b/app/views/old_nodes/show.html.erb
new file mode 100644
index 000000000..b69c29723
--- /dev/null
+++ b/app/views/old_nodes/show.html.erb
@@ -0,0 +1,25 @@
+<% set_title t("browse.node.title_html", :name => printable_name(@feature)) %>
+
+<%= render "sidebar_header", :title => t("browse.node.title_html", :name => printable_name(@feature)) %>
+
+<%= render :partial => "browse/node", :object => @feature %>
+
+
+ <% unless @feature.redacted? %>
+ <%= link_to t("browse.download_xml"), node_version_path(*@feature.id) %>
+ ·
+ <% end %>
+ <%= link_to t("browse.view_details"), node_path(@feature.node_id) %>
+
+
+
+ <% if @feature.version > 1 %>
+ <%= link_to "<< #{t('browse.version')} ##{@feature.version - 1}", old_node_path(@feature.node_id, @feature.version - 1) %>
+ ·
+ <% end %>
+ <%= link_to t("browse.view_history"), node_history_path(@feature.node_id) %>
+ <% if @feature.version < @feature.current_node.version %>
+ ·
+ <%= link_to "#{t('browse.version')} ##{@feature.version + 1} >>", old_node_path(@feature.node_id, @feature.version + 1) %>
+ <% end %>
+
diff --git a/app/views/old_relations/not_found.html.erb b/app/views/old_relations/not_found.html.erb
new file mode 100644
index 000000000..1ee5d9d3f
--- /dev/null
+++ b/app/views/old_relations/not_found.html.erb
@@ -0,0 +1,7 @@
+<% set_title(t("browse.not_found.title")) %>
+
+<%= render "sidebar_header", :title => t("browse.not_found.title") %>
+
+
+
<%= t ".sorry", :id => params[:id], :version => params[:version] %>
+
diff --git a/app/views/old_relations/show.html.erb b/app/views/old_relations/show.html.erb
new file mode 100644
index 000000000..29d0b0079
--- /dev/null
+++ b/app/views/old_relations/show.html.erb
@@ -0,0 +1,25 @@
+<% set_title t("browse.relation.title_html", :name => printable_name(@feature)) %>
+
+<%= render "sidebar_header", :title => t("browse.relation.title_html", :name => printable_name(@feature)) %>
+
+<%= render :partial => "browse/relation", :object => @feature %>
+
+
+ <% unless @feature.redacted? %>
+ <%= link_to t("browse.download_xml"), relation_version_path(*@feature.id) %>
+ ·
+ <% end %>
+ <%= link_to t("browse.view_details"), relation_path(@feature.relation_id) %>
+
+
+
+ <% if @feature.version > 1 %>
+ <%= link_to "<< #{t('browse.version')} ##{@feature.version - 1}", old_relation_path(@feature.relation_id, @feature.version - 1) %>
+ ·
+ <% end %>
+ <%= link_to t("browse.view_history"), relation_history_path(@feature.relation_id) %>
+ <% if @feature.version < @feature.current_relation.version %>
+ ·
+ <%= link_to "#{t('browse.version')} ##{@feature.version + 1} >>", old_relation_path(@feature.relation_id, @feature.version + 1) %>
+ <% end %>
+
diff --git a/app/views/old_ways/not_found.html.erb b/app/views/old_ways/not_found.html.erb
new file mode 100644
index 000000000..1ee5d9d3f
--- /dev/null
+++ b/app/views/old_ways/not_found.html.erb
@@ -0,0 +1,7 @@
+<% set_title(t("browse.not_found.title")) %>
+
+<%= render "sidebar_header", :title => t("browse.not_found.title") %>
+
+
+
<%= t ".sorry", :id => params[:id], :version => params[:version] %>
+
diff --git a/app/views/old_ways/show.html.erb b/app/views/old_ways/show.html.erb
new file mode 100644
index 000000000..e9976dd78
--- /dev/null
+++ b/app/views/old_ways/show.html.erb
@@ -0,0 +1,25 @@
+<% set_title t("browse.way.title_html", :name => printable_name(@feature)) %>
+
+<%= render "sidebar_header", :title => t("browse.way.title_html", :name => printable_name(@feature)) %>
+
+<%= render :partial => "browse/way", :object => @feature %>
+
+
+ <% unless @feature.redacted? %>
+ <%= link_to t("browse.download_xml"), way_version_path(*@feature.id) %>
+ ·
+ <% end %>
+ <%= link_to t("browse.view_details"), way_path(@feature.way_id) %>
+
+
+
+ <% if @feature.version > 1 %>
+ <%= link_to "<< #{t('browse.version')} ##{@feature.version - 1}", old_way_path(@feature.way_id, @feature.version - 1) %>
+ ·
+ <% end %>
+ <%= link_to t("browse.view_history"), way_history_path(@feature.way_id) %>
+ <% if @feature.version < @feature.current_way.version %>
+ ·
+ <%= link_to "#{t('browse.version')} ##{@feature.version + 1} >>", old_way_path(@feature.way_id, @feature.version + 1) %>
+ <% end %>
+
diff --git a/config/locales/en.yml b/config/locales/en.yml
index ab6bf8fd2..dcb877f7b 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -428,6 +428,15 @@ en:
introduction: "Click on the map to find nearby features."
nearby: "Nearby features"
enclosing: "Enclosing features"
+ old_nodes:
+ not_found:
+ sorry: "Sorry, node #%{id} version %{version} could not be found."
+ old_ways:
+ not_found:
+ sorry: "Sorry, way #%{id} version %{version} could not be found."
+ old_relations:
+ not_found:
+ sorry: "Sorry, relation #%{id} version %{version} could not be found."
changesets:
changeset_paging_nav:
showing_page: "Page %{page}"
diff --git a/config/routes.rb b/config/routes.rb
index a38f8450f..09afe8fd9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -111,10 +111,13 @@ OpenStreetMap::Application.routes.draw do
# Data browsing
get "/way/:id" => "browse#way", :id => /\d+/, :as => :way
get "/way/:id/history" => "browse#way_history", :id => /\d+/, :as => :way_history
+ resources :old_ways, :path => "/way/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
get "/node/:id" => "browse#node", :id => /\d+/, :as => :node
get "/node/:id/history" => "browse#node_history", :id => /\d+/, :as => :node_history
+ resources :old_nodes, :path => "/node/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
get "/relation/:id" => "browse#relation", :id => /\d+/, :as => :relation
get "/relation/:id/history" => "browse#relation_history", :id => /\d+/, :as => :relation_history
+ resources :old_relations, :path => "/relation/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
get "/changeset/:id" => "browse#changeset", :as => :changeset, :id => /\d+/
get "/changeset/:id/comments/feed" => "changeset_comments#index", :as => :changeset_comments_feed, :id => /\d*/, :defaults => { :format => "rss" }
resources :notes, :path => "note", :only => [:show, :new]
diff --git a/test/controllers/browse_controller_test.rb b/test/controllers/browse_controller_test.rb
index 674a318ed..7df246c57 100644
--- a/test/controllers/browse_controller_test.rb
+++ b/test/controllers/browse_controller_test.rb
@@ -39,35 +39,93 @@ class BrowseControllerTest < ActionDispatch::IntegrationTest
end
def test_read_relation
- browse_check :relation_path, create(:relation).id, "browse/feature"
+ relation = create(:relation)
+ browse_check :relation_path, relation.id, "browse/feature"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_relation_path relation, 1}']", :text => "1", :count => 1
+ end
+ assert_select ".secondary-actions a[href='#{api_relation_path relation}']", :count => 1
+ assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
+ end
+
+ def test_multiple_version_relation_links
+ relation = create(:relation, :with_history, :version => 2)
+ browse_check :relation_path, relation.id, "browse/feature"
+ assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_relation_path relation, 2}']", :count => 1
end
def test_read_relation_history
- browse_check :relation_history_path, create(:relation, :with_history).id, "browse/history"
+ relation = create(:relation, :with_history)
+ browse_check :relation_history_path, relation.id, "browse/history"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_relation_path relation, 1}']", :text => "1", :count => 1
+ end
end
def test_read_way
- browse_check :way_path, create(:way).id, "browse/feature"
+ way = create(:way)
+ browse_check :way_path, way.id, "browse/feature"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_way_path way, 1}']", :text => "1", :count => 1
+ end
+ assert_select ".secondary-actions a[href='#{api_way_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
+ end
+
+ def test_multiple_version_way_links
+ way = create(:way, :with_history, :version => 2)
+ browse_check :way_path, way.id, "browse/feature"
+ assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_way_path way, 2}']", :count => 1
end
def test_read_way_history
- browse_check :way_history_path, create(:way, :with_history).id, "browse/history"
+ way = create(:way, :with_history)
+ browse_check :way_history_path, way.id, "browse/history"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_way_path way, 1}']", :text => "1", :count => 1
+ end
end
def test_read_node
node = create(:node)
browse_check :node_path, node.id, "browse/feature"
- assert_select "a[href='#{api_node_path node}']", :count => 1
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_node_path node, 1}']", :text => "1", :count => 1
+ end
+ assert_select ".secondary-actions a[href='#{api_node_path node}']", :count => 1
+ assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 0
+ end
+
+ def test_multiple_version_node_links
+ node = create(:node, :with_history, :version => 2)
+ browse_check :node_path, node.id, "browse/feature"
+ assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_node_path node, 2}']", :count => 1
end
def test_read_deleted_node
node = create(:node, :visible => false)
browse_check :node_path, node.id, "browse/feature"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_node_path node, 1}']", :text => "1", :count => 1
+ end
assert_select "a[href='#{api_node_path node}']", :count => 0
end
def test_read_node_history
- browse_check :node_history_path, create(:node, :with_history).id, "browse/history"
+ node = create(:node, :with_history)
+ browse_check :node_history_path, node.id, "browse/history"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_node_path node, 1}']", :text => "1", :count => 1
+ end
end
def test_read_changeset
diff --git a/test/controllers/old_nodes_controller_test.rb b/test/controllers/old_nodes_controller_test.rb
new file mode 100644
index 000000000..3f2958bd3
--- /dev/null
+++ b/test/controllers/old_nodes_controller_test.rb
@@ -0,0 +1,72 @@
+require "test_helper"
+
+class OldNodesControllerTest < ActionDispatch::IntegrationTest
+ def test_routes
+ assert_routing(
+ { :path => "/node/1/history/2", :method => :get },
+ { :controller => "old_nodes", :action => "show", :id => "1", :version => "2" }
+ )
+ end
+
+ def test_visible_with_one_version
+ node = create(:node, :with_history)
+ get old_node_path(node, 1)
+ assert_response :success
+ assert_template "old_nodes/show"
+ assert_template :layout => "map"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_node_path node, 1}']", :count => 0
+ end
+ assert_select ".secondary-actions a[href='#{node_version_path node, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
+ assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
+ end
+
+ def test_visible_with_two_versions
+ node = create(:node, :with_history, :version => 2)
+ get old_node_path(node, 1)
+ assert_response :success
+ assert_template "old_nodes/show"
+ assert_template :layout => "map"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_node_path node, 1}']", :count => 0
+ end
+ assert_select ".secondary-actions a[href='#{node_version_path node, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
+ assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_node_path node, 2}']", :count => 1
+
+ get old_node_path(node, 2)
+ assert_response :success
+ assert_template "old_nodes/show"
+ assert_template :layout => "map"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_node_path node, 2}']", :count => 0
+ end
+ assert_select ".secondary-actions a[href='#{node_version_path node, 2}']", :count => 1
+ assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
+ assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 1
+ end
+
+ def test_redacted
+ node = create(:node, :with_history, :deleted, :version => 2)
+ node_v1 = node.old_nodes.find_by(:version => 1)
+ node_v1.redact!(create(:redaction))
+ get old_node_path(node, 1)
+ assert_response :success
+ assert_template "old_nodes/show"
+ assert_template :layout => "map"
+ assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{node_version_path node, 1}']", :count => 0
+ end
+
+ def test_not_found
+ get old_node_path(0, 0)
+ assert_response :not_found
+ assert_template "old_nodes/not_found"
+ assert_template :layout => "map"
+ assert_select "#sidebar_content", /node #0 version 0 could not be found/
+ end
+end
diff --git a/test/controllers/old_relations_controller_test.rb b/test/controllers/old_relations_controller_test.rb
new file mode 100644
index 000000000..311e5958a
--- /dev/null
+++ b/test/controllers/old_relations_controller_test.rb
@@ -0,0 +1,81 @@
+require "test_helper"
+
+class OldRelationsControllerTest < ActionDispatch::IntegrationTest
+ def test_routes
+ assert_routing(
+ { :path => "/relation/1/history/2", :method => :get },
+ { :controller => "old_relations", :action => "show", :id => "1", :version => "2" }
+ )
+ end
+
+ def test_visible_with_one_version
+ relation = create(:relation, :with_history)
+ get old_relation_path(relation, 1)
+ assert_response :success
+ assert_template "old_relations/show"
+ assert_template :layout => "map"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
+ end
+ assert_select ".secondary-actions a[href='#{relation_version_path relation, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
+ assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
+ end
+
+ def test_visible_with_two_versions
+ relation = create(:relation, :with_history, :version => 2)
+ get old_relation_path(relation, 1)
+ assert_response :success
+ assert_template "old_relations/show"
+ assert_template :layout => "map"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
+ end
+ assert_select ".secondary-actions a[href='#{relation_version_path relation, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
+ assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_relation_path relation, 2}']", :count => 1
+
+ get old_relation_path(relation, 2)
+ assert_response :success
+ assert_template "old_relations/show"
+ assert_template :layout => "map"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_relation_path relation, 2}']", :count => 0
+ end
+ assert_select ".secondary-actions a[href='#{relation_version_path relation, 2}']", :count => 1
+ assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
+ assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 1
+ end
+
+ def test_visible_with_members
+ relation = create(:relation, :with_history)
+ create(:old_relation_member, :old_relation => relation.old_relations.first)
+ get old_relation_path(relation, 1)
+ assert_response :success
+ assert_template "old_relations/show"
+ assert_template :layout => "map"
+ end
+
+ def test_redacted
+ relation = create(:relation, :with_history, :deleted, :version => 2)
+ relation_v1 = relation.old_relations.find_by(:version => 1)
+ relation_v1.redact!(create(:redaction))
+ get old_relation_path(relation, 1)
+ assert_response :success
+ assert_template "old_relations/show"
+ assert_template :layout => "map"
+ assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{relation_version_path relation, 1}']", :count => 0
+ end
+
+ def test_not_found
+ get old_relation_path(0, 0)
+ assert_response :not_found
+ assert_template "old_relations/not_found"
+ assert_template :layout => "map"
+ assert_select "#sidebar_content", /relation #0 version 0 could not be found/
+ end
+end
diff --git a/test/controllers/old_ways_controller_test.rb b/test/controllers/old_ways_controller_test.rb
new file mode 100644
index 000000000..d428605c5
--- /dev/null
+++ b/test/controllers/old_ways_controller_test.rb
@@ -0,0 +1,86 @@
+require "test_helper"
+
+class OldWaysControllerTest < ActionDispatch::IntegrationTest
+ def test_routes
+ assert_routing(
+ { :path => "/way/1/history/2", :method => :get },
+ { :controller => "old_ways", :action => "show", :id => "1", :version => "2" }
+ )
+ end
+
+ def test_visible_with_one_version
+ way = create(:way, :with_history)
+ get old_way_path(way, 1)
+ assert_response :success
+ assert_template "old_ways/show"
+ assert_template :layout => "map"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_way_path way, 1}']", :count => 0
+ end
+ assert_select ".secondary-actions a[href='#{way_version_path way, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
+ end
+
+ def test_visible_with_two_versions
+ way = create(:way, :with_history, :version => 2)
+ get old_way_path(way, 1)
+ assert_response :success
+ assert_template "old_ways/show"
+ assert_template :layout => "map"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_way_path way, 1}']", :count => 0
+ end
+ assert_select ".secondary-actions a[href='#{way_version_path way, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_way_path way, 2}']", :count => 1
+
+ get old_way_path(way, 2)
+ assert_response :success
+ assert_template "old_ways/show"
+ assert_template :layout => "map"
+ assert_select "h4", /^Version/ do
+ assert_select "a[href='#{old_way_path way, 2}']", :count => 0
+ end
+ assert_select ".secondary-actions a[href='#{way_version_path way, 2}']", :count => 1
+ assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 1
+ end
+
+ def test_visible_with_shared_nodes
+ node = create(:node, :with_history)
+ way = create(:way, :with_history)
+ create(:way_node, :way => way, :node => node)
+ create(:old_way_node, :old_way => way.old_ways.first, :node => node)
+ sharing_way = create(:way, :with_history)
+ create(:way_node, :way => sharing_way, :node => node)
+ create(:old_way_node, :old_way => sharing_way.old_ways.first, :node => node)
+ get old_way_path(way, 1)
+ assert_response :success
+ assert_template "old_ways/show"
+ assert_template :layout => "map"
+ end
+
+ def test_redacted
+ way = create(:way, :with_history, :deleted, :version => 2)
+ way_v1 = way.old_ways.find_by(:version => 1)
+ way_v1.redact!(create(:redaction))
+ get old_way_path(way, 1)
+ assert_response :success
+ assert_template "old_ways/show"
+ assert_template :layout => "map"
+ assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{way_version_path way, 1}']", :count => 0
+ end
+
+ def test_not_found
+ get old_way_path(0, 0)
+ assert_response :not_found
+ assert_template "old_ways/not_found"
+ assert_template :layout => "map"
+ assert_select "#sidebar_content", /way #0 version 0 could not be found/
+ end
+end