From 1bc43900789e8bd9e2231eba102841df11a30202 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 15 Jan 2014 16:13:21 -0500 Subject: [PATCH] Bug 10276 [QA Followup] - Extend IndependentBranches to support groups of libraries Signed-off-by: Mark Tompsett --- C4/Branch.pm | 13 +++++-------- t/db_dependent/Branch.t | 5 ++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/C4/Branch.pm b/C4/Branch.pm index c4d314a..86ee7e8 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -500,16 +500,13 @@ sub GetIndependentGroupModificationRights { push( @params, $other_branch ); } + $sql .= q{ UNION SELECT branchcode FROM branches WHERE branchcode = ? }; + push( @params, $this_branch ); + my $dbh = C4::Context->dbh; my @branchcodes = @{ $dbh->selectcol_arrayref( $sql, {}, @params ) }; - if ( $stringify ) { - if ( @branchcodes ) { - return join( ',', map { qq{'$_'} } @branchcodes ); - } else { - return qq{'$this_branch'}; - } - } + return join( ',', map { qq{'$_'} } @branchcodes ) if $stringify; if ( wantarray() ) { if ( @branchcodes ) { @@ -518,7 +515,7 @@ sub GetIndependentGroupModificationRights { return $this_branch; } } else { - return scalar(@branchcodes); + return scalar(@branchcodes) > 1; } } diff --git a/t/db_dependent/Branch.t b/t/db_dependent/Branch.t index e692c78..84b894a 100644 --- a/t/db_dependent/Branch.t +++ b/t/db_dependent/Branch.t @@ -21,7 +21,7 @@ use Modern::Perl; use C4::Context; use Data::Dumper; -use Test::More tests => 69; +use Test::More tests => 70; use C4::Branch; @@ -389,6 +389,9 @@ is_deeply( \@branches_bra, [ 'BRA', 'BRB' ], 'Libraries in LIBCATCODE returned c $string = GetIndependentGroupModificationRights({ branch => 'BRA', stringify => 1 }); ok( $string eq q{'BRA','BRB'}, "String returns correctly" ); +$string = GetIndependentGroupModificationRights({ branch => 'BRC', stringify => 1 }); +ok( $string eq q{'BRC'}, "String returns correctly" ); + ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRA' }), 'Boolean test for BRA rights to BRA returns true' ); ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRB'}), 'Boolean test for BRA rights to BRB returns true' ); ok( !GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRC'}), 'Boolean test for BRA rights to BRC returns false' ); -- 1.7.2.5