From 3c22a993c3fff1fac5509989d96b06b5e8fddb3e Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 7 Jul 2025 06:20:44 +0300 Subject: [PATCH] Change method to compare tags with response --- .../api/relations_controller_test.rb | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/test/controllers/api/relations_controller_test.rb b/test/controllers/api/relations_controller_test.rb index bb5b2a1bd..60b6877d6 100644 --- a/test/controllers/api/relations_controller_test.rb +++ b/test/controllers/api/relations_controller_test.rb @@ -400,18 +400,15 @@ module Api # check that the downloaded tags are the same as the uploaded tags... new_version = do_update(rel, rel_id, auth_header) get api_relation_path(rel_id) - assert_response :success - assert_tags_equal rel, xml_parse(@response.body) + assert_tags_equal_response rel # 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) + assert_tags_equal_response rel # 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) + assert_tags_equal_response rel end ## @@ -440,18 +437,15 @@ module Api # check that the downloaded tags are the same as the uploaded tags... new_version = do_update_diff(rel, auth_header) get api_relation_path(rel_id) - assert_response :success - assert_tags_equal rel, xml_parse(@response.body) + assert_tags_equal_response rel # 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) + assert_tags_equal_response rel # 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) + assert_tags_equal_response rel end def test_update_wrong_id @@ -1134,14 +1128,17 @@ module Api end ## - # assert that all tags on relation documents +a+ and +b+ - # are equal - def assert_tags_equal(a, b) + # assert that tags on relation document +rel+ + # are equal to tags in response + def assert_tags_equal_response(rel) + assert_response :success + response_xml = xml_parse(@response.body) + # turn the XML doc into tags hashes - a_tags = get_tags_as_hash(a) - b_tags = get_tags_as_hash(b) + rel_tags = get_tags_as_hash(rel) + response_tags = get_tags_as_hash(response_xml) - assert_equal a_tags, b_tags, "Tags should be identical." + assert_equal rel_tags, response_tags, "Tags should be identical." end ## -- 2.39.5