From 4aa7327ef30eb468f69a3afc8b7d0c8dea91280d Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 7 Jul 2025 05:53:37 +0300 Subject: [PATCH] Remove with_relation private method --- .../api/relations_controller_test.rb | 96 +++++++++---------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/test/controllers/api/relations_controller_test.rb b/test/controllers/api/relations_controller_test.rb index 983d336cb..c808c57ae 100644 --- a/test/controllers/api/relations_controller_test.rb +++ b/test/controllers/api/relations_controller_test.rb @@ -387,23 +387,29 @@ module Api auth_header = bearer_authorization_header user - with_relation(relation.id) do |rel| - # alter one of the tags - tag = rel.find("//osm/relation/tag").first - tag["v"] = "some changed value" - update_changeset(rel, changeset.id) - - # check that the downloaded tags are the same as the uploaded tags... - new_version = with_update(rel, auth_header) do |new_rel| - assert_tags_equal rel, new_rel - end + get api_relation_path(relation) + assert_response :success + rel = xml_parse(@response.body) - # check the original one in the current_* table again - with_relation(relation.id) { |r| assert_tags_equal rel, r } + # alter one of the tags + tag = rel.find("//osm/relation/tag").first + tag["v"] = "some changed value" + update_changeset(rel, changeset.id) - # now check the version in the history - with_relation(relation.id, new_version) { |r| assert_tags_equal rel, r } + # check that the downloaded tags are the same as the uploaded tags... + new_version = with_update(rel, auth_header) do |new_rel| + assert_tags_equal rel, new_rel end + + # check the original one in the current_* table again + get api_relation_path(relation) + assert_response :success + assert_tags_equal rel, xml_parse(@response.body) + + # now check the version in the history + get api_relation_version_path(relation, new_version) + assert_response :success + assert_tags_equal rel, xml_parse(@response.body) end ## @@ -419,23 +425,29 @@ module Api auth_header = bearer_authorization_header user - with_relation(relation.id) do |rel| - # alter one of the tags - tag = rel.find("//osm/relation/tag").first - tag["v"] = "some changed value" - update_changeset(rel, changeset.id) - - # check that the downloaded tags are the same as the uploaded tags... - new_version = with_update_diff(rel, auth_header) do |new_rel| - assert_tags_equal rel, new_rel - end + get api_relation_path(relation) + assert_response :success + rel = xml_parse(@response.body) - # check the original one in the current_* table again - with_relation(relation.id) { |r| assert_tags_equal rel, r } + # alter one of the tags + tag = rel.find("//osm/relation/tag").first + tag["v"] = "some changed value" + update_changeset(rel, changeset.id) - # now check the version in the history - with_relation(relation.id, new_version) { |r| assert_tags_equal rel, r } + # check that the downloaded tags are the same as the uploaded tags... + new_version = with_update_diff(rel, auth_header) do |new_rel| + assert_tags_equal rel, new_rel end + + # check the original one in the current_* table again + get api_relation_path(relation) + assert_response :success + assert_tags_equal rel, xml_parse(@response.body) + + # now check the version in the history + get api_relation_version_path(relation, new_version) + assert_response :success + assert_tags_equal rel, xml_parse(@response.body) end def test_update_wrong_id @@ -445,11 +457,13 @@ module Api other_relation = create(:relation) auth_header = bearer_authorization_header user - with_relation(relation.id) do |rel| - update_changeset(rel, changeset.id) - put api_relation_path(other_relation), :params => rel.to_s, :headers => auth_header - assert_response :bad_request - end + get api_relation_path(relation) + assert_response :success + rel = xml_parse(@response.body) + + update_changeset(rel, changeset.id) + put api_relation_path(other_relation), :params => rel.to_s, :headers => auth_header + assert_response :bad_request end # ------------------------------------- @@ -1073,22 +1087,6 @@ module Api end end - ## - # yields the relation with the given +id+ (and optional +version+ - # to read from the history tables) into the block. the parsed XML - # doc is returned. - def with_relation(id, ver = nil) - if ver.nil? - get api_relation_path(id) - else - with_controller(OldRelationsController.new) do - get api_relation_version_path(id, ver) - end - end - assert_response :success - yield xml_parse(@response.body) - end - ## # updates the relation (XML) +rel+ and # yields the new version of that relation into the block. -- 2.39.5