From 1c28487ebf8a170a2da822d93c8f0a662ff99c8a Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 10 Jul 2025 11:09:11 +0300 Subject: [PATCH] Update number of modified relations in changeset --- app/models/relation.rb | 1 + .../api/changesets/uploads_controller_test.rb | 21 +++++++++++++++++++ .../api/relations_controller_test.rb | 2 ++ 3 files changed, 24 insertions(+) diff --git a/app/models/relation.rb b/app/models/relation.rb index 9ef2d2979..810e78248 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -190,6 +190,7 @@ class Relation < ApplicationRecord self.tags = new_relation.tags self.members = new_relation.members self.visible = true + changeset.num_modified_relations += 1 save_with_history! end end diff --git a/test/controllers/api/changesets/uploads_controller_test.rb b/test/controllers/api/changesets/uploads_controller_test.rb index 76a7a38b5..9cc0673ba 100644 --- a/test/controllers/api/changesets/uploads_controller_test.rb +++ b/test/controllers/api/changesets/uploads_controller_test.rb @@ -808,6 +808,9 @@ module Api changeset.reload assert_equal 1, changeset.num_changes + assert_predicate changeset, :num_type_changes_in_sync? + assert_equal 1, changeset.num_modified_relations + relation.reload assert_equal 2, relation.version assert_equal 0, relation.tags.size, "relation #{relation.id} should now have no tags" @@ -872,6 +875,11 @@ module Api changeset.reload assert_equal 3, changeset.num_changes + assert_predicate changeset, :num_type_changes_in_sync? + assert_equal 1, changeset.num_modified_nodes + assert_equal 1, changeset.num_modified_ways + assert_equal 1, changeset.num_modified_relations + node.reload assert_equal 2, node.version assert_equal 2 * GeoRecord::SCALE, node.latitude @@ -1056,6 +1064,12 @@ module Api assert_dom "diffResult>node", 2 assert_dom "diffResult>relation", 1 + changeset.reload + assert_equal 3, changeset.num_changes + assert_predicate changeset, :num_type_changes_in_sync? + assert_equal 2, changeset.num_modified_nodes + assert_equal 1, changeset.num_modified_relations + assert_equal 1, Node.find(node.id).tags.size, "node #{node.id} should now have one tag" assert_equal 0, Relation.find(relation.id).tags.size, "relation #{relation.id} should now have no tags" end @@ -1454,6 +1468,13 @@ module Api assert_dom "> relation", 1 end + changeset.reload + assert_equal 3, changeset.num_changes + assert_predicate changeset, :num_type_changes_in_sync? + assert_equal 1, changeset.num_created_nodes + assert_equal 1, changeset.num_modified_ways + assert_equal 1, changeset.num_modified_relations + assert_equal 2, Node.find(new_node_id).tags.size, "new node should have two tags" assert_equal [new_node_id, node.id], Way.find(way.id).nds, "way nodes should match" Relation.find(relation.id).members.each do |type, id, _role| diff --git a/test/controllers/api/relations_controller_test.rb b/test/controllers/api/relations_controller_test.rb index 1ec1b3d5b..f2fae8fe2 100644 --- a/test/controllers/api/relations_controller_test.rb +++ b/test/controllers/api/relations_controller_test.rb @@ -499,6 +499,8 @@ module Api changeset.reload assert_equal 1, changeset.num_changes + assert_predicate changeset, :num_type_changes_in_sync? + assert_equal 1, changeset.num_modified_relations end end -- 2.39.5