From 891972d0d335c4cf13ea458a024256367c21b6ad Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 26 May 2022 11:17:18 -0300 Subject: [PATCH] Bug 30855: Rename /import => /import_batches This patch renames the route to make it consistent for future additions. To test: 1. Run $ git grep 'matches/chosen' => FAIL: all occurences use /api/v1/import/ 2. Apply this patch 3. Run: $ git grep 'matches/chosen' => SUCCESS: All occurences have '/api/v1/import_batches/' 4. Run: $ kshell k$ prove t/db_dependent/api/v1/import_record_matches.t => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/ImportRecordMatches.pm | 4 ++-- .../{import_record_matches.yaml => import_batches.yaml} | 2 +- api/v1/swagger/swagger.yaml | 4 ++-- .../prog/en/modules/tools/manage-marc-import.tt | 2 +- t/db_dependent/api/v1/import_record_matches.t | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) rename api/v1/swagger/paths/{import_record_matches.yaml => import_batches.yaml} (97%) diff --git a/Koha/REST/V1/ImportRecordMatches.pm b/Koha/REST/V1/ImportRecordMatches.pm index cb7d022e78..b414a091ef 100644 --- a/Koha/REST/V1/ImportRecordMatches.pm +++ b/Koha/REST/V1/ImportRecordMatches.pm @@ -33,7 +33,7 @@ use Try::Tiny; Method that handles unselecting all chosen matches for an import record -DELETE /api/v1/import/{import_batch_id}/records/{import_record_id}/matches/chosen +DELETE /api/v1/import_batches/{import_batch_id}/records/{import_record_id}/matches/chosen =cut @@ -63,7 +63,7 @@ sub unset_chosen { Method that handles modifying if a Koha::Import::Record::Match object has been chosen for overlay -PUT /api/v1/import/{import_batch_id}/records/{import_record_id}/matches/chosen +PUT /api/v1/import_batches/{import_batch_id}/records/{import_record_id}/matches/chosen Body should contain the condidate_match_id to chose diff --git a/api/v1/swagger/paths/import_record_matches.yaml b/api/v1/swagger/paths/import_batches.yaml similarity index 97% rename from api/v1/swagger/paths/import_record_matches.yaml rename to api/v1/swagger/paths/import_batches.yaml index 7536e4d8fd..0fe737a040 100644 --- a/api/v1/swagger/paths/import_record_matches.yaml +++ b/api/v1/swagger/paths/import_batches.yaml @@ -1,5 +1,5 @@ --- -"/import/{import_batch_id}/records/{import_record_id}/matches/chosen": +"/import_batches/{import_batch_id}/records/{import_record_id}/matches/chosen": put: x-mojo-to: ImportRecordMatches#set_chosen operationId: setChosen diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml index 4233f0d6b6..88e3bef4bd 100644 --- a/api/v1/swagger/swagger.yaml +++ b/api/v1/swagger/swagger.yaml @@ -143,8 +143,8 @@ paths: $ref: "./paths/ill_backends.yaml#/~1ill_backends~1{ill_backend_id}" /illrequests: $ref: ./paths/illrequests.yaml#/~1illrequests - "/import/{import_batch_id}/records/{import_record_id}/matches/chosen": - $ref: "./paths/import_record_matches.yaml#/~1import~1{import_batch_id}~1records~1{import_record_id}~1matches~1chosen" + "/import_batches/{import_batch_id}/records/{import_record_id}/matches/chosen": + $ref: "./paths/import_batches.yaml#/~1import_batches~1{import_batch_id}~1records~1{import_record_id}~1matches~1chosen" /import_batch_profiles: $ref: ./paths/import_batch_profiles.yaml#/~1import_batch_profiles "/import_batch_profiles/{import_batch_profile_id}": diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt index e62ed34c69..67dd9249e1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt @@ -621,7 +621,7 @@ apidata = JSON.stringify({ candidate_match_id: $(this).val() }); } $.ajax({ - url: '/api/v1/import/[% import_batch_id | html %]/records/'+$(this).data('import_record_id')+'/matches/chosen', + url: '/api/v1/import_batches/[% import_batch_id | html %]/records/'+$(this).data('import_record_id')+'/matches/chosen', method: apimethod, data: apidata, contentType: 'application/json' diff --git a/t/db_dependent/api/v1/import_record_matches.t b/t/db_dependent/api/v1/import_record_matches.t index 9e79e4a85c..aad5ae7c91 100755 --- a/t/db_dependent/api/v1/import_record_matches.t +++ b/t/db_dependent/api/v1/import_record_matches.t @@ -67,7 +67,7 @@ subtest 'import record matches tests' => sub { # Unauthorized attempt to update my $tx = $t->ua->build_tx( - PUT => "/api/v1/import/".$match_1->import_record->import_batch_id."/records/".$match_1->import_record_id."/matches/chosen"=> + PUT => "/api/v1/import_batches/".$match_1->import_record->import_batch_id."/records/".$match_1->import_record_id."/matches/chosen"=> json => { candidate_match_id => $match_1->candidate_match_id } @@ -79,7 +79,7 @@ subtest 'import record matches tests' => sub { # Invalid attempt to allow match on a non-existent record $tx = $t->ua->build_tx( - PUT => "/api/v1/import/".$del_import_batch_id."/records/".$del_match_id."/matches/chosen" => + PUT => "/api/v1/import_batches/".$del_import_batch_id."/records/".$del_match_id."/matches/chosen" => json => { candidate_match_id => $match_1->candidate_match_id } @@ -94,7 +94,7 @@ subtest 'import record matches tests' => sub { # Valid, authorised update $tx = $t->ua->build_tx( - PUT => "/api/v1/import/".$match_1->import_record->import_batch_id."/records/".$match_1->import_record_id."/matches/chosen" => + PUT => "/api/v1/import_batches/".$match_1->import_record->import_batch_id."/records/".$match_1->import_record_id."/matches/chosen" => json => { candidate_match_id => $match_1->candidate_match_id } @@ -111,7 +111,7 @@ subtest 'import record matches tests' => sub { # Valid unsetting $tx = $t->ua->build_tx( - DELETE => "/api/v1/import/".$match_1->import_record->import_batch_id."/records/".$match_1->import_record_id."/matches/chosen" => + DELETE => "/api/v1/import_batches/".$match_1->import_record->import_batch_id."/records/".$match_1->import_record_id."/matches/chosen" => json => { } ); -- 2.39.5