Bugzilla – Attachment 83531 Details for
Bug 21786
Routes for credits should include library_id
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21786: Unit tests
Bug-21786-Unit-tests.patch (text/plain), 3.43 KB, created by
Alex Arnaud
on 2018-12-27 15:45:32 UTC
(
hide
)
Description:
Bug 21786: Unit tests
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2018-12-27 15:45:32 UTC
Size:
3.43 KB
patch
obsolete
>From be7f540cc564df1880b00fd58f67504e4aedd6f2 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 9 Nov 2018 16:29:15 -0300 >Subject: [PATCH] Bug 21786: Unit tests > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com> >--- > t/db_dependent/api/v1/patrons_accounts.t | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/api/v1/patrons_accounts.t b/t/db_dependent/api/v1/patrons_accounts.t >index bf8b9de..9f1c4f2 100644 >--- a/t/db_dependent/api/v1/patrons_accounts.t >+++ b/t/db_dependent/api/v1/patrons_accounts.t >@@ -46,8 +46,9 @@ subtest 'get_balance() tests' => sub { > $schema->storage->txn_begin; > > my ( $patron, $session_id ) = create_user_and_session({ authorized => 0 }); >- my $patron_id = $patron->id; >- my $account = $patron->account; >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $patron_id = $patron->id; >+ my $account = $patron->account; > > my $tx = $t->ua->build_tx(GET => "/api/v1/patrons/$patron_id/account"); > $tx->req->cookies({ name => 'CGISESSID', value => $session_id }); >@@ -68,6 +69,7 @@ subtest 'get_balance() tests' => sub { > accounttype => "N", # New card > amountoutstanding => 50, > manager_id => $patron->borrowernumber, >+ branchcode => $library->id > } > )->store(); > $account_line_1->discard_changes; >@@ -81,6 +83,7 @@ subtest 'get_balance() tests' => sub { > accounttype => "N", # New card > amountoutstanding => 50.01, > manager_id => $patron->borrowernumber, >+ branchcode => $library->id > } > )->store(); > $account_line_2->discard_changes; >@@ -125,7 +128,8 @@ subtest 'get_balance() tests' => sub { > ); > > # add a credit >- my $credit_line = $account->add_credit({ amount => 10, user_id => $patron->id }); >+ my $credit_line = $account->add_credit( >+ { amount => 10, user_id => $patron->id, library_id => $library->id } ); > # re-read from the DB > $credit_line->discard_changes; > $tx = $t->ua->build_tx( GET => "/api/v1/patrons/$patron_id/account" ); >@@ -149,11 +153,12 @@ subtest 'get_balance() tests' => sub { > > subtest 'add_credit() tests' => sub { > >- plan tests => 17; >+ plan tests => 18; > > $schema->storage->txn_begin; > > my ( $patron, $session_id ) = create_user_and_session( { authorized => 1 } ); >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); > my $patron_id = $patron->id; > my $account = $patron->account; > >@@ -194,12 +199,17 @@ subtest 'add_credit() tests' => sub { > )->store(); > > is( $account->outstanding_debits->total_outstanding, 25 ); >+ $credit->{library_id} = $library->id; > $tx = $t->ua->build_tx( > POST => "/api/v1/patrons/$patron_id/account/credits" => json => $credit ); > $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); > $tx->req->env( { REMOTE_ADDR => '127.0.0.1' } ); > $t->request_ok($tx)->status_is(200)->json_has('/account_line_id'); > >+ my $account_line_id = $tx->res->json->{account_line_id}; >+ is( Koha::Account::Lines->find($account_line_id)->branchcode, >+ $library->id, 'Library id is sored correctly' ); >+ > is( $account->outstanding_debits->total_outstanding, > 0, "Debits have been cancelled automatically" ); > >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21786
:
82198
|
82199
|
82200
|
82279
|
82280
|
82281
|
83529
|
83530
| 83531 |
83532
|
83533