Bug 3050: QA follow-up
authorJonathan Druart <jonathan.druart@biblibre.com>
Wed, 21 May 2014 10:08:00 +0000 (12:08 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Sun, 25 May 2014 21:15:03 +0000 (21:15 +0000)
1/ Use the usual way for ordering dates in table
2/ Add a confirmation dialog box on deleting a file
3/ Add some UTs

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice-files.tt
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt
t/db_dependent/Koha_Misc_Files.t

index 1121536..08ca3cd 100644 (file)
         $("#invoice_files_details_table").dataTable($.extend(true, {}, dataTablesDefaults, {
             "aoColumnDefs": [
                 { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
-                { "aTargets": [ 3 ], "sType": "natural" }
+                { "aTargets": [ "title-string" ], "sType": "title-string" }
             ],
             bInfo: false,
             bPaginate: false,
             bFilter: false,
             sDom: "t"
         }));
+        $("a.delete_file").click(function(){
+            return ( confirm( _("Are you sure you want to delete this file ?") ) );
+        });
     });
 //]]>
 </script>
                       <td><a href="?invoiceid=[% invoiceid %]&amp;op=download&amp;view=1&amp;file_id=[% f.file_id %]">[% f.file_name | html %]</a></td>
                       <td>[% f.file_type | html %]</td>
                       <td>[% f.file_description | html %]</td>
-                      <td><!-- [% f.date_uploaded %] -->[% f.date_uploaded | $KohaDates %]</td>
+                      <td class="title-string">
+                        <span title="[% f.date_uploaded %]">[% f.date_uploaded | $KohaDates %]</span>
+                      </td>
                       <td>[% f.file_size %]</td>
-                      <td><a href="?invoiceid=[% invoiceid %]&amp;op=delete&amp;file_id=[% f.file_id %]">Delete</a></td>
+                      <td><a class="delete_file" href="?invoiceid=[% invoiceid %]&amp;op=delete&amp;file_id=[% f.file_id %]">Delete</a></td>
                       <td><a href="?invoiceid=[% invoiceid %]&amp;op=download&amp;file_id=[% f.file_id %]">Download</a></td>
                   </tr>
                 [% END %]
index 911ff81..8056c1d 100644 (file)
@@ -31,7 +31,7 @@
 [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
         $("#invoice_files_table").dataTable($.extend(true, {}, dataTablesDefaults, {
             "aoColumnDefs": [
-                { "aTargets": [ 3 ], "sType": "natural" }
+                { "aTargets": [ "title-string" ], "sType": "title-string" }
             ],
             bInfo: false,
             bPaginate: false,
                          <td><a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid %]&amp;op=download&amp;view=1&amp;file_id=[% f.file_id %]">[% f.file_name | html %]</a></td>
                          <td>[% f.file_type | html %]</td>
                          <td>[% f.file_description | html %]</td>
-                         <td><!-- [% f.date_uploaded %] -->[% f.date_uploaded | $KohaDates %]</td>
+                         <td class="title-string">
+                           <span title="[% f.date_uploaded %]">[% f.date_uploaded | $KohaDates %]</span>
+                         </td>
                     </tr>
                 [% END %]
                 </tbody>
index d88da5c..6a51126 100755 (executable)
@@ -5,7 +5,7 @@
 
 use Modern::Perl;
 use C4::Context;
-use Test::More tests => 27;
+use Test::More tests => 30;
 
 BEGIN {
     use_ok('Koha::Misc::Files');
@@ -16,6 +16,7 @@ $dbh->{AutoCommit} = 0;
 $dbh->{RaiseError} = 1;
 
 ## new() parameter handling check
+is(Koha::Misc::Files->new(), undef, "new() param check test/0");
 is(Koha::Misc::Files->new(recordid => 12), undef, "new() param check test/1");
 is(Koha::Misc::Files->new(recordid => 'aa123', tabletag => 'ttag_a'), undef, "new() param check test/2");
 
@@ -76,10 +77,12 @@ $files_a_123_infos = $mf_a_123->GetFilesInfo();
 is(scalar @$files_a_123_infos, 3, "GetFilesInfo() result count after DelFile()");
 
 ## DelAllFiles() tests
-$mf_a_123->DelAllFiles();
+my $number_of_deleted_files_a_123 = $mf_a_123->DelAllFiles();
+is( $number_of_deleted_files_a_123, 3, "DelAllFiles returns the number of deleted files/1" );
 $files_a_123_infos = $mf_a_123->GetFilesInfo();
 is(scalar @$files_a_123_infos, 0, "GetFilesInfo() result count after DelAllFiles()/1");
-$mf_b_221->DelAllFiles();
+my $number_of_deleted_files_b_221 = $mf_b_221->DelAllFiles();
+is( $number_of_deleted_files_b_221, 1, "DelAllFiles returns the number of deleted files/2" );
 is(scalar @{$mf_b_221->GetFilesInfo()}, 0, "GetFilesInfo() result count after DelAllFiles()/2");
 
 $dbh->rollback;