Validations on the way tags, with unit tests
This commit is contained in:
parent
1818679416
commit
96dfe22fb0
7 changed files with 148 additions and 4 deletions
|
@ -4,5 +4,5 @@ class NodeTag < ActiveRecord::Base
|
|||
belongs_to :node, :foreign_key => 'id'
|
||||
|
||||
validates_presence_of :id
|
||||
validates_length_of :k, :v, :within => 0..255, :allow_blank => true
|
||||
validates_length_of :k, :v, :maximum => 255, :allow_blank => true
|
||||
end
|
||||
|
|
|
@ -4,6 +4,6 @@ class OldNodeTag < ActiveRecord::Base
|
|||
set_table_name 'node_tags'
|
||||
|
||||
validates_presence_of :id, :version
|
||||
validates_length_of :k, :v, :within => 0..255, :allow_blank => true
|
||||
validates_length_of :k, :v, :maximum => 255, :allow_blank => true
|
||||
|
||||
end
|
||||
|
|
|
@ -3,4 +3,8 @@ class OldWayTag < ActiveRecord::Base
|
|||
|
||||
set_table_name 'way_tags'
|
||||
|
||||
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
|
||||
end
|
||||
|
|
|
@ -6,4 +6,9 @@ class WayTag < ActiveRecord::Base
|
|||
# FIXME add a real multipart key to waytags so that we can do eager loadin
|
||||
|
||||
belongs_to :way, :foreign_key => 'id'
|
||||
|
||||
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
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue