diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb
index 547f9365e2..3802fb8261 100644
--- a/app/abilities/ability.rb
+++ b/app/abilities/ability.rb
@@ -4,8 +4,8 @@ class Ability
include CanCan::Ability
def initialize(user)
- can [:relation, :relation_history, :way, :way_history, :node, :node_history, :query], :browse
- can [:show], [OldNode, OldWay, OldRelation]
+ can [:relation, :way, :node, :query], :browse
+ can [:index, :show], [OldNode, OldWay, OldRelation]
can [:show, :new], Note
can :search, :direction
can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :key, :id], :site
diff --git a/app/controllers/browse_controller.rb b/app/controllers/browse_controller.rb
index db291f6eb8..f69acc158e 100644
--- a/app/controllers/browse_controller.rb
+++ b/app/controllers/browse_controller.rb
@@ -6,7 +6,6 @@ class BrowseController < ApplicationController
before_action -> { check_database_readable(:need_api => true) }
before_action :require_oauth
before_action :update_totp, :only => [:query]
- before_action :require_moderator_for_unredacted_history, :only => [:relation_history, :way_history, :node_history]
around_action :web_timeout
authorize_resource :class => false
@@ -18,14 +17,6 @@ def relation
render :action => "not_found", :status => :not_found
end
- def relation_history
- @type = "relation"
- @feature = Relation.preload(:relation_tags, :old_relations => [:old_tags, { :changeset => [:changeset_tags, :user], :old_members => :member }]).find(params[:id])
- render "history"
- rescue ActiveRecord::RecordNotFound
- render :action => "not_found", :status => :not_found
- end
-
def way
@type = "way"
@feature = Way.preload(:way_tags, :containing_relation_members, :changeset => [:changeset_tags, :user], :nodes => [:node_tags, { :ways => :way_tags }]).find(params[:id])
@@ -34,14 +25,6 @@ def way
render :action => "not_found", :status => :not_found
end
- def way_history
- @type = "way"
- @feature = Way.preload(:way_tags, :old_ways => [:old_tags, { :changeset => [:changeset_tags, :user], :old_nodes => { :node => [:node_tags, :ways] } }]).find(params[:id])
- render "history"
- rescue ActiveRecord::RecordNotFound
- render :action => "not_found", :status => :not_found
- end
-
def node
@type = "node"
@feature = Node.preload(:node_tags, :containing_relation_members, :changeset => [:changeset_tags, :user], :ways => :way_tags).find(params[:id])
@@ -50,19 +33,5 @@ def node
render :action => "not_found", :status => :not_found
end
- def node_history
- @type = "node"
- @feature = Node.preload(:node_tags, :old_nodes => [:old_tags, { :changeset => [:changeset_tags, :user] }]).find(params[:id])
- render "history"
- rescue ActiveRecord::RecordNotFound
- render :action => "not_found", :status => :not_found
- end
-
def query; end
-
- private
-
- def require_moderator_for_unredacted_history
- deny_access(nil) if params[:show_redactions] && !current_user&.moderator?
- end
end
diff --git a/app/controllers/old_nodes_controller.rb b/app/controllers/old_nodes_controller.rb
index 9ef2ef8816..596b579673 100644
--- a/app/controllers/old_nodes_controller.rb
+++ b/app/controllers/old_nodes_controller.rb
@@ -11,6 +11,14 @@ class OldNodesController < ApplicationController
before_action :require_moderator_for_unredacted_history
around_action :web_timeout
+ def index
+ @type = "node"
+ @feature = Node.preload(:node_tags, :old_nodes => [:old_tags, { :changeset => [:changeset_tags, :user] }]).find(params[:id])
+ render "browse/history"
+ rescue ActiveRecord::RecordNotFound
+ render "browse/not_found", :status => :not_found
+ end
+
def show
@type = "node"
@feature = OldNode.preload(:old_tags, :changeset => [:changeset_tags, :user]).find([params[:id], params[:version]])
diff --git a/app/controllers/old_relations_controller.rb b/app/controllers/old_relations_controller.rb
index b9e151a4fd..d57cf25fe0 100644
--- a/app/controllers/old_relations_controller.rb
+++ b/app/controllers/old_relations_controller.rb
@@ -11,6 +11,14 @@ class OldRelationsController < ApplicationController
before_action :require_moderator_for_unredacted_history
around_action :web_timeout
+ def index
+ @type = "relation"
+ @feature = Relation.preload(:relation_tags, :old_relations => [:old_tags, { :changeset => [:changeset_tags, :user], :old_members => :member }]).find(params[:id])
+ render "browse/history"
+ rescue ActiveRecord::RecordNotFound
+ render "browse/not_found", :status => :not_found
+ end
+
def show
@type = "relation"
@feature = OldRelation.preload(:old_tags, :changeset => [:changeset_tags, :user], :old_members => :member).find([params[:id], params[:version]])
diff --git a/app/controllers/old_ways_controller.rb b/app/controllers/old_ways_controller.rb
index dd3c3279fd..de60de317f 100644
--- a/app/controllers/old_ways_controller.rb
+++ b/app/controllers/old_ways_controller.rb
@@ -11,6 +11,14 @@ class OldWaysController < ApplicationController
before_action :require_moderator_for_unredacted_history
around_action :web_timeout
+ def index
+ @type = "way"
+ @feature = Way.preload(:way_tags, :old_ways => [:old_tags, { :changeset => [:changeset_tags, :user], :old_nodes => { :node => [:node_tags, :ways] } }]).find(params[:id])
+ render "browse/history"
+ rescue ActiveRecord::RecordNotFound
+ render "browse/not_found", :status => :not_found
+ end
+
def show
@type = "way"
@feature = OldWay.preload(:old_tags, :changeset => [:changeset_tags, :user], :old_nodes => { :node => [:node_tags, :ways] }).find([params[:id], params[:version]])
diff --git a/app/views/browse/_version_actions.erb b/app/views/browse/_version_actions.erb
index 3d4e4be13e..63cadeb3fa 100644
--- a/app/views/browse/_version_actions.erb
+++ b/app/views/browse/_version_actions.erb
@@ -21,7 +21,7 @@
<% end %>
·
<% end %>
- <%= link_to t("browse.view_history"), :controller => :browse, :action => "#{@type}_history" %>
+ <%= link_to t("browse.view_history"), :action => :index %>
<% unless @feature.latest_version? %>
·
<%= link_to({ :version => @feature.version + 1 }, { :class => "icon-link" }) do %>
diff --git a/app/views/browse/feature.html.erb b/app/views/browse/feature.html.erb
index 9ee9f807fb..7f96b74b98 100644
--- a/app/views/browse/feature.html.erb
+++ b/app/views/browse/feature.html.erb
@@ -17,10 +17,10 @@
<% end %>
·
<% end %>
- <%= link_to t("browse.view_history"), :action => "#{@type}_history" %>
+ <%= link_to t("browse.view_history"), :controller => "old_#{@type.pluralize}" %>
<% if current_user&.moderator? %>
·
- <%= link_to(t("browse.view_unredacted_history"), :action => "#{@type}_history", :params => { :show_redactions => true }) %>
+ <%= link_to(t("browse.view_unredacted_history"), :controller => "old_#{@type.pluralize}", :params => { :show_redactions => true }) %>
<% end %>
<% if @feature.version > 1 %>
·
diff --git a/app/views/browse/history.html.erb b/app/views/browse/history.html.erb
index b557c339b1..d257d25a2d 100644
--- a/app/views/browse/history.html.erb
+++ b/app/views/browse/history.html.erb
@@ -2,17 +2,17 @@
<%= 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 %>
+<%= render :partial => "browse/#{@type}", :collection => @feature.send(:"old_#{@type}s").reverse %>
- <%= link_to(t("browse.download_xml"), :controller => "api/old_#{@type.pluralize}", :action => "history") %>
+ <%= link_to t("browse.download_xml"), :controller => "api/old_#{@type.pluralize}", :action => "history" %>
·
- <%= link_to(t("browse.view_details"), :action => @type) %>
+ <%= link_to t("browse.view_details"), :controller => "browse", :action => @type %>
<% if params[:show_redactions] %>
·
- <%= link_to(t("browse.view_history"), :action => "#{@type}_history") %>
+ <%= link_to t("browse.view_history") %>
<% elsif current_user&.moderator? %>
·
- <%= link_to(t("browse.view_unredacted_history"), :action => "#{@type}_history", :params => { :show_redactions => true }) %>
+ <%= link_to t("browse.view_unredacted_history"), :params => { :show_redactions => true } %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 842da82b3d..819baf65a9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -110,13 +110,13 @@
# Data browsing
get "/way/:id" => "browse#way", :id => /\d+/, :as => :way
- get "/way/:id/history" => "browse#way_history", :id => /\d+/, :as => :way_history
+ get "/way/:id/history" => "old_ways#index", :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
+ get "/node/:id/history" => "old_nodes#index", :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
+ get "/relation/:id/history" => "old_relations#index", :id => /\d+/, :as => :relation_history
resources :old_relations, :path => "/relation/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
resources :changesets, :path => "changeset", :id => /\d+/, :only => :show
get "/changeset/:id/comments/feed" => "changeset_comments#index", :as => :changeset_comments_feed, :id => /\d*/, :defaults => { :format => "rss" }
diff --git a/test/controllers/browse_controller_test.rb b/test/controllers/browse_controller_test.rb
index fcdd7c7521..4bdad7a4d0 100644
--- a/test/controllers/browse_controller_test.rb
+++ b/test/controllers/browse_controller_test.rb
@@ -8,26 +8,14 @@ def test_routes
{ :path => "/node/1", :method => :get },
{ :controller => "browse", :action => "node", :id => "1" }
)
- assert_routing(
- { :path => "/node/1/history", :method => :get },
- { :controller => "browse", :action => "node_history", :id => "1" }
- )
assert_routing(
{ :path => "/way/1", :method => :get },
{ :controller => "browse", :action => "way", :id => "1" }
)
- assert_routing(
- { :path => "/way/1/history", :method => :get },
- { :controller => "browse", :action => "way_history", :id => "1" }
- )
assert_routing(
{ :path => "/relation/1", :method => :get },
{ :controller => "browse", :action => "relation", :id => "1" }
)
- assert_routing(
- { :path => "/relation/1/history", :method => :get },
- { :controller => "browse", :action => "relation_history", :id => "1" }
- )
assert_routing(
{ :path => "/query", :method => :get },
{ :controller => "browse", :action => "query" }
@@ -53,14 +41,6 @@ def test_multiple_version_relation_links
assert_select ".secondary-actions a[href='#{old_relation_path relation, 2}']", :count => 1
end
- def test_read_relation_history
- relation = create(:relation, :with_history)
- sidebar_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
way = create(:way)
sidebar_browse_check :way_path, way.id, "browse/feature"
@@ -80,14 +60,6 @@ def test_multiple_version_way_links
assert_select ".secondary-actions a[href='#{old_way_path way, 2}']", :count => 1
end
- def test_read_way_history
- way = create(:way, :with_history)
- sidebar_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)
sidebar_browse_check :node_path, node.id, "browse/feature"
@@ -116,14 +88,6 @@ def test_read_deleted_node
assert_select "a[href='#{api_node_path node}']", :count => 0
end
- def test_read_node_history
- node = create(:node, :with_history)
- sidebar_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
-
##
# Methods to check redaction.
#
@@ -148,109 +112,6 @@ def test_redacted_node
assert_select ".browse-section.browse-node .longitude", 0
end
- def test_redacted_node_history
- node = create(:node, :with_history, :deleted, :version => 2)
- node_v1 = node.old_nodes.find_by(:version => 1)
- node_v1.redact!(create(:redaction))
-
- get node_history_path(:id => node)
- assert_response :success
- assert_template "browse/history"
-
- # there are 2 revisions of the redacted node, but only one
- # should be showing details here.
- assert_select ".browse-section", 2
- assert_select ".browse-section.browse-redacted", 1
- assert_select ".browse-section.browse-node", 1
- assert_select ".browse-section.browse-node .latitude", 0
- assert_select ".browse-section.browse-node .longitude", 0
- end
-
- def test_redacted_node_unredacted_history
- session_for(create(:moderator_user))
- node = create(:node, :with_history, :deleted, :version => 2)
- node_v1 = node.old_nodes.find_by(:version => 1)
- node_v1.redact!(create(:redaction))
-
- get node_history_path(:id => node, :params => { :show_redactions => true })
- assert_response :success
- assert_template "browse/history"
-
- assert_select ".browse-section", 2
- assert_select ".browse-section.browse-redacted", 0
- assert_select ".browse-section.browse-node", 2
- end
-
- def test_redacted_way_history
- way = create(:way, :with_history, :version => 4)
- way_v1 = way.old_ways.find_by(:version => 1)
- way_v1.redact!(create(:redaction))
- way_v3 = way.old_ways.find_by(:version => 3)
- way_v3.redact!(create(:redaction))
-
- get way_history_path(:id => way)
- assert_response :success
- assert_template "browse/history"
-
- # there are 4 revisions of the redacted way, but only 2
- # should be showing details here.
- assert_select ".browse-section", 4
- assert_select ".browse-section.browse-redacted", 2
- assert_select ".browse-section.browse-way", 2
- end
-
- def test_redacted_way_unredacted_history
- session_for(create(:moderator_user))
- way = create(:way, :with_history, :version => 4)
- way_v1 = way.old_ways.find_by(:version => 1)
- way_v1.redact!(create(:redaction))
- way_v3 = way.old_ways.find_by(:version => 3)
- way_v3.redact!(create(:redaction))
-
- get way_history_path(:id => way, :params => { :show_redactions => true })
- assert_response :success
- assert_template "browse/history"
-
- assert_select ".browse-section", 4
- assert_select ".browse-section.browse-redacted", 0
- assert_select ".browse-section.browse-way", 4
- end
-
- def test_redacted_relation_history
- relation = create(:relation, :with_history, :version => 4)
- relation_v1 = relation.old_relations.find_by(:version => 1)
- relation_v1.redact!(create(:redaction))
- relation_v3 = relation.old_relations.find_by(:version => 3)
- relation_v3.redact!(create(:redaction))
-
- get relation_history_path(:id => relation)
- assert_response :success
- assert_template "browse/history"
-
- # there are 4 revisions of the redacted relation, but only 2
- # should be showing details here.
- assert_select ".browse-section", 4
- assert_select ".browse-section.browse-redacted", 2
- assert_select ".browse-section.browse-relation", 2
- end
-
- def test_redacted_relation_unredacted_history
- session_for(create(:moderator_user))
- relation = create(:relation, :with_history, :version => 4)
- relation_v1 = relation.old_relations.find_by(:version => 1)
- relation_v1.redact!(create(:redaction))
- relation_v3 = relation.old_relations.find_by(:version => 3)
- relation_v3.redact!(create(:redaction))
-
- get relation_history_path(:id => relation, :params => { :show_redactions => true })
- assert_response :success
- assert_template "browse/history"
-
- assert_select ".browse-section", 4
- assert_select ".browse-section.browse-redacted", 0
- assert_select ".browse-section.browse-relation", 4
- end
-
def test_query
get query_path
assert_response :success
@@ -285,56 +146,4 @@ def test_moderator_user_feature_page_secondary_actions
assert_select ".secondary-actions a", :text => "View History", :count => 1
assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 1
end
-
- def test_anonymous_user_history_page_secondary_actions
- node = create(:node, :with_history)
- get node_history_path(:id => node)
- assert_response :success
- assert_select ".secondary-actions a", :text => "View Details", :count => 1
- assert_select ".secondary-actions a", :text => "View History", :count => 0
- assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
- end
-
- def test_regular_user_history_page_secondary_actions
- session_for(create(:user))
- node = create(:node, :with_history)
- get node_history_path(:id => node)
- assert_response :success
- assert_select ".secondary-actions a", :text => "View Details", :count => 1
- assert_select ".secondary-actions a", :text => "View History", :count => 0
- assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
- end
-
- def test_moderator_user_history_page_secondary_actions
- session_for(create(:moderator_user))
- node = create(:node, :with_history)
- get node_history_path(:id => node)
- assert_response :success
- assert_select ".secondary-actions a", :text => "View Details", :count => 1
- assert_select ".secondary-actions a", :text => "View History", :count => 0
- assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 1
- end
-
- def test_anonymous_user_unredacted_history_page_secondary_actions
- node = create(:node, :with_history)
- get node_history_path(:id => node, :params => { :show_redactions => true })
- assert_response :redirect
- end
-
- def test_regular_user_unredacted_history_page_secondary_actions
- session_for(create(:user))
- node = create(:node, :with_history)
- get node_history_path(:id => node, :params => { :show_redactions => true })
- assert_response :redirect
- end
-
- def test_moderator_user_unredacted_history_page_secondary_actions
- session_for(create(:moderator_user))
- node = create(:node, :with_history)
- get node_history_path(:id => node, :params => { :show_redactions => true })
- assert_response :success
- assert_select ".secondary-actions a", :text => "View Details", :count => 1
- assert_select ".secondary-actions a", :text => "View History", :count => 1
- assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
- end
end
diff --git a/test/controllers/old_nodes_controller_test.rb b/test/controllers/old_nodes_controller_test.rb
index 81a98766ab..bb4dffdc6e 100644
--- a/test/controllers/old_nodes_controller_test.rb
+++ b/test/controllers/old_nodes_controller_test.rb
@@ -2,12 +2,109 @@
class OldNodesControllerTest < ActionDispatch::IntegrationTest
def test_routes
+ assert_routing(
+ { :path => "/node/1/history", :method => :get },
+ { :controller => "old_nodes", :action => "index", :id => "1" }
+ )
assert_routing(
{ :path => "/node/1/history/2", :method => :get },
{ :controller => "old_nodes", :action => "show", :id => "1", :version => "2" }
)
end
+ def test_history
+ node = create(:node, :with_history)
+ sidebar_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_history_of_redacted
+ node = create(:node, :with_history, :deleted, :version => 2)
+ node_v1 = node.old_nodes.find_by(:version => 1)
+ node_v1.redact!(create(:redaction))
+
+ get node_history_path(:id => node)
+ assert_response :success
+ assert_template "browse/history"
+
+ # there are 2 revisions of the redacted node, but only one
+ # should be showing details here.
+ assert_select ".browse-section", 2
+ assert_select ".browse-section.browse-redacted", 1
+ assert_select ".browse-section.browse-node", 1
+ assert_select ".browse-section.browse-node .latitude", 0
+ assert_select ".browse-section.browse-node .longitude", 0
+ end
+
+ def test_unredacted_history_of_redacted
+ session_for(create(:moderator_user))
+ node = create(:node, :with_history, :deleted, :version => 2)
+ node_v1 = node.old_nodes.find_by(:version => 1)
+ node_v1.redact!(create(:redaction))
+
+ get node_history_path(:id => node, :params => { :show_redactions => true })
+ assert_response :success
+ assert_template "browse/history"
+
+ assert_select ".browse-section", 2
+ assert_select ".browse-section.browse-redacted", 0
+ assert_select ".browse-section.browse-node", 2
+ end
+
+ def test_anonymous_user_history_page_secondary_actions
+ node = create(:node, :with_history)
+ get node_history_path(:id => node)
+ assert_response :success
+ assert_select ".secondary-actions a", :text => "View Details", :count => 1
+ assert_select ".secondary-actions a", :text => "View History", :count => 0
+ assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
+ end
+
+ def test_regular_user_history_page_secondary_actions
+ session_for(create(:user))
+ node = create(:node, :with_history)
+ get node_history_path(:id => node)
+ assert_response :success
+ assert_select ".secondary-actions a", :text => "View Details", :count => 1
+ assert_select ".secondary-actions a", :text => "View History", :count => 0
+ assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
+ end
+
+ def test_moderator_user_history_page_secondary_actions
+ session_for(create(:moderator_user))
+ node = create(:node, :with_history)
+ get node_history_path(:id => node)
+ assert_response :success
+ assert_select ".secondary-actions a", :text => "View Details", :count => 1
+ assert_select ".secondary-actions a", :text => "View History", :count => 0
+ assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 1
+ end
+
+ def test_anonymous_user_unredacted_history_page_secondary_actions
+ node = create(:node, :with_history)
+ get node_history_path(:id => node, :params => { :show_redactions => true })
+ assert_response :redirect
+ end
+
+ def test_regular_user_unredacted_history_page_secondary_actions
+ session_for(create(:user))
+ node = create(:node, :with_history)
+ get node_history_path(:id => node, :params => { :show_redactions => true })
+ assert_response :redirect
+ end
+
+ def test_moderator_user_unredacted_history_page_secondary_actions
+ session_for(create(:moderator_user))
+ node = create(:node, :with_history)
+ get node_history_path(:id => node, :params => { :show_redactions => true })
+ assert_response :success
+ assert_select ".secondary-actions a", :text => "View Details", :count => 1
+ assert_select ".secondary-actions a", :text => "View History", :count => 1
+ assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
+ end
+
def test_visible_with_one_version
node = create(:node, :with_history)
get old_node_path(node, 1)
diff --git a/test/controllers/old_relations_controller_test.rb b/test/controllers/old_relations_controller_test.rb
index 66a960e6f7..a766f8b8db 100644
--- a/test/controllers/old_relations_controller_test.rb
+++ b/test/controllers/old_relations_controller_test.rb
@@ -2,12 +2,59 @@
class OldRelationsControllerTest < ActionDispatch::IntegrationTest
def test_routes
+ assert_routing(
+ { :path => "/relation/1/history", :method => :get },
+ { :controller => "old_relations", :action => "index", :id => "1" }
+ )
assert_routing(
{ :path => "/relation/1/history/2", :method => :get },
{ :controller => "old_relations", :action => "show", :id => "1", :version => "2" }
)
end
+ def test_history
+ relation = create(:relation, :with_history)
+ sidebar_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_history_of_redacted
+ relation = create(:relation, :with_history, :version => 4)
+ relation_v1 = relation.old_relations.find_by(:version => 1)
+ relation_v1.redact!(create(:redaction))
+ relation_v3 = relation.old_relations.find_by(:version => 3)
+ relation_v3.redact!(create(:redaction))
+
+ get relation_history_path(:id => relation)
+ assert_response :success
+ assert_template "browse/history"
+
+ # there are 4 revisions of the redacted relation, but only 2
+ # should be showing details here.
+ assert_select ".browse-section", 4
+ assert_select ".browse-section.browse-redacted", 2
+ assert_select ".browse-section.browse-relation", 2
+ end
+
+ def test_unredacted_history_of_redacted
+ session_for(create(:moderator_user))
+ relation = create(:relation, :with_history, :version => 4)
+ relation_v1 = relation.old_relations.find_by(:version => 1)
+ relation_v1.redact!(create(:redaction))
+ relation_v3 = relation.old_relations.find_by(:version => 3)
+ relation_v3.redact!(create(:redaction))
+
+ get relation_history_path(:id => relation, :params => { :show_redactions => true })
+ assert_response :success
+ assert_template "browse/history"
+
+ assert_select ".browse-section", 4
+ assert_select ".browse-section.browse-redacted", 0
+ assert_select ".browse-section.browse-relation", 4
+ end
+
def test_visible_with_one_version
relation = create(:relation, :with_history)
get old_relation_path(relation, 1)
diff --git a/test/controllers/old_ways_controller_test.rb b/test/controllers/old_ways_controller_test.rb
index 65e26ef20a..6455343cfa 100644
--- a/test/controllers/old_ways_controller_test.rb
+++ b/test/controllers/old_ways_controller_test.rb
@@ -2,12 +2,59 @@
class OldWaysControllerTest < ActionDispatch::IntegrationTest
def test_routes
+ assert_routing(
+ { :path => "/way/1/history", :method => :get },
+ { :controller => "old_ways", :action => "index", :id => "1" }
+ )
assert_routing(
{ :path => "/way/1/history/2", :method => :get },
{ :controller => "old_ways", :action => "show", :id => "1", :version => "2" }
)
end
+ def test_history
+ way = create(:way, :with_history)
+ sidebar_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_history_of_redacted
+ way = create(:way, :with_history, :version => 4)
+ way_v1 = way.old_ways.find_by(:version => 1)
+ way_v1.redact!(create(:redaction))
+ way_v3 = way.old_ways.find_by(:version => 3)
+ way_v3.redact!(create(:redaction))
+
+ get way_history_path(:id => way)
+ assert_response :success
+ assert_template "browse/history"
+
+ # there are 4 revisions of the redacted way, but only 2
+ # should be showing details here.
+ assert_select ".browse-section", 4
+ assert_select ".browse-section.browse-redacted", 2
+ assert_select ".browse-section.browse-way", 2
+ end
+
+ def test_unredacted_history_of_redacted
+ session_for(create(:moderator_user))
+ way = create(:way, :with_history, :version => 4)
+ way_v1 = way.old_ways.find_by(:version => 1)
+ way_v1.redact!(create(:redaction))
+ way_v3 = way.old_ways.find_by(:version => 3)
+ way_v3.redact!(create(:redaction))
+
+ get way_history_path(:id => way, :params => { :show_redactions => true })
+ assert_response :success
+ assert_template "browse/history"
+
+ assert_select ".browse-section", 4
+ assert_select ".browse-section.browse-redacted", 0
+ assert_select ".browse-section.browse-way", 4
+ end
+
def test_visible_with_one_version
way = create(:way, :with_history)
get old_way_path(way, 1)