:changeset, :query], :browse
can [:show], OldNode
can [:show], OldWay
+ can [:show], OldRelation
can [:show, :new], Note
can :search, :direction
can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :key, :id], :site
"/way/:id(/history)": OSM.Browse(map, "way"),
"/way/:id/history/:version": OSM.OldBrowse(),
"/relation/:id(/history)": OSM.Browse(map, "relation"),
+ "/relation/:id/history/:version": OSM.OldBrowse(),
"/changeset/:id": OSM.Changeset(map),
"/query": OSM.Query(map)
});
--- /dev/null
+class OldRelationsController < ApplicationController
+ layout :map_layout
+
+ before_action :authorize_web
+ before_action :set_locale
+ before_action -> { check_database_readable(:need_api => true) }
+ before_action :require_oauth
+
+ authorize_resource
+
+ around_action :web_timeout
+
+ def show
+ @type = "relation"
+ @feature = OldRelation.preload(:old_tags, :changeset => [:changeset_tags, :user], :old_members => :member).find([params[:id], params[:version]])
+ rescue ActiveRecord::RecordNotFound
+ render :action => "not_found", :status => :not_found
+ end
+end
</div>
<% else %>
<div class="browse-section browse-relation">
- <%= render :partial => "common_details", :object => relation %>
+ <%= render :partial => "browse/common_details", :object => relation %>
<% unless relation.containing_relation_members.empty? %>
<h4><%= t "browse.part_of" %></h4>
<details <%= "open" if relation.relation_members.count < 10 %>>
<summary><%= t ".members_count", :count => relation.relation_members.count %></summary>
<ul class="list-unstyled">
- <%= render :partial => "relation_member", :collection => relation.relation_members %>
+ <%= render :partial => "browse/relation_member", :collection => relation.relation_members %>
</ul>
</details>
<% end %>
<% member_class = link_class(relation_member.member_type.downcase, relation_member.member)
- linked_name = link_to printable_name(relation_member.member), { :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, { :title => link_title(relation_member.member), :rel => link_follow(relation_member.member) }
+ linked_name = link_to printable_name(relation_member.member), { :controller => :browse, :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, { :title => link_title(relation_member.member), :rel => link_follow(relation_member.member) }
type_str = t ".type.#{relation_member.member_type.downcase}" %>
<li class="<%= member_class %>">
<%= if relation_member.member_role.blank?
--- /dev/null
+<% set_title(t("browse.not_found.title")) %>
+
+<%= render "sidebar_header", :title => t("browse.not_found.title") %>
+
+<div>
+ <p><%= t ".sorry", :id => params[:id], :version => params[:version] %></p>
+</div>
--- /dev/null
+<% 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 %>
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}"
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]
--- /dev/null
+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
+ relation = create(:relation, :with_history)
+ get old_relation_path(relation, 1)
+ assert_response :success
+ assert_template "old_relations/show"
+ assert_template :layout => "map"
+ 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_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