File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,10 @@ def run
1313 StoreFile : true ,
1414 )
1515
16- from_format = @from_format || detect_format ( params )
1716 read_timeout = @conversion_timeout + config . conversion_timeout_delta if @conversion_timeout
18- converter = params [ :converter ] ? "/converter/#{ params [ :converter ] } " : ''
1917
2018 response = ConvertApi . client . post (
21- "convert/ #{ from_format } /to/ #{ @to_format } #{ converter } " ,
19+ request_path ( params ) ,
2220 params ,
2321 read_timeout : read_timeout ,
2422 )
@@ -28,6 +26,14 @@ def run
2826
2927 private
3028
29+ def request_path ( params )
30+ from_format = @from_format || detect_format ( params )
31+ converter = params [ :converter ] ? "/converter/#{ params [ :converter ] } " : ''
32+ async = params [ :Async ] ? 'async/' : ''
33+
34+ "#{ async } convert/#{ from_format } /to/#{ @to_format } #{ converter } "
35+ end
36+
3137 def normalize_params ( params )
3238 result = { }
3339
Original file line number Diff line number Diff line change 1616
1717 expect ( subject ) . to be_instance_of ( ConvertApi ::Result )
1818 end
19+
20+ describe 'async' do
21+ let ( :params ) { { Async : true , File : 'https://www.w3.org/TR/2003/REC-PNG-20031110/iso_8859-1.txt' } }
22+
23+ it 'submits an async task and returns result' do
24+ expect ( ConvertApi . client ) . to (
25+ receive ( :post ) . with ( 'async/convert/txt/to/pdf' , instance_of ( Hash ) , instance_of ( Hash ) ) . and_return ( result )
26+ )
27+
28+ expect ( subject ) . to be_instance_of ( ConvertApi ::Result )
29+ end
30+ end
1931 end
2032end
You can’t perform that action at this time.
0 commit comments