MDL-56486 workshop: Fix behat scenario for submission attachments

This Behat scenario was not failing only because it actually relied on
the bug in the wrongly set accepted_types for submission attachments.
Now that the previous commit has fixed that bug, this scenario started
to fail correctly.

We need to do the same trick here as we are doing in the latter
scenario: we first upload a valid file to bypass the upload repository
checks, and rename it before submitting the form. That allows us to see
that the invalid file is caught finally.

p.s. It was a silly mistake of mine. I should had been wondering why
the same procedure worked for one field and not for the other. I would
spot the bug with wrong accepted_types earlier.
This commit is contained in:
David Mudrák 2017-07-12 11:39:49 +02:00
parent afa6deec48
commit 581710e278

View file

@ -42,7 +42,13 @@ Feature: File types of the submission and feedback attachments can be limitted
And I set the following fields to these values: And I set the following fields to these values:
| Title | Submission1 | | Title | Submission1 |
| Submission content | See the attached file | | Submission content | See the attached file |
And I upload "mod/workshop/tests/fixtures/testable.php" file to "Attachment" filemanager # We can't directly upload the invalid file here as the upload repository would throw an exception.
# So instead we try to trick the filemanager and bypass its checks, to be finally stopped by the
# form field validation.
And I upload "mod/workshop/tests/fixtures/moodlelogo.png" file to "Attachment" filemanager
And I follow "moodlelogo.png"
And I set the field "Name" to "testable.php"
And I press "Update"
When I press "Save changes" When I press "Save changes"
Then I should see "Some files (testable.php) cannot be uploaded. Only file types image are allowed." Then I should see "Some files (testable.php) cannot be uploaded. Only file types image are allowed."
# Remove the invalid file and attach an image instead. # Remove the invalid file and attach an image instead.