def element_single_current_link(type, object, url)
link_to url, { :class => element_class(type, object), :title => element_title(object), :rel => (link_follow(object) if type == "node") } do
element_strikethrough object do
- printable_name object
+ printable_element_name object
end
end
end
end
end
- def printable_name(object, version: false)
+ def printable_element_name(object)
id = if object.id.is_a?(Array)
object.id[0]
else
object.id
end
- name = t "printable_name.with_id", :id => id.to_s
- name = t "printable_name.with_version", :id => name, :version => object.version.to_s if version
+ name = id.to_s
# don't look at object tags if redacted, so as to avoid giving
# away redacted version tag information.
name
end
+ def printable_element_version(object)
+ t "printable_name.version", :version => object.version
+ end
+
def element_strikethrough(object, &block)
if object.redacted? || !object.visible?
tag.s(&block)
-<li><%= linked_name = link_to printable_name(containing_relation.relation), :action => "relation", :id => containing_relation.relation.id.to_s
+<li><%= linked_name = link_to printable_element_name(containing_relation.relation), :action => "relation", :id => containing_relation.relation.id.to_s
if containing_relation.member_role.blank?
t ".entry_html", :relation_name => linked_name
else
-<% linked_name = link_to printable_name(relation_member.member), { :controller => :browse, :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, { :rel => link_follow(relation_member.member) }
+<% linked_name = link_to printable_element_name(relation_member.member), { :controller => :browse, :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, { :rel => link_follow(relation_member.member) }
type_str = t ".type.#{relation_member.member_type.downcase}" %>
<%= element_list_item relation_member.member_type.downcase, relation_member.member do %>
<%= if relation_member.member_role.blank?
<ul class="list-unstyled">
<% @ways.each do |way| %>
<%= element_list_item "way", way do %>
- <%= link_to printable_name(way, :version => true), { :action => "way", :id => way.way_id.to_s } %>
+ <%= t "printable_name.current_and_old_links_html",
+ :current_link => link_to(printable_element_name(way), way_path(way.way_id)),
+ :old_link => link_to(printable_element_version(way), old_way_path(way.way_id, way.version)) %>
<% end %>
<% end %>
</ul>
<ul class="list-unstyled">
<% @relations.each do |relation| %>
<%= element_list_item "relation", relation do %>
- <%= link_to printable_name(relation, :version => true), { :action => "relation", :id => relation.relation_id.to_s } %>
+ <%= t "printable_name.current_and_old_links_html",
+ :current_link => link_to(printable_element_name(relation), relation_path(relation.relation_id)),
+ :old_link => link_to(printable_element_version(relation), old_relation_path(relation.relation_id, relation.version)) %>
<% end %>
<% end %>
</ul>
<ul class="list-unstyled">
<% @nodes.each do |node| %>
<%= element_list_item "node", node do %>
- <%= link_to printable_name(node, :version => true), { :action => "node", :id => node.node_id.to_s }, { :rel => link_follow(node) } %>
+ <%= t "printable_name.current_and_old_links_html",
+ :current_link => link_to(printable_element_name(node), node_path(node.node_id), { :rel => link_follow(node) }),
+ :old_link => link_to(printable_element_version(node), old_node_path(node.node_id, node.version), { :rel => link_follow(node) }) %>
<% end %>
<% end %>
</ul>
-<% set_title(t("browse.#{@type}.title_html", :name => printable_name(@feature))) %>
+<% set_title(t("browse.#{@type}.title_html", :name => printable_element_name(@feature))) %>
-<%= render "sidebar_header", :title => t("browse.#{@type}.title_html", :name => printable_name(@feature)) %>
+<%= render "sidebar_header", :title => t("browse.#{@type}.title_html", :name => printable_element_name(@feature)) %>
<%= render :partial => @type, :object => @feature %>
-<% set_title(t("browse.#{@type}.history_title_html", :name => printable_name(@feature))) %>
+<% set_title(t("browse.#{@type}.history_title_html", :name => printable_element_name(@feature))) %>
-<%= render "sidebar_header", :title => t("browse.#{@type}.history_title_html", :name => printable_name(@feature)) %>
+<%= render "sidebar_header", :title => t("browse.#{@type}.history_title_html", :name => printable_element_name(@feature)) %>
<%= render :partial => @type, :collection => @feature.send(:"old_#{@type}s").reverse %>
-<% set_title t("browse.node.title_html", :name => printable_name(@feature)) %>
+<% set_title t("browse.node.title_html", :name => printable_element_name(@feature)) %>
-<%= render "sidebar_header", :title => t("browse.node.title_html", :name => printable_name(@feature)) %>
+<%= render "sidebar_header", :title => t("browse.node.title_html", :name => printable_element_name(@feature)) %>
<%= render :partial => "browse/node", :object => @feature %>
-<% set_title t("browse.relation.title_html", :name => printable_name(@feature)) %>
+<% set_title t("browse.relation.title_html", :name => printable_element_name(@feature)) %>
-<%= render "sidebar_header", :title => t("browse.relation.title_html", :name => printable_name(@feature)) %>
+<%= render "sidebar_header", :title => t("browse.relation.title_html", :name => printable_element_name(@feature)) %>
<%= render :partial => "browse/relation", :object => @feature %>
-<% set_title t("browse.way.title_html", :name => printable_name(@feature)) %>
+<% set_title t("browse.way.title_html", :name => printable_element_name(@feature)) %>
-<%= render "sidebar_header", :title => t("browse.way.title_html", :name => printable_name(@feature)) %>
+<%= render "sidebar_header", :title => t("browse.way.title_html", :name => printable_element_name(@feature)) %>
<%= render :partial => "browse/way", :object => @feature %>
one: "%{count} year ago"
other: "%{count} years ago"
printable_name:
- with_id: "%{id}"
- with_version: "%{id}, v%{version}"
+ version: "v%{version}"
with_name_html: "%{name} (%{id})"
+ current_and_old_links_html: "%{current_link}, %{old_link}"
editor:
default: "Default (currently %{name})"
id:
assert_select "div.changeset-comments ul li", :count => 4
end
+ def test_read_changeset_element_links
+ changeset = create(:changeset)
+ node = create(:node, :with_history, :changeset => changeset)
+
+ browse_check :changeset_path, changeset.id, "browse/changeset"
+ assert_dom "a[href='#{node_path node}']", :count => 1
+ assert_dom "a[href='#{old_node_path node, 1}']", :count => 1
+ end
+
##
# Methods to check redaction.
#
include ERB::Util
include ApplicationHelper
- def test_printable_name
+ def test_printable_element_name
node = create(:node, :with_history, :version => 2)
node_v1 = node.old_nodes.find_by(:version => 1)
node_v2 = node.old_nodes.find_by(:version => 2)
deleted_node = create(:node, :deleted)
- assert_dom_equal deleted_node.id.to_s, printable_name(deleted_node)
- assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
- assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
- assert_dom_equal node.id.to_s, printable_name(node_v1)
- assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
- assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
- assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
+ assert_dom_equal deleted_node.id.to_s, printable_element_name(deleted_node)
+ assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_element_name(node)
+ assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_element_name(node_v2)
+ assert_dom_equal node.id.to_s, printable_element_name(node_v1)
+ assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_element_name(node_with_ref_without_name)
I18n.with_locale "pt" do
- assert_dom_equal deleted_node.id.to_s, printable_name(deleted_node)
- assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
- assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
- assert_dom_equal node.id.to_s, printable_name(node_v1)
- assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
- assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
- assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
+ assert_dom_equal deleted_node.id.to_s, printable_element_name(deleted_node)
+ assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_element_name(node)
+ assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_element_name(node_v2)
+ assert_dom_equal node.id.to_s, printable_element_name(node_v1)
+ assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_element_name(node_with_ref_without_name)
end
I18n.with_locale "pt-BR" do
- assert_dom_equal deleted_node.id.to_s, printable_name(deleted_node)
- assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
- assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
- assert_dom_equal node.id.to_s, printable_name(node_v1)
- assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
- assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
- assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
+ assert_dom_equal deleted_node.id.to_s, printable_element_name(deleted_node)
+ assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_element_name(node)
+ assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_element_name(node_v2)
+ assert_dom_equal node.id.to_s, printable_element_name(node_v1)
+ assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_element_name(node_with_ref_without_name)
end
I18n.with_locale "de" do
- assert_dom_equal deleted_node.id.to_s, printable_name(deleted_node)
- assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
- assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
- assert_dom_equal node.id.to_s, printable_name(node_v1)
- assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
- assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
- assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
+ assert_dom_equal deleted_node.id.to_s, printable_element_name(deleted_node)
+ assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_element_name(node)
+ assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_element_name(node_v2)
+ assert_dom_equal node.id.to_s, printable_element_name(node_v1)
+ assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_element_name(node_with_ref_without_name)
end
end