From 0c8e738d1b42ae3deb8a122b63dddff1519dfcce Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 18 Apr 2018 13:56:00 -0300 Subject: [PATCH] Bug 20568: (QA follow-up) Test client_id and secret are not overwritten Signed-off-by: Tomas Cohen Arazi Signed-off-by: Julian Maurice --- t/db_dependent/Koha/ApiKeys.t | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/ApiKeys.t b/t/db_dependent/Koha/ApiKeys.t index 08f7ee9fb3..7becc0dcb1 100755 --- a/t/db_dependent/Koha/ApiKeys.t +++ b/t/db_dependent/Koha/ApiKeys.t @@ -35,7 +35,7 @@ my $uuid_gen_secret_counter = 0; subtest 'store() tests' => sub { - plan tests => 9; + plan tests => 13; $schema->storage->txn_begin; @@ -65,6 +65,16 @@ subtest 'store() tests' => sub { is( $api_key->description, $description, 'Description is correctly stored' ); is( $api_key->active, 1, 'Key is active by default' ); + # revoke, to call store + my $original_api_key = $api_key->unblessed; + $api_key->active(0)->store; + $api_key->discard_changes; + + is( $api_key->client_id, $original_api_key->{client_id}, '->store() preserves the client_id' ); + is( $api_key->secret, $original_api_key->{secret}, '->store() preserves the secret' ); + is( $api_key->patron_id, $original_api_key->{patron_id}, '->store() preserves the patron_id' ); + is( $api_key->active, 0, '->store() preserves the active value' ); + my $patron_to_delete = $builder->build_object( { class => 'Koha::Patrons' } ); my $deleted_id = $patron_to_delete->id; $patron_to_delete->delete; -- 2.14.2