annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
- argon2 (2.3.0)
+ argon2 (2.3.2)
ffi (~> 1.15)
ffi-compiler (~> 1.0)
ast (2.4.2)
autoprefixer-rails (10.4.19.0)
execjs (~> 2)
aws-eventstream (1.3.0)
- aws-partitions (1.1044.0)
- aws-sdk-core (3.217.1)
+ aws-partitions (1.1049.0)
+ aws-sdk-core (3.218.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
+ base64
jmespath (~> 1, >= 1.6.1)
- aws-sdk-kms (1.97.0)
+ aws-sdk-kms (1.98.0)
aws-sdk-core (~> 3, >= 3.216.0)
aws-sigv4 (~> 1.5)
- aws-sdk-s3 (1.179.0)
+ aws-sdk-s3 (1.180.0)
aws-sdk-core (~> 3, >= 3.216.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
railties (>= 5)
doorkeeper-i18n (5.2.7)
doorkeeper (>= 5.2)
- doorkeeper-openid_connect (1.8.10)
+ doorkeeper-openid_connect (1.8.11)
doorkeeper (>= 5.5, < 5.9)
jwt (>= 2.5)
+ ostruct (>= 0.5)
drb (2.2.1)
dry-configurable (1.3.0)
dry-core (~> 1.1)
image_optim (~> 0.24)
railties
sprockets
- image_processing (1.13.0)
- mini_magick (>= 4.9.5, < 5)
+ image_processing (1.14.0)
+ mini_magick (>= 4.9.5, < 6)
ruby-vips (>= 2.0.17, < 3)
image_size (3.4.0)
in_threads (1.6.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
- json (2.9.1)
+ json (2.10.1)
jwt (2.10.1)
base64
kgio (2.11.4)
marcel (1.0.4)
matrix (0.4.2)
maxminddb (0.1.22)
- mini_magick (4.13.2)
+ mini_magick (5.1.2)
+ benchmark
+ logger
mini_mime (1.1.5)
mini_portile2 (2.8.8)
mini_racer (0.9.0)
minitest (5.25.4)
minitest-focus (1.4.0)
minitest (>= 4, < 6)
- msgpack (1.7.5)
+ msgpack (1.8.0)
multi_json (1.15.0)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
nap (1.1.0)
net-http (0.6.0)
uri
- net-imap (0.5.5)
+ net-imap (0.5.6)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
- net-smtp (0.5.0)
+ net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.2)
iniparse (~> 1.4)
rexml (>= 3.3.9)
parallel (1.26.3)
- parser (3.3.7.0)
+ parser (3.3.7.1)
ast (~> 2.4.1)
racc
pg (1.5.9)
rb-inotify (0.11.1)
ffi (~> 1.0)
rchardet (1.9.0)
- rdoc (6.11.0)
+ rdoc (6.12.0)
psych (>= 4.0.0)
regexp_parser (2.10.0)
reline (0.6.0)
rouge (4.5.1)
rtlcss (0.2.1)
mini_racer (>= 0.6.3)
- rubocop (1.71.1)
+ rubocop (1.71.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
rubocop (~> 1.0)
ruby-openid (2.9.2)
ruby-progressbar (1.13.0)
- ruby-vips (2.2.2)
+ ruby-vips (2.2.3)
ffi (~> 1.12)
logger
rubyzip (2.4.1)
simpleidn
vendorer (0.2.0)
version_gem (1.1.4)
- webmock (3.24.0)
+ webmock (3.25.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
can [:read, :download], Changeset
can :read, Tracepoint
can :read, User
- can :read, [Node, Way, Relation]
- can [:history, :read], [OldNode, OldWay, OldRelation]
+ can :read, [Node, Way, Relation, OldNode, OldWay, OldRelation]
can :read, UserBlock
if user&.active?
*/
setTimeout(function () {
$("header").children(":visible").each(function (i, e) {
- headerWidth = headerWidth + $(e).outerWidth();
+ headerWidth += $(e).outerWidth();
});
$("body").addClass("compact-nav");
$("header").children(":visible").each(function (i, e) {
- compactWidth = compactWidth + $(e).outerWidth();
+ compactWidth += $(e).outerWidth();
});
$("body").removeClass("compact-nav");
function getDirectionsEndpointCoordinatesFromInput(input) {
if (input.attr("data-lat") && input.attr("data-lon")) {
return input.attr("data-lat") + "," + input.attr("data-lon");
- } else {
- return $(input).val();
}
+ return $(input).val();
}
var updateMenu = function updateMenu() {
},
error: function (XMLHttpRequest, textStatus) {
dataLoader = null;
- if (textStatus === "abort") { return; }
+ if (textStatus === "abort") return;
function closeError() {
$("#browse_status").empty();
}
}
- if (tags.name) {
- return tags.name;
- } else if (tags.ref) {
- return tags.ref;
- } else if (tags["addr:housename"]) {
- return tags["addr:housename"];
- } else if (tags["addr:housenumber"] && tags["addr:street"]) {
+ for (const key of ["name", "ref", "addr:housename"]) {
+ if (tags[key]) {
+ return tags[key];
+ }
+ }
+
+ if (tags["addr:housenumber"] && tags["addr:street"]) {
return tags["addr:housenumber"] + " " + tags["addr:street"];
- } else {
- return "#" + feature.id;
}
+ return "#" + feature.id;
}
function featureGeometry(feature) {
.hide();
if (marker) map.removeLayer(marker);
- marker = L.circle(latlng, Object.assign({
+ marker = L.circle(latlng, {
radius: radius,
- className: "query-marker"
- }, featureStyle)).addTo(map);
+ className: "query-marker",
+ ...featureStyle
+ }).addTo(map);
runQuery(latlng, radius, nearby, $("#query-nearby"), false);
runQuery(latlng, radius, isin, $("#query-isin"), true, compareSize);
L.OSM.locate = function (options) {
- var control = L.control.locate(Object.assign({
+ var control = L.control.locate({
icon: "icon geolocate",
iconLoading: "icon geolocate",
strings: {
popup: function (options) {
return I18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance });
}
- }
- }, options));
+ },
+ ...options
+ });
control.onAdd = function (map) {
var container = Object.getPrototypeOf(this).onAdd.apply(this, [map]);
},
mapParams: function (search) {
- var params = OSM.params(search), mapParams = {};
+ var params = OSM.params(search),
+ mapParams = {};
if (params.mlon && params.mlat) {
mapParams.marker = true;
before_action :set_request_formats
def index
- relation_ids = RelationMember.where(:member_type => "Node", :member_id => params[:node_id]).collect(&:relation_id).uniq
-
- @relations = []
-
- Relation.find(relation_ids).each do |relation|
- @relations << relation if relation.visible
- end
+ @relations = Relation
+ .visible
+ .where(:id => RelationMember.where(
+ :member_type => "Node",
+ :member_id => params[:node_id]
+ ).select(:relation_id))
# Render the result
respond_to do |format|
# :node_id parameter. note that this used to return deleted ways as well, but
# this seemed not to be the expected behaviour, so it was removed.
def index
- way_ids = WayNode.where(:node_id => params[:node_id]).collect { |ws| ws.id[0] }.uniq
-
- @ways = Way.where(:id => way_ids, :visible => true)
+ @ways = Way
+ .visible
+ .where(:id => WayNode.where(
+ :node_id => params[:node_id]
+ ).select(:way_id))
# Render the result
respond_to do |format|
module Api
class OldElementsController < ApiController
before_action :check_api_writable, :only => [:redact]
- before_action :setup_user_auth, :only => [:history, :show]
+ before_action :setup_user_auth, :only => [:index, :show]
before_action :authorize, :only => [:redact]
authorize_resource
- before_action :lookup_old_element, :except => [:history]
- before_action :lookup_old_element_versions, :only => [:history]
+ before_action :lookup_old_element, :except => [:index]
+ before_action :lookup_old_element_versions, :only => [:index]
before_action :set_request_formats, :except => [:redact]
- def history
+ def index
# the .where() method used in the lookup_old_element_versions
# call won't throw an error if no records are found, so we have
# to do that ourselves.
private
def lookup_old_element
- @old_element = OldNode.find([params[:id], params[:version]])
+ @old_element = OldNode.find([params[:node_id], params[:version]])
end
def lookup_old_element_versions
- @elements = OldNode.where(:node_id => params[:id]).order(:version)
+ @elements = OldNode.where(:node_id => params[:node_id]).order(:version)
end
end
end
private
def lookup_old_element
- @old_element = OldRelation.find([params[:id], params[:version]])
+ @old_element = OldRelation.find([params[:relation_id], params[:version]])
end
def lookup_old_element_versions
- @elements = OldRelation.where(:relation_id => params[:id]).order(:version)
+ @elements = OldRelation.where(:relation_id => params[:relation_id]).order(:version)
end
end
end
private
def lookup_old_element
- @old_element = OldWay.find([params[:id], params[:version]])
+ @old_element = OldWay.find([params[:way_id], params[:version]])
end
def lookup_old_element_versions
- @elements = OldWay.where(:way_id => params[:id]).order(:version)
+ @elements = OldWay.where(:way_id => params[:way_id]).order(:version)
end
end
end
before_action :set_request_formats
def index
- relation_ids = RelationMember.where(:member_type => "Relation", :member_id => params[:relation_id]).collect(&:relation_id).uniq
-
- @relations = []
-
- Relation.find(relation_ids).each do |relation|
- @relations << relation if relation.visible
- end
+ @relations = Relation
+ .visible
+ .where(:id => RelationMember.where(
+ :member_type => "Relation",
+ :member_id => params[:relation_id]
+ ).select(:relation_id))
# Render the result
respond_to do |format|
before_action :set_request_formats
def index
- relation_ids = RelationMember.where(:member_type => "Way", :member_id => params[:way_id]).collect(&:relation_id).uniq
-
- @relations = []
-
- Relation.find(relation_ids).each do |relation|
- @relations << relation if relation.visible
- end
+ @relations = Relation
+ .visible
+ .where(:id => RelationMember.where(
+ :member_type => "Way",
+ :member_id => params[:way_id]
+ ).select(:relation_id))
# Render the result
respond_to do |format|
request.content_security_policy = policy
- case Settings.status
- when "database_offline", "api_offline"
- flash.now[:warning] = t("layouts.osm_offline")
- when "database_readonly", "api_readonly"
- flash.now[:warning] = t("layouts.osm_read_only")
- end
+ flash.now[:warning] = { :partial => "layouts/offline_flash" } unless api_status == "online"
request.xhr? ? "xhr" : "map"
end
rescue ActiveRecord::RecordNotFound
# don't try and derive a location from a missing/deleted object
end
+
+ if api_status != "online"
+ flash.now[:warning] = { :partial => "layouts/offline_flash" }
+ elsif current_user && !current_user.data_public?
+ flash.now[:warning] = { :partial => "not_public_flash" }
+ else
+ @enable_editor = true
+ end
end
def copyright
def export; end
def offline
- flash.now[:warning] = if Settings.status == "database_offline"
- t("layouts.osm_offline")
- else
- t("layouts.osm_read_only")
- end
+ flash.now[:warning] = { :partial => "layouts/offline_flash" }
render :html => nil, :layout => true
end
--- /dev/null
+<div class="d-flex flex-column gap-2">
+ <% if %w[database_offline api_offline].include? Settings.status %>
+ <p class="mb-0">
+ <%= t(".osm_offline") %>
+ </p>
+ <% elsif %w[database_readonly api_readonly].include? Settings.status %>
+ <p class="mb-0">
+ <%= t(".osm_read_only") %>
+ </p>
+ <% end %>
+
+ <% if Settings.status_expected_restore_date %>
+ <% expected_restore_time = Time.parse(Settings.status_expected_restore_date).utc %>
+ <% if expected_restore_time > Time.now.utc %>
+ <p class="mb-0">
+ <%= t ".expected_restore_html", :time => friendly_date(expected_restore_time) %>
+ </p>
+ <% end %>
+ <% end %>
+
+ <% if Settings.status_announcement_url %>
+ <p class="mb-0">
+ <%= link_to t(".announcement"), Settings.status_announcement_url %>
+ </p>
+ <% end %>
+</div>
<%= link_to t("browse.view_details"), :controller => @type.pluralize, :action => :show %>
<% if !@feature.redacted? %>
·
- <%= link_to t("browse.download_xml"), :controller => "api/old_#{@type.pluralize}", :action => :show %>
+ <%= link_to t("browse.download_xml"), send(:"api_#{@type}_version_path", *@feature.id) %>
<% elsif current_user&.moderator? %>
·
<% if !params[:show_redactions] %>
<%= render :partial => "browse/#{@type}", :collection => @feature.send(:"old_#{@type}s").reverse %>
<div class='secondary-actions'>
- <%= link_to t("browse.download_xml"), :controller => "api/old_#{@type.pluralize}", :action => "history" %>
+ <%= link_to t("browse.download_xml"), send(:"api_#{@type}_versions_path", @feature.id) %>
·
<%= link_to t("browse.view_details"), :controller => @type.pluralize, :action => :show %>
<% if params[:show_redactions] %>
--- /dev/null
+<p><%= t ".not_public" %></p>
+<p><%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %></p>
+<p><%= t ".anon_edits_html", :link => link_to(t(".anon_edits_link_text"), t(".anon_edits_link")) %></p>
<% content_for :content do %>
- <% if Settings.status == "database_offline" or Settings.status == "api_offline" %>
- <div class="alert alert-warning text-center">
- <p class="my-2"><%= t "layouts.osm_offline" %></p>
- </div>
- <% elsif Settings.status == "database_readonly" or Settings.status == "api_readonly" %>
- <div class="alert alert-warning text-center">
- <p class="my-2"><%= t "layouts.osm_read_only" %></p>
- </div>
- <% elsif !current_user.data_public? %>
- <p><%= t ".not_public" %></p>
- <p><%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %></p>
- <p><%= t ".anon_edits_html", :link => link_to(t(".anon_edits_link_text"), t(".anon_edits_link")) %></p>
- <% else %>
+ <% if @enable_editor %>
<%= render :partial => preferred_editor %>
<% end %>
<% end %>
+/* eslint sort-keys: ["error", "asc", {minKeys: 5}] */
+
const globals = require("globals");
const js = require("@eslint/js");
const erb = require("eslint-plugin-erb");
module.exports = [
js.configs.recommended,
erb.configs.recommended,
+ {
+ ignores: [
+ "app/assets/javascripts/i18n/",
+ "coverage/assets/",
+ "public/assets/",
+ "vendor/"
+ ]
+ },
{
plugins: {
"@stylistic": stylisticJs
Cookies: "readonly",
I18n: "readonly",
L: "readonly",
- OSM: "writable",
Matomo: "readonly",
+ OSM: "writable",
Turbo: "readonly",
updateLinks: "readonly"
}
"@stylistic/eol-last": "error",
"@stylistic/func-call-spacing": "error",
"@stylistic/indent": ["error", 2, {
- SwitchCase: 1,
- VariableDeclarator: "first",
+ CallExpression: { arguments: "first" },
FunctionDeclaration: { parameters: "first" },
FunctionExpression: { parameters: "first" },
- CallExpression: { arguments: "first" }
+ SwitchCase: 1,
+ VariableDeclarator: "first"
}],
"@stylistic/key-spacing": "error",
"@stylistic/keyword-spacing": "error",
+ "@stylistic/max-statements-per-line": "error",
"@stylistic/no-floating-decimal": "error",
"@stylistic/no-mixed-operators": "error",
- "@stylistic/no-multiple-empty-lines": "error",
"@stylistic/no-multi-spaces": "error",
+ "@stylistic/no-multiple-empty-lines": "error",
"@stylistic/no-trailing-spaces": "error",
"@stylistic/no-whitespace-before-property": "error",
"@stylistic/object-curly-newline": ["error", { consistent: true }],
"@stylistic/object-curly-spacing": ["error", "always"],
"@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
+ "@stylistic/one-var-declaration-per-line": "error",
"@stylistic/operator-linebreak": ["error", "after"],
"@stylistic/padded-blocks": ["error", "never"],
"@stylistic/quote-props": ["error", "consistent-as-needed", { keywords: true, numbers: true }],
"no-caller": "error",
"no-console": "warn",
"no-div-regex": "error",
+ "no-else-return": ["error", { allowElseIf: false }],
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-iterator": "error",
- "no-labels": "error",
"no-label-var": "error",
+ "no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "off",
"no-unused-vars": ["error", { caughtErrors: "none" }],
+ "no-use-before-define": ["error", { functions: false }],
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-return": "error",
- "no-use-before-define": ["error", { functions: false }],
"no-void": "error",
"no-warning-comments": "warn",
+ "operator-assignment": "error",
+ "prefer-object-spread": "error",
"radix": ["error", "always"],
"yoda": "error"
}
reports: Meldungen
last_updated: Zuletzt aktualisiert
last_updated_time_ago_user_html: '%{time_ago} von %{user}'
+ reporting_users: Benutzer melden
reports_count:
one: Eine Meldung
other: '%{count} Meldungen'
reopened: Der Problemstatus wurde auf „Offen“ geändert
comments:
comment_from_html: Kommentar von %{user_link} erstellt am %{comment_created_at}
+ reassign_to_moderators: Weise das Problem den Moderatoren zu
+ reassign_to_administrators: Weise das Problem den Administratoren zu
reports:
reported_by_html: Gemeldet als %{category} von %{user} bei %{updated_at}
helper:
open_title: Ungelöster Hinweis Nr. %{note_name}
closed_title: Erledigter Hinweis Nr. %{note_name}
hidden_title: Versteckter Hinweis Nr. %{note_name}
+ description_when_author_is_deleted: gelöscht
event_opened_by_html: Erstellt von %{user} %{time_ago}
event_opened_by_anonymous_html: Erstellt von anonym %{time_ago}
event_commented_by_html: Kommentar von %{user} %{time_ago}
reports: Αναφορές
last_updated: Τελευταία ενημέρωση
last_updated_time_ago_user_html: '%{time_ago} από %{user}'
+ reporting_users: Αναφερόμενοι Χρήστες
reports_count:
one: '%{count} Αναφορά'
other: '%{count} Αναφορές'
reopened: Η κατάσταση του ζητήματος έχει οριστεί σε 'Ανοιχτό'
comments:
comment_from_html: Σχόλιο από %{user_link} γραμμένο στις %{comment_created_at}
+ reassign_to_moderators: Ανάθεση ζητήματος σε Συντονιστές
+ reassign_to_administrators: Ανάθεση ζητήματος σε Διαχειριστές
reports:
reported_by_html: Αναφέρθηκε ως %{category} από %{user} στις %{updated_at}
helper:
open_title: 'Ανοικτή σημείωση #%{note_name}'
closed_title: 'Επιλυμένη σημείωση #%{note_name}'
hidden_title: 'Κρυφή σημείωση #%{note_name}'
+ description_when_author_is_deleted: διαγράφηκε
event_opened_by_html: Δημιουργήθηκε από %{user} %{time_ago}
event_opened_by_anonymous_html: Δημιουργήθηκε από ανώνυμο %{time_ago}
event_commented_by_html: Σχολιάστηκε από %{user} %{time_ago}
partners_corpmembers: "OSMF corporate members"
partners_partners: "partners"
tou: "Terms of Use"
- osm_offline: "The OpenStreetMap database is currently offline while essential database maintenance work is carried out."
- osm_read_only: "The OpenStreetMap database is currently in read-only mode while essential database maintenance work is carried out."
nothing_to_preview: "Nothing to preview."
help: Help
about: About
communities: Communities
learn_more: "Learn More"
more: More
+ offline_flash:
+ osm_offline: "The OpenStreetMap database is currently offline while essential maintenance work is carried out."
+ osm_read_only: "The OpenStreetMap database is currently in read-only mode while essential maintenance work is carried out."
+ expected_restore_html: "Services are expected to be restored in %{time}."
+ announcement: "You can read the announcement here."
user_mailer:
diary_comment_notification:
description: "OpenStreetMap Diary Entry #%{id}"
license_url: "https://openstreetmap.org/copyright"
project_url: "https://openstreetmap.org"
remote_failed: "Editing failed - make sure JOSM or Merkaartor is loaded and the remote control option is enabled"
- edit:
+ not_public_flash:
not_public: "You have not set your edits to be public."
not_public_description_html: "You can no longer edit the map unless you do so. You can set your edits as public from your %{user_page}."
user_page_link: user page
anon_edits_html: "(%{link})"
anon_edits_link: "https://wiki.openstreetmap.org/wiki/Disabling_anonymous_edits"
anon_edits_link_text: "Find out why this is the case."
+ edit:
id_not_configured: "iD has not been configured"
export:
title: "Export"
message: Teachdaireachd
node: Nòd
node_tag: Taga nòid
+ note: Nòta
old_node: Seann nòd
old_node_tag: Taga seann nòid
old_relation: Seann dàimh
name: Ainm (Riatanach)
callback_url: URL ais-ghairm
support_url: URL taice
+ allow_read_prefs: na roghainnean a' chleachdaiche aca a leughadh
+ allow_write_prefs: na roghainnean a' chleachdaiche aca atharrachadh
allow_write_api: am mapa atharrachadh
allow_read_gpx: na lorgaidhean GPS prìobhaideach aca a leughadh
allow_write_gpx: lorgaidhean GPS a luchdadh suas
language_code: Cànan
doorkeeper/application:
name: Ainm
+ scopes: Ceadan
friend:
user: Cleachdaiche
friend: Caraid
longitude: Domhan-fhad
public: Poblach
description: Tuairisgeul
- gpx_file: Luchdaich suas faidhle GPX
+ gpx_file: Tagh faidhle lorgadh GPS
visibility: Faicsinneachd
tagstring: Tagaichean
message:
redaction:
title: Tiotal
description: Tuairisgeul
+ report:
+ category: Tagh adhbhar dhan aithris agad
user:
email: Post-d
new_email: An seòladh puist-d ùr
active: Gnìomhach
display_name: Ainm seallaidh
- description: Tuairisgeul
+ description: Tuairisgeul Pròifile
home_lat: Domhan-leud
home_lon: Domhan-fhad
languages: Cànain
auth:
providers:
google: Google
+ facebook: Facebook
+ github: GitHub
+ wikipedia: Uicipeid
api:
notes:
comment:
openid:
link text: dè th`ann?
contributor terms:
- heading: 'Teirmichean a'' chom-pàirtiche:'
+ heading: Teirmichean a' chom-pàirtiche
agreed: Dh'aontaich thu ri teirmichean ùra a' chom-pàirtiche.
not yet agreed: Cha do dh'aontaich thu ri teirmichean ùra a' chom-pàirtiche
fhathast.
cancel: Sguir dheth
terms:
show:
- title: Teirmichean a' chom-pàirtiche
- heading: Teirmichean a' chom-pàirtiche
+ title: Teirmichean
+ heading: Teirmichean
+ heading_ct: Teirmichean a' chom-pàirtiche
consider_pd: A bharrachd air an aonta gu h-àrd, aontaichidh mi gun dèid na
bheir mi dhuibh 'nam cho-thabhartaiche a chur sa Public Domain
consider_pd_why: Dè th`ann?
+ cancel: Sguir dheth
you need to accept or decline: Feuch an leugh thu teirmichean ùra a' chom-pàirtiche
agus an uairsin aontaich no nach gabh riutha mus lean thu air adhart.
legale_select: 'Dùthaich còmhnaidh:'
show:
title: 'Seata atharraichean: %{id}'
created: 'Air a chruthachadh: %{when}'
+ closed: 'Air a dhùnadh: %{when}'
created_ago_html: Air a chruthachadh %{time_ago}
+ closed_ago_html: Air a dhùnadh %{time_ago}
created_ago_by_html: Air a chruthachadh %{time_ago} le %{user}
+ closed_ago_by_html: Air a dhùnadh %{time_ago} le %{user}
discussion: Deasbaireachd
join_discussion: Clàraich a-steach gus pàirt a ghabhail san deasbaireachd
subscribe: Fo-sgrìobh
nearby users: Cleachdaichean am fagas eile
no nearby users: Chan eil cleachdaiche sam bith eile ann a dh'innis gu bheil
iad ris an obair-mhapa am fagas.
+ followed_changesets: seataichean atharraichean
nearby_changesets: seata atharraichean nan cleachdaichean am fagas
nearby_diaries: clàran leabhair-latha am fagas
diary_entries:
station: Stèisean trama-adhair
aeroway:
aerodrome: Raon-adhair
- apron: Aparan
- gate: Geata
+ apron: Aparan puirt-adhair
+ gate: Geata puirt-adhair
+ hangar: Hangar
helipad: Port-heileacoptair
runway: Raon-laighe
taxiway: Raon-cuairteachaidh
- terminal: Tèirmineal
+ terminal: Tèirmineal puirt-adhair
amenity:
animal_shelter: Fasgadh bheathaichean
arts_centre: Ionad ealain
fire_station: Stèisean-smàlaidh
food_court: Talla bìdh
fountain: Fuaran
- fuel: Connadh
+ fuel: Stèisean-peatrail
gambling: Cearrachas
grave_yard: Cladh
hospital: Ospadal
hunting_stand: Stannd seilge
ice_cream: Reòiteagan
+ internet_cafe: Cafaidh eadar-lìn
kindergarten: Sgoil-àraich
+ language_school: Sgoil cànain
library: Leabhar-lann
marketplace: Ionad-margaidh
monastery: Manachainn
waste_basket: Bogsa-sgudail
waste_disposal: Ionad-sgudail
boundary:
+ aboriginal_lands: Tìrean Tùsanaich
administrative: Crìoch rianachd
census: Crìoch cunntas-sluaigh
national_park: Pàirc nàiseanta
viaduct: Drochaid-rathaid
"yes": Drochaid
building:
+ chapel: Seipeal
garage: Garaids
garages: Garaidsean
+ hangar: Hangar
house: Taigh
+ roof: Mullach
shed: Seada
static_caravan: Carabhan
"yes": Togalach
photographer: Neach-dhealbh
plumber: Plumair
shoemaker: Greusaiche
+ stonemason: Clachair
tailor: Tàillear
"yes": Bùth cheàrd
emergency:
bus_guideway: Lonaig bus-stiùirichte
bus_stop: Stad-bus
construction: Mòr-rathad 'ga thogail
+ corridor: Trannsa
cycleway: Slighe baidhseagail
elevator: Àrdaichear
emergency_access_point: Puing-inntrigidh èiginn
wayside_cross: Cros ri taobh an rathaid
wayside_shrine: Naomh-chiste ri taobh an rathaid
wreck: Long bhriste
+ information:
+ map: Mapa
junction:
"yes": Gobhal
landuse:
track: Cuairt-ruith
water_park: Pàirc-uisge
"yes": Cur-seachad
+ lock:
+ "yes": Tuil-dhoras
man_made:
+ bridge: Drochaid
cairn: Càrn
lighthouse: Taigh-solais
pier: Cidhe
sand: Gainmheach
scree: Sgàirneach
scrub: Fiodhach
+ shingle: Mol
spring: Fuaran
stone: Clach
strait: Caolas
carpet: Bùth bhratan
charity: Bùth carthannais
chemist: Bùth-chungaidhean
+ chocolate: Seòclaid
clothes: Bùth aodach
+ coffee: Bùth cofaidh
computer: Bùth choimpiutairean
confectionery: Bùth mìlseanachd
convenience: Bùth goireasach
grocery: Gròsair
hairdresser: Gruagaire
hardware: Bùth leasachadh dachaigh
- hifi: HiFi
+ hifi: Bùth HiFi
jewelry: Bùth usgaran
kiosk: Cìtheasg
+ kitchen: Bùth cidsin
laundry: Taigh-nigheachain
mall: Ionad-seopadaireachd
mobile_phone: Bùth fhònaichean-làmhe
outdoor: Bùth acainnean blàir
pet: Bùth pheatachan
photo: Bùth dhealbhan
+ seafood: Biadh na mara
second_hand: Bùth rudan ath-làimhe
shoes: Bùth bhrògan
sports: Bùth spòrs
tunnel:
culvert: Cùlbhart
"yes": Tunail
+ water:
+ lake: Loch
+ pond: Lod
+ reservoir: Stòr-amar
+ lock: Tuil-dhoras
waterway:
artificial: Slighe-uisge fhuadain
boatyard: Bàta-lann
search: Lorg
states:
open: Fosgailte
+ page:
+ states:
+ open: Fosgailte
show:
reports:
one: '%{count} aithris'
helper:
reportable_title:
note: 'Nòta #%{note_id}'
+ reports:
+ new:
+ categories:
+ diary_comment:
+ other_label: Eile
+ user:
+ other_label: Eile
+ note:
+ other_label: Eile
layouts:
logo:
alt_text: Suaicheantas OpenStreetMap
intro_header: Fàilte gu OpenStreetMap!
intro_text: '''S e mapa an t-saoghail a tha san OpenStreetMap a chaidh a chruthachadh
le daoine mar thu fhèin ''s a tha saor fo cheadachas fhosgailte.'
+ partners_fastly: Fastly
partners_partners: com-pàirtichean eile
osm_offline: Tha an stòr-dàta aig OpenStreetMap far loidhńe an-dràsta on a tha
sinn a' dèanamh obair-charaidh riatanach air.
hi: Shin thu, %{to_user},
see_their_profile: '''S urrainn dhut a'' phròifil aig an neach ud a shealltainn
air %{userurl}.'
+ gpx_details:
+ description: Tuairisgeul
+ tags: Tagaichean
gpx_failure:
hi: Shin thu, %{to_user},
failed_to_import: 'ion-phortachadh. Seo a'' mhearachd:'
an URL?
update:
flash changed: Chaidh am facal-faire agad atharrachadh.
+ preferences:
+ show:
+ site_color_schemes:
+ light: Soilleir
+ dark: Dorcha
+ map_color_schemes:
+ light: Soilleir
+ dark: Dorcha
profiles:
edit:
+ cancel: Sguir dheth
image: Dealbh
gravatar:
gravatar: Cleachd Gravatar
richtext_field:
edit: Deasaich
pagination:
+ changeset_comments:
+ older: Beachdan nas sine
+ newer: Beachdan nas ùire
diary_comments:
older: Beachdan nas sine
newer: Beachdan nas ùire
description: Tuairisgeul
created_at: Air a chruthachadh
last_changed: An t-atharrachadh mu dheireadh
+ closed: Dùinte
show:
title: 'Nòta: %{id}'
description: Tuairisgeul
reports: Denuncias
last_updated: Última actualización
last_updated_time_ago_user_html: '%{time_ago} por %{user}'
+ reporting_users: Usuarios denunciantes
reports_count:
one: '%{count} denuncia'
other: '%{count} denuncias'
reopened: O estado da incidencia mudou a "Aberta"
comments:
comment_from_html: Comentario de %{user_link} no %{comment_created_at}
+ reassign_to_moderators: Reasignar a incidencia aos moderadores
+ reassign_to_administrators: Reasignar a incidencia aos administradores
reports:
reported_by_html: Denunciado coma %{category} por %{user} o %{updated_at}
helper:
open_title: Nota sen resolver n.º %{note_name}
closed_title: Nota resolta n.º %{note_name}
hidden_title: Nota agochada n.º %{note_name}
+ description_when_author_is_deleted: eliminado
event_opened_by_html: Creado por %{user} %{time_ago}
event_opened_by_anonymous_html: Creado por un usuario anónimo %{time_ago}
event_commented_by_html: Comentario de %{user} %{time_ago}
open_title: 'Nota irrisolta #%{note_name}'
closed_title: 'Nota risolta #%{note_name}'
hidden_title: 'Nota nascosta #%{note_name}'
+ description_when_author_is_deleted: cancellato
event_opened_by_html: Creata da %{user} %{time_ago}
event_opened_by_anonymous_html: Creata da anonimo %{time_ago}
event_commented_by_html: Commento da %{user} %{time_ago}
reports: Rapporten
last_updated: Lescht Aktualiséierung
last_updated_time_ago_user_html: '%{time_ago} vum %{user}'
+ reporting_users: Benotzer mellen
reports_count:
one: '%{count} Bericht'
other: '%{count} Berichter'
open_title: 'Ongeléisten Hiweis #%{note_name}'
closed_title: 'Geléisten Hiweis #%{note_name}'
hidden_title: Verstoppt Notiz N° %{note_name}
+ description_when_author_is_deleted: geläscht
report: Dësen Hiweis mellen
discussion: Diskussioun
subscribe: Abonéieren
# Author: BushmanK
# Author: Butko
# Author: CM3X
+# Author: Cabadeck
# Author: Calibrator
# Author: Chilin
# Author: Cjaushe4ka
reopened: Статус проблемы был установлен в "Открыто"
comments:
comment_from_html: Комментарий участника %{user_link}, созданный %{comment_created_at}
+ reassign_to_administrators: Перенаправить проблему Администраторам
reports:
reported_by_html: Указано как %{category} пользователем %{user} %{updated_at}
helper:
show:
title: نوٹ:%{id}
description: تفصیل
+ description_when_author_is_deleted: مٹا ݙتے
discussion: بحث مباحثہ
subscribe: سبسکرائب کرو
unsubscribe: اݨ سبسکرائب کرو
open_title: Нерешена белешка бр. %{note_name}
closed_title: Решена белешка бр. %{note_name}
hidden_title: Скривена белешка бр. %{note_name}
+ description_when_author_is_deleted: обрисано
event_opened_by_html: Направио %{user} %{time_ago}
report: пријави ову белешку
anonymous_warning: Ова белешка садржи коментаре анонимних корисника које би
post "changeset/comment/:id/hide" => "changeset_comments#destroy", :as => :changeset_comment_hide, :id => /\d+/
post "changeset/comment/:id/unhide" => "changeset_comments#restore", :as => :changeset_comment_unhide, :id => /\d+/
- get "node/:id/history" => "old_nodes#history", :as => :api_node_history, :id => /\d+/
- post "node/:id/:version/redact" => "old_nodes#redact", :as => :node_version_redact, :version => /\d+/, :id => /\d+/
- get "node/:id/:version" => "old_nodes#show", :as => :api_old_node, :id => /\d+/, :version => /\d+/
+ post "node/:node_id/:version/redact" => "old_nodes#redact", :as => :node_version_redact, :version => /\d+/, :node_id => /\d+/
- get "way/:id/history" => "old_ways#history", :as => :api_way_history, :id => /\d+/
- post "way/:id/:version/redact" => "old_ways#redact", :as => :way_version_redact, :version => /\d+/, :id => /\d+/
- get "way/:id/:version" => "old_ways#show", :as => :api_old_way, :id => /\d+/, :version => /\d+/
+ post "way/:way_id/:version/redact" => "old_ways#redact", :as => :way_version_redact, :version => /\d+/, :id => /\d+/
- get "relation/:id/history" => "old_relations#history", :as => :api_relation_history, :id => /\d+/
- post "relation/:id/:version/redact" => "old_relations#redact", :as => :relation_version_redact, :version => /\d+/, :id => /\d+/
- get "relation/:id/:version" => "old_relations#show", :as => :api_old_relation, :id => /\d+/, :version => /\d+/
+ post "relation/:relation_id/:version/redact" => "old_relations#redact", :as => :relation_version_redact, :version => /\d+/, :id => /\d+/
end
namespace :api, :path => "api/0.6" do
resources :ways, :only => :index
resources :relations, :only => :index
end
+ resources :versions, :path => "history", :controller => :old_nodes, :only => :index
+ resources :versions, :path => "", :version => /\d+/, :param => :version, :controller => :old_nodes, :only => :show
end
put "node/create" => "nodes#create", :as => nil
scope :module => :ways do
resources :relations, :only => :index
end
+ resources :versions, :path => "history", :controller => :old_ways, :only => :index
+ resources :versions, :path => "", :version => /\d+/, :param => :version, :controller => :old_ways, :only => :show
end
put "way/create" => "ways#create", :as => nil
scope :module => :relations do
resources :relations, :only => :index
end
+ resources :versions, :path => "history", :controller => :old_relations, :only => :index
+ resources :versions, :path => "", :version => /\d+/, :param => :version, :controller => :old_relations, :only => :show
end
put "relation/create" => "relations#create", :as => nil
# database_offline - database offline with site in emergency mode
# gpx_offline - gpx storage offline
status: "online"
+# Expected services restoration date added to offline flash messages
+#status_expected_restore_date: "2024-12-18 12:00:00Z"
+# Application status announcement url added to offline flash messages
+#status_announcement_url: "https://en.osm.town/@osm_tech"
# The maximum area you're allowed to request, in square degrees
max_request_area: 0.25
# Number of GPS trace/trackpoints returned per-page
Rails.root.join("config/eslint.js").to_s
end
-def js_files
- Rails.application.assets.each_file.select do |file|
- (file.ends_with?(".js") || file.ends_with?(".js.erb")) && !file.match?(%r{/(gems|vendor|i18n|node_modules)/})
- end
-end
-
namespace "eslint" do
task :check => :environment do
- system(yarn_path, "run", "eslint", "-c", config_file, *js_files) || abort
+ system(yarn_path, "run", "eslint", "-c", config_file, "--no-warn-ignored", Rails.root.to_s) || abort
end
task :fix => :environment do
- system(yarn_path, "run", "eslint", "-c", config_file, "--fix", *js_files) || abort
+ system(yarn_path, "run", "eslint", "-c", config_file, "--no-warn-ignored", "--fix", Rails.root.to_s) || abort
end
end
module Api
class OldNodesControllerTest < ActionDispatch::IntegrationTest
- #
- # TODO: test history
- #
-
##
# test all routes which lead to this controller
def test_routes
assert_routing(
{ :path => "/api/0.6/node/1/history", :method => :get },
- { :controller => "api/old_nodes", :action => "history", :id => "1" }
+ { :controller => "api/old_nodes", :action => "index", :node_id => "1" }
)
assert_routing(
- { :path => "/api/0.6/node/1/2", :method => :get },
- { :controller => "api/old_nodes", :action => "show", :id => "1", :version => "2" }
+ { :path => "/api/0.6/node/1/history.json", :method => :get },
+ { :controller => "api/old_nodes", :action => "index", :node_id => "1", :format => "json" }
)
assert_routing(
- { :path => "/api/0.6/node/1/history.json", :method => :get },
- { :controller => "api/old_nodes", :action => "history", :id => "1", :format => "json" }
+ { :path => "/api/0.6/node/1/2", :method => :get },
+ { :controller => "api/old_nodes", :action => "show", :node_id => "1", :version => "2" }
)
assert_routing(
{ :path => "/api/0.6/node/1/2.json", :method => :get },
- { :controller => "api/old_nodes", :action => "show", :id => "1", :version => "2", :format => "json" }
+ { :controller => "api/old_nodes", :action => "show", :node_id => "1", :version => "2", :format => "json" }
)
assert_routing(
{ :path => "/api/0.6/node/1/2/redact", :method => :post },
- { :controller => "api/old_nodes", :action => "redact", :id => "1", :version => "2" }
+ { :controller => "api/old_nodes", :action => "redact", :node_id => "1", :version => "2" }
)
end
- ##
- # test the version call by submitting several revisions of a new node
- # to the API and ensuring that later calls to version return the
- # matching versions of the object.
- #
- ##
- # FIXME: Move this test to being an integration test since it spans multiple controllers
- def test_version
- private_user = create(:user, :data_public => false)
- private_node = create(:node, :with_history, :version => 4, :lat => 0, :lon => 0, :changeset => create(:changeset, :user => private_user))
- user = create(:user)
- node = create(:node, :with_history, :version => 4, :lat => 0, :lon => 0, :changeset => create(:changeset, :user => user))
- create_list(:node_tag, 2, :node => node)
- # Ensure that the current tags are propagated to the history too
- propagate_tags(node, node.old_nodes.last)
-
- ## First try this with a non-public user
- auth_header = bearer_authorization_header private_user
-
- # setup a simple XML node
- xml_doc = xml_for_node(private_node)
- xml_node = xml_doc.find("//osm/node").first
- nodeid = private_node.id
-
- # keep a hash of the versions => string, as we'll need something
- # to test against later
- versions = {}
-
- # save a version for later checking
- versions[xml_node["version"]] = xml_doc.to_s
-
- # randomly move the node about
- 3.times do
- # move the node somewhere else
- xml_node["lat"] = precision(rand - 0.5).to_s
- xml_node["lon"] = precision(rand - 0.5).to_s
- with_controller(NodesController.new) do
- put api_node_path(nodeid), :params => xml_doc.to_s, :headers => auth_header
- assert_response :forbidden, "Should have rejected node update"
- xml_node["version"] = @response.body.to_s
- end
- # save a version for later checking
- versions[xml_node["version"]] = xml_doc.to_s
- end
-
- # add a bunch of random tags
- 3.times do
- xml_tag = XML::Node.new("tag")
- xml_tag["k"] = random_string
- xml_tag["v"] = random_string
- xml_node << xml_tag
- with_controller(NodesController.new) do
- put api_node_path(nodeid), :params => xml_doc.to_s, :headers => auth_header
- assert_response :forbidden,
- "should have rejected node #{nodeid} (#{@response.body}) with forbidden"
- xml_node["version"] = @response.body.to_s
+ def test_index
+ node = create(:node, :version => 2)
+ create(:old_node, :node_id => node.id, :version => 1, :latitude => 60 * OldNode::SCALE, :longitude => 30 * OldNode::SCALE)
+ create(:old_node, :node_id => node.id, :version => 2, :latitude => 61 * OldNode::SCALE, :longitude => 31 * OldNode::SCALE)
+
+ get api_node_versions_path(node)
+
+ assert_response :success
+ assert_dom "osm:root", 1 do
+ assert_dom "> node", 2 do |dom_nodes|
+ assert_dom dom_nodes[0], "> @id", node.id.to_s
+ assert_dom dom_nodes[0], "> @version", "1"
+ assert_dom dom_nodes[0], "> @lat", "60.0000000"
+ assert_dom dom_nodes[0], "> @lon", "30.0000000"
+
+ assert_dom dom_nodes[1], "> @id", node.id.to_s
+ assert_dom dom_nodes[1], "> @version", "2"
+ assert_dom dom_nodes[1], "> @lat", "61.0000000"
+ assert_dom dom_nodes[1], "> @lon", "31.0000000"
end
- # save a version for later checking
- versions[xml_node["version"]] = xml_doc.to_s
end
+ end
- # probably should check that they didn't get written to the database
-
- ## Now do it with the public user
- auth_header = bearer_authorization_header user
-
- # setup a simple XML node
+ ##
+ # test that redacted nodes aren't visible in the history
+ def test_index_redacted
+ node = create(:node, :with_history, :version => 2)
+ node_v1 = node.old_nodes.find_by(:version => 1)
+ node_v1.redact!(create(:redaction))
- xml_doc = xml_for_node(node)
- xml_node = xml_doc.find("//osm/node").first
- nodeid = node.id
+ get api_node_versions_path(node)
+ assert_response :success, "Redaction shouldn't have stopped history working."
+ assert_select "osm node[id='#{node_v1.node_id}'][version='#{node_v1.version}']", 0,
+ "redacted node #{node_v1.node_id} version #{node_v1.version} shouldn't be present in the history."
- # keep a hash of the versions => string, as we'll need something
- # to test against later
- versions = {}
+ # not even to a logged-in user
+ auth_header = bearer_authorization_header
+ get api_node_versions_path(node), :headers => auth_header
+ assert_response :success, "Redaction shouldn't have stopped history working."
+ assert_select "osm node[id='#{node_v1.node_id}'][version='#{node_v1.version}']", 0,
+ "redacted node #{node_v1.node_id} version #{node_v1.version} shouldn't be present in the history, even when logged in."
+ end
- # save a version for later checking
- versions[xml_node["version"]] = xml_doc.to_s
+ def test_show
+ node = create(:node, :version => 2)
+ create(:old_node, :node_id => node.id, :version => 1, :latitude => 60 * OldNode::SCALE, :longitude => 30 * OldNode::SCALE)
+ create(:old_node, :node_id => node.id, :version => 2, :latitude => 61 * OldNode::SCALE, :longitude => 31 * OldNode::SCALE)
- # randomly move the node about
- 3.times do
- # move the node somewhere else
- xml_node["lat"] = precision(rand - 0.5).to_s
- xml_node["lon"] = precision(rand - 0.5).to_s
- with_controller(NodesController.new) do
- put api_node_path(nodeid), :params => xml_doc.to_s, :headers => auth_header
- assert_response :success
- xml_node["version"] = @response.body.to_s
- end
- # save a version for later checking
- versions[xml_node["version"]] = xml_doc.to_s
- end
+ get api_node_version_path(node, 1)
- # add a bunch of random tags
- 3.times do
- xml_tag = XML::Node.new("tag")
- xml_tag["k"] = random_string
- xml_tag["v"] = random_string
- xml_node << xml_tag
- with_controller(NodesController.new) do
- put api_node_path(nodeid), :params => xml_doc.to_s, :headers => auth_header
- assert_response :success,
- "couldn't update node #{nodeid} (#{@response.body})"
- xml_node["version"] = @response.body.to_s
+ assert_response :success
+ assert_dom "osm:root", 1 do
+ assert_dom "> node", 1 do
+ assert_dom "> @id", node.id.to_s
+ assert_dom "> @version", "1"
+ assert_dom "> @lat", "60.0000000"
+ assert_dom "> @lon", "30.0000000"
end
- # save a version for later checking
- versions[xml_node["version"]] = xml_doc.to_s
end
- # check all the versions
- versions.each_key do |key|
- get api_old_node_path(nodeid, key.to_i)
-
- assert_response :success,
- "couldn't get version #{key.to_i} of node #{nodeid}"
+ get api_node_version_path(node, 2)
- check_node = Node.from_xml(versions[key])
- api_node = Node.from_xml(@response.body.to_s)
-
- assert_nodes_are_equal check_node, api_node
+ assert_response :success
+ assert_dom "osm:root", 1 do
+ assert_dom "> node", 1 do
+ assert_dom "> @id", node.id.to_s
+ assert_dom "> @version", "2"
+ assert_dom "> @lat", "61.0000000"
+ assert_dom "> @lon", "31.0000000"
+ end
end
end
- def test_not_found_version
+ def test_show_not_found
check_not_found_id_version(70000, 312344)
check_not_found_id_version(-1, -13)
check_not_found_id_version(create(:node).id, 24354)
end
##
- # Test that getting the current version is identical to picking
- # that version with the version URI call.
- def test_current_version
- node = create(:node, :with_history)
- used_node = create(:node, :with_history)
- create(:way_node, :node => used_node)
- node_used_by_relationship = create(:node, :with_history)
- create(:relation_member, :member => node_used_by_relationship)
- node_with_versions = create(:node, :with_history, :version => 4)
-
- create(:node_tag, :node => node)
- create(:node_tag, :node => used_node)
- create(:node_tag, :node => node_used_by_relationship)
- create(:node_tag, :node => node_with_versions)
- propagate_tags(node, node.old_nodes.last)
- propagate_tags(used_node, used_node.old_nodes.last)
- propagate_tags(node_used_by_relationship, node_used_by_relationship.old_nodes.last)
- propagate_tags(node_with_versions, node_with_versions.old_nodes.last)
-
- check_current_version(node)
- check_current_version(used_node)
- check_current_version(node_used_by_relationship)
- check_current_version(node_with_versions)
+ # test that redacted nodes aren't visible, regardless of
+ # authorisation except as moderator...
+ def test_show_redacted
+ node = create(:node, :with_history, :version => 2)
+ node_v1 = node.old_nodes.find_by(:version => 1)
+ node_v1.redact!(create(:redaction))
+
+ get api_node_version_path(node_v1.node_id, node_v1.version)
+ assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
+
+ # not even to a logged-in user
+ auth_header = bearer_authorization_header
+ get api_node_version_path(node_v1.node_id, node_v1.version), :headers => auth_header
+ assert_response :forbidden, "Redacted node shouldn't be visible via the version API, even when logged in."
end
# Ensure the lat/lon is formatted as a decimal e.g. not 4.0e-05
def test_lat_lon_xml_format
old_node = create(:old_node, :latitude => (0.00004 * OldNode::SCALE).to_i, :longitude => (0.00008 * OldNode::SCALE).to_i)
- get api_node_history_path(old_node.node_id)
+ get api_node_versions_path(old_node.node_id)
assert_match(/lat="0.0000400"/, response.body)
assert_match(/lon="0.0000800"/, response.body)
end
assert_response :success, "should be OK to redact old version as moderator with write_redactions scope."
end
- ##
- # test that redacted nodes aren't visible, regardless of
- # authorisation except as moderator...
- def test_version_redacted
- node = create(:node, :with_history, :version => 2)
- node_v1 = node.old_nodes.find_by(:version => 1)
- node_v1.redact!(create(:redaction))
-
- get api_old_node_path(node_v1.node_id, node_v1.version)
- assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
-
- # not even to a logged-in user
- auth_header = bearer_authorization_header
- get api_old_node_path(node_v1.node_id, node_v1.version), :headers => auth_header
- assert_response :forbidden, "Redacted node shouldn't be visible via the version API, even when logged in."
- end
-
- ##
- # test that redacted nodes aren't visible in the history
- def test_history_redacted
- node = create(:node, :with_history, :version => 2)
- node_v1 = node.old_nodes.find_by(:version => 1)
- node_v1.redact!(create(:redaction))
-
- get api_node_history_path(node)
- assert_response :success, "Redaction shouldn't have stopped history working."
- assert_select "osm node[id='#{node_v1.node_id}'][version='#{node_v1.version}']", 0,
- "redacted node #{node_v1.node_id} version #{node_v1.version} shouldn't be present in the history."
-
- # not even to a logged-in user
- auth_header = bearer_authorization_header
- get api_node_history_path(node), :headers => auth_header
- assert_response :success, "Redaction shouldn't have stopped history working."
- assert_select "osm node[id='#{node_v1.node_id}'][version='#{node_v1.version}']", 0,
- "redacted node #{node_v1.node_id} version #{node_v1.version} shouldn't be present in the history, even when logged in."
- end
-
##
# test the redaction of an old version of a node, while being
# authorised as a moderator.
# check moderator can still see the redacted data, when passing
# the appropriate flag
- get api_old_node_path(node_v3.node_id, node_v3.version), :headers => auth_header
+ get api_node_version_path(node_v3.node_id, node_v3.version), :headers => auth_header
assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed."
- get api_old_node_path(node_v3.node_id, node_v3.version, :show_redactions => "true"), :headers => auth_header
+ get api_node_version_path(node_v3.node_id, node_v3.version, :show_redactions => "true"), :headers => auth_header
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
# and when accessed via history
- get api_node_history_path(node)
+ get api_node_versions_path(node)
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm node[id='#{node_v3.node_id}'][version='#{node_v3.version}']", 0,
"node #{node_v3.node_id} version #{node_v3.version} should not be present in the history for moderators when not passing flag."
- get api_node_history_path(node, :show_redactions => "true"), :headers => auth_header
+ get api_node_versions_path(node, :show_redactions => "true"), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm node[id='#{node_v3.node_id}'][version='#{node_v3.version}']", 1,
"node #{node_v3.node_id} version #{node_v3.version} should still be present in the history for moderators when passing flag."
auth_header = bearer_authorization_header
# check can't see the redacted data
- get api_old_node_path(node_v3.node_id, node_v3.version), :headers => auth_header
+ get api_node_version_path(node_v3.node_id, node_v3.version), :headers => auth_header
assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
# and when accessed via history
- get api_node_history_path(node), :headers => auth_header
+ get api_node_versions_path(node), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm node[id='#{node_v3.node_id}'][version='#{node_v3.version}']", 0,
"redacted node #{node_v3.node_id} version #{node_v3.version} shouldn't be present in the history."
# check moderator can now see the redacted data, when not
# passing the aspecial flag
- get api_old_node_path(node_v1.node_id, node_v1.version), :headers => auth_header
+ get api_node_version_path(node_v1.node_id, node_v1.version), :headers => auth_header
assert_response :success, "After unredaction, node should not be gone for moderator."
# and when accessed via history
- get api_node_history_path(node)
+ get api_node_versions_path(node)
assert_response :success, "Unredaction shouldn't have stopped history working."
assert_select "osm node[id='#{node_v1.node_id}'][version='#{node_v1.version}']", 1,
"node #{node_v1.node_id} version #{node_v1.version} should now be present in the history for moderators without passing flag."
auth_header = bearer_authorization_header
# check normal user can now see the redacted data
- get api_old_node_path(node_v1.node_id, node_v1.version), :headers => auth_header
+ get api_node_version_path(node_v1.node_id, node_v1.version), :headers => auth_header
assert_response :success, "After unredaction, node should be visible to normal users."
# and when accessed via history
- get api_node_history_path(node)
+ get api_node_versions_path(node)
assert_response :success, "Unredaction shouldn't have stopped history working."
assert_select "osm node[id='#{node_v1.node_id}'][version='#{node_v1.version}']", 1,
"node #{node_v1.node_id} version #{node_v1.version} should now be present in the history for normal users without passing flag."
end
def do_redact_node(node, redaction, headers = {})
- get api_old_node_path(node.node_id, node.version), :headers => headers
+ get api_node_version_path(node.node_id, 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(node.node_id, 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(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 api_old_node_path(node_id, 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
-
def check_not_found_id_version(id, version)
- get api_old_node_path(id, version)
+ get api_node_version_path(id, version)
assert_response :not_found
rescue ActionController::UrlGenerationError => e
assert_match(/No route matches/, e.to_s)
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 { 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
- end
end
end
def test_routes
assert_routing(
{ :path => "/api/0.6/relation/1/history", :method => :get },
- { :controller => "api/old_relations", :action => "history", :id => "1" }
+ { :controller => "api/old_relations", :action => "index", :relation_id => "1" }
)
assert_routing(
- { :path => "/api/0.6/relation/1/2", :method => :get },
- { :controller => "api/old_relations", :action => "show", :id => "1", :version => "2" }
+ { :path => "/api/0.6/relation/1/history.json", :method => :get },
+ { :controller => "api/old_relations", :action => "index", :relation_id => "1", :format => "json" }
)
assert_routing(
- { :path => "/api/0.6/relation/1/history.json", :method => :get },
- { :controller => "api/old_relations", :action => "history", :id => "1", :format => "json" }
+ { :path => "/api/0.6/relation/1/2", :method => :get },
+ { :controller => "api/old_relations", :action => "show", :relation_id => "1", :version => "2" }
)
assert_routing(
{ :path => "/api/0.6/relation/1/2.json", :method => :get },
- { :controller => "api/old_relations", :action => "show", :id => "1", :version => "2", :format => "json" }
+ { :controller => "api/old_relations", :action => "show", :relation_id => "1", :version => "2", :format => "json" }
)
assert_routing(
{ :path => "/api/0.6/relation/1/2/redact", :method => :post },
- { :controller => "api/old_relations", :action => "redact", :id => "1", :version => "2" }
+ { :controller => "api/old_relations", :action => "redact", :relation_id => "1", :version => "2" }
)
end
- # -------------------------------------
- # Test reading old relations.
- # -------------------------------------
- def test_history
- # check that a visible relations is returned properly
- get api_relation_history_path(create(:relation, :with_history))
+ ##
+ # check that a visible relations is returned properly
+ def test_index
+ relation = create(:relation, :with_history, :version => 2)
+
+ get api_relation_versions_path(relation)
+
assert_response :success
+ assert_dom "osm:root", 1 do
+ assert_dom "> relation", 2 do |dom_relations|
+ assert_dom dom_relations[0], "> @id", relation.id.to_s
+ assert_dom dom_relations[0], "> @version", "1"
+
+ assert_dom dom_relations[1], "> @id", relation.id.to_s
+ assert_dom dom_relations[1], "> @version", "2"
+ end
+ end
+ end
- # check chat a non-existent relations is not returned
- get api_relation_history_path(0)
+ ##
+ # check that a non-existent relations is not returned
+ def test_index_invalid
+ get api_relation_versions_path(0)
assert_response :not_found
end
+ ##
+ # test that redacted relations aren't visible in the history
+ def test_index_redacted
+ relation = create(:relation, :with_history, :version => 2)
+ relation_v1 = relation.old_relations.find_by(:version => 1)
+ relation_v1.redact!(create(:redaction))
+
+ get api_relation_versions_path(relation)
+ assert_response :success, "Redaction shouldn't have stopped history working."
+ assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 0,
+ "redacted relation #{relation_v1.relation_id} version #{relation_v1.version} shouldn't be present in the history."
+
+ # not even to a logged-in user
+ auth_header = bearer_authorization_header
+ get api_relation_versions_path(relation), :headers => auth_header
+ assert_response :success, "Redaction shouldn't have stopped history working."
+ assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 0,
+ "redacted relation #{relation_v1.relation_id} version #{relation_v1.version} shouldn't be present in the history, even when logged in."
+ end
+
+ def test_show
+ relation = create(:relation, :with_history, :version => 2)
+ create(:old_relation_tag, :old_relation => relation.old_relations[0], :k => "k1", :v => "v1")
+ create(:old_relation_tag, :old_relation => relation.old_relations[1], :k => "k2", :v => "v2")
+
+ get api_relation_version_path(relation, 1)
+
+ assert_response :success
+ assert_dom "osm:root", 1 do
+ assert_dom "> relation", 1 do
+ assert_dom "> @id", relation.id.to_s
+ assert_dom "> @version", "1"
+ assert_dom "> tag", 1 do
+ assert_dom "> @k", "k1"
+ assert_dom "> @v", "v1"
+ end
+ end
+ end
+
+ get api_relation_version_path(relation, 2)
+
+ assert_response :success
+ assert_dom "osm:root", 1 do
+ assert_dom "> relation", 1 do
+ assert_dom "> @id", relation.id.to_s
+ assert_dom "> @version", "2"
+ assert_dom "> tag", 1 do
+ assert_dom "> @k", "k2"
+ assert_dom "> @v", "v2"
+ end
+ end
+ end
+ end
+
+ ##
+ # test that redacted relations aren't visible, regardless of
+ # authorisation except as moderator...
+ def test_show_redacted
+ relation = create(:relation, :with_history, :version => 2)
+ relation_v1 = relation.old_relations.find_by(:version => 1)
+ relation_v1.redact!(create(:redaction))
+
+ get api_relation_version_path(relation_v1.relation_id, relation_v1.version)
+ assert_response :forbidden, "Redacted relation shouldn't be visible via the version API."
+
+ # not even to a logged-in user
+ auth_header = bearer_authorization_header
+ get api_relation_version_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
+ assert_response :forbidden, "Redacted relation shouldn't be visible via the version API, even when logged in."
+ end
+
##
# test the redaction of an old version of a relation, while not being
# authorised.
assert_response :success, "should be OK to redact old version as moderator with write_redactions scope."
end
- ##
- # test that redacted relations aren't visible, regardless of
- # authorisation except as moderator...
- def test_version_redacted
- relation = create(:relation, :with_history, :version => 2)
- relation_v1 = relation.old_relations.find_by(:version => 1)
- relation_v1.redact!(create(:redaction))
-
- get api_old_relation_path(relation_v1.relation_id, relation_v1.version)
- assert_response :forbidden, "Redacted relation shouldn't be visible via the version API."
-
- # not even to a logged-in user
- auth_header = bearer_authorization_header
- get api_old_relation_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
- assert_response :forbidden, "Redacted relation shouldn't be visible via the version API, even when logged in."
- end
-
- ##
- # test that redacted relations aren't visible in the history
- def test_history_redacted
- relation = create(:relation, :with_history, :version => 2)
- relation_v1 = relation.old_relations.find_by(:version => 1)
- relation_v1.redact!(create(:redaction))
-
- get api_relation_history_path(relation)
- assert_response :success, "Redaction shouldn't have stopped history working."
- assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 0,
- "redacted relation #{relation_v1.relation_id} version #{relation_v1.version} shouldn't be present in the history."
-
- # not even to a logged-in user
- auth_header = bearer_authorization_header
- get api_old_relation_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
- get api_relation_history_path(relation), :headers => auth_header
- assert_response :success, "Redaction shouldn't have stopped history working."
- assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 0,
- "redacted relation #{relation_v1.relation_id} version #{relation_v1.version} shouldn't be present in the history, even when logged in."
- end
-
##
# test the redaction of an old version of a relation, while being
# authorised as a moderator.
# check moderator can still see the redacted data, when passing
# the appropriate flag
- get api_old_relation_path(relation_v3.relation_id, relation_v3.version), :headers => auth_header
+ get api_relation_version_path(relation_v3.relation_id, relation_v3.version), :headers => auth_header
assert_response :forbidden, "After redaction, relation should be gone for moderator, when flag not passed."
- get api_old_relation_path(relation_v3.relation_id, relation_v3.version, :show_redactions => "true"), :headers => auth_header
+ get api_relation_version_path(relation_v3.relation_id, relation_v3.version, :show_redactions => "true"), :headers => auth_header
assert_response :success, "After redaction, relation should not be gone for moderator, when flag passed."
# and when accessed via history
- get api_relation_history_path(relation), :headers => auth_header
+ get api_relation_versions_path(relation), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm relation[id='#{relation_v3.relation_id}'][version='#{relation_v3.version}']", 0,
"relation #{relation_v3.relation_id} version #{relation_v3.version} should not be present in the history for moderators when not passing flag."
- get api_relation_history_path(relation, :show_redactions => "true"), :headers => auth_header
+ get api_relation_versions_path(relation, :show_redactions => "true"), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm relation[id='#{relation_v3.relation_id}'][version='#{relation_v3.version}']", 1,
"relation #{relation_v3.relation_id} version #{relation_v3.version} should still be present in the history for moderators when passing flag."
auth_header = bearer_authorization_header
# check can't see the redacted data
- get api_old_relation_path(relation_v3.relation_id, relation_v3.version), :headers => auth_header
+ get api_relation_version_path(relation_v3.relation_id, relation_v3.version), :headers => auth_header
assert_response :forbidden, "Redacted relation shouldn't be visible via the version API."
# and when accessed via history
- get api_relation_history_path(relation), :headers => auth_header
+ get api_relation_versions_path(relation), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm relation[id='#{relation_v3.relation_id}'][version='#{relation_v3.version}']", 0,
"redacted relation #{relation_v3.relation_id} version #{relation_v3.version} shouldn't be present in the history."
# check moderator can still see the redacted data, without passing
# the appropriate flag
- get api_old_relation_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
+ get api_relation_version_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
assert_response :success, "After unredaction, relation should not be gone for moderator."
# and when accessed via history
- get api_relation_history_path(relation), :headers => auth_header
+ get api_relation_versions_path(relation), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 1,
"relation #{relation_v1.relation_id} version #{relation_v1.version} should still be present in the history for moderators."
auth_header = bearer_authorization_header
# check normal user can now see the redacted data
- get api_old_relation_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
+ get api_relation_version_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
assert_response :success, "After redaction, node should not be gone for normal user."
# and when accessed via history
- get api_relation_history_path(relation), :headers => auth_header
+ get api_relation_versions_path(relation), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 1,
"relation #{relation_v1.relation_id} version #{relation_v1.version} should still be present in the history for normal users."
private
- ##
- # check that the current version of a relation is equivalent to the
- # version which we're getting from the versions call.
- def check_current_version(relation_id)
- # get the current version
- current_relation = with_controller(RelationsController.new) do
- get :show, :params => { :id => relation_id }
- assert_response :success, "can't get current relation #{relation_id}"
- Relation.from_xml(@response.body)
- end
- assert_not_nil current_relation, "getting relation #{relation_id} returned nil"
-
- # get the "old" version of the relation from the version method
- get :version, :params => { :id => relation_id, :version => current_relation.version }
- assert_response :success, "can't get old relation #{relation_id}, v#{current_relation.version}"
- old_relation = Relation.from_xml(@response.body)
-
- # check that the relations are identical
- assert_relations_are_equal current_relation, old_relation
- end
-
- ##
- # look at all the versions of the relation in the history and get each version from
- # the versions call. check that they're the same.
- def check_history_equals_versions(relation_id)
- get :history, :params => { :id => relation_id }
- assert_response :success, "can't get relation #{relation_id} from API"
- history_doc = XML::Parser.string(@response.body).parse
- assert_not_nil history_doc, "parsing relation #{relation_id} history failed"
-
- history_doc.find("//osm/relation").each do |relation_doc|
- history_relation = Relation.from_xml_node(relation_doc)
- assert_not_nil history_relation, "parsing relation #{relation_id} version failed"
-
- get :version, :params => { :id => relation_id, :version => history_relation.version }
- assert_response :success, "couldn't get relation #{relation_id}, v#{history_relation.version}"
- version_relation = Relation.from_xml(@response.body)
- assert_not_nil version_relation, "failed to parse #{relation_id}, v#{history_relation.version}"
-
- assert_relations_are_equal history_relation, version_relation
- end
- end
-
def do_redact_redactable_relation(headers = {})
relation = create(:relation, :with_history, :version => 4)
relation_v3 = relation.old_relations.find_by(:version => 3)
end
def do_redact_relation(relation, redaction, headers = {})
- get api_old_relation_path(relation.relation_id, relation.version)
+ get api_relation_version_path(relation.relation_id, relation.version)
assert_response :success, "should be able to get version #{relation.version} of relation #{relation.relation_id}."
# now redact it
def test_routes
assert_routing(
{ :path => "/api/0.6/way/1/history", :method => :get },
- { :controller => "api/old_ways", :action => "history", :id => "1" }
+ { :controller => "api/old_ways", :action => "index", :way_id => "1" }
)
assert_routing(
- { :path => "/api/0.6/way/1/2", :method => :get },
- { :controller => "api/old_ways", :action => "show", :id => "1", :version => "2" }
+ { :path => "/api/0.6/way/1/history.json", :method => :get },
+ { :controller => "api/old_ways", :action => "index", :way_id => "1", :format => "json" }
)
assert_routing(
- { :path => "/api/0.6/way/1/history.json", :method => :get },
- { :controller => "api/old_ways", :action => "history", :id => "1", :format => "json" }
+ { :path => "/api/0.6/way/1/2", :method => :get },
+ { :controller => "api/old_ways", :action => "show", :way_id => "1", :version => "2" }
)
assert_routing(
{ :path => "/api/0.6/way/1/2.json", :method => :get },
- { :controller => "api/old_ways", :action => "show", :id => "1", :version => "2", :format => "json" }
+ { :controller => "api/old_ways", :action => "show", :way_id => "1", :version => "2", :format => "json" }
)
assert_routing(
{ :path => "/api/0.6/way/1/2/redact", :method => :post },
- { :controller => "api/old_ways", :action => "redact", :id => "1", :version => "2" }
+ { :controller => "api/old_ways", :action => "redact", :way_id => "1", :version => "2" }
)
end
- # -------------------------------------
- # Test reading old ways.
- # -------------------------------------
+ ##
+ # check that a visible way is returned properly
+ def test_index
+ way = create(:way, :with_history, :version => 2)
+
+ get api_way_versions_path(way)
- def test_history_visible
- # check that a visible way is returned properly
- get api_way_history_path(create(:way, :with_history))
assert_response :success
+ assert_dom "osm:root", 1 do
+ assert_dom "> way", 2 do |dom_ways|
+ assert_dom dom_ways[0], "> @id", way.id.to_s
+ assert_dom dom_ways[0], "> @version", "1"
+
+ assert_dom dom_ways[1], "> @id", way.id.to_s
+ assert_dom dom_ways[1], "> @version", "2"
+ end
+ end
end
- def test_history_invisible
- # check that an invisible way's history is returned properly
- get api_way_history_path(create(:way, :with_history, :deleted))
+ ##
+ # check that an invisible way's history is returned properly
+ def test_index_invisible
+ get api_way_versions_path(create(:way, :with_history, :deleted))
assert_response :success
end
- def test_history_invalid
- # check chat a non-existent way is not returned
- get api_way_history_path(0)
+ ##
+ # check chat a non-existent way is not returned
+ def test_index_invalid
+ get api_way_versions_path(0)
assert_response :not_found
end
##
- # check that we can retrieve versions of a way
- def test_version
- way = create(:way, :with_history)
- used_way = create(:way, :with_history)
- create(:relation_member, :member => used_way)
- way_with_versions = create(:way, :with_history, :version => 4)
+ # test that redacted ways aren't visible in the history
+ def test_index_redacted
+ way = create(:way, :with_history, :version => 2)
+ way_v1 = way.old_ways.find_by(:version => 1)
+ way_v1.redact!(create(:redaction))
+
+ get api_way_versions_path(way)
+ assert_response :success, "Redaction shouldn't have stopped history working."
+ assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 0,
+ "redacted way #{way_v1.way_id} version #{way_v1.version} shouldn't be present in the history."
+
+ # not even to a logged-in user
+ auth_header = bearer_authorization_header
+ get api_way_versions_path(way), :headers => auth_header
+ assert_response :success, "Redaction shouldn't have stopped history working."
+ assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 0,
+ "redacted node #{way_v1.way_id} version #{way_v1.version} shouldn't be present in the history, even when logged in."
+ end
+
+ def test_show
+ way = create(:way, :with_history, :version => 2)
+
+ get api_way_version_path(way, 1)
+
+ assert_response :success
+ assert_dom "osm:root", 1 do
+ assert_dom "> way", 1 do
+ assert_dom "> @id", way.id.to_s
+ assert_dom "> @version", "1"
+ end
+ end
- create(:way_tag, :way => way)
- create(:way_tag, :way => used_way)
- create(:way_tag, :way => way_with_versions)
- propagate_tags(way, way.old_ways.last)
- propagate_tags(used_way, used_way.old_ways.last)
- propagate_tags(way_with_versions, way_with_versions.old_ways.last)
+ get api_way_version_path(way, 2)
- check_current_version(way.id)
- check_current_version(used_way.id)
- check_current_version(way_with_versions.id)
+ assert_response :success
+ assert_dom "osm:root", 1 do
+ assert_dom "> way", 1 do
+ assert_dom "> @id", way.id.to_s
+ assert_dom "> @version", "2"
+ end
+ end
+ end
+
+ ##
+ # test that redacted ways aren't visible, regardless of
+ # authorisation except as moderator...
+ def test_show_redacted
+ way = create(:way, :with_history, :version => 2)
+ way_v1 = way.old_ways.find_by(:version => 1)
+ way_v1.redact!(create(:redaction))
+
+ get api_way_version_path(way_v1.way_id, way_v1.version)
+ assert_response :forbidden, "Redacted way shouldn't be visible via the version API."
+
+ # not even to a logged-in user
+ auth_header = bearer_authorization_header
+ get api_way_version_path(way_v1.way_id, way_v1.version), :headers => auth_header
+ assert_response :forbidden, "Redacted way shouldn't be visible via the version API, even when logged in."
end
##
assert_response :success, "should be OK to redact old version as moderator with write_redactions scope."
end
- ##
- # test that redacted ways aren't visible, regardless of
- # authorisation except as moderator...
- def test_version_redacted
- way = create(:way, :with_history, :version => 2)
- way_v1 = way.old_ways.find_by(:version => 1)
- way_v1.redact!(create(:redaction))
-
- get api_old_way_path(way_v1.way_id, way_v1.version)
- assert_response :forbidden, "Redacted way shouldn't be visible via the version API."
-
- # not even to a logged-in user
- auth_header = bearer_authorization_header
- get api_old_way_path(way_v1.way_id, way_v1.version), :headers => auth_header
- assert_response :forbidden, "Redacted way shouldn't be visible via the version API, even when logged in."
- end
-
- ##
- # test that redacted ways aren't visible in the history
- def test_history_redacted
- way = create(:way, :with_history, :version => 2)
- way_v1 = way.old_ways.find_by(:version => 1)
- way_v1.redact!(create(:redaction))
-
- get api_way_history_path(way)
- assert_response :success, "Redaction shouldn't have stopped history working."
- assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 0,
- "redacted way #{way_v1.way_id} version #{way_v1.version} shouldn't be present in the history."
-
- # not even to a logged-in user
- auth_header = bearer_authorization_header
- get api_way_history_path(way), :headers => auth_header
- assert_response :success, "Redaction shouldn't have stopped history working."
- assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 0,
- "redacted node #{way_v1.way_id} version #{way_v1.version} shouldn't be present in the history, even when logged in."
- end
-
##
# test the redaction of an old version of a way, while being
# authorised as a moderator.
# check moderator can still see the redacted data, when passing
# the appropriate flag
- get api_old_way_path(way_v3.way_id, way_v3.version), :headers => auth_header
+ get api_way_version_path(way_v3.way_id, way_v3.version), :headers => auth_header
assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed."
- get api_old_way_path(way_v3.way_id, way_v3.version, :show_redactions => "true"), :headers => auth_header
+ get api_way_version_path(way_v3.way_id, way_v3.version, :show_redactions => "true"), :headers => auth_header
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
# and when accessed via history
- get api_way_history_path(way), :headers => auth_header
+ get api_way_versions_path(way), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm way[id='#{way_v3.way_id}'][version='#{way_v3.version}']", 0,
"way #{way_v3.way_id} version #{way_v3.version} should not be present in the history for moderators when not passing flag."
- get api_way_history_path(way, :show_redactions => "true"), :headers => auth_header
+ get api_way_versions_path(way, :show_redactions => "true"), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm way[id='#{way_v3.way_id}'][version='#{way_v3.version}']", 1,
"way #{way_v3.way_id} version #{way_v3.version} should still be present in the history for moderators when passing flag."
auth_header = bearer_authorization_header
# check can't see the redacted data
- get api_old_way_path(way_v3.way_id, way_v3.version), :headers => auth_header
+ get api_way_version_path(way_v3.way_id, way_v3.version), :headers => auth_header
assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
# and when accessed via history
- get api_way_history_path(way), :headers => auth_header
+ get api_way_versions_path(way), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm way[id='#{way_v3.way_id}'][version='#{way_v3.version}']", 0,
"redacted way #{way_v3.way_id} version #{way_v3.version} shouldn't be present in the history."
# check moderator can still see the unredacted data, without passing
# the appropriate flag
- get api_old_way_path(way_v1.way_id, way_v1.version), :headers => auth_header
+ get api_way_version_path(way_v1.way_id, way_v1.version), :headers => auth_header
assert_response :success, "After unredaction, node should not be gone for moderator."
# and when accessed via history
- get api_way_history_path(way), :headers => auth_header
+ get api_way_versions_path(way), :headers => auth_header
assert_response :success, "Unredaction shouldn't have stopped history working."
assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 1,
"way #{way_v1.way_id} version #{way_v1.version} should still be present in the history for moderators."
auth_header = bearer_authorization_header
# check normal user can now see the unredacted data
- get api_old_way_path(way_v1.way_id, way_v1.version), :headers => auth_header
+ get api_way_version_path(way_v1.way_id, way_v1.version), :headers => auth_header
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
# and when accessed via history
- get api_way_history_path(way), :headers => auth_header
+ get api_way_versions_path(way), :headers => auth_header
assert_response :success, "Redaction shouldn't have stopped history working."
assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 1,
"way #{way_v1.way_id} version #{way_v1.version} should still be present in the history for normal users."
private
- ##
- # check that the current version of a way is equivalent to the
- # version which we're getting from the versions call.
- def check_current_version(way_id)
- # get the current version
- current_way = with_controller(WaysController.new) do
- get api_way_path(way_id)
- assert_response :success, "can't get current way #{way_id}"
- Way.from_xml(@response.body)
- end
- assert_not_nil current_way, "getting way #{way_id} returned nil"
-
- # get the "old" version of the way from the version method
- get api_old_way_path(way_id, current_way.version)
- assert_response :success, "can't get old way #{way_id}, v#{current_way.version}"
- old_way = Way.from_xml(@response.body)
-
- # check that the ways are identical
- assert_ways_are_equal current_way, old_way
- end
-
##
# look at all the versions of the way in the history and get each version from
# the versions call. check that they're the same.
def check_history_equals_versions(way_id)
- get api_way_history_path(way_id)
+ get api_way_versions_path(way_id)
assert_response :success, "can't get way #{way_id} from API"
history_doc = XML::Parser.string(@response.body).parse
assert_not_nil history_doc, "parsing way #{way_id} history failed"
history_way = Way.from_xml_node(way_doc)
assert_not_nil history_way, "parsing way #{way_id} version failed"
- get api_old_way_path(way_id, history_way.version)
+ get api_way_version_path(way_id, history_way.version)
assert_response :success, "couldn't get way #{way_id}, v#{history_way.version}"
version_way = Way.from_xml(@response.body)
assert_not_nil version_way, "failed to parse #{way_id}, v#{history_way.version}"
end
def do_redact_way(way, redaction, headers = {})
- get api_old_way_path(way.way_id, way.version)
+ get api_way_version_path(way.way_id, way.version)
assert_response :success, "should be able to get version #{way.version} of way #{way.way_id}."
# now redact it
post way_version_redact_path(way.way_id, way.version), :params => { :redaction => redaction.id }, :headers => headers
end
-
- def propagate_tags(way, old_way)
- way.tags.each do |k, v|
- create(:old_way_tag, :old_way => old_way, :k => k, :v => v)
- end
- end
end
end
# check the ordering in the history tables:
with_controller(OldRelationsController.new) do
- get api_old_relation_path(relation_id, 2)
+ get api_relation_version_path(relation_id, 2)
assert_response :success, "can't read back version 2 of the relation #{relation_id}"
check_ordering(doc, @response.body)
end
# check the ordering in the history tables:
with_controller(OldRelationsController.new) do
- get api_old_relation_path(relation_id, 1)
+ get api_relation_version_path(relation_id, 1)
assert_response :success, "can't read back version 1 of the relation: #{@response.body}"
check_ordering(doc, @response.body)
end
get api_relation_path(id)
else
with_controller(OldRelationsController.new) do
- get api_old_relation_path(id, ver)
+ get api_relation_version_path(id, ver)
end
end
assert_response :success
assert_select "h4", /^Version/ do
assert_select "a[href='#{old_node_path node, 1}']", :count => 0
end
- assert_select ".secondary-actions a[href='#{api_old_node_path node, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{api_node_version_path node, 1}']", :count => 1
assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
assert_select ".secondary-actions a[href='#{old_node_path node, 1, :params => { :show_redactions => true }}']", :count => 0
assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
assert_select "h4", /^Version/ do
assert_select "a[href='#{old_node_path node, 1}']", :count => 0
end
- assert_select ".secondary-actions a[href='#{api_old_node_path node, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{api_node_version_path node, 1}']", :count => 1
assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
assert_select ".secondary-actions a[href='#{old_node_path node, 2}']", :count => 1
assert_select "h4", /^Version/ do
assert_select "a[href='#{old_node_path node, 2}']", :count => 0
end
- assert_select ".secondary-actions a[href='#{api_old_node_path node, 2}']", :count => 1
+ assert_select ".secondary-actions a[href='#{api_node_version_path node, 2}']", :count => 1
assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 1
assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
assert_select ".secondary-actions a[href='#{old_node_path node, 1, :params => { :show_redactions => true }}']", :count => 0
assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 0
- assert_select ".secondary-actions a[href='#{api_old_node_path node, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_node_version_path node, 1}']", :count => 0
end
test "show unrevealed redacted versions to regular users" do
assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
assert_select ".secondary-actions a[href='#{old_node_path node, 1, :params => { :show_redactions => true }}']", :count => 0
assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 0
- assert_select ".secondary-actions a[href='#{api_old_node_path node, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_node_version_path node, 1}']", :count => 0
end
test "show unrevealed redacted versions to moderators" do
assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
assert_select ".secondary-actions a[href='#{old_node_path node, 1, :params => { :show_redactions => true }}']", :count => 1
assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 0
- assert_select ".secondary-actions a[href='#{api_old_node_path node, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_node_version_path node, 1}']", :count => 0
end
test "don't reveal redacted versions to anonymous users" do
assert_select "h4", /^Version/ do
assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
end
- assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 1}']", :count => 1
assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
assert_select ".secondary-actions a[href='#{old_relation_path relation, 1, :params => { :show_redactions => true }}']", :count => 0
assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
assert_select "h4", /^Version/ do
assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
end
- assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 1}']", :count => 1
assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
assert_select ".secondary-actions a[href='#{old_relation_path relation, 2}']", :count => 1
assert_select "h4", /^Version/ do
assert_select "a[href='#{old_relation_path relation, 2}']", :count => 0
end
- assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 2}']", :count => 1
+ assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 2}']", :count => 1
assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 1
assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
assert_select ".secondary-actions a[href='#{old_relation_path relation, 1, :params => { :show_redactions => true }}']", :count => 0
assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
- assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 1}']", :count => 0
end
test "show unrevealed redacted versions to regular users" do
assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
assert_select ".secondary-actions a[href='#{old_relation_path relation, 1, :params => { :show_redactions => true }}']", :count => 0
assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
- assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 1}']", :count => 0
end
test "show unrevealed redacted versions to moderators" do
assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
assert_select ".secondary-actions a[href='#{old_relation_path relation, 1, :params => { :show_redactions => true }}']", :count => 1
assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
- assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 1}']", :count => 0
end
test "don't reveal redacted versions to anonymous users" do
assert_select "h4", /^Version/ do
assert_select "a[href='#{old_way_path way, 1}']", :count => 0
end
- assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{api_way_version_path way, 1}']", :count => 1
assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 0
assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
assert_select "h4", /^Version/ do
assert_select "a[href='#{old_way_path way, 1}']", :count => 0
end
- assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 1
+ assert_select ".secondary-actions a[href='#{api_way_version_path way, 1}']", :count => 1
assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
assert_select ".secondary-actions a[href='#{old_way_path way, 2}']", :count => 1
assert_select "h4", /^Version/ do
assert_select "a[href='#{old_way_path way, 2}']", :count => 0
end
- assert_select ".secondary-actions a[href='#{api_old_way_path way, 2}']", :count => 1
+ assert_select ".secondary-actions a[href='#{api_way_version_path way, 2}']", :count => 1
assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 1
assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 0
assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
- assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_way_version_path way, 1}']", :count => 0
end
test "show unrevealed redacted versions to regular users" do
assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 0
assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
- assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_way_version_path way, 1}']", :count => 0
end
test "show unrevealed redacted versions to moderators" do
assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 1
assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
- assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_way_version_path way, 1}']", :count => 0
end
test "don't reveal redacted versions to anonymous users" do
--- /dev/null
+require "test_helper"
+
+class NodeVersionsTest < ActionDispatch::IntegrationTest
+ ##
+ # test the version call by submitting several revisions of a new node
+ # to the API and ensuring that later calls to version return the
+ # matching versions of the object.
+ def test_version
+ private_user = create(:user, :data_public => false)
+ private_node = create(:node, :with_history, :version => 4, :lat => 0, :lon => 0, :changeset => create(:changeset, :user => private_user))
+ user = create(:user)
+ node = create(:node, :with_history, :version => 4, :lat => 0, :lon => 0, :changeset => create(:changeset, :user => user))
+ create_list(:node_tag, 2, :node => node)
+ # Ensure that the current tags are propagated to the history too
+ propagate_tags(node, node.old_nodes.last)
+
+ ## First try this with a non-public user
+ auth_header = bearer_authorization_header private_user
+
+ # setup a simple XML node
+ xml_doc = xml_for_node(private_node)
+ xml_node = xml_doc.find("//osm/node").first
+ node_id = private_node.id
+
+ # keep a hash of the versions => string, as we'll need something
+ # to test against later
+ versions = {}
+
+ # save a version for later checking
+ versions[xml_node["version"]] = xml_doc.to_s
+
+ # randomly move the node about
+ 3.times do
+ # move the node somewhere else
+ xml_node["lat"] = precision(rand - 0.5).to_s
+ xml_node["lon"] = precision(rand - 0.5).to_s
+ with_controller(NodesController.new) do
+ put api_node_path(node_id), :params => xml_doc.to_s, :headers => auth_header
+ assert_response :forbidden, "Should have rejected node update"
+ xml_node["version"] = @response.body.to_s
+ end
+ # save a version for later checking
+ versions[xml_node["version"]] = xml_doc.to_s
+ end
+
+ # add a bunch of random tags
+ 3.times do
+ xml_tag = XML::Node.new("tag")
+ xml_tag["k"] = random_string
+ xml_tag["v"] = random_string
+ xml_node << xml_tag
+ with_controller(NodesController.new) do
+ put api_node_path(node_id), :params => xml_doc.to_s, :headers => auth_header
+ assert_response :forbidden,
+ "should have rejected node #{node_id} (#{@response.body}) with forbidden"
+ xml_node["version"] = @response.body.to_s
+ end
+ # save a version for later checking
+ versions[xml_node["version"]] = xml_doc.to_s
+ end
+
+ # probably should check that they didn't get written to the database
+
+ ## Now do it with the public user
+ auth_header = bearer_authorization_header user
+
+ # setup a simple XML node
+
+ xml_doc = xml_for_node(node)
+ xml_node = xml_doc.find("//osm/node").first
+ node_id = node.id
+
+ # keep a hash of the versions => string, as we'll need something
+ # to test against later
+ versions = {}
+
+ # save a version for later checking
+ versions[xml_node["version"]] = xml_doc.to_s
+
+ # randomly move the node about
+ 3.times do
+ # move the node somewhere else
+ xml_node["lat"] = precision(rand - 0.5).to_s
+ xml_node["lon"] = precision(rand - 0.5).to_s
+ with_controller(NodesController.new) do
+ put api_node_path(node_id), :params => xml_doc.to_s, :headers => auth_header
+ assert_response :success
+ xml_node["version"] = @response.body.to_s
+ end
+ # save a version for later checking
+ versions[xml_node["version"]] = xml_doc.to_s
+ end
+
+ # add a bunch of random tags
+ 3.times do
+ xml_tag = XML::Node.new("tag")
+ xml_tag["k"] = random_string
+ xml_tag["v"] = random_string
+ xml_node << xml_tag
+ with_controller(NodesController.new) do
+ put api_node_path(node_id), :params => xml_doc.to_s, :headers => auth_header
+ assert_response :success,
+ "couldn't update node #{node_id} (#{@response.body})"
+ xml_node["version"] = @response.body.to_s
+ end
+ # save a version for later checking
+ versions[xml_node["version"]] = xml_doc.to_s
+ end
+
+ # check all the versions
+ versions.each_key do |key|
+ get api_node_version_path(node_id, key.to_i)
+
+ assert_response :success,
+ "couldn't get version #{key.to_i} of node #{node_id}"
+
+ check_node = Node.from_xml(versions[key])
+ api_node = Node.from_xml(@response.body.to_s)
+
+ assert_nodes_are_equal check_node, api_node
+ end
+ end
+
+ ##
+ # Test that getting the current version is identical to picking
+ # that version with the version URI call.
+ def test_current_version
+ node = create(:node, :with_history)
+ used_node = create(:node, :with_history)
+ create(:way_node, :node => used_node)
+ node_used_by_relationship = create(:node, :with_history)
+ create(:relation_member, :member => node_used_by_relationship)
+ node_with_versions = create(:node, :with_history, :version => 4)
+
+ create(:node_tag, :node => node)
+ create(:node_tag, :node => used_node)
+ create(:node_tag, :node => node_used_by_relationship)
+ create(:node_tag, :node => node_with_versions)
+ propagate_tags(node, node.old_nodes.last)
+ propagate_tags(used_node, used_node.old_nodes.last)
+ propagate_tags(node_used_by_relationship, node_used_by_relationship.old_nodes.last)
+ propagate_tags(node_with_versions, node_with_versions.old_nodes.last)
+
+ check_current_version(node)
+ check_current_version(used_node)
+ check_current_version(node_used_by_relationship)
+ check_current_version(node_with_versions)
+ end
+
+ private
+
+ def check_current_version(node_id)
+ # get the current version of the node
+ current_node = with_controller(NodesController.new) do
+ get api_node_path(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 api_node_version_path(node_id, 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 { 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
+ end
+end
--- /dev/null
+require "test_helper"
+
+class WayVersionsTest < ActionDispatch::IntegrationTest
+ ##
+ # check that we can retrieve versions of a way
+ def test_version
+ way = create(:way, :with_history)
+ used_way = create(:way, :with_history)
+ create(:relation_member, :member => used_way)
+ way_with_versions = create(:way, :with_history, :version => 4)
+
+ create(:way_tag, :way => way)
+ create(:way_tag, :way => used_way)
+ create(:way_tag, :way => way_with_versions)
+ propagate_tags(way, way.old_ways.last)
+ propagate_tags(used_way, used_way.old_ways.last)
+ propagate_tags(way_with_versions, way_with_versions.old_ways.last)
+
+ check_current_version(way.id)
+ check_current_version(used_way.id)
+ check_current_version(way_with_versions.id)
+ end
+
+ private
+
+ ##
+ # check that the current version of a way is equivalent to the
+ # version which we're getting from the versions call.
+ def check_current_version(way_id)
+ # get the current version
+ current_way = with_controller(WaysController.new) do
+ get api_way_path(way_id)
+ assert_response :success, "can't get current way #{way_id}"
+ Way.from_xml(@response.body)
+ end
+ assert_not_nil current_way, "getting way #{way_id} returned nil"
+
+ # get the "old" version of the way from the version method
+ get api_way_version_path(way_id, current_way.version)
+ assert_response :success, "can't get old way #{way_id}, v#{current_way.version}"
+ old_way = Way.from_xml(@response.body)
+
+ # check that the ways are identical
+ assert_ways_are_equal current_way, old_way
+ end
+
+ def propagate_tags(way, old_way)
+ way.tags.each do |k, v|
+ create(:old_way_tag, :old_way => old_way, :k => k, :v => v)
+ end
+ end
+end
integrity sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==
"@stylistic/eslint-plugin-js@^3.0.0":
- version "3.0.1"
- resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-js/-/eslint-plugin-js-3.0.1.tgz#15638c55a9adab2c110243a9f0d812264b067aab"
- integrity sha512-hjp6BKXSUdlY4l20pDb0EjIB5PtQDGihk2EUKCjJ5gaRVfcmMMkaIyVd/yK3oH7OLxWWBxJ8qSSo+zEdkmpnYA==
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-js/-/eslint-plugin-js-3.1.0.tgz#b36292b09bd810ea1b34e0720512f137335ef745"
+ integrity sha512-lQktsOiCr8S6StG29C5fzXYxLOD6ID1rp4j6TRS+E/qY1xd59Fm7dy5qm9UauJIEoSTlYx6yGsCHYh5UkgXPyg==
dependencies:
eslint-visitor-keys "^4.2.0"
espree "^10.3.0"