-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create tempfile using the basename without extension: #201
Create tempfile using the basename without extension: #201
Conversation
- 5f78451 introduced a change to keep the filename extension when creating the tempfile - `Tempfile#path` is now returning the filename with the extension followed by random chars and the extension again ```ruby puts Rack::Test::UploadedFile.new('foo.txt').path # => '/var/xxx/foo.txt2017-30-08-dsad.txt' ``` - This PR modifies this behaviour to not include the file extension as part of the file basename when creating the Tempfile
a187321
to
776036e
Compare
Thanks for the suggestion! To make the change clearer, could you re-formulate the spec to say "file name matches foo" instead of "file name does not match bar"? Or add a comment explaining the expected format. |
Thanks for the feedback ! Will take care on it when I return from vacations
(no laptop right now :( )
…On Wed, Sep 6, 2017 at 13:53 Per Lundberg ***@***.***> wrote:
Thanks for the suggestion! To make the change clearer, could you
re-formulate the spec to say "file name matches foo" instead of "file name
does not match bar"? Or add a comment explaining the expected format.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#201 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHvvhn0cYXQrt_6FUXfsR9DtEsT7AlSoks5sfuo1gaJpZM4PH-Wk>
.
|
Take care, no worries for my sake! Enjoy the vacation! 😎 |
@Edouard-chin Ping - any updates on this? |
Apologize for the time it took me to get back on this, looks like I took too much vacations 😂 The year is always present in a tmpfile name (ruby Tempfile uses Dir::Tmpname.create) |
@perlun I think this is ready for re-review, now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the effort! I will include this now in the all-great, upcoming release.
|
||
regex = /foo#{Time.now.year}.*\.txt\Z/ | ||
expect(uploaded_file.path).to match(regex) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, this is what the test output looks like with this change, but without the actual bug fix:
1) Rack::Test::UploadedFile creates Tempfiles with a path that includes a single extension
Failure/Error: expect(uploaded_file.path).to match(regex)
expected "/var/folders/r8/mlwxnwln1vl5_t_nn90cpr5w0000gn/T/foo.txt20180327-86535-10jssch.txt" to match /foo2018.*\.txt\Z/
Diff:
@@ -1,2 +1,2 @@
-/foo2018.*\.txt\Z/
+"/var/folders/r8/mlwxnwln1vl5_t_nn90cpr5w0000gn/T/foo.txt20180327-86535-10jssch.txt"
...i.e. foo.txt20180327-86535-10jssch.txt
contains the .txt
extension twice.
* Create tempfile using the basename without extension: - 5f78451 introduced a change to keep the filename extension when creating the tempfile - `Tempfile#path` is now returning the filename with the extension followed by random chars and the extension again ```ruby puts Rack::Test::UploadedFile.new('foo.txt').path # => '/var/xxx/foo.txt2017-30-08-dsad.txt' ``` - This PR modifies this behaviour to not include the file extension as part of the file basename when creating the Tempfile * PR Review
👋 Hello guys, thanks for creating and maintaining this gem
Tempfile#path
is now returning the filename with the extension followed by random chars and the extension again