-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add read_timeout option to UriAdapter download_content method #2232
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,8 @@ def self.options | |
:log_command => true, | ||
:swallow_stderr => true, | ||
:content_type_mappings => {}, | ||
:use_exif_orientation => true | ||
:use_exif_orientation => true, | ||
:read_timeout => 120 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
While we change this file, can we change this whole hash to 1.9 syntax please?
Let's do this, too. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do we get the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You're right, I changed it to nil.
Actually, trailing commas are not preferred: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It's fine, as we are not making it worse in this PR, but paperclip subscribes to thoughtbot guidelines, encoded in Hound CI: https://github.com/thoughtbot/guides/blob/master/style/ruby/sample.rb#L46-L59. |
||
} | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,4 +99,21 @@ | |
end | ||
end | ||
|
||
describe "#download_content" do | ||
before do | ||
Paperclip.options[:read_timeout] = 240 | ||
Paperclip::UriAdapter.any_instance.stubs(:open).returns(StringIO.new("xxx")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [82/80] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [82/80] |
||
@uri = URI.parse("https://github.com/thoughtbot/paper:clip.jpg") | ||
@subject = Paperclip.io_adapters.for(@uri) | ||
end | ||
|
||
after do | ||
@subject.send(:download_content) | ||
end | ||
|
||
it "calls open with given read_timeout" do | ||
@subject.expects(:open).with(@uri, read_timeout: 240).at_least_once | ||
end | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra empty line detected at block body end. |
||
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.
Use the new Ruby 1.9 hash syntax.