Bugzilla – Attachment 21287 Details for
Bug 8435
new permissions on subscriptions "superserials"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8435: Followup add unit tests for can_edit_subscription
Bug-8435-Followup-add-unit-tests-for-caneditsubscr.patch (text/plain), 3.33 KB, created by
Chris Cormack
on 2013-09-20 19:54:54 UTC
(
hide
)
Description:
Bug 8435: Followup add unit tests for can_edit_subscription
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2013-09-20 19:54:54 UTC
Size:
3.33 KB
patch
obsolete
>From 7ef6e9313d4897e52d817a89c07fe23b44c1334e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 27 Mar 2013 16:53:56 +0100 >Subject: [PATCH] Bug 8435: Followup add unit tests for can_edit_subscription > >Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> >--- > C4/Serials.pm | 9 +++++++ > t/db_dependent/Serials_2.t | 63 +++++++++++++++++++++++++++++++++++++++++++--- > 2 files changed, 68 insertions(+), 4 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 9e587e8..0fd2695 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -20,6 +20,7 @@ package C4::Serials; > > use strict; > use warnings; >+use C4::Auth qw(haspermission); > use C4::Context; > use C4::Dates qw(format_date format_date_in_iso); > use Date::Calc qw(:all); >@@ -2519,6 +2520,14 @@ sub subscriptionCurrentlyOnOrder { > return $sth->fetchrow_array; > } > >+=head2 can_edit_subscription >+ >+ $can = can_edit_subscription( $subscriptionid[, $userid] ); >+ >+Return 1 if the subscription is editable by the current logged user (or a given $userid), else 0. >+ >+=cut >+ > sub can_edit_subscription { > my ( $subscription, $userid ) = @_; > my $flags = C4::Context->userenv->{flags}; >diff --git a/t/db_dependent/Serials_2.t b/t/db_dependent/Serials_2.t >index 01cf853..7c37dee 100644 >--- a/t/db_dependent/Serials_2.t >+++ b/t/db_dependent/Serials_2.t >@@ -1,10 +1,65 @@ > #!/usr/bin/perl >-use strict; >-use warnings; >+use Modern::Perl; > >-use Test::More; >+use Test::More tests => 4; > > use_ok('C4::Serials'); >+use_ok('C4::Budgets'); >+ > my $supplierlist=eval{GetSuppliersWithLateIssues()}; > ok(length($@)==0,"No SQL problem in GetSuppliersWithLateIssues"); >-done_testing(); >+ >+my $biblionumber = 1; >+my $budgetid; >+my $bpid = AddBudgetPeriod({ >+ budget_period_startdate => '01-01-2015', >+ budget_period_enddate => '31-12-2015', >+ budget_description => "budget desc" >+}); >+ >+my $budget_id = AddBudget({ >+ budget_code => "ABCD", >+ budget_amount => "123.132", >+ budget_name => "Périodiques", >+ budget_notes => "This is a note", >+ budget_description => "Serials", >+ budget_active => 1, >+ budget_period_id => $bpid >+}); >+ >+my $subscriptionid = NewSubscription( >+ undef, "", undef, undef, $budget_id, $biblionumber, '01-01-2013',undef, >+ undef, undef, undef, undef, undef, undef, undef, undef, >+ undef, undef, undef, undef, undef, undef, undef, undef, >+ undef, undef, undef, undef, undef, undef, undef, 1, >+ "notes", undef, undef, undef, undef, undef, undef, 0, >+ "intnotes", 0, undef, undef, 0, undef, '31-12-2013', >+); >+die unless $subscriptionid; >+ >+# Can edit a subscription >+my @USERENV = ( >+ 1, >+ 'test', >+ 'MASTERTEST', >+ 'Test', >+ 'Test', >+ 't', >+ 0, >+ 0, >+); >+ >+C4::Context->_new_userenv ('DUMMY_SESSION_ID'); >+C4::Context->set_userenv ( @USERENV ); >+my $userenv = C4::Context->userenv; >+ >+my $subscription = GetSubscription( $subscriptionid ); >+ >+is( C4::Serials::can_edit_subscription($subscription), 1, "User can edit a subscription with an empty branchcode"); >+#TODO add UT when C4::Auth->set_permissions (or setuserflags) will exist. >+ >+ >+# cleaning >+DelSubscription( $subscription->{subscriptionid} ); >+DelBudgetPeriod($bpid); >+DelBudget($budget_id); >-- >1.8.4.rc2
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 8435
:
10821
|
11377
|
11411
|
11892
|
13396
|
15673
|
16404
|
16462
|
16740
|
16750
|
16751
|
16798
|
16799
|
16801
|
16802
|
16803
|
16943
|
16944
|
19260
|
19261
|
19266
|
19268
|
20536
|
21286
|
21287
|
21288
|
21289
|
22624
|
22625
|
22626
|
22627
|
22628