From e01a309970af3b91c0c756e6756180e3762fc108 Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Thu, 29 Mar 2012 16:12:01 +0100 Subject: [PATCH] Added test for changeset/download hiding redacted elements --- app/controllers/changeset_controller.rb | 9 +++++---- test/functional/changeset_controller_test.rb | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index 2e6258ea8..34ca24762 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -143,10 +143,11 @@ class ChangesetController < ApplicationController def download changeset = Changeset.find(params[:id]) - # get all the elements in the changeset and stick them in a big array. - elements = [changeset.old_nodes, - changeset.old_ways, - changeset.old_relations].flatten + # get all the elements in the changeset which haven't been redacted + # and stick them in a big array. + elements = [changeset.old_nodes.unredacted, + changeset.old_ways.unredacted, + changeset.old_relations.unredacted].flatten # sort the elements by timestamp and version number, as this is the # almost sensible ordering available. this would be much nicer if diff --git a/test/functional/changeset_controller_test.rb b/test/functional/changeset_controller_test.rb index a586b3dee..8bba90975 100644 --- a/test/functional/changeset_controller_test.rb +++ b/test/functional/changeset_controller_test.rb @@ -1747,6 +1747,22 @@ EOF assert_template 'user/no_such_user' end + ## + # check that the changeset download for a changeset with a redacted + # element in it doesn't contain that element. + def test_diff_download_redacted + changeset_id = changesets(:public_user_first_change).id + + get :download, :id => changeset_id + assert_response :success + + assert_select "osmChange", 1 + # this changeset contains node 17 in versions 1 & 2, but 1 should + # be hidden. + assert_select "osmChange node[id=17]", 1 + assert_select "osmChange node[id=17][version=1]", 0 + end + #------------------------------------------------------------ # utility functions #------------------------------------------------------------ -- 2.39.5