groupdocs 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +9 -9
- data/CHANGELOG.md +482 -477
- data/Gemfile +3 -3
- data/LICENSE.txt +21 -21
- data/README.md +94 -94
- data/Rakefile +9 -9
- data/examples/README.md +12 -12
- data/examples/api-samples/Gemfile +5 -5
- data/examples/api-samples/Gemfile.lock +49 -49
- data/examples/api-samples/README.md +23 -23
- data/examples/api-samples/public/css/style.css +229 -229
- data/examples/api-samples/public/docs/annotation-sample.html +167 -167
- data/examples/api-samples/public/docs/docco.css +500 -500
- data/examples/api-samples/public/docs/envelope-sample.html +374 -374
- data/examples/api-samples/public/docs/sample01.html +181 -181
- data/examples/api-samples/public/docs/sample02.html +199 -199
- data/examples/api-samples/public/docs/sample03.html +318 -318
- data/examples/api-samples/public/docs/sample04.html +217 -217
- data/examples/api-samples/public/docs/sample05.html +296 -296
- data/examples/api-samples/public/docs/sample06.html +347 -347
- data/examples/api-samples/public/docs/sample07.html +209 -209
- data/examples/api-samples/public/docs/sample08.html +277 -277
- data/examples/api-samples/public/docs/sample09.html +314 -314
- data/examples/api-samples/public/docs/sample10.html +270 -270
- data/examples/api-samples/public/docs/sample11.html +462 -462
- data/examples/api-samples/public/docs/sample12.html +199 -199
- data/examples/api-samples/public/docs/sample13.html +201 -201
- data/examples/api-samples/public/docs/sample14.html +204 -204
- data/examples/api-samples/public/docs/sample15.html +182 -182
- data/examples/api-samples/public/docs/sample16.html +234 -234
- data/examples/api-samples/public/docs/sample17.html +309 -309
- data/examples/api-samples/public/docs/sample18.html +721 -721
- data/examples/api-samples/public/docs/sample19.html +631 -631
- data/examples/api-samples/public/docs/sample20.html +230 -230
- data/examples/api-samples/public/docs/sample21.html +790 -790
- data/examples/api-samples/public/docs/sample22.html +408 -408
- data/examples/api-samples/public/docs/sample25.html +550 -550
- data/examples/api-samples/public/templates/base-simple_source.html +191 -191
- data/examples/api-samples/public/templates/testdocument.html +100 -100
- data/examples/api-samples/public/templates/welcome.htm +137 -137
- data/examples/api-samples/samples/annotation-sample.rb +56 -56
- data/examples/api-samples/samples/envelope-sample.rb +133 -133
- data/examples/api-samples/samples/sample01.rb +44 -44
- data/examples/api-samples/samples/sample02.rb +50 -50
- data/examples/api-samples/samples/sample03.rb +79 -79
- data/examples/api-samples/samples/sample04.rb +54 -54
- data/examples/api-samples/samples/sample05.rb +83 -83
- data/examples/api-samples/samples/sample06.rb +86 -86
- data/examples/api-samples/samples/sample07.rb +59 -59
- data/examples/api-samples/samples/sample08.rb +76 -76
- data/examples/api-samples/samples/sample09.rb +85 -85
- data/examples/api-samples/samples/sample10.rb +70 -70
- data/examples/api-samples/samples/sample11.rb +132 -132
- data/examples/api-samples/samples/sample12.rb +48 -48
- data/examples/api-samples/samples/sample13.rb +49 -49
- data/examples/api-samples/samples/sample14.rb +54 -54
- data/examples/api-samples/samples/sample15.rb +43 -43
- data/examples/api-samples/samples/sample16.rb +57 -57
- data/examples/api-samples/samples/sample17.rb +70 -70
- data/examples/api-samples/samples/sample18.rb +190 -190
- data/examples/api-samples/samples/sample19.rb +188 -188
- data/examples/api-samples/samples/sample20.rb +68 -68
- data/examples/api-samples/samples/sample21.rb +212 -212
- data/examples/api-samples/samples/sample22.rb +109 -109
- data/examples/api-samples/samples/sample25.rb +127 -127
- data/examples/api-samples/views/_others_samples.haml +233 -233
- data/examples/api-samples/views/annotation_sample.haml +63 -63
- data/examples/api-samples/views/envelope_sample.haml +72 -72
- data/examples/api-samples/views/index.haml +235 -235
- data/examples/api-samples/views/layout.haml +3 -3
- data/examples/api-samples/views/sample01.haml +63 -63
- data/examples/api-samples/views/sample02.haml +52 -52
- data/examples/api-samples/views/sample03.haml +87 -87
- data/examples/api-samples/views/sample04.haml +55 -55
- data/examples/api-samples/views/sample05.haml +86 -86
- data/examples/api-samples/views/sample06.haml +58 -58
- data/examples/api-samples/views/sample07.haml +52 -52
- data/examples/api-samples/views/sample08.haml +100 -100
- data/examples/api-samples/views/sample09.haml +95 -95
- data/examples/api-samples/views/sample10.haml +93 -93
- data/examples/api-samples/views/sample11.haml +140 -140
- data/examples/api-samples/views/sample12.haml +68 -68
- data/examples/api-samples/views/sample13.haml +64 -64
- data/examples/api-samples/views/sample14.haml +60 -60
- data/examples/api-samples/views/sample15.haml +51 -51
- data/examples/api-samples/views/sample16.haml +50 -50
- data/examples/api-samples/views/sample17.haml +54 -54
- data/examples/api-samples/views/sample18.haml +143 -143
- data/examples/api-samples/views/sample19.haml +92 -92
- data/examples/api-samples/views/sample20.haml +54 -54
- data/examples/api-samples/views/sample21.haml +123 -123
- data/examples/api-samples/views/sample22.haml +106 -106
- data/examples/api-samples/views/sample25.haml +101 -101
- data/examples/api-samples/views/sample31.haml +2 -2
- data/examples/api-samples/web.rb +20 -20
- data/examples/viewer/Gemfile +5 -5
- data/examples/viewer/app.rb +52 -52
- data/groupdocs.gemspec +31 -31
- data/lib/groupdocs.rb +62 -62
- data/lib/groupdocs/api.rb +6 -6
- data/lib/groupdocs/api/entity.rb +112 -112
- data/lib/groupdocs/api/helpers.rb +11 -11
- data/lib/groupdocs/api/helpers/access_mode_helper.rb +27 -27
- data/lib/groupdocs/api/helpers/access_rights_helper.rb +55 -55
- data/lib/groupdocs/api/helpers/accessor_helper.rb +30 -30
- data/lib/groupdocs/api/helpers/byte_flag_helper.rb +49 -49
- data/lib/groupdocs/api/helpers/credentials_helper.rb +35 -35
- data/lib/groupdocs/api/helpers/mime_helper.rb +21 -21
- data/lib/groupdocs/api/helpers/path_helper.rb +28 -28
- data/lib/groupdocs/api/helpers/rest_helper.rb +99 -99
- data/lib/groupdocs/api/helpers/signature_public_helper.rb +22 -22
- data/lib/groupdocs/api/helpers/status_helper.rb +27 -27
- data/lib/groupdocs/api/helpers/url_helper.rb +101 -101
- data/lib/groupdocs/api/request.rb +91 -91
- data/lib/groupdocs/datasource.rb +249 -249
- data/lib/groupdocs/datasource/field.rb +39 -39
- data/lib/groupdocs/document.rb +1550 -1550
- data/lib/groupdocs/document/annotation.rb +421 -421
- data/lib/groupdocs/document/annotation/reply.rb +173 -173
- data/lib/groupdocs/document/annotation/reviewer.rb +66 -66
- data/lib/groupdocs/document/change.rb +56 -56
- data/lib/groupdocs/document/field.rb +53 -53
- data/lib/groupdocs/document/metadata.rb +32 -32
- data/lib/groupdocs/document/rectangle.rb +18 -18
- data/lib/groupdocs/document/view.rb +36 -36
- data/lib/groupdocs/errors.rb +8 -8
- data/lib/groupdocs/job.rb +468 -468
- data/lib/groupdocs/questionnaire.rb +530 -530
- data/lib/groupdocs/questionnaire/collector.rb +335 -335
- data/lib/groupdocs/questionnaire/execution.rb +181 -181
- data/lib/groupdocs/questionnaire/page.rb +43 -43
- data/lib/groupdocs/questionnaire/question.rb +108 -108
- data/lib/groupdocs/questionnaire/question/answer.rb +15 -15
- data/lib/groupdocs/signature.rb +380 -380
- data/lib/groupdocs/signature/contact.rb +181 -181
- data/lib/groupdocs/signature/envelope.rb +747 -747
- data/lib/groupdocs/signature/envelope/log.rb +20 -20
- data/lib/groupdocs/signature/field.rb +286 -286
- data/lib/groupdocs/signature/field/location.rb +71 -71
- data/lib/groupdocs/signature/form.rb +804 -804
- data/lib/groupdocs/signature/list.rb +92 -92
- data/lib/groupdocs/signature/recipient.rb +79 -79
- data/lib/groupdocs/signature/role.rb +54 -54
- data/lib/groupdocs/signature/shared.rb +6 -6
- data/lib/groupdocs/signature/shared/document_methods.rb +158 -158
- data/lib/groupdocs/signature/shared/entity_fields.rb +76 -76
- data/lib/groupdocs/signature/shared/entity_methods.rb +144 -144
- data/lib/groupdocs/signature/shared/field_methods.rb +354 -354
- data/lib/groupdocs/signature/shared/recipient_methods.rb +75 -75
- data/lib/groupdocs/signature/shared/resource_methods.rb +65 -65
- data/lib/groupdocs/signature/template.rb +124 -124
- data/lib/groupdocs/storage.rb +44 -44
- data/lib/groupdocs/storage/file.rb +432 -432
- data/lib/groupdocs/storage/folder.rb +288 -288
- data/lib/groupdocs/storage/package.rb +48 -48
- data/lib/groupdocs/storage/provider.rb +32 -32
- data/lib/groupdocs/subscription.rb +323 -323
- data/lib/groupdocs/subscription/limit.rb +20 -20
- data/lib/groupdocs/user.rb +955 -930
- data/lib/groupdocs/version.rb +3 -3
- data/spec/groupdocs/api/entity_spec.rb +55 -55
- data/spec/groupdocs/api/helpers/access_mode_helper_spec.rb +21 -21
- data/spec/groupdocs/api/helpers/access_rights_helper_spec.rb +43 -43
- data/spec/groupdocs/api/helpers/accessor_helper_spec.rb +16 -16
- data/spec/groupdocs/api/helpers/byte_flag_helper_spec.rb +23 -23
- data/spec/groupdocs/api/helpers/credentials_helpers_spec.rb +48 -48
- data/spec/groupdocs/api/helpers/mime_helper_spec.rb +16 -16
- data/spec/groupdocs/api/helpers/path_helper_spec.rb +15 -15
- data/spec/groupdocs/api/helpers/rest_helper_spec.rb +161 -161
- data/spec/groupdocs/api/helpers/signature_public_helper_spec.rb +21 -21
- data/spec/groupdocs/api/helpers/status_helper_spec.rb +22 -22
- data/spec/groupdocs/api/helpers/url_helper_spec.rb +112 -112
- data/spec/groupdocs/api/request_spec.rb +112 -112
- data/spec/groupdocs/datasource/field_spec.rb +29 -29
- data/spec/groupdocs/datasource_spec.rb +145 -145
- data/spec/groupdocs/document/annotation/reply_spec.rb +154 -154
- data/spec/groupdocs/document/annotation/reviewer_spec.rb +51 -51
- data/spec/groupdocs/document/annotation_spec.rb +234 -234
- data/spec/groupdocs/document/change_spec.rb +39 -39
- data/spec/groupdocs/document/field_spec.rb +28 -28
- data/spec/groupdocs/document/metadata_spec.rb +21 -21
- data/spec/groupdocs/document/rectangle_spec.rb +14 -14
- data/spec/groupdocs/document/view_spec.rb +33 -33
- data/spec/groupdocs/document_spec.rb +859 -859
- data/spec/groupdocs/errors_spec.rb +7 -7
- data/spec/groupdocs/job_spec.rb +323 -323
- data/spec/groupdocs/questionnaire/collector_spec.rb +197 -197
- data/spec/groupdocs/questionnaire/execution_spec.rb +162 -162
- data/spec/groupdocs/questionnaire/page_spec.rb +47 -47
- data/spec/groupdocs/questionnaire/question/answer_spec.rb +9 -9
- data/spec/groupdocs/questionnaire/question_spec.rb +75 -75
- data/spec/groupdocs/questionnaire_spec.rb +295 -295
- data/spec/groupdocs/signature/contact_spec.rb +142 -142
- data/spec/groupdocs/signature/envelope/log_spec.rb +15 -15
- data/spec/groupdocs/signature/envelope_spec.rb +384 -384
- data/spec/groupdocs/signature/field/location_spec.rb +40 -40
- data/spec/groupdocs/signature/field_spec.rb +235 -235
- data/spec/groupdocs/signature/form_spec.rb +205 -205
- data/spec/groupdocs/signature/list_spec.rb +87 -87
- data/spec/groupdocs/signature/recipient_spec.rb +26 -26
- data/spec/groupdocs/signature/role_spec.rb +47 -47
- data/spec/groupdocs/signature/template_spec.rb +80 -80
- data/spec/groupdocs/signature_spec.rb +194 -194
- data/spec/groupdocs/storage/file_spec.rb +303 -303
- data/spec/groupdocs/storage/folder_spec.rb +270 -270
- data/spec/groupdocs/storage/package_spec.rb +38 -38
- data/spec/groupdocs/storage/provider_spec.rb +21 -21
- data/spec/groupdocs/storage_spec.rb +27 -27
- data/spec/groupdocs/subscription/limit_spec.rb +16 -16
- data/spec/groupdocs/subscription_spec.rb +74 -74
- data/spec/groupdocs/user_spec.rb +257 -257
- data/spec/groupdocs_spec.rb +63 -63
- data/spec/spec_helper.rb +73 -73
- data/spec/support/json/annotation_access_set.json +11 -11
- data/spec/support/json/annotation_collaborators_get.json +16 -16
- data/spec/support/json/annotation_collaborators_set.json +16 -16
- data/spec/support/json/annotation_create.json +12 -12
- data/spec/support/json/annotation_list.json +32 -32
- data/spec/support/json/annotation_marker_move.json +10 -10
- data/spec/support/json/annotation_move.json +8 -8
- data/spec/support/json/annotation_remove.json +9 -9
- data/spec/support/json/annotation_replies_create.json +9 -9
- data/spec/support/json/annotation_replies_get.json +25 -25
- data/spec/support/json/annotation_reviewers_get.json +18 -18
- data/spec/support/json/comparison_changes.json +46 -46
- data/spec/support/json/comparison_compare.json +8 -8
- data/spec/support/json/comparison_document.json +10 -10
- data/spec/support/json/contact_add.json +12 -12
- data/spec/support/json/contacts_get.json +19 -19
- data/spec/support/json/contacts_import.json +8 -8
- data/spec/support/json/datasource_add.json +8 -8
- data/spec/support/json/datasource_get.json +22 -22
- data/spec/support/json/datasource_remove.json +8 -8
- data/spec/support/json/datasource_update.json +8 -8
- data/spec/support/json/delete_account.json +9 -9
- data/spec/support/json/document_access_info_get.json +14 -14
- data/spec/support/json/document_convert.json +8 -8
- data/spec/support/json/document_datasource.json +10 -10
- data/spec/support/json/document_fields.json +34 -34
- data/spec/support/json/document_formats.json +8 -8
- data/spec/support/json/document_metadata.json +15 -15
- data/spec/support/json/document_page_images_get.json +20 -20
- data/spec/support/json/document_questionnaire_create.json +9 -9
- data/spec/support/json/document_questionnaires.json +23 -23
- data/spec/support/json/document_sharers_remove.json +8 -8
- data/spec/support/json/document_sharers_set.json +16 -16
- data/spec/support/json/document_thumbnails.json +24 -24
- data/spec/support/json/document_views.json +32 -32
- data/spec/support/json/envelope_get.json +46 -46
- data/spec/support/json/envelope_logs.json +16 -16
- data/spec/support/json/envelope_recipient_add.json +26 -26
- data/spec/support/json/envelopes_all.json +48 -48
- data/spec/support/json/envelopes_resources.json +31 -31
- data/spec/support/json/file_compress.json +8 -8
- data/spec/support/json/file_copy.json +14 -14
- data/spec/support/json/file_delete.json +5 -5
- data/spec/support/json/file_move.json +14 -14
- data/spec/support/json/file_upload.json +8 -8
- data/spec/support/json/folder_create.json +8 -8
- data/spec/support/json/folder_delete.json +5 -5
- data/spec/support/json/folder_list.json +22 -22
- data/spec/support/json/folder_move.json +8 -8
- data/spec/support/json/folder_sharers_get.json +16 -16
- data/spec/support/json/folder_sharers_remove.json +8 -8
- data/spec/support/json/folder_sharers_set.json +16 -16
- data/spec/support/json/form_get.json +21 -21
- data/spec/support/json/forms_all.json +23 -23
- data/spec/support/json/job_add_url.json +8 -8
- data/spec/support/json/job_create.json +8 -8
- data/spec/support/json/job_documents.json +40 -40
- data/spec/support/json/job_file_add.json +8 -8
- data/spec/support/json/job_get.json +30 -30
- data/spec/support/json/job_update.json +7 -7
- data/spec/support/json/jobs_get.json +58 -58
- data/spec/support/json/list_add.json +12 -12
- data/spec/support/json/lists_get.json +19 -19
- data/spec/support/json/package_create.json +7 -7
- data/spec/support/json/questionnaire_collector.json +17 -17
- data/spec/support/json/questionnaire_collectors.json +38 -38
- data/spec/support/json/questionnaire_collectors_add.json +10 -10
- data/spec/support/json/questionnaire_create.json +10 -10
- data/spec/support/json/questionnaire_datasources.json +26 -26
- data/spec/support/json/questionnaire_execution_add.json +9 -9
- data/spec/support/json/questionnaire_execution_status_set.json +8 -8
- data/spec/support/json/questionnaire_execution_update.json +8 -8
- data/spec/support/json/questionnaire_executions.json +28 -28
- data/spec/support/json/questionnaire_get.json +17 -17
- data/spec/support/json/questionnaire_remove.json +8 -8
- data/spec/support/json/questionnaire_update.json +8 -8
- data/spec/support/json/questionnaires_get.json +40 -40
- data/spec/support/json/sign_documents.json +16 -16
- data/spec/support/json/signature_create.json +12 -12
- data/spec/support/json/signature_field_add.json +25 -25
- data/spec/support/json/signature_fields_get.json +27 -27
- data/spec/support/json/signature_roles_get.json +17 -17
- data/spec/support/json/signatures_get.json +19 -19
- data/spec/support/json/storage_info.json +10 -10
- data/spec/support/json/subscription_plan_get.json +9 -9
- data/spec/support/json/subscription_plans_get.json +17 -17
- data/spec/support/json/template_get.json +35 -35
- data/spec/support/json/template_get_documents.json +15 -15
- data/spec/support/json/template_get_recipients.json +20 -20
- data/spec/support/json/templates_all.json +37 -37
- data/spec/support/json/templates_get.json +21 -21
- data/spec/support/json/update_account.json +10 -10
- data/spec/support/json/user_area.json +67 -67
- data/spec/support/json/user_embed_key.json +38 -38
- data/spec/support/json/user_get_embed_key.json +67 -67
- data/spec/support/json/user_login.json +67 -67
- data/spec/support/json/user_profile_get.json +24 -24
- data/spec/support/json/user_providers.json +31 -31
- data/spec/support/json/user_roles.json +25 -25
- data/spec/support/json/user_users_get.json +27 -27
- data/spec/support/shared_examples/api/entity.rb +39 -39
- data/spec/support/shared_examples/api/helpers/access_mode_helper.rb +11 -11
- data/spec/support/shared_examples/api/helpers/status_helper.rb +11 -11
- data/spec/support/shared_examples/signature/shared/document_methods.rb +68 -68
- data/spec/support/shared_examples/signature/shared/entity_fields.rb +56 -56
- data/spec/support/shared_examples/signature/shared/entity_methods.rb +116 -116
- data/spec/support/shared_examples/signature/shared/field_methods.rb +220 -220
- data/spec/support/shared_examples/signature/shared/recipient_methods.rb +46 -46
- data/spec/support/shared_examples/signature/shared/resource_methods.rb +46 -46
- metadata +35 -55
@@ -1,142 +1,142 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe GroupDocs::Signature::Contact do
|
4
|
-
|
5
|
-
it_behaves_like GroupDocs::Api::Entity
|
6
|
-
|
7
|
-
describe '.get!' do
|
8
|
-
before(:each) do
|
9
|
-
mock_api_server(load_json('contacts_get'))
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'accepts access credentials hash' do
|
13
|
-
lambda do
|
14
|
-
described_class.get!({}, :client_id => 'client_id', :private_key => 'private_key')
|
15
|
-
end.should_not raise_error()
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'allows passing options' do
|
19
|
-
lambda { described_class.get!(:page => 1, :email => 'com') }.should_not raise_error()
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns array of GroupDocs::Signature::Contact objects' do
|
23
|
-
contacts = described_class.get!
|
24
|
-
contacts.should be_an(Array)
|
25
|
-
contacts.each do |contact|
|
26
|
-
contact.should be_a(GroupDocs::Signature::Contact)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '.import!' do
|
32
|
-
let(:contact) do
|
33
|
-
described_class.new(:first_name => 'John', :last_name => 'Smith', :email => 'john@smith.com')
|
34
|
-
end
|
35
|
-
|
36
|
-
before(:each) do
|
37
|
-
mock_api_server(load_json('contacts_import'))
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'accepts access credentials hash' do
|
41
|
-
lambda do
|
42
|
-
described_class.import!([contact], :client_id => 'client_id', :private_key => 'private_key')
|
43
|
-
end.should_not raise_error()
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'raises error if contacts is not array' do
|
47
|
-
lambda { described_class.import!(contact) }.should raise_error(ArgumentError)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'raises error if array element is not GroupDocs::Signature::Contact' do
|
51
|
-
lambda { described_class.import!(%w(test)) }.should raise_error(ArgumentError)
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'uses hashed version of array elements as request body' do
|
55
|
-
contact.should_receive(:to_hash)
|
56
|
-
described_class.import!([contact])
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '.add_integration!' do
|
61
|
-
before(:each) do
|
62
|
-
mock_api_server('{ "status": "Ok", "result": { "contact": null }}')
|
63
|
-
end
|
64
|
-
|
65
|
-
let(:integration) do
|
66
|
-
{
|
67
|
-
:provider => :google,
|
68
|
-
:refresh_token => 'token',
|
69
|
-
:access_token => 'token',
|
70
|
-
:access_token_expiration => '2014-12-12'
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'accepts access credentials hash' do
|
75
|
-
lambda do
|
76
|
-
described_class.add_integration!(integration, :client_id => 'client_id', :private_key => 'private_key')
|
77
|
-
end.should_not raise_error()
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
it { should have_accessor(:id) }
|
82
|
-
it { should have_accessor(:firstName) }
|
83
|
-
it { should have_accessor(:lastName) }
|
84
|
-
it { should have_accessor(:nickname) }
|
85
|
-
it { should have_accessor(:email) }
|
86
|
-
it { should have_accessor(:provider) }
|
87
|
-
|
88
|
-
it { should alias_accessor(:first_name, :firstName) }
|
89
|
-
it { should alias_accessor(:last_name, :lastName) }
|
90
|
-
|
91
|
-
describe '#add!' do
|
92
|
-
before(:each) do
|
93
|
-
mock_api_server(load_json('contact_add'))
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'accepts access credentials hash' do
|
97
|
-
lambda do
|
98
|
-
subject.add!(:client_id => 'client_id', :private_key => 'private_key')
|
99
|
-
end.should_not raise_error()
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'uses hashed version of self as request body' do
|
103
|
-
subject.should_receive(:to_hash)
|
104
|
-
subject.add!
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'updates identifier of contact' do
|
108
|
-
lambda do
|
109
|
-
subject.add!
|
110
|
-
end.should change(subject, :id)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe '#update!' do
|
115
|
-
before(:each) do
|
116
|
-
mock_api_server(load_json('contact_add'))
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'accepts access credentials hash' do
|
120
|
-
lambda do
|
121
|
-
subject.update!(:client_id => 'client_id', :private_key => 'private_key')
|
122
|
-
end.should_not raise_error()
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'uses hashed version of self as request body' do
|
126
|
-
subject.should_receive(:to_hash)
|
127
|
-
subject.add!
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe '#delete!' do
|
132
|
-
before(:each) do
|
133
|
-
mock_api_server('{ "status": "Ok", "result": { "contact": null }}')
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'accepts access credentials hash' do
|
137
|
-
lambda do
|
138
|
-
subject.delete!(:client_id => 'client_id', :private_key => 'private_key')
|
139
|
-
end.should_not raise_error()
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GroupDocs::Signature::Contact do
|
4
|
+
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
6
|
+
|
7
|
+
describe '.get!' do
|
8
|
+
before(:each) do
|
9
|
+
mock_api_server(load_json('contacts_get'))
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'accepts access credentials hash' do
|
13
|
+
lambda do
|
14
|
+
described_class.get!({}, :client_id => 'client_id', :private_key => 'private_key')
|
15
|
+
end.should_not raise_error()
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'allows passing options' do
|
19
|
+
lambda { described_class.get!(:page => 1, :email => 'com') }.should_not raise_error()
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns array of GroupDocs::Signature::Contact objects' do
|
23
|
+
contacts = described_class.get!
|
24
|
+
contacts.should be_an(Array)
|
25
|
+
contacts.each do |contact|
|
26
|
+
contact.should be_a(GroupDocs::Signature::Contact)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '.import!' do
|
32
|
+
let(:contact) do
|
33
|
+
described_class.new(:first_name => 'John', :last_name => 'Smith', :email => 'john@smith.com')
|
34
|
+
end
|
35
|
+
|
36
|
+
before(:each) do
|
37
|
+
mock_api_server(load_json('contacts_import'))
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'accepts access credentials hash' do
|
41
|
+
lambda do
|
42
|
+
described_class.import!([contact], :client_id => 'client_id', :private_key => 'private_key')
|
43
|
+
end.should_not raise_error()
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'raises error if contacts is not array' do
|
47
|
+
lambda { described_class.import!(contact) }.should raise_error(ArgumentError)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'raises error if array element is not GroupDocs::Signature::Contact' do
|
51
|
+
lambda { described_class.import!(%w(test)) }.should raise_error(ArgumentError)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'uses hashed version of array elements as request body' do
|
55
|
+
contact.should_receive(:to_hash)
|
56
|
+
described_class.import!([contact])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '.add_integration!' do
|
61
|
+
before(:each) do
|
62
|
+
mock_api_server('{ "status": "Ok", "result": { "contact": null }}')
|
63
|
+
end
|
64
|
+
|
65
|
+
let(:integration) do
|
66
|
+
{
|
67
|
+
:provider => :google,
|
68
|
+
:refresh_token => 'token',
|
69
|
+
:access_token => 'token',
|
70
|
+
:access_token_expiration => '2014-12-12'
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'accepts access credentials hash' do
|
75
|
+
lambda do
|
76
|
+
described_class.add_integration!(integration, :client_id => 'client_id', :private_key => 'private_key')
|
77
|
+
end.should_not raise_error()
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it { should have_accessor(:id) }
|
82
|
+
it { should have_accessor(:firstName) }
|
83
|
+
it { should have_accessor(:lastName) }
|
84
|
+
it { should have_accessor(:nickname) }
|
85
|
+
it { should have_accessor(:email) }
|
86
|
+
it { should have_accessor(:provider) }
|
87
|
+
|
88
|
+
it { should alias_accessor(:first_name, :firstName) }
|
89
|
+
it { should alias_accessor(:last_name, :lastName) }
|
90
|
+
|
91
|
+
describe '#add!' do
|
92
|
+
before(:each) do
|
93
|
+
mock_api_server(load_json('contact_add'))
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'accepts access credentials hash' do
|
97
|
+
lambda do
|
98
|
+
subject.add!(:client_id => 'client_id', :private_key => 'private_key')
|
99
|
+
end.should_not raise_error()
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'uses hashed version of self as request body' do
|
103
|
+
subject.should_receive(:to_hash)
|
104
|
+
subject.add!
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'updates identifier of contact' do
|
108
|
+
lambda do
|
109
|
+
subject.add!
|
110
|
+
end.should change(subject, :id)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#update!' do
|
115
|
+
before(:each) do
|
116
|
+
mock_api_server(load_json('contact_add'))
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'accepts access credentials hash' do
|
120
|
+
lambda do
|
121
|
+
subject.update!(:client_id => 'client_id', :private_key => 'private_key')
|
122
|
+
end.should_not raise_error()
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'uses hashed version of self as request body' do
|
126
|
+
subject.should_receive(:to_hash)
|
127
|
+
subject.add!
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#delete!' do
|
132
|
+
before(:each) do
|
133
|
+
mock_api_server('{ "status": "Ok", "result": { "contact": null }}')
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'accepts access credentials hash' do
|
137
|
+
lambda do
|
138
|
+
subject.delete!(:client_id => 'client_id', :private_key => 'private_key')
|
139
|
+
end.should_not raise_error()
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe GroupDocs::Signature::Envelope::Log do
|
4
|
-
|
5
|
-
it_behaves_like GroupDocs::Api::Entity
|
6
|
-
|
7
|
-
it { should have_accessor(:id) }
|
8
|
-
it { should have_accessor(:date) }
|
9
|
-
it { should have_accessor(:userName) }
|
10
|
-
it { should have_accessor(:action) }
|
11
|
-
it { should have_accessor(:remoteAddress) }
|
12
|
-
|
13
|
-
it { should alias_accessor(:user_name, :userName) }
|
14
|
-
it { should alias_accessor(:remote_address, :remoteAddress) }
|
15
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GroupDocs::Signature::Envelope::Log do
|
4
|
+
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
6
|
+
|
7
|
+
it { should have_accessor(:id) }
|
8
|
+
it { should have_accessor(:date) }
|
9
|
+
it { should have_accessor(:userName) }
|
10
|
+
it { should have_accessor(:action) }
|
11
|
+
it { should have_accessor(:remoteAddress) }
|
12
|
+
|
13
|
+
it { should alias_accessor(:user_name, :userName) }
|
14
|
+
it { should alias_accessor(:remote_address, :remoteAddress) }
|
15
|
+
end
|
@@ -1,384 +1,384 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe GroupDocs::Signature::Envelope do
|
4
|
-
|
5
|
-
it_behaves_like GroupDocs::Api::Entity
|
6
|
-
include_examples GroupDocs::Signature::DocumentMethods
|
7
|
-
include_examples GroupDocs::Signature::EntityFields
|
8
|
-
include_examples GroupDocs::Signature::EntityMethods
|
9
|
-
include_examples GroupDocs::Signature::FieldMethods
|
10
|
-
include_examples GroupDocs::Signature::RecipientMethods
|
11
|
-
include_examples GroupDocs::Signature::ResourceMethods
|
12
|
-
|
13
|
-
describe '.all!' do
|
14
|
-
before(:each) do
|
15
|
-
mock_api_server(load_json('envelopes_all'))
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'accepts access credentials hash' do
|
19
|
-
lambda do
|
20
|
-
described_class.all!({}, :client_id => 'client_id', :private_key => 'private_key')
|
21
|
-
end.should_not raise_error()
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'allows passing options' do
|
25
|
-
lambda { described_class.all!(:page => 1, :count => 3) }.should_not raise_error()
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns array of GroupDocs::Signature::Envelope objects' do
|
29
|
-
envelopes = described_class.all!
|
30
|
-
envelopes.should be_an(Array)
|
31
|
-
envelopes.each do |envelope|
|
32
|
-
envelope.should be_a(GroupDocs::Signature::Envelope)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '.for_me!' do
|
38
|
-
before(:each) do
|
39
|
-
mock_api_server(load_json('envelopes_all'))
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'accepts access credentials hash' do
|
43
|
-
lambda do
|
44
|
-
described_class.for_me!({}, :client_id => 'client_id', :private_key => 'private_key')
|
45
|
-
end.should_not raise_error()
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'allows passing options' do
|
49
|
-
lambda { described_class.for_me!(:page => 1, :count => 3) }.should_not raise_error()
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'returns array of GroupDocs::Signature::Envelope objects' do
|
53
|
-
envelopes = described_class.for_me!
|
54
|
-
envelopes.should be_an(Array)
|
55
|
-
envelopes.each do |envelope|
|
56
|
-
envelope.should be_a(GroupDocs::Signature::Envelope)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
it { should have_accessor(:creationDateTime) }
|
62
|
-
it { should have_accessor(:status) }
|
63
|
-
it { should have_accessor(:statusDateTime) }
|
64
|
-
it { should have_accessor(:envelopeExpireTime) }
|
65
|
-
it { should have_accessor(:isDemo) }
|
66
|
-
it { should have_accessor(:status) }
|
67
|
-
|
68
|
-
it { should alias_accessor(:creation_date_time, :creationDateTime) }
|
69
|
-
it { should alias_accessor(:status_date_time, :statusDateTime) }
|
70
|
-
it { should alias_accessor(:envelope_expire_time, :envelopeExpireTime) }
|
71
|
-
it { should alias_accessor(:is_demo, :isDemo) }
|
72
|
-
|
73
|
-
describe '#status' do
|
74
|
-
it 'converts status to human-readable format' do
|
75
|
-
subject.status = 1
|
76
|
-
subject.status.should == :in_progress
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#add_recipient!' do
|
81
|
-
before(:each) do
|
82
|
-
mock_api_server(load_json('envelope_recipient_add'))
|
83
|
-
end
|
84
|
-
|
85
|
-
let(:recipient) do
|
86
|
-
GroupDocs::Signature::Recipient.new
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'accepts access credentials hash' do
|
90
|
-
lambda do
|
91
|
-
subject.add_recipient!(recipient, :client_id => 'client_id', :private_key => 'private_key')
|
92
|
-
end.should_not raise_error()
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
96
|
-
lambda { subject.add_recipient!('Recipient') }.should raise_error(ArgumentError)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe '#modify_recipient!' do
|
101
|
-
let(:recipient) do
|
102
|
-
GroupDocs::Signature::Recipient.new
|
103
|
-
end
|
104
|
-
|
105
|
-
before(:each) do
|
106
|
-
mock_api_server('{ "status": "Ok", "result": {}}')
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'accepts access credentials hash' do
|
110
|
-
lambda do
|
111
|
-
subject.modify_recipient!(recipient, :client_id => 'client_id', :private_key => 'private_key')
|
112
|
-
end.should_not raise_error()
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
116
|
-
lambda { subject.modify_recipient!('Recipient') }.should raise_error(ArgumentError)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe '#delegate_recipient!' do
|
121
|
-
let(:old) { GroupDocs::Signature::Recipient.new }
|
122
|
-
let(:new) { GroupDocs::Signature::Recipient.new }
|
123
|
-
|
124
|
-
before(:each) do
|
125
|
-
mock_api_server('{ "status": "Ok", "result": {}}')
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'accepts access credentials hash' do
|
129
|
-
lambda do
|
130
|
-
subject.delegate_recipient!(old, new, :client_id => 'client_id', :private_key => 'private_key')
|
131
|
-
end.should_not raise_error()
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'raises error if old recipient is not GroupDocs::Signature::Recipient object' do
|
135
|
-
lambda { subject.delegate_recipient!('Recipient', new) }.should raise_error(ArgumentError)
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'raises error if new recipient is not GroupDocs::Signature::Recipient object' do
|
139
|
-
lambda { subject.delegate_recipient!(old, 'Recipient') }.should raise_error(ArgumentError)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe '#fill_field!' do
|
144
|
-
let(:field) { GroupDocs::Signature::Field.new(:location => { :location_x => 0.1, :page => 1 }) }
|
145
|
-
let(:document) { GroupDocs::Document.new(:file => GroupDocs::Storage::File.new) }
|
146
|
-
let(:recipient) { GroupDocs::Signature::Recipient.new }
|
147
|
-
|
148
|
-
before(:each) do
|
149
|
-
mock_api_server(load_json('signature_field_add'))
|
150
|
-
end
|
151
|
-
|
152
|
-
it 'accepts access credentials hash' do
|
153
|
-
lambda do
|
154
|
-
subject.fill_field!('test', field, document, recipient, {}, :client_id => 'client_id', :private_key => 'private_key')
|
155
|
-
end.should_not raise_error()
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'can be public' do
|
159
|
-
lambda { subject.fill_field!('test', field, document, recipient, :public => true) }.should_not raise_error()
|
160
|
-
end
|
161
|
-
|
162
|
-
it 'raises error if field is not GroupDocs::Signature::Field object' do
|
163
|
-
lambda { subject.fill_field!('test', 'Field', document, recipient) }.should raise_error(ArgumentError)
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'raises error if document is not GroupDocs::Document object' do
|
167
|
-
lambda { subject.fill_field!('test', field, 'Document', recipient) }.should raise_error(ArgumentError)
|
168
|
-
end
|
169
|
-
|
170
|
-
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
171
|
-
lambda { subject.fill_field!('test', field, document, 'Recipient') }.should raise_error(ArgumentError)
|
172
|
-
end
|
173
|
-
|
174
|
-
it 'returns filled field' do
|
175
|
-
subject.fill_field!('test', field, document, recipient).should be_a(GroupDocs::Signature::Field)
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'uses signature identifier if field is :signature and GroupDocs::Signature is passed' do
|
179
|
-
api = double(GroupDocs::Api::Request)
|
180
|
-
api.stub(:execute! => { :field => {} })
|
181
|
-
GroupDocs::Api::Request.stub(:new => api)
|
182
|
-
signature = GroupDocs::Signature.new(:id => '123')
|
183
|
-
api.should_receive(:add_params).with(:signatureId => '123')
|
184
|
-
field.field_type = :signature
|
185
|
-
subject.fill_field!(signature, field, document, recipient)
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'converts boolean value to required string if field is :checkbox' do
|
189
|
-
api = double(GroupDocs::Api::Request)
|
190
|
-
options = {}
|
191
|
-
api.stub(:execute! => { :field => {} })
|
192
|
-
api.stub(:options => { :request_body => nil })
|
193
|
-
GroupDocs::Api::Request.stub(:new => api)
|
194
|
-
field.field_type = :checkbox
|
195
|
-
subject.fill_field!(true, field, document, recipient)
|
196
|
-
api.options[:request_body].should == 'on'
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
describe '#sign!' do
|
201
|
-
let(:recipient) { GroupDocs::Signature::Recipient.new }
|
202
|
-
|
203
|
-
before(:each) do
|
204
|
-
mock_api_server('{ "status": "Ok", "result": {}}')
|
205
|
-
end
|
206
|
-
|
207
|
-
it 'accepts access credentials hash' do
|
208
|
-
lambda do
|
209
|
-
subject.sign!(recipient, {}, :client_id => 'client_id', :private_key => 'private_key')
|
210
|
-
end.should_not raise_error()
|
211
|
-
end
|
212
|
-
|
213
|
-
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
214
|
-
lambda { subject.sign!('Recipient') }.should raise_error(ArgumentError)
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
describe '#decline!' do
|
219
|
-
let(:recipient) { GroupDocs::Signature::Recipient.new }
|
220
|
-
|
221
|
-
before(:each) do
|
222
|
-
mock_api_server('{ "status": "Ok", "result": {}}')
|
223
|
-
end
|
224
|
-
|
225
|
-
it 'accepts access credentials hash' do
|
226
|
-
lambda do
|
227
|
-
subject.decline!(recipient, :client_id => 'client_id', :private_key => 'private_key')
|
228
|
-
end.should_not raise_error()
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
232
|
-
lambda { subject.decline!('Recipient') }.should raise_error(ArgumentError)
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
describe '#signed_documents!' do
|
237
|
-
before(:each) do
|
238
|
-
mock_api_server(File.read('spec/support/files/resume.pdf'))
|
239
|
-
subject.name = 'envelope'
|
240
|
-
end
|
241
|
-
|
242
|
-
let(:path) { Dir.tmpdir }
|
243
|
-
|
244
|
-
it 'accepts access credentials hash' do
|
245
|
-
lambda do
|
246
|
-
subject.signed_documents!(path, :client_id => 'client_id', :private_key => 'private_key')
|
247
|
-
end.should_not raise_error(ArgumentError)
|
248
|
-
end
|
249
|
-
|
250
|
-
it 'returns saved file path' do
|
251
|
-
subject.stub(:documents! => [1])
|
252
|
-
subject.signed_documents!(path).should == "#{path}/#{subject.name}.pdf"
|
253
|
-
end
|
254
|
-
|
255
|
-
context 'no documents' do
|
256
|
-
before(:each) do
|
257
|
-
mock_api_server(File.read('spec/support/files/envelope.zip'))
|
258
|
-
end
|
259
|
-
|
260
|
-
it 'downloads ZIP file' do
|
261
|
-
file = double('file')
|
262
|
-
subject.stub(:documents! => [])
|
263
|
-
Object::File.should_receive(:open).with("#{path}/#{subject.name}.zip", 'wb').and_yield(file)
|
264
|
-
file.should_receive(:write).with(File.read('spec/support/files/envelope.zip'))
|
265
|
-
subject.signed_documents!(path)
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
context 'single document' do
|
270
|
-
before(:each) do
|
271
|
-
mock_api_server(File.read('spec/support/files/resume.pdf'))
|
272
|
-
end
|
273
|
-
|
274
|
-
it 'downloads PDF file' do
|
275
|
-
file = double('file')
|
276
|
-
subject.stub(:documents! => [1])
|
277
|
-
Object::File.should_receive(:open).with("#{path}/#{subject.name}.pdf", 'wb').and_yield(file)
|
278
|
-
file.should_receive(:write).with(File.read('spec/support/files/resume.pdf'))
|
279
|
-
subject.signed_documents!(path)
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
context 'multiple documents' do
|
284
|
-
before(:each) do
|
285
|
-
mock_api_server(File.read('spec/support/files/envelope.zip'))
|
286
|
-
end
|
287
|
-
|
288
|
-
it 'downloads ZIP file' do
|
289
|
-
file = double('file')
|
290
|
-
subject.stub(:documents! => [1, 2])
|
291
|
-
Object::File.should_receive(:open).with("#{path}/#{subject.name}.zip", 'wb').and_yield(file)
|
292
|
-
file.should_receive(:write).with(File.read('spec/support/files/envelope.zip'))
|
293
|
-
subject.signed_documents!(path)
|
294
|
-
end
|
295
|
-
end
|
296
|
-
end
|
297
|
-
|
298
|
-
describe '#signed_document!' do
|
299
|
-
before(:each) do
|
300
|
-
mock_api_server(File.read('spec/support/files/resume.pdf'))
|
301
|
-
subject.name = 'envelope'
|
302
|
-
end
|
303
|
-
|
304
|
-
let(:path) { Dir.tmpdir }
|
305
|
-
let(:document) { GroupDocs::Document.new(:file => GroupDocs::Storage::File.new) }
|
306
|
-
|
307
|
-
it 'accepts access credentials hash' do
|
308
|
-
lambda do
|
309
|
-
subject.signed_document!(document, path, :client_id => 'client_id', :private_key => 'private_key')
|
310
|
-
end.should_not raise_error()
|
311
|
-
end
|
312
|
-
|
313
|
-
it 'returns saved file path' do
|
314
|
-
subject.signed_document!(document, path).should == "#{path}/#{subject.name}.pdf"
|
315
|
-
end
|
316
|
-
|
317
|
-
it 'downloads PDF file' do
|
318
|
-
file = double('file')
|
319
|
-
Object::File.should_receive(:open).with("#{path}/#{subject.name}.pdf", 'wb').and_yield(file)
|
320
|
-
file.should_receive(:write).with(File.read('spec/support/files/resume.pdf'))
|
321
|
-
subject.signed_document!(document, path)
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
describe '#logs!' do
|
326
|
-
before(:each) do
|
327
|
-
mock_api_server(load_json('envelope_logs'))
|
328
|
-
end
|
329
|
-
|
330
|
-
it 'accepts access credentials hash' do
|
331
|
-
lambda do
|
332
|
-
subject.logs!(:client_id => 'client_id', :private_key => 'private_key')
|
333
|
-
end.should_not raise_error()
|
334
|
-
end
|
335
|
-
|
336
|
-
it 'returns array of GroupDocs::Signature::Envelope::Log objects' do
|
337
|
-
logs = subject.logs!
|
338
|
-
logs.should be_an(Array)
|
339
|
-
logs.each do |log|
|
340
|
-
log.should be_a(GroupDocs::Signature::Envelope::Log)
|
341
|
-
end
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
describe '#send!' do
|
346
|
-
before(:each) do
|
347
|
-
mock_api_server('{ "status": "Ok", "result": {}}')
|
348
|
-
end
|
349
|
-
|
350
|
-
it 'accepts access credentials hash' do
|
351
|
-
lambda do
|
352
|
-
subject.send!(nil, :client_id => 'client_id', :private_key => 'private_key')
|
353
|
-
end.should_not raise_error()
|
354
|
-
end
|
355
|
-
|
356
|
-
it 'accepts webhook callback URL and sends it as plain text' do
|
357
|
-
subject.send! 'http://mywebsite.com'
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
|
-
describe '#archive!' do
|
362
|
-
before(:each) do
|
363
|
-
mock_api_server('{ "status": "Ok", "result": {}}')
|
364
|
-
end
|
365
|
-
|
366
|
-
it 'accepts access credentials hash' do
|
367
|
-
lambda do
|
368
|
-
subject.archive!(:client_id => 'client_id', :private_key => 'private_key')
|
369
|
-
end.should_not raise_error()
|
370
|
-
end
|
371
|
-
end
|
372
|
-
|
373
|
-
describe '#restart!' do
|
374
|
-
before(:each) do
|
375
|
-
mock_api_server('{ "status": "Ok", "result": {}}')
|
376
|
-
end
|
377
|
-
|
378
|
-
it 'accepts access credentials hash' do
|
379
|
-
lambda do
|
380
|
-
subject.restart!(:client_id => 'client_id', :private_key => 'private_key')
|
381
|
-
end.should_not raise_error()
|
382
|
-
end
|
383
|
-
end
|
384
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GroupDocs::Signature::Envelope do
|
4
|
+
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
6
|
+
include_examples GroupDocs::Signature::DocumentMethods
|
7
|
+
include_examples GroupDocs::Signature::EntityFields
|
8
|
+
include_examples GroupDocs::Signature::EntityMethods
|
9
|
+
include_examples GroupDocs::Signature::FieldMethods
|
10
|
+
include_examples GroupDocs::Signature::RecipientMethods
|
11
|
+
include_examples GroupDocs::Signature::ResourceMethods
|
12
|
+
|
13
|
+
describe '.all!' do
|
14
|
+
before(:each) do
|
15
|
+
mock_api_server(load_json('envelopes_all'))
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'accepts access credentials hash' do
|
19
|
+
lambda do
|
20
|
+
described_class.all!({}, :client_id => 'client_id', :private_key => 'private_key')
|
21
|
+
end.should_not raise_error()
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'allows passing options' do
|
25
|
+
lambda { described_class.all!(:page => 1, :count => 3) }.should_not raise_error()
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns array of GroupDocs::Signature::Envelope objects' do
|
29
|
+
envelopes = described_class.all!
|
30
|
+
envelopes.should be_an(Array)
|
31
|
+
envelopes.each do |envelope|
|
32
|
+
envelope.should be_a(GroupDocs::Signature::Envelope)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '.for_me!' do
|
38
|
+
before(:each) do
|
39
|
+
mock_api_server(load_json('envelopes_all'))
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'accepts access credentials hash' do
|
43
|
+
lambda do
|
44
|
+
described_class.for_me!({}, :client_id => 'client_id', :private_key => 'private_key')
|
45
|
+
end.should_not raise_error()
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'allows passing options' do
|
49
|
+
lambda { described_class.for_me!(:page => 1, :count => 3) }.should_not raise_error()
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns array of GroupDocs::Signature::Envelope objects' do
|
53
|
+
envelopes = described_class.for_me!
|
54
|
+
envelopes.should be_an(Array)
|
55
|
+
envelopes.each do |envelope|
|
56
|
+
envelope.should be_a(GroupDocs::Signature::Envelope)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it { should have_accessor(:creationDateTime) }
|
62
|
+
it { should have_accessor(:status) }
|
63
|
+
it { should have_accessor(:statusDateTime) }
|
64
|
+
it { should have_accessor(:envelopeExpireTime) }
|
65
|
+
it { should have_accessor(:isDemo) }
|
66
|
+
it { should have_accessor(:status) }
|
67
|
+
|
68
|
+
it { should alias_accessor(:creation_date_time, :creationDateTime) }
|
69
|
+
it { should alias_accessor(:status_date_time, :statusDateTime) }
|
70
|
+
it { should alias_accessor(:envelope_expire_time, :envelopeExpireTime) }
|
71
|
+
it { should alias_accessor(:is_demo, :isDemo) }
|
72
|
+
|
73
|
+
describe '#status' do
|
74
|
+
it 'converts status to human-readable format' do
|
75
|
+
subject.status = 1
|
76
|
+
subject.status.should == :in_progress
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#add_recipient!' do
|
81
|
+
before(:each) do
|
82
|
+
mock_api_server(load_json('envelope_recipient_add'))
|
83
|
+
end
|
84
|
+
|
85
|
+
let(:recipient) do
|
86
|
+
GroupDocs::Signature::Recipient.new
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'accepts access credentials hash' do
|
90
|
+
lambda do
|
91
|
+
subject.add_recipient!(recipient, :client_id => 'client_id', :private_key => 'private_key')
|
92
|
+
end.should_not raise_error()
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
96
|
+
lambda { subject.add_recipient!('Recipient') }.should raise_error(ArgumentError)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#modify_recipient!' do
|
101
|
+
let(:recipient) do
|
102
|
+
GroupDocs::Signature::Recipient.new
|
103
|
+
end
|
104
|
+
|
105
|
+
before(:each) do
|
106
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'accepts access credentials hash' do
|
110
|
+
lambda do
|
111
|
+
subject.modify_recipient!(recipient, :client_id => 'client_id', :private_key => 'private_key')
|
112
|
+
end.should_not raise_error()
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
116
|
+
lambda { subject.modify_recipient!('Recipient') }.should raise_error(ArgumentError)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#delegate_recipient!' do
|
121
|
+
let(:old) { GroupDocs::Signature::Recipient.new }
|
122
|
+
let(:new) { GroupDocs::Signature::Recipient.new }
|
123
|
+
|
124
|
+
before(:each) do
|
125
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'accepts access credentials hash' do
|
129
|
+
lambda do
|
130
|
+
subject.delegate_recipient!(old, new, :client_id => 'client_id', :private_key => 'private_key')
|
131
|
+
end.should_not raise_error()
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'raises error if old recipient is not GroupDocs::Signature::Recipient object' do
|
135
|
+
lambda { subject.delegate_recipient!('Recipient', new) }.should raise_error(ArgumentError)
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'raises error if new recipient is not GroupDocs::Signature::Recipient object' do
|
139
|
+
lambda { subject.delegate_recipient!(old, 'Recipient') }.should raise_error(ArgumentError)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe '#fill_field!' do
|
144
|
+
let(:field) { GroupDocs::Signature::Field.new(:location => { :location_x => 0.1, :page => 1 }) }
|
145
|
+
let(:document) { GroupDocs::Document.new(:file => GroupDocs::Storage::File.new) }
|
146
|
+
let(:recipient) { GroupDocs::Signature::Recipient.new }
|
147
|
+
|
148
|
+
before(:each) do
|
149
|
+
mock_api_server(load_json('signature_field_add'))
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'accepts access credentials hash' do
|
153
|
+
lambda do
|
154
|
+
subject.fill_field!('test', field, document, recipient, {}, :client_id => 'client_id', :private_key => 'private_key')
|
155
|
+
end.should_not raise_error()
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'can be public' do
|
159
|
+
lambda { subject.fill_field!('test', field, document, recipient, :public => true) }.should_not raise_error()
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'raises error if field is not GroupDocs::Signature::Field object' do
|
163
|
+
lambda { subject.fill_field!('test', 'Field', document, recipient) }.should raise_error(ArgumentError)
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'raises error if document is not GroupDocs::Document object' do
|
167
|
+
lambda { subject.fill_field!('test', field, 'Document', recipient) }.should raise_error(ArgumentError)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
171
|
+
lambda { subject.fill_field!('test', field, document, 'Recipient') }.should raise_error(ArgumentError)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'returns filled field' do
|
175
|
+
subject.fill_field!('test', field, document, recipient).should be_a(GroupDocs::Signature::Field)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'uses signature identifier if field is :signature and GroupDocs::Signature is passed' do
|
179
|
+
api = double(GroupDocs::Api::Request)
|
180
|
+
api.stub(:execute! => { :field => {} })
|
181
|
+
GroupDocs::Api::Request.stub(:new => api)
|
182
|
+
signature = GroupDocs::Signature.new(:id => '123')
|
183
|
+
api.should_receive(:add_params).with(:signatureId => '123')
|
184
|
+
field.field_type = :signature
|
185
|
+
subject.fill_field!(signature, field, document, recipient)
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'converts boolean value to required string if field is :checkbox' do
|
189
|
+
api = double(GroupDocs::Api::Request)
|
190
|
+
options = {}
|
191
|
+
api.stub(:execute! => { :field => {} })
|
192
|
+
api.stub(:options => { :request_body => nil })
|
193
|
+
GroupDocs::Api::Request.stub(:new => api)
|
194
|
+
field.field_type = :checkbox
|
195
|
+
subject.fill_field!(true, field, document, recipient)
|
196
|
+
api.options[:request_body].should == 'on'
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe '#sign!' do
|
201
|
+
let(:recipient) { GroupDocs::Signature::Recipient.new }
|
202
|
+
|
203
|
+
before(:each) do
|
204
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'accepts access credentials hash' do
|
208
|
+
lambda do
|
209
|
+
subject.sign!(recipient, {}, :client_id => 'client_id', :private_key => 'private_key')
|
210
|
+
end.should_not raise_error()
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
214
|
+
lambda { subject.sign!('Recipient') }.should raise_error(ArgumentError)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
describe '#decline!' do
|
219
|
+
let(:recipient) { GroupDocs::Signature::Recipient.new }
|
220
|
+
|
221
|
+
before(:each) do
|
222
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'accepts access credentials hash' do
|
226
|
+
lambda do
|
227
|
+
subject.decline!(recipient, :client_id => 'client_id', :private_key => 'private_key')
|
228
|
+
end.should_not raise_error()
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
232
|
+
lambda { subject.decline!('Recipient') }.should raise_error(ArgumentError)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
describe '#signed_documents!' do
|
237
|
+
before(:each) do
|
238
|
+
mock_api_server(File.read('spec/support/files/resume.pdf'))
|
239
|
+
subject.name = 'envelope'
|
240
|
+
end
|
241
|
+
|
242
|
+
let(:path) { Dir.tmpdir }
|
243
|
+
|
244
|
+
it 'accepts access credentials hash' do
|
245
|
+
lambda do
|
246
|
+
subject.signed_documents!(path, :client_id => 'client_id', :private_key => 'private_key')
|
247
|
+
end.should_not raise_error(ArgumentError)
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'returns saved file path' do
|
251
|
+
subject.stub(:documents! => [1])
|
252
|
+
subject.signed_documents!(path).should == "#{path}/#{subject.name}.pdf"
|
253
|
+
end
|
254
|
+
|
255
|
+
context 'no documents' do
|
256
|
+
before(:each) do
|
257
|
+
mock_api_server(File.read('spec/support/files/envelope.zip'))
|
258
|
+
end
|
259
|
+
|
260
|
+
it 'downloads ZIP file' do
|
261
|
+
file = double('file')
|
262
|
+
subject.stub(:documents! => [])
|
263
|
+
Object::File.should_receive(:open).with("#{path}/#{subject.name}.zip", 'wb').and_yield(file)
|
264
|
+
file.should_receive(:write).with(File.read('spec/support/files/envelope.zip'))
|
265
|
+
subject.signed_documents!(path)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
context 'single document' do
|
270
|
+
before(:each) do
|
271
|
+
mock_api_server(File.read('spec/support/files/resume.pdf'))
|
272
|
+
end
|
273
|
+
|
274
|
+
it 'downloads PDF file' do
|
275
|
+
file = double('file')
|
276
|
+
subject.stub(:documents! => [1])
|
277
|
+
Object::File.should_receive(:open).with("#{path}/#{subject.name}.pdf", 'wb').and_yield(file)
|
278
|
+
file.should_receive(:write).with(File.read('spec/support/files/resume.pdf'))
|
279
|
+
subject.signed_documents!(path)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
context 'multiple documents' do
|
284
|
+
before(:each) do
|
285
|
+
mock_api_server(File.read('spec/support/files/envelope.zip'))
|
286
|
+
end
|
287
|
+
|
288
|
+
it 'downloads ZIP file' do
|
289
|
+
file = double('file')
|
290
|
+
subject.stub(:documents! => [1, 2])
|
291
|
+
Object::File.should_receive(:open).with("#{path}/#{subject.name}.zip", 'wb').and_yield(file)
|
292
|
+
file.should_receive(:write).with(File.read('spec/support/files/envelope.zip'))
|
293
|
+
subject.signed_documents!(path)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
describe '#signed_document!' do
|
299
|
+
before(:each) do
|
300
|
+
mock_api_server(File.read('spec/support/files/resume.pdf'))
|
301
|
+
subject.name = 'envelope'
|
302
|
+
end
|
303
|
+
|
304
|
+
let(:path) { Dir.tmpdir }
|
305
|
+
let(:document) { GroupDocs::Document.new(:file => GroupDocs::Storage::File.new) }
|
306
|
+
|
307
|
+
it 'accepts access credentials hash' do
|
308
|
+
lambda do
|
309
|
+
subject.signed_document!(document, path, :client_id => 'client_id', :private_key => 'private_key')
|
310
|
+
end.should_not raise_error()
|
311
|
+
end
|
312
|
+
|
313
|
+
it 'returns saved file path' do
|
314
|
+
subject.signed_document!(document, path).should == "#{path}/#{subject.name}.pdf"
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'downloads PDF file' do
|
318
|
+
file = double('file')
|
319
|
+
Object::File.should_receive(:open).with("#{path}/#{subject.name}.pdf", 'wb').and_yield(file)
|
320
|
+
file.should_receive(:write).with(File.read('spec/support/files/resume.pdf'))
|
321
|
+
subject.signed_document!(document, path)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
describe '#logs!' do
|
326
|
+
before(:each) do
|
327
|
+
mock_api_server(load_json('envelope_logs'))
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'accepts access credentials hash' do
|
331
|
+
lambda do
|
332
|
+
subject.logs!(:client_id => 'client_id', :private_key => 'private_key')
|
333
|
+
end.should_not raise_error()
|
334
|
+
end
|
335
|
+
|
336
|
+
it 'returns array of GroupDocs::Signature::Envelope::Log objects' do
|
337
|
+
logs = subject.logs!
|
338
|
+
logs.should be_an(Array)
|
339
|
+
logs.each do |log|
|
340
|
+
log.should be_a(GroupDocs::Signature::Envelope::Log)
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
describe '#send!' do
|
346
|
+
before(:each) do
|
347
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'accepts access credentials hash' do
|
351
|
+
lambda do
|
352
|
+
subject.send!(nil, :client_id => 'client_id', :private_key => 'private_key')
|
353
|
+
end.should_not raise_error()
|
354
|
+
end
|
355
|
+
|
356
|
+
it 'accepts webhook callback URL and sends it as plain text' do
|
357
|
+
subject.send! 'http://mywebsite.com'
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
describe '#archive!' do
|
362
|
+
before(:each) do
|
363
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
364
|
+
end
|
365
|
+
|
366
|
+
it 'accepts access credentials hash' do
|
367
|
+
lambda do
|
368
|
+
subject.archive!(:client_id => 'client_id', :private_key => 'private_key')
|
369
|
+
end.should_not raise_error()
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
describe '#restart!' do
|
374
|
+
before(:each) do
|
375
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
376
|
+
end
|
377
|
+
|
378
|
+
it 'accepts access credentials hash' do
|
379
|
+
lambda do
|
380
|
+
subject.restart!(:client_id => 'client_id', :private_key => 'private_key')
|
381
|
+
end.should_not raise_error()
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|