amf_handle_error_with_timeout("'getway_old' #{id}, #{timestamp}", 'way',id) do
if timestamp == ''
# undelete
- old_way = OldWay.where(:visible => true, :id => id).order("version DESC").first
+ old_way = OldWay.where(:visible => true, :way_id => id).order("version DESC").first
points = old_way.get_nodes_undelete unless old_way.nil?
else
begin
# revert
timestamp = DateTime.strptime(timestamp.to_s, "%d %b %Y, %H:%M:%S")
- old_way = OldWay.where("id = ? AND timestamp <= ?", id, timestamp).order("timestamp DESC").first
+ old_way = OldWay.where("way_id = ? AND timestamp <= ?", id, timestamp).order("timestamp DESC").first
unless old_way.nil?
points = old_way.get_nodes_revert(timestamp)
if !old_way.visible
created << elt.to_xml_node
else
# get the previous version from the element history
- prev_elt = elt.class.where(:id => elt.id, :version => elt.version).first
+ prev_elt = elt.class.find([elt.id, elt.version])
unless elt.visible
# if the element isn't visible then it must have been deleted, so
# output the *previous* XML
end
def version
- if old_node = OldNode.where(:id => params[:id], :version => params[:version]).first
+ if old_node = OldNode.where(:node_id => params[:id], :version => params[:version]).first
response.last_modified = old_node.timestamp
doc = OSM::API.new.get_xml_doc
end
def version
- if old_relation = OldRelation.where(:id => params[:id], :version => params[:version]).first
+ if old_relation = OldRelation.where(:relation_id => params[:id], :version => params[:version]).first
response.last_modified = old_relation.timestamp
doc = OSM::API.new.get_xml_doc
end
def version
- if old_way = OldWay.where(:id => params[:id], :version => params[:version]).first
+ if old_way = OldWay.where(:way_id => params[:id], :version => params[:version]).first
response.last_modified = old_way.timestamp
doc = OSM::API.new.get_xml_doc
end
def relations_for_object(objtype)
- relationids = RelationMember.where(:member_type => objtype, :member_id => params[:id]).collect { |ws| ws.id[0] }.uniq
+ relationids = RelationMember.where(:member_type => objtype, :member_id => params[:id]).collect { |ws| ws.relation_id }.uniq
doc = OSM::API.new.get_xml_doc
belongs_to :user
- has_many :changeset_tags, :foreign_key => 'id'
+ has_many :changeset_tags
has_many :nodes
has_many :ways
self.save!
tags = self.tags
- ChangesetTag.delete_all(['id = ?', self.id])
+ ChangesetTag.delete_all(:changeset_id => self.id)
tags.each do |k,v|
tag = ChangesetTag.new
+ tag.changeset_id = self.id
tag.k = k
tag.v = v
- tag.id = self.id
tag.save!
end
end
class ChangesetTag < ActiveRecord::Base
- belongs_to :changeset, :foreign_key => 'id'
+ set_primary_keys :changeset_id, :k
- validates_presence_of :id
- validates_length_of :k, :v, :maximum => 255, :allow_blank => true
- validates_uniqueness_of :id, :scope => :k
- validates_numericality_of :id, :only_integer => true
+ belongs_to :changeset
+
+ validates_presence_of :changeset
+ validates_length_of :k, :maximum => 255, :allow_blank => true
+ validates_uniqueness_of :k, :scope => :changeset_id
+ validates_length_of :v, :maximum => 255, :allow_blank => true
end
belongs_to :changeset
- has_many :old_nodes, :foreign_key => :id, :order => :version
+ has_many :old_nodes, :order => :version
has_many :way_nodes
has_many :ways, :through => :way_nodes
- has_many :node_tags, :foreign_key => :id
+ has_many :node_tags
has_many :old_way_nodes
has_many :ways_via_history, :class_name=> "Way", :through => :old_way_nodes, :source => :way
# Create a NodeTag
tags = self.tags
- NodeTag.delete_all(['id = ?', self.id])
+ NodeTag.delete_all(:node_id => self.id)
tags.each do |k,v|
tag = NodeTag.new
+ tag.node_id = self.id
tag.k = k
tag.v = v
- tag.id = self.id
tag.save!
end
class NodeTag < ActiveRecord::Base
set_table_name 'current_node_tags'
+ set_primary_keys :node_id, :k
- belongs_to :node, :foreign_key => 'id'
+ belongs_to :node
- validates_presence_of :id
- validates_length_of :k, :v, :maximum => 255, :allow_blank => true
- validates_uniqueness_of :id, :scope => :k
- validates_numericality_of :id, :only_integer => true
+ validates_presence_of :node
+ validates_length_of :k, :maximum => 255, :allow_blank => true
+ validates_uniqueness_of :k, :scope => :node_id
+ validates_length_of :v, :maximum => 255, :allow_blank => true
end
include ConsistencyValidations
set_table_name 'nodes'
-
- # Should probably have the composite primary key set in the model
- # however there are some weird bugs happening when you do
- #set_primary_keys :id, :version
-
+ set_primary_keys :node_id, :version
+
validates_presence_of :changeset_id, :timestamp
validates_inclusion_of :visible, :in => [ true, false ]
validates_numericality_of :latitude, :longitude
old_node.tags = node.tags
old_node.timestamp = node.timestamp
old_node.changeset_id = node.changeset_id
- old_node.id = node.id
+ old_node.node_id = node.id
old_node.version = node.version
return old_node
end
def to_xml_node
el1 = XML::Node.new 'node'
- el1['id'] = self.id.to_s
+ el1['id'] = self.node_id.to_s
el1['lat'] = self.lat.to_s
el1['lon'] = self.lon.to_s
el1['changeset'] = self.changeset.id.to_s
clear_aggregation_cache
clear_association_cache
#ok from here
- @attributes.update(OldNode.where('id = ? AND timestamp = ? AND version = ?', self.id, self.timestamp, self.version).first.instance_variable_get('@attributes'))
+ @attributes.update(OldNode.where(:node_id => self.node_id, :timestamp => self.timestamp, :version => self.version).first.instance_variable_get('@attributes'))
self.tags.each do |k,v|
tag = OldNodeTag.new
tag.k = k
tag.v = v
- tag.id = self.id
+ tag.node_id = self.node_id
tag.version = self.version
tag.save!
end
def tags
unless @tags
- @tags = Hash.new
- OldNodeTag.where("id = ? AND version = ?", self.id, self.version).each do |tag|
- @tags[tag.k] = tag.v
- end
+ @tags = Hash.new
+ OldNodeTag.where(:node_id => self.node_id, :version => self.version).each do |tag|
+ @tags[tag.k] = tag.v
+ end
end
@tags = Hash.new unless @tags
@tags
class OldNodeTag < ActiveRecord::Base
set_table_name 'node_tags'
+ set_primary_keys :node_id, :version, :k
- belongs_to :user
+ belongs_to :old_node, :foreign_key => [:node_id, :version]
- validates_presence_of :id, :version
- validates_length_of :k, :v, :maximum => 255, :allow_blank => true
- validates_uniqueness_of :id, :scope => [:k, :version]
- validates_numericality_of :id, :version, :only_integer => true
+ validates_presence_of :old_node
+ validates_length_of :k, :maximum => 255, :allow_blank => true
+ validates_uniqueness_of :k, :scope => [:node_id, :version]
+ validates_length_of :v, :maximum => 255, :allow_blank => true
end
include ConsistencyValidations
set_table_name 'relations'
+ set_primary_keys :relation_id, :version
belongs_to :changeset
+
+ has_many :old_members, :class_name => 'OldRelationMember', :foreign_key => [:relation_id, :version], :order => :sequence_id
+ has_many :old_tags, :class_name => 'OldRelationTag', :foreign_key => [:relation_id, :version]
validates_associated :changeset
old_relation.visible = relation.visible
old_relation.changeset_id = relation.changeset_id
old_relation.timestamp = relation.timestamp
- old_relation.id = relation.id
+ old_relation.relation_id = relation.id
old_relation.version = relation.version
old_relation.members = relation.members
old_relation.tags = relation.tags
save!
clear_aggregation_cache
clear_association_cache
- @attributes.update(OldRelation.where('id = ? AND timestamp = ?', self.id, self.timestamp).order("version DESC").first.instance_variable_get('@attributes'))
+ @attributes.update(OldRelation.where(:relation_id => self.relation_id, :timestamp => self.timestamp).order("version DESC").first.instance_variable_get('@attributes'))
# ok, you can touch from here on
tag = OldRelationTag.new
tag.k = k
tag.v = v
- tag.id = self.id
+ tag.relation_id = self.relation_id
tag.version = self.version
tag.save!
end
self.members.each_with_index do |m,i|
member = OldRelationMember.new
- member.id = [self.id, self.version, i]
+ member.id = [self.relation_id, self.version, i]
member.member_type = m[0].classify
member.member_id = m[1]
member.member_role = m[2]
def members
unless @members
- @members = Array.new
- OldRelationMember.where("id = ? AND version = ?", self.id, self.version).order(:sequence_id).each do |m|
- @members += [[m.type,m.id,m.role]]
- end
+ @members = Array.new
+ OldRelationMember.where(:relation_id => self.relation_id, :version => self.version).order(:sequence_id).each do |m|
+ @members += [[m.type,m.id,m.role]]
+ end
end
@members
end
def tags
unless @tags
- @tags = Hash.new
- OldRelationTag.where("id = ? AND version = ?", self.id, self.version).each do |tag|
- @tags[tag.k] = tag.v
- end
+ @tags = Hash.new
+ OldRelationTag.where(:relation_id => self.relation_id, :version => self.version).each do |tag|
+ @tags[tag.k] = tag.v
+ end
end
@tags = Hash.new unless @tags
@tags
@tags = t
end
-# has_many :relation_segments, :class_name => 'OldRelationSegment', :foreign_key => 'id'
-# has_many :relation_tags, :class_name => 'OldRelationTag', :foreign_key => 'id'
-
- def old_members
- OldRelationMember.where('id = ? AND version = ?', self.id, self.version).order(:sequence_id)
- end
-
- def old_tags
- OldRelationTag.where('id = ? AND version = ?', self.id, self.version)
- end
-
def to_xml
doc = OSM::API.new.get_xml_doc
doc.root << to_xml_node()
def to_xml_node
el1 = XML::Node.new 'relation'
- el1['id'] = self.id.to_s
+ el1['id'] = self.relation_id.to_s
el1['visible'] = self.visible.to_s
el1['timestamp'] = self.timestamp.xmlschema
if self.changeset.user.data_public?
class OldRelationMember < ActiveRecord::Base
set_table_name 'relation_members'
+ set_primary_keys :relation_id, :version, :sequence_id
- set_primary_keys :id, :version, :sequence_id
- belongs_to :relation, :foreign_key=> :id
+ belongs_to :old_relation, :foreign_key => [:relation_id, :version]
# A bit messy, referring to the current tables, should do for the data browser for now
belongs_to :member, :polymorphic => true
end
class OldRelationTag < ActiveRecord::Base
set_table_name 'relation_tags'
+ set_primary_keys :relation_id, :version, :k
+
+ belongs_to :old_relation, :foreign_key => [:relation_id, :version]
- belongs_to :old_relation, :foreign_key => [:id, :version]
-
- validates_presence_of :id, :version
- validates_length_of :k, :v, :maximum => 255, :allow_blank => true
- validates_uniqueness_of :id, :scope => [:k, :version]
- validates_numericality_of :id, :version, :only_integer => true
+ validates_presence_of :old_relation
+ validates_length_of :k, :maximum => 255, :allow_blank => true
+ validates_uniqueness_of :k, :scope => [:relation_id, :version]
+ validates_length_of :v, :maximum => 255, :allow_blank => true
end
include ConsistencyValidations
set_table_name 'ways'
+ set_primary_keys :way_id, :version
belongs_to :changeset
+ has_many :old_nodes, :class_name => 'OldWayNode', :foreign_key => [:way_id, :version]
+ has_many :old_tags, :class_name => 'OldWayTag', :foreign_key => [:way_id, :version]
+
validates_associated :changeset
def self.from_way(way)
old_way.visible = way.visible
old_way.changeset_id = way.changeset_id
old_way.timestamp = way.timestamp
- old_way.id = way.id
+ old_way.way_id = way.id
old_way.version = way.version
old_way.nds = way.nds
old_way.tags = way.tags
save!
clear_aggregation_cache
clear_association_cache
- @attributes.update(OldWay.where('id = ? AND timestamp = ?', self.id, self.timestamp).order("version DESC").first.instance_variable_get('@attributes'))
+ @attributes.update(OldWay.where(:way_id => self.way_id, :timestamp => self.timestamp).order("version DESC").first.instance_variable_get('@attributes'))
# ok, you can touch from here on
tag = OldWayTag.new
tag.k = k
tag.v = v
- tag.id = self.id
+ tag.way_id = self.way_id
tag.version = self.version
tag.save!
end
sequence = 1
self.nds.each do |n|
nd = OldWayNode.new
- nd.id = [self.id, self.version, sequence]
+ nd.id = [self.way_id, self.version, sequence]
nd.node_id = n
nd.save!
sequence += 1
def nds
unless @nds
- @nds = Array.new
- OldWayNode.where("id = ? AND version = ?", self.id, self.version).order(:sequence_id).each do |nd|
- @nds += [nd.node_id]
- end
+ @nds = Array.new
+ OldWayNode.where(:way_id => self.way_id, :version => self.version).order(:sequence_id).each do |nd|
+ @nds += [nd.node_id]
+ end
end
@nds
end
def tags
unless @tags
- @tags = Hash.new
- OldWayTag.where("id = ? AND version = ?", self.id, self.version).each do |tag|
- @tags[tag.k] = tag.v
- end
+ @tags = Hash.new
+ OldWayTag.where(:way_id => self.way_id, :version => self.version).each do |tag|
+ @tags[tag.k] = tag.v
+ end
end
@tags = Hash.new unless @tags
@tags
@tags = t
end
-# has_many :way_nodes, :class_name => 'OldWayNode', :foreign_key => 'id'
-# has_many :way_tags, :class_name => 'OldWayTag', :foreign_key => 'id'
-
- def old_nodes
- OldWayNode.where('id = ? AND version = ?', self.id, self.version)
- end
-
- def old_tags
- OldWayTag.where('id = ? AND version = ?', self.id, self.version)
- end
-
def to_xml_node
el1 = XML::Node.new 'way'
- el1['id'] = self.id.to_s
+ el1['id'] = self.way_id.to_s
el1['visible'] = self.visible.to_s
el1['timestamp'] = self.timestamp.xmlschema
if self.changeset.user.data_public?
def get_nodes_revert(timestamp)
points=[]
self.nds.each do |n|
- oldnode = OldNode.where('id = ? AND timestamp <= ?', n, timestamp).order("timestamp DESC").first
+ oldnode = OldNode.where('node_id = ? AND timestamp <= ?', n, timestamp).order("timestamp DESC").first
curnode = Node.find(n)
id = n; reuse = curnode.visible
if oldnode.lat != curnode.lat or oldnode.lon != curnode.lon or oldnode.tags != curnode.tags then
# node has changed: if it's in other ways, give it a new id
- if curnode.ways-[self.id] then id=-1; reuse=false end
+ if curnode.ways-[self.node_id] then id=-1; reuse=false end
end
points << [oldnode.lon, oldnode.lat, id, curnode.version, oldnode.tags_as_hash, reuse]
end
class OldWayNode < ActiveRecord::Base
set_table_name 'way_nodes'
+ set_primary_keys :way_id, :version, :sequence_id
- set_primary_keys :id, :version, :sequence_id
-
- belongs_to :way, :foreign_key=> :id
-
- # A bit messy, referring to current nodes, should do for the data browser for now
+ belongs_to :old_way, :foreign_key => [:way_id, :version]
+ # A bit messy, referring to current nodes and ways, should do for the data browser for now
belongs_to :node
+ belongs_to :way
end
class OldWayTag < ActiveRecord::Base
set_table_name 'way_tags'
+ set_primary_keys :way_id, :version, :k
- belongs_to :old_way, :foreign_key => [:id, :version]
+ belongs_to :old_way, :foreign_key => [:way_id, :version]
- validates_presence_of :id
- validates_length_of :k, :v, :maximum => 255, :allow_blank => true
- validates_uniqueness_of :id, :scope => [:k, :version]
- validates_numericality_of :id, :version, :only_integer => true
+ validates_presence_of :old_way
+ validates_length_of :k, :maximum => 255, :allow_blank => true
+ validates_uniqueness_of :k, :scope => [:way_id, :version]
+ validates_length_of :v, :maximum => 255, :allow_blank => true
end
belongs_to :changeset
- has_many :old_relations, :foreign_key => 'id', :order => 'version'
+ has_many :old_relations, :order => 'version'
- has_many :relation_members, :foreign_key => 'id', :order => 'sequence_id'
- has_many :relation_tags, :foreign_key => 'id'
+ has_many :relation_members, :order => 'sequence_id'
+ has_many :relation_tags
has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation, :extend => ObjectFinder
# if there are left-over tags then they are new and will have to
# be added.
tags_changed |= (not tags.empty?)
- RelationTag.delete_all(:id => self.id)
+ RelationTag.delete_all(:relation_id => self.id)
self.tags.each do |k,v|
tag = RelationTag.new
+ tag.relation_id = self.id
tag.k = k
tag.v = v
- tag.id = self.id
tag.save!
end
# members may be in a different order and i don't feel like implementing
# a longest common subsequence algorithm to optimise this.
members = self.members
- RelationMember.delete_all(:id => self.id)
+ RelationMember.delete_all(:relation_id => self.id)
members.each_with_index do |m,i|
mem = RelationMember.new
- mem.id = [self.id, i]
+ mem.relation_id = self.id
+ mem.sequence_id = i
mem.member_type = m[0]
mem.member_id = m[1]
mem.member_role = m[2]
class RelationMember < ActiveRecord::Base
- set_table_name 'current_relation_members'
-
- set_primary_keys :id, :sequence_id
+ set_table_name 'current_relation_members'
+ set_primary_keys :relation_id, :sequence_id
+ belongs_to :relation
belongs_to :member, :polymorphic => true
- belongs_to :relation, :foreign_key => :id
after_find :set_class_from_type
after_initialize :set_class_from_type
class RelationTag < ActiveRecord::Base
set_table_name 'current_relation_tags'
+ set_primary_keys :relation_id, :k
- belongs_to :relation, :foreign_key => 'id'
+ belongs_to :relation
- validates_presence_of :id
- validates_length_of :k, :v, :maximum => 255, :allow_blank => true
- validates_uniqueness_of :id, :scope => :k
- validates_numericality_of :id, :only_integer => true
+ validates_presence_of :relation
+ validates_length_of :k, :maximum => 255, :allow_blank => true
+ validates_uniqueness_of :k, :scope => :relation_id
+ validates_length_of :v, :maximum => 255, :allow_blank => true
end
belongs_to :changeset
- has_many :old_ways, :foreign_key => 'id', :order => 'version'
+ has_many :old_ways, :order => 'version'
- has_many :way_nodes, :foreign_key => 'id', :order => 'sequence_id'
+ has_many :way_nodes, :order => 'sequence_id'
has_many :nodes, :through => :way_nodes, :order => 'sequence_id'
- has_many :way_tags, :foreign_key => 'id'
+ has_many :way_tags
has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation, :extend => ObjectFinder
self.save!
tags = self.tags
- WayTag.delete_all(['id = ?', self.id])
+ WayTag.delete_all(:way_id => self.id)
tags.each do |k,v|
tag = WayTag.new
+ tag.way_id = self.id
tag.k = k
tag.v = v
- tag.id = self.id
tag.save!
end
nds = self.nds
- WayNode.delete_all(['id = ?', self.id])
+ WayNode.delete_all(:way_id => self.id)
sequence = 1
nds.each do |n|
nd = WayNode.new
cs.save!
end
end
-
end
class WayNode < ActiveRecord::Base
set_table_name 'current_way_nodes'
+ set_primary_keys :way_id, :sequence_id
- set_primary_keys :id, :sequence_id
+ belongs_to :way
belongs_to :node
-
- belongs_to :way, :foreign_key => :id
end
class WayTag < ActiveRecord::Base
set_table_name 'current_way_tags'
+ set_primary_keys :way_id, :k
- # False multipart keys. The following would be a hack:
- # set_primary_keys :id, :k, :v
- # FIXME add a real multipart key to waytags so that we can do eager loadin
-
- belongs_to :way, :foreign_key => 'id'
+ belongs_to :way
- validates_presence_of :id
- validates_length_of :k, :v, :maximum => 255, :allow_blank => true
- validates_uniqueness_of :id, :scope => :k
- validates_numericality_of :id, :only_integer => true
+ validates_presence_of :way
+ validates_length_of :k, :maximum => 255, :allow_blank => true
+ validates_uniqueness_of :k, :scope => :way_id
+ validates_length_of :v, :maximum => 255, :allow_blank => true
end
--- /dev/null
+class RenameIds < ActiveRecord::Migration
+ def change
+ rename_column :changeset_tags, :id, :changeset_id
+ rename_column :current_node_tags, :id, :node_id
+ rename_column :nodes, :id, :node_id
+ rename_column :node_tags, :id, :node_id
+ rename_column :current_way_tags, :id, :way_id
+ rename_column :current_way_nodes, :id, :way_id
+ rename_column :ways, :id, :way_id
+ rename_column :way_tags, :id, :way_id
+ rename_column :way_nodes, :id, :way_id
+ rename_column :current_relation_tags, :id, :relation_id
+ rename_column :current_relation_members, :id, :relation_id
+ rename_column :relations, :id, :relation_id
+ rename_column :relation_tags, :id, :relation_id
+ rename_column :relation_members, :id, :relation_id
+ end
+end
changeset_1_tag_1:
- id: 1
+ changeset_id: 1
k: created_by
v: test suite yml
changeset_2_tag_1:
- id: 2
+ changeset_id: 2
k: created_by
v: test suite yml 2
t1:
- id: 1
+ node_id: 1
k: 'testvisible'
v: 'yes'
t2:
- id: 2
+ node_id: 2
k: 'testused'
v: 'yes'
t3:
- id: 3
+ node_id: 3
k: 'test'
v: 'yes'
t4:
- id: 4
+ node_id: 4
k: 'test'
v: 'yes'
nv_t1:
- id: 15
+ node_id: 15
k: 'testing'
v: 'added in node version 3'
nv_t2:
- id: 15
+ node_id: 15
k: 'testing two'
v: 'modified in node version 4'
public_v_t1:
- id: 16
+ node_id: 16
k: 'testvisible'
v: 'yes'
t1:
- id: 1
+ relation_id: 1
member_role: "some"
member_type: "Way"
member_id: 3
t2:
- id: 1
+ relation_id: 1
member_role: "some"
member_type: "Node"
member_id: 5
t3:
- id: 1
+ relation_id: 1
member_role: "some"
member_type: "Relation"
member_id: 3
t4:
- id: 3
+ relation_id: 3
member_role: "some"
member_type: "Node"
member_id: 5
t5:
- id: 2
+ relation_id: 2
member_role: "some"
member_type: "Node"
member_id: 5
public_used:
- id: 6
+ relation_id: 6
member_role: "used by other relation"
member_type: "Relation"
member_id: 5
t1:
- id: 1
+ relation_id: 1
k: 'test'
v: 'yes'
t2:
- id: 2
+ relation_id: 2
k: 'test'
v: 'yes'
t3:
- id: 3
+ relation_id: 3
k: 'test'
v: 'yes'
mt_1:
- id: 4
+ relation_id: 4
k: 'tag1'
v: 'val1'
mt_2:
- id: 4
+ relation_id: 4
k: 'tag2'
v: 'val2'
mt_3:
- id: 4
+ relation_id: 4
k: 'tag3'
v: 'val3'
mt_4:
- id: 4
+ relation_id: 4
k: 'tag4'
v: 'val4'
t1:
- id: 1
+ way_id: 1
node_id: 3
sequence_id: 1
t2:
- id: 2
+ way_id: 2
node_id: 3
sequence_id: 1
t3:
- id: 3
+ way_id: 3
node_id: 3
sequence_id: 1
t4:
- id: 4
+ way_id: 4
node_id: 15
sequence_id: 1
w5_n1:
- id: 5
+ way_id: 5
node_id: 4
sequence_id: 1
w5_n2:
- id: 5
+ way_id: 5
node_id: 4
sequence_id: 2
t1:
- id: 1
+ way_id: 1
k: 'test'
v: 'yes'
t2:
- id: 2
+ way_id: 2
k: 'test'
v: 'yes'
t3:
- id: 3
+ way_id: 3
k: 'test'
v: 'yes'
t1:
- id: 1
+ node_id: 1
k: 'testvisible'
v: 'yes'
version: 1
t2:
- id: 3
+ node_id: 3
k: 'test'
v: 'yes'
version: 1
t3:
- id: 4
+ node_id: 4
k: 'test'
v: 'yes'
version: 1
nv3_t1:
- id: 15
+ node_id: 15
k: 'testing'
v: 'added in node version 3'
version: 3
nv3_t2:
- id: 15
+ node_id: 15
k: 'testing two'
v: 'added in node version 3'
version: 3
nv3_t3:
- id: 15
+ node_id: 15
k: 'testing three'
v: 'added in node version 3'
version: 3
nv4_t1:
- id: 15
+ node_id: 15
k: 'testing'
v: 'added in node version 3'
version: 4
nv4_t2:
- id: 15
+ node_id: 15
k: 'testing two'
v: 'modified in node version 4'
version: 4
public_v_t1:
- id: 16
+ node_id: 16
k: 'testvisible'
v: 'yes'
version: 1
<% SCALE = 10000000 unless defined?(SCALE) %>
visible_node:
- id: 1
+ node_id: 1
latitude: <%= 1*SCALE %>
longitude: <%= 1*SCALE %>
changeset_id: 1
timestamp: 2007-01-01 00:00:00
invisible_node:
- id: 2
+ node_id: 2
latitude: <%= 2*SCALE %>
longitude: <%= 2*SCALE %>
changeset_id: 1
timestamp: 2007-01-01 00:00:00
used_node_1:
- id: 3
+ node_id: 3
latitude: <%= 3*SCALE %>
longitude: <%= 3*SCALE %>
changeset_id: 2
timestamp: 2007-01-01 00:00:00
used_node_2:
- id: 4
+ node_id: 4
latitude: <%= 4*SCALE %>
longitude: <%= 4*SCALE %>
changeset_id: 1
timestamp: 2007-01-01 00:00:00
node_used_by_relationship:
- id: 5
+ node_id: 5
latitude: <%= 5*SCALE %>
longitude: <%= 5*SCALE %>
changeset_id: 2
timestamp: 2007-01-01 00:00:00
node_too_far_north:
- id: 6
+ node_id: 6
latitude: <%= 90.01*SCALE %>
longitude: <%= 6*SCALE %>
changeset_id: 5
timestamp: 2007-01-01 00:00:00
node_north_limit:
- id: 11
+ node_id: 11
latitude: <%= 90*SCALE %>
longitude: <%= 11*SCALE %>
changeset_id: 5
timestamp: 2008-07-08 14:50:00
node_too_far_south:
- id: 7
+ node_id: 7
latitude: <%= -90.01*SCALE %>
longitude: <%= 7*SCALE %>
changeset_id: 5
timestamp: 2007-01-01 00:00:00
node_south_limit:
- id: 12
+ node_id: 12
latitude: <%= -90*SCALE %>
longitude: <%= 12*SCALE %>
changeset_id: 5
timestamp: 2008-07-08 15:02:18
node_too_far_west:
- id: 8
+ node_id: 8
latitude: <%= 8*SCALE %>
longitude: <%= -180.01*SCALE %>
changeset_id: 5
timestamp: 2007-01-01 00:00:00
node_west_limit:
- id: 13
+ node_id: 13
latitude: <%= 13*SCALE %>
longitude: <%= -180*SCALE %>
changeset_id: 5
timestamp: 2008-07-08 15:17:37
node_too_far_east:
- id: 9
+ node_id: 9
latitude: <%= 9*SCALE %>
longitude: <%= 180.01*SCALE %>
changeset_id: 5
timestamp: 2007-01-01 00:00:00
node_east_limit:
- id: 14
+ node_id: 14
latitude: <%= 14*SCALE %>
longitude: <%= 180*SCALE %>
changeset_id: 5
timestamp: 2008-07-08 15:46:16
node_totally_wrong:
- id: 10
+ node_id: 10
latitude: <%= 200*SCALE %>
longitude: <%= 200*SCALE %>
changeset_id: 5
timestamp: 2007-01-01 00:00:00
node_with_versions_v1:
- id: 15
+ node_id: 15
latitude: <%= 1*SCALE %>
longitude: <%= 1*SCALE %>
changeset_id: 4
timestamp: 2008-01-01 00:01:00
node_with_versions_v2:
- id: 15
+ node_id: 15
latitude: <%= 2*SCALE %>
longitude: <%= 2*SCALE %>
changeset_id: 4
timestamp: 2008-01-01 00:02:00
node_with_versions_v3:
- id: 15
+ node_id: 15
latitude: <%= 1*SCALE %>
longitude: <%= 1*SCALE %>
changeset_id: 4
timestamp: 2008-01-01 00:03:00
node_with_versions_v4:
- id: 15
+ node_id: 15
latitude: <%= 1*SCALE %>
longitude: <%= 1*SCALE %>
changeset_id: 4
timestamp: 2008-01-01 00:04:00
public_visible_node:
- id: 16
+ node_id: 16
latitude: <%= 1*SCALE %>
longitude: <%= 1*SCALE %>
changeset_id: 2
t1:
- id: 1
+ relation_id: 1
member_role: "some"
member_type: "Way"
member_id: 3
version: 1
t2:
- id: 1
+ relation_id: 1
member_role: "some"
member_type: "Node"
member_id: 5
version: 1
t3:
- id: 1
+ relation_id: 1
member_role: "some"
member_type: "Relation"
member_id: 3
version: 1
t4:
- id: 3
+ relation_id: 3
member_role: "some"
member_type: "Node"
member_id: 5
version: 1
t5:
- id: 2
+ relation_id: 2
member_role: "some"
member_type: "Node"
member_id: 5
version: 1
public_used:
- id: 6
+ relation_id: 6
member_role: "used by other relation"
member_type: "Relation"
member_id: 5
t1:
- id: 1
+ relation_id: 1
k: 'test'
v: 'yes'
version: 1
t2:
- id: 2
+ relation_id: 2
k: 'test'
v: 'yes'
version: 1
t3:
- id: 3
+ relation_id: 3
k: 'test'
v: 'yes'
version: 1
mt_1:
- id: 4
+ relation_id: 4
k: 'tag1'
v: 'val1'
version: 1
mt_2:
- id: 4
+ relation_id: 4
k: 'tag2'
v: 'val2'
version: 1
mt_3:
- id: 4
+ relation_id: 4
k: 'tag3'
v: 'val3'
version: 1
mt_4:
- id: 4
+ relation_id: 4
k: 'tag4'
v: 'val4'
version: 1
visible_relation:
- id: 1
+ relation_id: 1
changeset_id: 1
timestamp: 2007-01-01 00:00:00
visible: true
version: 1
invisible_relation:
- id: 2
+ relation_id: 2
changeset_id: 3
timestamp: 2007-01-01 00:00:00
visible: false
version: 1
used_relation:
- id: 3
+ relation_id: 3
changeset_id: 1
timestamp: 2007-01-01 00:00:00
visible: true
version: 1
multi_tag_relation:
- id: 4
+ relation_id: 4
changeset_id: 4
timestamp: 2009-04-21 09:50:57
visible: true
version: 1
public_used_relation:
- id: 5
+ relation_id: 5
changeset_id: 2
timestamp: 2009-04-22 00:30:03
visible: true
version: 1
public_visible_relation:
- id: 6
+ relation_id: 6
changeset_id: 2
timestamp: 2009-04-22 00:34:12
visible: true
t1a:
- id: 1
+ way_id: 1
node_id: 3
sequence_id: 1
version: 1
t2:
- id: 2
+ way_id: 2
node_id: 3
sequence_id: 1
version: 1
t3:
- id: 3
+ way_id: 3
node_id: 3
sequence_id: 1
version: 1
w4_v1_n1:
- id: 4
+ way_id: 4
node_id: 3
sequence_id: 1
version: 1
w4_v1_n2:
- id: 4
+ way_id: 4
node_id: 4
sequence_id: 2
version: 1
w4_v2_n1:
- id: 4
+ way_id: 4
node_id: 15
sequence_id: 1
version: 2
w4_v2_n2:
- id: 4
+ way_id: 4
node_id: 3
sequence_id: 2
version: 2
w4_v2_n3:
- id: 4
+ way_id: 4
node_id: 4
sequence_id: 3
version: 2
w4_v3_n1:
- id: 4
+ way_id: 4
node_id: 15
sequence_id: 1
version: 3
w4_v3_n2:
- id: 4
+ way_id: 4
node_id: 3
sequence_id: 2
version: 3
w4_v4_n1:
- id: 4
+ way_id: 4
node_id: 15
sequence_id: 1
version: 4
w5_n1:
- id: 5
+ way_id: 5
node_id: 4
sequence_id: 1
version: 1
w5_n2:
- id: 5
+ way_id: 5
node_id: 4
sequence_id: 2
version: 1
t1:
- id: 1
+ way_id: 1
k: 'test'
v: 'yes'
version: 1
t2:
- id: 2
+ way_id: 2
k: 'test'
v: 'yes'
version: 1
t3:
- id: 3
+ way_id: 3
k: 'test'
v: 'yes'
version: 1
visible_way:
- id: 1
+ way_id: 1
changeset_id: 2
timestamp: 2007-01-01 00:00:00
visible: true
version: 1
invisible_way:
- id: 2
+ way_id: 2
changeset_id: 2
timestamp: 2007-01-01 00:00:00
visible: false
version: 1
used_way:
- id: 3
+ way_id: 3
changeset_id: 2
timestamp: 2007-01-01 00:00:00
visible: true
version: 1
way_with_versions_v1:
- id: 4
+ way_id: 4
changeset_id: 4
timestamp: 2008-01-01 00:01:00
visible: true
version: 1
way_with_versions_v2:
- id: 4
+ way_id: 4
changeset_id: 4
timestamp: 2008-01-01 00:02:00
visible: true
version: 2
way_with_versions:
- id: 4
+ way_id: 4
changeset_id: 4
timestamp: 2008-01-01 00:03:00
visible: true
version: 3
way_with_versions_v4:
- id: 4
+ way_id: 4
changeset_id: 4
timestamp: 2008-01-01 00:04:00
visible: true
version: 4
way_with_duplicate_nodes:
- id: 5
+ way_id: 5
changeset_id: 2
timestamp: 2007-01-01 00:00:00
visible: true
# instead of a version number...
# try to get version 1
v1 = ways(:way_with_versions_v1)
- { latest => '',
- v1 => v1.timestamp.strftime("%d %b %Y, %H:%M:%S")
- }.each do |way, t|
- amf_content "getway_old", "/1", [way.id, t]
+ { latest.id => '',
+ v1.way_id => v1.timestamp.strftime("%d %b %Y, %H:%M:%S")
+ }.each do |id, t|
+ amf_content "getway_old", "/1", [id, t]
post :amf_read
assert_response :success
amf_parse_response
returned_way = amf_result("/1")
assert_equal 0, returned_way[0]
- assert_equal way.id, returned_way[2]
+ assert_equal id, returned_way[2]
# API returns the *latest* version, even for old ways...
assert_equal latest.version, returned_way[5]
end
v1 = ways(:way_with_versions_v1)
# try to get last visible version of non-existent way
# try to get specific version of non-existent way
- [[nil, ''],
- [nil, '1 Jan 1970, 00:00:00'],
- [v1, (v1.timestamp - 10).strftime("%d %b %Y, %H:%M:%S")]
- ].each do |way, t|
- amf_content "getway_old", "/1", [way.nil? ? 0 : way.id, t]
+ [[0, ''],
+ [0, '1 Jan 1970, 00:00:00'],
+ [v1.way_id, (v1.timestamp - 10).strftime("%d %b %Y, %H:%M:%S")]
+ ].each do |id, t|
+ amf_content "getway_old", "/1", [id, t]
post :amf_read
assert_response :success
amf_parse_response
# Finally check that the node that was saved has saved the data correctly
# in both the current and history tables
# First check the current table
- current_node = Node.find(result[3])
+ current_node = Node.find(result[3].to_i)
assert_in_delta lat, current_node.lat, 0.00001, "The latitude was not retreieved correctly"
assert_in_delta lon, current_node.lon, 0.00001, "The longitude was not retreived correctly"
assert_equal 0, current_node.tags.size, "There seems to be a tag that has been added to the node"
# Finally check that the node that was saved has saved the data correctly
# in both the current and history tables
# First check the current table
- current_node = Node.find(result[3])
+ current_node = Node.find(result[3].to_i)
assert_in_delta lat, current_node.lat, 0.00001, "The latitude was not retreieved correctly"
assert_in_delta lon, current_node.lon, 0.00001, "The longitude was not retreived correctly"
assert_equal 2, current_node.tags.size, "There seems to be a tag that has been added to the node"
# Finally check that the node that was saved has saved the data correctly
# in both the current and history tables
# First check the current table
- current_node = Node.find(result[3])
+ current_node = Node.find(result[3].to_i)
assert_equal 1, current_node.tags.size, "There seems to be a tag that has been added to the node"
assert_equal({ "something" => "foo\t\n\rbar" }, current_node.tags, "tags were not fixed correctly")
assert_equal result[4], current_node.version, "The version returned, is different to the one returned by the amf"
assert_equal 3, result.size, result.inspect
assert_equal 0, result[0]
- new_cs_id = result[2]
+ new_cs_id = result[2].to_i
cs = Changeset.find(new_cs_id)
assert_equal "foobar", cs.tags["comment"]
end
def test_read_relation
- browse_check 'relation', relations(:visible_relation)
+ browse_check 'relation', relations(:visible_relation).relation_id
end
def test_read_relation_history
- browse_check 'relation_history', relations(:visible_relation)
+ browse_check 'relation_history', relations(:visible_relation).relation_id
end
def test_read_way
- browse_check 'way', ways(:visible_way)
+ browse_check 'way', ways(:visible_way).way_id
end
def test_read_way_history
- browse_check 'way_history', ways(:visible_way)
+ browse_check 'way_history', ways(:visible_way).way_id
end
def test_read_node
- browse_check 'node', nodes(:visible_node)
+ browse_check 'node', nodes(:visible_node).node_id
end
def test_read_node_history
- browse_check 'node_history', nodes(:visible_node)
+ browse_check 'node_history', nodes(:visible_node).node_id
end
def test_read_changeset
- browse_check 'changeset', changesets(:normal_user_first_change)
+ browse_check 'changeset', changesets(:normal_user_first_change).id
end
# This is a convenience method for most of the above checks
# First we check that when we don't have an id, it will correctly return a 404
# then we check that we get the correct 404 when a non-existant id is passed
# then we check that it will get a successful response, when we do pass an id
- def browse_check(type, fixture)
+ def browse_check(type, id)
get type
assert_response :not_found
assert_template 'not_found'
get type, {:id => -10} # we won't have an id that's negative
assert_response :not_found
assert_template 'not_found'
- get type, {:id => fixture.id}
+ get type, {:id => id}
assert_response :success
assert_template type
end
# FIXME needs more assert_select tests
assert_select "osmChange[version='#{API_VERSION}'][generator='#{GENERATOR}']" do
assert_select "create", :count => 5
- assert_select "create>node[id=#{nodes(:used_node_2).id}][visible=#{nodes(:used_node_2).visible?}][version=#{nodes(:used_node_2).version}]" do
+ assert_select "create>node[id=#{nodes(:used_node_2).node_id}][visible=#{nodes(:used_node_2).visible?}][version=#{nodes(:used_node_2).version}]" do
assert_select "tag[k=#{node_tags(:t3).k}][v=#{node_tags(:t3).v}]"
end
- assert_select "create>node[id=#{nodes(:visible_node).id}]"
+ assert_select "create>node[id=#{nodes(:visible_node).node_id}]"
end
end
content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'><tag k='foo' v='#{'x'*256}'/></node></osm>")
put :create
assert_response :bad_request, "node upload did not return bad_request status"
- assert_equal ["NodeTag ", " v: is too long (maximum is 255 characters) (\"#{'x'*256}\")"], @response.body.split(/[0-9]+:/)
+ assert_equal ["NodeTag ", " v: is too long (maximum is 255 characters) (\"#{'x'*256}\")"], @response.body.split(/[0-9]+,foo:/)
end
# -------------------------------------
def test_history
# check that a visible relations is returned properly
- get :history, :id => relations(:visible_relation).id
+ get :history, :id => relations(:visible_relation).relation_id
assert_response :success
# check chat a non-existent relations is not returned
get :history, :id => 0
assert_response :not_found
-
end
-
end
def test_history_visible
# check that a visible way is returned properly
- get :history, :id => ways(:visible_way).id
+ get :history, :id => ways(:visible_way).way_id
assert_response :success
end
def test_history_invisible
# check that an invisible way's history is returned properly
- get :history, :id => ways(:invisible_way).id
+ get :history, :id => ways(:invisible_way).way_id
assert_response :success
end
key = "k"
(0..255).each do |i|
tag = ChangesetTag.new
- tag.id = 1
+ tag.changeset_id = 1
tag.k = key*i
tag.v = "v"
assert tag.valid?
val = "v"
(0..255).each do |i|
tag = ChangesetTag.new
- tag.id = 1
+ tag.changeset_id = 1
tag.k = "k"
tag.v = val*i
assert tag.valid?
def test_length_key_invalid
["k"*256].each do |k|
tag = ChangesetTag.new
- tag.id = 1
+ tag.changeset_id = 1
tag.k = k
tag.v = "v"
assert !tag.valid?, "Key #{k} should be too long"
def test_length_value_invalid
["v"*256].each do |v|
tag = ChangesetTag.new
- tag.id = 1
+ tag.changeset_id = 1
tag.k = "k"
tag.v = v
assert !tag.valid?, "Value #{v} should be too long"
def test_empty_tag_invalid
tag = ChangesetTag.new
assert !tag.valid?, "Empty tag should be invalid"
- assert tag.errors[:id].any?
+ assert tag.errors[:changeset].any?
end
def test_uniqueness
tag = ChangesetTag.new
- tag.id = changeset_tags(:changeset_1_tag_1).id
+ tag.changeset_id = changeset_tags(:changeset_1_tag_1).id
tag.k = changeset_tags(:changeset_1_tag_1).k
tag.v = changeset_tags(:changeset_1_tag_1).v
assert tag.new_record?
key = "k"
(0..255).each do |i|
tag = NodeTag.new
- tag.id = current_node_tags(:t1).id
+ tag.node_id = current_node_tags(:t1).node_id
tag.k = key*i
tag.v = "v"
assert tag.valid?
val = "v"
(0..255).each do |i|
tag = NodeTag.new
- tag.id = current_node_tags(:t1).id
+ tag.node_id = current_node_tags(:t1).node_id
tag.k = "k"
tag.v = val*i
assert tag.valid?
def test_length_key_invalid
["k"*256].each do |i|
tag = NodeTag.new
- tag.id = current_node_tags(:t1).id
+ tag.node_id = current_node_tags(:t1).node_id
tag.k = i
tag.v = "v"
assert !tag.valid?, "Key should be too long"
def test_length_value_invalid
["k"*256].each do |i|
tag = NodeTag.new
- tag.id = current_node_tags(:t1).id
+ tag.node_id = current_node_tags(:t1).node_id
tag.k = "k"
tag.v = i
assert !tag.valid?, "Value should be too long"
def test_empty_node_tag_invalid
tag = NodeTag.new
assert !tag.valid?, "Empty tag should be invalid"
- assert tag.errors[:id].any?
+ assert tag.errors[:node].any?
end
def test_uniqueness
tag = NodeTag.new
- tag.id = current_node_tags(:t1).id
+ tag.node_id = current_node_tags(:t1).node_id
tag.k = current_node_tags(:t1).k
tag.v = current_node_tags(:t1).v
assert tag.new_record?
end
def test_node_too_far_north
- invalid_node_test(:node_too_far_north)
+ invalid_node_test(:node_too_far_north)
end
def test_node_north_limit
assert_equal node_template.visible, node.visible
assert_equal node_template.timestamp.to_i, node.timestamp.to_i
- assert_equal OldNode.find(:all, :conditions => [ "id = ?", node_template.id ]).length, 1
- old_node = OldNode.find(:first, :conditions => [ "id = ?", node_template.id ])
+ assert_equal OldNode.where(:node_id => node_template.id).count, 1
+ old_node = OldNode.where(:node_id => node_template.id).first
assert_not_nil old_node
assert_equal node_template.latitude, old_node.latitude
assert_equal node_template.longitude, old_node.longitude
node_template = Node.find(current_nodes(:visible_node).id)
assert_not_nil node_template
- assert_equal OldNode.find(:all, :conditions => [ "id = ?", node_template.id ]).length, 1
- old_node_template = OldNode.find(:first, :conditions => [ "id = ?", node_template.id ])
- assert_not_nil old_node_template
+ assert_equal OldNode.where(:node_id => node_template.id).count, 1
+ node = Node.find(node_template.id)
+ assert_not_nil node
node_template.latitude = 12.3456
node_template.longitude = 65.4321
#node_template.tags = "updated=yes"
- assert node_template.update_from(old_node_template, users(:normal_user))
+ assert node.update_from(node_template, users(:normal_user))
node = Node.find(node_template.id)
assert_not_nil node
assert_equal node_template.changeset_id, node.changeset_id
assert_equal node_template.visible, node.visible
#assert_equal node_template.tags, node.tags
- assert_equal node_template.timestamp.to_i, node.timestamp.to_i
- assert_equal OldNode.find(:all, :conditions => [ "id = ?", node_template.id ]).length, 2
- assert_equal OldNode.find(:all, :conditions => [ "id = ? and timestamp = ?", node_template.id, node_template.timestamp ]).length, 1
- old_node = OldNode.find(:first, :conditions => [ "id = ? and timestamp = ?", node_template.id, node_template.timestamp ])
+ assert_equal OldNode.where(:node_id => node_template.id).count, 2
+ old_node = OldNode.where(:node_id => node_template.id, :version => 2).first
assert_not_nil old_node
assert_equal node_template.latitude, old_node.latitude
assert_equal node_template.longitude, old_node.longitude
assert_equal node_template.changeset_id, old_node.changeset_id
assert_equal node_template.visible, old_node.visible
#assert_equal node_template.tags, old_node.tags
- assert_equal node_template.timestamp.to_i, old_node.timestamp.to_i
end
def test_delete
node_template = Node.find(current_nodes(:visible_node))
assert_not_nil node_template
- assert_equal OldNode.find(:all, :conditions => [ "id = ?", node_template.id ]).length, 1
- old_node_template = OldNode.find(:first, :conditions => [ "id = ?", node_template.id ])
- assert_not_nil old_node_template
+ assert_equal OldNode.where(:node_id => node_template.id).count, 1
+ node = Node.find(node_template.id)
+ assert_not_nil node
- assert node_template.delete_with_history!(old_node_template, users(:normal_user))
+ assert node.delete_with_history!(node_template, users(:normal_user))
node = Node.find(node_template.id)
assert_not_nil node
assert_equal node_template.latitude, node.latitude
assert_equal node_template.longitude, node.longitude
assert_equal node_template.changeset_id, node.changeset_id
- assert_equal node_template.visible, node.visible
+ assert_equal false, node.visible
#assert_equal node_template.tags, node.tags
- assert_equal node_template.timestamp.to_i, node.timestamp.to_i
- assert_equal OldNode.find(:all, :conditions => [ "id = ?", node_template.id ]).length, 2
- assert_equal OldNode.find(:all, :conditions => [ "id = ? and timestamp = ?", node_template.id, node_template.timestamp ]).length, 1
- old_node = OldNode.find(:first, :conditions => [ "id = ? and timestamp = ?", node_template.id, node_template.timestamp ])
+ assert_equal OldNode.where(:node_id => node_template.id).count, 2
+ old_node = OldNode.where(:node_id => node_template.id, :version => 2).first
assert_not_nil old_node
assert_equal node_template.latitude, old_node.latitude
assert_equal node_template.longitude, old_node.longitude
assert_equal node_template.changeset_id, old_node.changeset_id
- assert_equal node_template.visible, old_node.visible
+ assert_equal false, old_node.visible
#assert_equal node_template.tags, old_node.tags
- assert_equal node_template.timestamp.to_i, old_node.timestamp.to_i
end
def test_from_xml_no_id
key = "k"
(0..255).each do |i|
tag = OldNodeTag.new
- tag.id = node_tags(:t1).id
+ tag.node_id = node_tags(:t1).node_id
tag.version = node_tags(:t1).version
tag.k = key*i
tag.v = "v"
val = "v"
(0..255).each do |i|
tag = OldNodeTag.new
- tag.id = node_tags(:t1).id
+ tag.node_id = node_tags(:t1).node_id
tag.version = node_tags(:t1).version
tag.k = "k"
tag.v = val*i
def test_length_key_invalid
["k"*256].each do |i|
tag = OldNodeTag.new
- tag.id = node_tags(:t1).id
+ tag.node_id = node_tags(:t1).node_id
tag.version = node_tags(:t1).version
tag.k = i
tag.v = "v", "Key should be too long"
def test_length_value_invalid
["k"*256].each do |i|
tag = OldNodeTag.new
- tag.id = node_tags(:t1).id
+ tag.node_id = node_tags(:t1).node_id
tag.version = node_tags(:t1).version
tag.k = "k"
tag.v = i
end
end
- def test_empty_old_node_tag_invalid
+ def test_empty_tag_invalid
tag = OldNodeTag.new
assert !tag.valid?, "Empty tag should be invalid"
- assert tag.errors[:id].any?
- assert tag.errors[:version].any?
+ assert tag.errors[:old_node].any?
end
def test_uniqueness
tag = OldNodeTag.new
- tag.id = node_tags(:t1).id
+ tag.node_id = node_tags(:t1).node_id
tag.version = node_tags(:t1).version
tag.k = node_tags(:t1).k
tag.v = node_tags(:t1).v
end
def test_node_too_far_north
- invalid_node_test(:node_too_far_north)
+ invalid_node_test(:node_too_far_north)
end
def test_node_north_limit
# the fixture
def valid_node_test(nod)
node = nodes(nod)
- dbnode = Node.find(node.id)
+ dbnode = Node.find(node.node_id)
assert_equal dbnode.lat, node.latitude.to_f/SCALE
assert_equal dbnode.lon, node.longitude.to_f/SCALE
assert_equal dbnode.changeset_id, node.changeset_id
# fixture
def invalid_node_test(nod)
node = nodes(nod)
- dbnode = Node.find(node.id)
+ dbnode = Node.find(node.node_id)
assert_equal dbnode.lat, node.latitude.to_f/SCALE
assert_equal dbnode.lon, node.longitude.to_f/SCALE
assert_equal dbnode.changeset_id, node.changeset_id
#assert_equal node.tile, QuadTile.tile_for_point(nodes(nod).lat, nodes(nod).lon)
assert_equal false, node.valid?
end
-
-
end
key = "k"
(0..255).each do |i|
tag = OldRelationTag.new
- tag.id = relation_tags(:t1).id
+ tag.relation_id = relation_tags(:t1).relation_id
tag.version = 1
tag.k = key*i
tag.v = "v"
val = "v"
(0..255).each do |i|
tag = OldRelationTag.new
- tag.id = relation_tags(:t1).id
+ tag.relation_id = relation_tags(:t1).relation_id
tag.version = 1
tag.k = "k"
tag.v = val*i
def test_length_key_invalid
["k"*256].each do |i|
tag = OldRelationTag.new
- tag.id = relation_tags(:t1).id
+ tag.relation_id = relation_tags(:t1).relation_id
tag.version = 1
tag.k = i
tag.v = "v"
def test_length_value_invalid
["k"*256].each do |i|
tag = OldRelationTag.new
- tag.id = relation_tags(:t1).id
+ tag.relation_id = relation_tags(:t1).relation_id
tag.version = 1
tag.k = "k"
tag.v = i
end
end
- def test_empty_node_tag_invalid
+ def test_empty_tag_invalid
tag = OldRelationTag.new
assert !tag.valid?, "Empty tag should be invalid"
- assert tag.errors[:id].any?
+ assert tag.errors[:old_relation].any?
end
def test_uniqueness
tag = OldRelationTag.new
- tag.id = relation_tags(:t1).id
+ tag.relation_id = relation_tags(:t1).relation_id
tag.version = relation_tags(:t1).version
tag.k = relation_tags(:t1).k
tag.v = relation_tags(:t1).v
key = "k"
(0..255).each do |i|
tag = OldWayTag.new
- tag.id = way_tags(:t1).id
+ tag.way_id = way_tags(:t1).way_id
tag.version = 1
tag.k = key*i
tag.v = "v"
val = "v"
(0..255).each do |i|
tag = OldWayTag.new
- tag.id = way_tags(:t1).id
+ tag.way_id = way_tags(:t1).way_id
tag.version = 1
tag.k = "k"
tag.v = val*i
def test_length_key_invalid
["k"*256].each do |i|
tag = OldWayTag.new
- tag.id = way_tags(:t1).id
+ tag.way_id = way_tags(:t1).way_id
tag.version = 1
tag.k = i
tag.v = "v"
def test_length_value_invalid
["k"*256].each do |i|
tag = OldWayTag.new
- tag.id = way_tags(:t1).id
+ tag.way_id = way_tags(:t1).way_id
tag.version = 1
tag.k = "k"
tag.v = i
end
end
- def test_empty_node_tag_invalid
- tag = OldNodeTag.new
+ def test_empty_tag_invalid
+ tag = OldWayTag.new
assert !tag.valid?, "Empty tag should be invalid"
- assert tag.errors[:id].any?
+ assert tag.errors[:old_way].any?
end
def test_uniqueness
tag = OldWayTag.new
- tag.id = way_tags(:t1).id
+ tag.way_id = way_tags(:t1).way_id
tag.version = way_tags(:t1).version
tag.k = way_tags(:t1).k
tag.v = way_tags(:t1).v
key = "k"
(0..255).each do |i|
tag = RelationTag.new
- tag.id = 1
+ tag.relation_id = 1
tag.k = key*i
tag.v = "v"
assert tag.valid?
val = "v"
(0..255).each do |i|
tag = RelationTag.new
- tag.id = 1
+ tag.relation_id = 1
tag.k = "k"
tag.v = val*i
assert tag.valid?
def test_length_key_invalid
["k"*256].each do |i|
tag = RelationTag.new
- tag.id = 1
+ tag.relation_id = 1
tag.k = i
tag.v = "v"
assert !tag.valid?, "Key #{i} should be too long"
def test_length_value_invalid
["v"*256].each do |i|
tag = RelationTag.new
- tag.id = 1
+ tag.relation_id = 1
tag.k = "k"
tag.v = i
assert !tag.valid?, "Value #{i} should be too long"
def test_empty_tag_invalid
tag = RelationTag.new
assert !tag.valid?, "Empty relation tag should be invalid"
- assert tag.errors[:id].any?
+ assert tag.errors[:relation].any?
end
def test_uniquness
tag = RelationTag.new
- tag.id = current_relation_tags(:t1).id
+ tag.relation_id = current_relation_tags(:t1).relation_id
tag.k = current_relation_tags(:t1).k
tag.v = current_relation_tags(:t1).v
assert tag.new_record?
# assert_equal 0, RelationTag.count(:conditions => ['v=?', v])
# # make sure we select a tag on a relation which has more than one tag
- # id = current_relations(:multi_tag_relation).id
+ # id = current_relations(:multi_tag_relation).relation_id
# tag = RelationTag.find(:first, :conditions => ["id = ?", id])
# tag.v = v
# tag.save!
class WayNodeTest < ActiveSupport::TestCase
api_fixtures
-
+
def test_way_nodes_count
assert_equal 6, WayNode.count
end
-
end
key = "k"
(0..255).each do |i|
tag = WayTag.new
- tag.id = current_way_tags(:t1).id
+ tag.way_id = current_way_tags(:t1).way_id
tag.k = key*i
tag.v = current_way_tags(:t1).v
assert tag.valid?
val = "v"
(0..255).each do |i|
tag = WayTag.new
- tag.id = current_way_tags(:t1).id
+ tag.way_id = current_way_tags(:t1).way_id
tag.k = "k"
tag.v = val*i
assert tag.valid?
def test_length_key_invalid
["k"*256].each do |i|
tag = WayTag.new
- tag.id = current_way_tags(:t1).id
+ tag.way_id = current_way_tags(:t1).way_id
tag.k = i
tag.v = "v"
assert !tag.valid?, "Key #{i} should be too long"
def test_length_value_invalid
["v"*256].each do |i|
tag = WayTag.new
- tag.id = current_way_tags(:t1).id
+ tag.way_id = current_way_tags(:t1).way_id
tag.k = "k"
tag.v = i
assert !tag.valid?, "Value #{i} should be too long"
def test_empty_tag_invalid
tag = WayTag.new
assert !tag.valid?, "Empty way tag should be invalid"
- assert tag.errors[:id].any?
+ assert tag.errors[:way].any?
end
def test_uniqueness
tag = WayTag.new
- tag.id = current_way_tags(:t1).id
+ tag.way_id = current_way_tags(:t1).way_id
tag.k = current_way_tags(:t1).k
tag.v = current_way_tags(:t1).v
assert tag.new_record?