Adding a restriction to prevent more than 2000 nodes to be added to any way. Tests...
[rails.git] / app / models / way.rb
index b413ccb280d24c4e56fdb287b4b57a3029298ed0..9d4d8ba87c0ac13c1ef635a612dfa191577e21e7 100644 (file)
@@ -238,6 +238,9 @@ class Way < ActiveRecord::Base
 
   def preconditions_ok?
     return false if self.nds.empty?
+    if self.nds.length > APP_CONFIG['max_number_of_way_nodes']
+      raise OSM::APITooManyWayNodesError.new(self.nds.count, APP_CONFIG['max_number_of_way_nodes'])
+    end
     self.nds.each do |n|
       node = Node.find(:first, :conditions => ["id = ?", n])
       unless node and node.visible