- def do_redact_node(node, redaction, headers = {})
- get node_version_path(:id => node.node_id, :version => node.version), :headers => headers
- assert_response :success, "should be able to get version #{node.version} of node #{node.node_id}."
-
- # now redact it
- post node_version_redact_path(:id => node.node_id, :version => node.version), :params => { :redaction => redaction.id }, :headers => headers
- end
-
- def check_current_version(node_id)
- # get the current version of the node
- current_node = with_controller(NodesController.new) do
- get api_node_path(:id => node_id)
- assert_response :success, "cant get current node #{node_id}"
- Node.from_xml(@response.body)
- end
- assert_not_nil current_node, "getting node #{node_id} returned nil"
-
- # get the "old" version of the node from the old_node interface
- get node_version_path(:id => node_id, :version => current_node.version)
- assert_response :success, "cant get old node #{node_id}, v#{current_node.version}"
- old_node = Node.from_xml(@response.body)
-
- # check the nodes are the same
- assert_nodes_are_equal current_node, old_node
- end
-
- ##
- # returns a 16 character long string with some nasty characters in it.
- # this ought to stress-test the tag handling as well as the versioning.
- def random_string
- letters = [["!", '"', "$", "&", ";", "@"],
- ("a".."z").to_a,
- ("A".."Z").to_a,
- ("0".."9").to_a].flatten
- (1..16).map { |_i| letters[rand(letters.length)] }.join
- end
-
- ##
- # truncate a floating point number to the scale that it is stored in
- # the database. otherwise rounding errors can produce failing unit
- # tests when they shouldn't.
- def precision(f)
- (f * GeoRecord::SCALE).round.to_f / GeoRecord::SCALE
- end
-
- def propagate_tags(node, old_node)
- node.tags.each do |k, v|
- create(:old_node_tag, :old_node => old_node, :k => k, :v => v)
- end