]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/relation.rb
Remove redundant presence validation on belongs_to
[rails.git] / app / models / relation.rb
index 365ea533e11259aa3f9ae9ebc495cb990b400c10..0adf1012d67e1b03f00595c44c06c317cd7ada45 100644 (file)
@@ -22,7 +22,6 @@ class Relation < ApplicationRecord
 
   include ConsistencyValidations
   include NotRedactable
-  include ObjectMetadata
 
   self.table_name = "current_relations"
 
@@ -40,8 +39,6 @@ class Relation < ApplicationRecord
                  :numericality => { :on => :update, :only_integer => true }
   validates :version, :presence => true,
                       :numericality => { :only_integer => true }
-  validates :changeset_id, :presence => true,
-                           :numericality => { :only_integer => true }
   validates :timestamp, :presence => true
   validates :changeset, :associated => true
   validates :visible, :inclusion => [true, false]
@@ -131,7 +128,7 @@ class Relation < ApplicationRecord
   end
 
   def tags
-    @tags ||= relation_tags.collect { |t| [t.k, t.v] }.to_h
+    @tags ||= relation_tags.to_h { |t| [t.k, t.v] }
   end
 
   attr_writer :members, :tags
@@ -207,6 +204,8 @@ class Relation < ApplicationRecord
   end
 
   def preconditions_ok?(good_members = [])
+    raise OSM::APITooManyRelationMembersError.new(id, members.length, Settings.max_number_of_relation_members) if members.length > Settings.max_number_of_relation_members
+
     # These are hastables that store an id in the index of all
     # the nodes/way/relations that have already been added.
     # If the member is valid and visible then we add it to the