diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Notifications/File.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Notifications/File.pm index 8aa43fa2f..08363ffd8 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Notifications/File.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Notifications/File.pm @@ -35,8 +35,8 @@ has fileNameSeparator => ( is => 'rw', default => '_' ); # If $ref is set, returns only notification corresponding to this reference. sub get { my ( $self, $uid, $ref ) = @_; - my $ext = $self->extension; return () unless ($uid); + my $ext = $self->extension; my $fns = $self->{fileNameSeparator}; my $identifier = &getIdentifier( $self, $uid, $ref ); @@ -61,11 +61,12 @@ sub get { sub getAccepted { my ( $self, $uid, $ref ) = @_; return () unless ($uid); + my $ext = $self->extension; my $fns = $self->{fileNameSeparator}; my $identifier = &getIdentifier( $self, $uid, $ref ); opendir D, $self->{dirName}; - my @notif = grep /^\d{8}${fns}${identifier}\S*\.(?:done|json)$/, readdir(D); + my @notif = grep /^\d{8}${fns}${identifier}\S*\.(?:done|$ext)$/, readdir(D); closedir D; my $files; diff --git a/lemonldap-ng-portal/t/40-Notifications-Explorer-JSON-File.t b/lemonldap-ng-portal/t/40-Notifications-Explorer-JSON-File.t index 76b3d9686..150b5ff9c 100644 --- a/lemonldap-ng-portal/t/40-Notifications-Explorer-JSON-File.t +++ b/lemonldap-ng-portal/t/40-Notifications-Explorer-JSON-File.t @@ -6,12 +6,12 @@ use JSON qw(from_json); require 't/test-lib.pm'; my $res; -my $file = "$main::tmpDir/20160530_dwho_dGVzdHJlZg==.json"; +my $file = "$main::tmpDir/20160530_allusers_dGVzdHJlZg==.json"; open F, "> $file" or die($!); print F '[ { - "uid": "dwho", + "uid": "allusers", "date": "2016-05-30", "reference": "testref", "title": "Test title", @@ -104,8 +104,8 @@ ok( ), "Accept notification" ); -$file =~ s/json$/done/; -ok( -e $file, 'Notification was deleted' ); + +ok( -e $file, 'Notification was not deleted' ); count(2); $id = expectCookie($res); @@ -216,8 +216,8 @@ ok( ok( $json = eval { from_json( $res->[2]->[0] ) }, 'Response is JSON' ) or print STDERR "$@\n" . Dumper($res); -ok( $json->{error} eq 'Missing parameter', ' Missing parameter' ) - or explain( $json, "Missing parameter" ); +ok( $json->{error} eq 'Missing epoch parameter', ' Missing epoch parameter' ) + or explain( $json, "Missing epoch parameter" ); count(3); # Bad request