Skip to content

Commit

Permalink
Item15145: fixed upload unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Jun 17, 2022
1 parent 8355d32 commit 6c7fdca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions UnitTestContrib/test/unit/UIFnCompileTests.pm
Expand Up @@ -14,6 +14,7 @@ our $SCRIPT_NAME;
our %expected_status_main_webhome = (
search => 302,
save => 302,
upload => 302,
login => 200,
logon => 200,
);
Expand Down
2 changes: 1 addition & 1 deletion UnitTestContrib/test/unit/UploadScriptTests.pm
Expand Up @@ -92,7 +92,7 @@ sub do_upload {
);
$query->uploads( \%uploads );

my $stream = $query->upload('filepath');
my $stream = $query->upload($fn);
$this->assert($stream);
seek( $stream, 0, 0 );

Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Request.pm
Expand Up @@ -715,7 +715,7 @@ to uploaded file.

sub upload {
my ( $this, $name ) = @_;
my $upload = $this->{uploads}{ $this->param($name) };
my $upload = $this->{uploads}{$name};
return defined $upload ? $upload->handle : undef;
}

Expand Down
13 changes: 5 additions & 8 deletions core/lib/Foswiki/UI/Upload.pm
Expand Up @@ -114,6 +114,11 @@ sub _upload {
my $user = $session->{user};

Foswiki::UI::checkValidationKey($session);
Foswiki::UI::checkWebExists( $session, $web, $topic, 'attach files to' );
Foswiki::UI::checkTopicExists( $session, $web, $topic, 'attach files to' );

my ($topicObject) = Foswiki::Func::readTopic( $web, $topic );
Foswiki::UI::checkAccess( $session, 'CHANGE', $topicObject );

my $hideFile = $query->param('hidefile') || '';
my $fileComment = $query->param('filecomment') || '';
Expand All @@ -134,14 +139,6 @@ sub _upload {
$filePath =~ s/\s*$//;

push @fileNames, $fileName;

Foswiki::UI::checkWebExists( $session, $web, $topic,
'attach files to' );
Foswiki::UI::checkTopicExists( $session, $web, $topic,
'attach files to' );
my ($topicObject) = Foswiki::Func::readTopic( $web, $topic );
Foswiki::UI::checkAccess( $session, 'CHANGE', $topicObject );

my $origName = $fileName;

# SMELL: would be much better to throw an exception if an attempt
Expand Down

0 comments on commit 6c7fdca

Please sign in to comment.