groupdocs 1.2.10 → 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -281,7 +281,9 @@ module GroupDocs
281
281
  end
282
282
 
283
283
  #
284
- # Downloads all signed documents as ZIP file to given pat.
284
+ # Downloads signed documents to given path.
285
+ # If there is only one file in envelope, it's saved as PDF.
286
+ # If there are two or more files in envelope, it's saved as ZIP.
285
287
  #
286
288
  # @param [String] path Directory to download file to
287
289
  # @param [Hash] access Access credentials
@@ -296,7 +298,13 @@ module GroupDocs
296
298
  request[:path] = "/signature/{{client_id}}/envelopes/#{id}/documents/get"
297
299
  end.execute!
298
300
 
299
- filepath = "#{path}/#{name}.zip"
301
+ filepath = "#{path}/#{name}."
302
+ if documents!.size == 1
303
+ filepath << 'pdf'
304
+ else
305
+ filepath << 'zip'
306
+ end
307
+
300
308
  Object::File.open(filepath, 'wb') do |file|
301
309
  file.write(response)
302
310
  end
@@ -1,3 +1,3 @@
1
1
  module GroupDocs
2
- VERSION = '1.2.10'
2
+ VERSION = '1.2.11'
3
3
  end # GroupDocs
@@ -206,8 +206,8 @@ describe GroupDocs::Signature::Envelope do
206
206
 
207
207
  describe '#signed_documents!' do
208
208
  before(:each) do
209
- mock_api_server(File.read('spec/support/files/envelope.zip'))
210
- subject.stub(name: 'envelope')
209
+ mock_api_server(File.read('spec/support/files/resume.pdf'))
210
+ subject.name = 'envelope'
211
211
  end
212
212
 
213
213
  let(:path) { Dir.tmpdir }
@@ -218,15 +218,51 @@ describe GroupDocs::Signature::Envelope do
218
218
  end.should_not raise_error(ArgumentError)
219
219
  end
220
220
 
221
- it 'downloads file to given path' do
222
- file = stub('file')
223
- Object::File.should_receive(:open).with("#{path}/#{subject.name}.zip", 'wb').and_yield(file)
224
- file.should_receive(:write).with(File.read('spec/support/files/envelope.zip'))
225
- subject.signed_documents!(path)
221
+ it 'returns saved file path' do
222
+ subject.stub(documents!: [1])
223
+ subject.signed_documents!(path).should == "#{path}/#{subject.name}.pdf"
226
224
  end
227
225
 
228
- it 'returns saved file path' do
229
- subject.signed_documents!(path).should == "#{path}/#{subject.name}.zip"
226
+ context 'no documents' do
227
+ before(:each) do
228
+ mock_api_server(File.read('spec/support/files/envelope.zip'))
229
+ end
230
+
231
+ it 'downloads ZIP file' do
232
+ file = stub('file')
233
+ subject.stub(documents!: [])
234
+ Object::File.should_receive(:open).with("#{path}/#{subject.name}.zip", 'wb').and_yield(file)
235
+ file.should_receive(:write).with(File.read('spec/support/files/envelope.zip'))
236
+ subject.signed_documents!(path)
237
+ end
238
+ end
239
+
240
+ context 'single document' do
241
+ before(:each) do
242
+ mock_api_server(File.read('spec/support/files/resume.pdf'))
243
+ end
244
+
245
+ it 'downloads ZIP file' do
246
+ file = stub('file')
247
+ subject.stub(documents!: [1])
248
+ Object::File.should_receive(:open).with("#{path}/#{subject.name}.pdf", 'wb').and_yield(file)
249
+ file.should_receive(:write).with(File.read('spec/support/files/resume.pdf'))
250
+ subject.signed_documents!(path)
251
+ end
252
+ end
253
+
254
+ context 'multiple documents' do
255
+ before(:each) do
256
+ mock_api_server(File.read('spec/support/files/envelope.zip'))
257
+ end
258
+
259
+ it 'downloads ZIP file' do
260
+ file = stub('file')
261
+ subject.stub(documents!: [1, 2])
262
+ Object::File.should_receive(:open).with("#{path}/#{subject.name}.zip", 'wb').and_yield(file)
263
+ file.should_receive(:write).with(File.read('spec/support/files/envelope.zip'))
264
+ subject.signed_documents!(path)
265
+ end
230
266
  end
231
267
  end
232
268
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groupdocs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.10
4
+ version: 1.2.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-12 00:00:00.000000000 Z
12
+ date: 2013-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -462,7 +462,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
462
462
  version: '0'
463
463
  segments:
464
464
  - 0
465
- hash: -4205405145410109468
465
+ hash: 3421241428358277947
466
466
  required_rubygems_version: !ruby/object:Gem::Requirement
467
467
  none: false
468
468
  requirements:
@@ -471,7 +471,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
471
471
  version: '0'
472
472
  segments:
473
473
  - 0
474
- hash: -4205405145410109468
474
+ hash: 3421241428358277947
475
475
  requirements: []
476
476
  rubyforge_project:
477
477
  rubygems_version: 1.8.24