Bugzilla – Attachment 29963 Details for
Bug 12627
SQLHelper replacement - C4::Suggestions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12627: SQLHelper replacement - C4::Suggestions
Bug-12627-SQLHelper-replacement---C4Suggestions.patch (text/plain), 3.16 KB, created by
Yohann Dufour
on 2014-07-23 07:36:34 UTC
(
hide
)
Description:
Bug 12627: SQLHelper replacement - C4::Suggestions
Filename:
MIME Type:
Creator:
Yohann Dufour
Created:
2014-07-23 07:36:34 UTC
Size:
3.16 KB
patch
obsolete
>From 5ca573349ec251a8b267120d82376ce509b09092 Mon Sep 17 00:00:00 2001 >From: Yohann Dufour <dufour.yohann@gmail.com> >Date: Wed, 23 Jul 2014 09:34:36 +0200 >Subject: [PATCH] Bug 12627: SQLHelper replacement - C4::Suggestions > >With this patch, the subroutines NewSuggestion and ModSuggestion uses DBIx::Class instead of C4::SQLHelper. >Moreover, the tests has been adapted to the values returned by DBIx::Class. > >Test plan: >1) Apply the patch 12445 in order to get the last unit tests for Suggestions > >2) Apply the patch > >3) Execute the unit tests by launching : >prove t/db_dependent/Suggestions.t > >4) The result has to be a success without error or warning : >t/db_dependent/Suggestions.t .. ok >All tests successful. >Files=1, Tests=91, 2 wallclock secs ( 0.05 usr 0.01 sys + 1.65 cusr 0.09 csys = 1.80 CPU) >Result: PASS >--- > C4/Suggestions.pm | 21 +++++++++++++++++---- > t/db_dependent/Suggestions.t | 2 +- > 2 files changed, 18 insertions(+), 5 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index b543293..82475db 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -26,7 +26,6 @@ use CGI; > use C4::Context; > use C4::Output; > use C4::Dates qw(format_date format_date_in_iso); >-use C4::SQLHelper qw(:all); > use C4::Debug; > use C4::Letters; > use List::MoreUtils qw(any); >@@ -426,8 +425,14 @@ Insert a new suggestion on database with value given on input arg. > > sub NewSuggestion { > my ($suggestion) = @_; >+ >+ my $new_suggestion = { %$suggestion }; > $suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS}; >- return InsertInTable( "suggestions", $suggestion ); >+ $new_suggestion->{status} = $suggestion->{STATUS}; >+ delete $new_suggestion->{STATUS}; >+ >+ my $rs = Koha::Database->new->schema->resultset('Suggestion'); >+ return $rs->create($new_suggestion)->id; > } > > =head2 ModSuggestion >@@ -445,9 +450,17 @@ Note that there is no function to modify a suggestion. > > sub ModSuggestion { > my ($suggestion) = @_; >- my $status_update_table = UpdateInTable( "suggestions", $suggestion ); >+ return unless( $suggestion and defined($suggestion->{suggestionid}) ); >+ >+ my $mod_suggestion = { %$suggestion }; >+ my $status = $suggestion->{STATUS}; >+ delete $mod_suggestion->{STATUS}; >+ $mod_suggestion->{status} = $status; >+ >+ my $rs = Koha::Database->new->schema->resultset('Suggestion'); >+ my $status_update_table = $rs->update($suggestion); > >- if ( $suggestion->{STATUS} ) { >+ if ( $status ) { > > # fetch the entire updated suggestion so that we can populate the letter > my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} ); >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 37261eb..ad1b195 100644 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -88,7 +88,7 @@ my $mod_suggestion1 = { > publishercode => 'my modified publishercode', > }; > my $status = ModSuggestion($mod_suggestion1); >-is( $status, '0E0', 'ModSuggestion without the suggestion id returns 0E0' ); >+is( $status, undef, 'ModSuggestion without the suggestion id returns undef' ); > > $mod_suggestion1->{suggestionid} = $my_suggestionid; > $status = ModSuggestion($mod_suggestion1); >-- >1.9.1
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 12627
:
29963
|
30095
|
30237
|
30269
|
30624
|
30635
|
30892
|
31916
|
31917
|
31937
|
31939
|
31940
|
31941
|
31942
|
31944
|
31948
|
31953
|
33244
|
33276
|
33277
|
33278
|
33279
|
33280
|
33281