From 0ab73ca895df4544736a6600f13f761e1217d870 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 10 Jul 2025 10:47:50 +0300 Subject: [PATCH] Update number of modified ways in changeset --- app/models/way.rb | 1 + .../api/changesets/uploads_controller_test.rb | 9 ++++++++- test/controllers/api/ways_controller_test.rb | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/models/way.rb b/app/models/way.rb index a702ab163..a689e7730 100644 --- a/app/models/way.rb +++ b/app/models/way.rb @@ -150,6 +150,7 @@ class Way < ApplicationRecord self.tags = new_way.tags self.nds = new_way.nds self.visible = true + changeset.num_modified_ways += 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 d757c2f2f..76a7a38b5 100644 --- a/test/controllers/api/changesets/uploads_controller_test.rb +++ b/test/controllers/api/changesets/uploads_controller_test.rb @@ -755,6 +755,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_ways + way.reload assert_equal 2, way.version assert_equal 0, way.tags.size, "way #{way.id} should now have no tags" @@ -1664,8 +1667,12 @@ module Api assert_response :success - # check the bbox changeset.reload + assert_equal 1, changeset.num_changes + assert_predicate changeset, :num_type_changes_in_sync? + assert_equal 1, changeset.num_modified_ways + + # check the bbox assert_equal 1.1 * GeoRecord::SCALE, changeset.min_lat, "min_lat should be 1.1 degrees" assert_equal 2.1 * GeoRecord::SCALE, changeset.min_lon, "min_lon should be 2.1 degrees" assert_equal 1.3 * GeoRecord::SCALE, changeset.max_lat, "max_lat should be 1.3 degrees" diff --git a/test/controllers/api/ways_controller_test.rb b/test/controllers/api/ways_controller_test.rb index d1bbc7f9a..87fae2398 100644 --- a/test/controllers/api/ways_controller_test.rb +++ b/test/controllers/api/ways_controller_test.rb @@ -891,6 +891,11 @@ module Api put api_way_path(way), :params => osm_xml.to_s, :headers => headers assert_response :success, "a valid update request failed" + + changeset.reload + assert_equal 1, changeset.num_changes + assert_predicate changeset, :num_type_changes_in_sync? + assert_equal 1, changeset.num_modified_ways end end @@ -928,6 +933,11 @@ module Api assert_response :success, "adding a new tag to a way should succeed" assert_equal way.version + 1, @response.body.to_i + + changeset.reload + assert_equal 1, changeset.num_changes + assert_predicate changeset, :num_type_changes_in_sync? + assert_equal 1, changeset.num_modified_ways end end -- 2.39.5