groupdocs 0.3.11 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +150 -0
- data/README.md +6 -58
- data/Rakefile +1 -1
- data/examples/README.md +13 -0
- data/examples/annotations/Gemfile +5 -0
- data/examples/annotations/app.rb +67 -0
- data/groupdocs.gemspec +3 -3
- data/lib/groupdocs.rb +11 -2
- data/lib/groupdocs/api/entity.rb +17 -1
- data/lib/groupdocs/api/helpers/path_helper.rb +10 -10
- data/lib/groupdocs/api/helpers/rest_helper.rb +7 -2
- data/lib/groupdocs/api/helpers/url_helper.rb +2 -4
- data/lib/groupdocs/api/request.rb +2 -4
- data/lib/groupdocs/datasource.rb +2 -2
- data/lib/groupdocs/datasource/field.rb +1 -1
- data/lib/groupdocs/document.rb +6 -18
- data/lib/groupdocs/document/annotation.rb +25 -2
- data/lib/groupdocs/document/annotation/reply.rb +6 -10
- data/lib/groupdocs/document/change.rb +1 -1
- data/lib/groupdocs/document/field.rb +1 -1
- data/lib/groupdocs/document/metadata.rb +1 -1
- data/lib/groupdocs/document/rectangle.rb +1 -1
- data/lib/groupdocs/document/view.rb +1 -1
- data/lib/groupdocs/job.rb +51 -8
- data/lib/groupdocs/questionnaire.rb +2 -2
- data/lib/groupdocs/questionnaire/execution.rb +1 -1
- data/lib/groupdocs/questionnaire/page.rb +1 -1
- data/lib/groupdocs/questionnaire/question.rb +1 -1
- data/lib/groupdocs/questionnaire/question/answer.rb +1 -1
- data/lib/groupdocs/signature.rb +134 -0
- data/lib/groupdocs/signature/contact.rb +141 -0
- data/lib/groupdocs/signature/envelope.rb +376 -0
- data/lib/groupdocs/signature/envelope/log.rb +22 -0
- data/lib/groupdocs/signature/field.rb +253 -0
- data/lib/groupdocs/signature/field/location.rb +72 -0
- data/lib/groupdocs/signature/form.rb +202 -0
- data/lib/groupdocs/signature/list.rb +93 -0
- data/lib/groupdocs/signature/recipient.rb +47 -0
- data/lib/groupdocs/signature/role.rb +84 -0
- data/lib/groupdocs/signature/shared.rb +6 -0
- data/lib/groupdocs/signature/shared/document_methods.rb +98 -0
- data/lib/groupdocs/signature/shared/entity_fields.rb +94 -0
- data/lib/groupdocs/signature/shared/entity_methods.rb +145 -0
- data/lib/groupdocs/signature/shared/field_methods.rb +282 -0
- data/lib/groupdocs/signature/shared/recipient_methods.rb +63 -0
- data/lib/groupdocs/signature/shared/resource_methods.rb +65 -0
- data/lib/groupdocs/signature/template.rb +104 -0
- data/lib/groupdocs/storage/file.rb +69 -62
- data/lib/groupdocs/storage/folder.rb +54 -88
- data/lib/groupdocs/storage/package.rb +1 -1
- data/lib/groupdocs/subscription.rb +113 -0
- data/lib/groupdocs/subscription/limit.rb +24 -0
- data/lib/groupdocs/user.rb +22 -2
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/api/entity_spec.rb +14 -0
- data/spec/groupdocs/api/helpers/path_helper_spec.rb +6 -19
- data/spec/groupdocs/api/helpers/rest_helper_spec.rb +9 -0
- data/spec/groupdocs/api/request_spec.rb +2 -7
- data/spec/groupdocs/datasource_spec.rb +3 -7
- data/spec/groupdocs/document/annotation/reply_spec.rb +11 -20
- data/spec/groupdocs/document/annotation_spec.rb +35 -31
- data/spec/groupdocs/document/field_spec.rb +1 -4
- data/spec/groupdocs/document/rectangle_spec.rb +10 -22
- data/spec/groupdocs/document_spec.rb +7 -27
- data/spec/groupdocs/job_spec.rb +43 -0
- data/spec/groupdocs/questionnaire/question_spec.rb +2 -6
- data/spec/groupdocs/questionnaire_spec.rb +3 -7
- data/spec/groupdocs/signature/contact_spec.rb +129 -0
- data/spec/groupdocs/signature/envelope/log_spec.rb +23 -0
- data/spec/groupdocs/signature/envelope_spec.rb +296 -0
- data/spec/groupdocs/signature/field/location_spec.rb +73 -0
- data/spec/groupdocs/signature/field_spec.rb +264 -0
- data/spec/groupdocs/signature/form_spec.rb +174 -0
- data/spec/groupdocs/signature/list_spec.rb +92 -0
- data/spec/groupdocs/signature/recipient_spec.rb +37 -0
- data/spec/groupdocs/signature/role_spec.rb +100 -0
- data/spec/groupdocs/signature/template_spec.rb +82 -0
- data/spec/groupdocs/signature_spec.rb +117 -0
- data/spec/groupdocs/storage/file_spec.rb +76 -61
- data/spec/groupdocs/storage/folder_spec.rb +43 -90
- data/spec/groupdocs/storage/package_spec.rb +1 -2
- data/spec/groupdocs/subscription/limit_spec.rb +24 -0
- data/spec/groupdocs/subscription_spec.rb +85 -0
- data/spec/groupdocs/user_spec.rb +27 -18
- data/spec/groupdocs_spec.rb +11 -0
- data/spec/spec_helper.rb +10 -1
- data/spec/support/files/envelope.zip +0 -0
- data/spec/support/json/annotation_access_set.json +11 -0
- data/spec/support/json/contact_add.json +12 -0
- data/spec/support/json/contacts_get.json +19 -0
- data/spec/support/json/contacts_import.json +8 -0
- data/spec/support/json/envelope_get.json +46 -0
- data/spec/support/json/envelope_logs.json +16 -0
- data/spec/support/json/envelopes_all.json +48 -0
- data/spec/support/json/envelopes_resources.json +31 -0
- data/spec/support/json/form_get.json +21 -0
- data/spec/support/json/forms_all.json +23 -0
- data/spec/support/json/job_get.json +30 -0
- data/spec/support/json/list_add.json +12 -0
- data/spec/support/json/lists_get.json +19 -0
- data/spec/support/json/signature_create.json +12 -0
- data/spec/support/json/signature_field_add.json +25 -0
- data/spec/support/json/signature_fields_get.json +27 -0
- data/spec/support/json/signature_roles_get.json +17 -0
- data/spec/support/json/signatures_get.json +19 -0
- data/spec/support/json/subscription_plan_get.json +9 -0
- data/spec/support/json/subscription_plans_get.json +17 -0
- data/spec/support/json/template_get.json +35 -0
- data/spec/support/json/template_get_documents.json +15 -0
- data/spec/support/json/template_get_recipients.json +20 -0
- data/spec/support/json/templates_all.json +37 -0
- data/spec/support/json/user_users_get.json +27 -0
- data/spec/support/shared_examples/signature/shared/document_methods.rb +68 -0
- data/spec/support/shared_examples/signature/shared/entity_fields.rb +89 -0
- data/spec/support/shared_examples/signature/shared/entity_methods.rb +116 -0
- data/spec/support/shared_examples/signature/shared/field_methods.rb +188 -0
- data/spec/support/shared_examples/signature/shared/recipient_methods.rb +42 -0
- data/spec/support/shared_examples/signature/shared/resource_methods.rb +46 -0
- metadata +139 -29
- data/lib/groupdocs/extensions.rb +0 -1
- data/lib/groupdocs/extensions/lookup.rb +0 -52
- data/spec/support/shared_examples/extensions/lookup.rb +0 -57
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"status": "Ok",
|
|
3
|
+
"result":
|
|
4
|
+
{
|
|
5
|
+
"template":
|
|
6
|
+
{
|
|
7
|
+
"id": "f0dc546a8f3705e3e8d861dee5efa363",
|
|
8
|
+
"name": "New template",
|
|
9
|
+
"ownerId": 115,
|
|
10
|
+
"ownerGuid": "67e9cf57a2b9da4d",
|
|
11
|
+
"reminderTime": 1,
|
|
12
|
+
"stepExpireTime": 3,
|
|
13
|
+
"templateExpireTime": 6,
|
|
14
|
+
"ownerShouldSign": true,
|
|
15
|
+
"orderedSignature": false,
|
|
16
|
+
"emailSubject": "",
|
|
17
|
+
"emailBody": "",
|
|
18
|
+
"documentsCount": 0,
|
|
19
|
+
"documentsPages": 0,
|
|
20
|
+
"recipients":
|
|
21
|
+
[
|
|
22
|
+
{
|
|
23
|
+
"id": "1252fbc7c4704d6ff8535a9daeaaff0e",
|
|
24
|
+
"firstName": "John",
|
|
25
|
+
"lastName": "Smith",
|
|
26
|
+
"email": "test@test.com",
|
|
27
|
+
"userId": 115,
|
|
28
|
+
"userGuid": "67e9cf57a2b9da4d",
|
|
29
|
+
"order": 32767,
|
|
30
|
+
"roleId": 2
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"status": "Ok",
|
|
3
|
+
"result":
|
|
4
|
+
{
|
|
5
|
+
"templateId": "f0dc546a8f3705e3e8d861dee5efa363",
|
|
6
|
+
"recipients":
|
|
7
|
+
[
|
|
8
|
+
{
|
|
9
|
+
"id": "1252fbc7c4704d6ff8535a9daeaaff0e",
|
|
10
|
+
"firstName": "John",
|
|
11
|
+
"lastName": "Smith",
|
|
12
|
+
"email": "test@test.com",
|
|
13
|
+
"userId": 115,
|
|
14
|
+
"userGuid": "67e9cf57a2b9da4d",
|
|
15
|
+
"order": 32767,
|
|
16
|
+
"roleId": 2
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"status": "Ok",
|
|
3
|
+
"result":
|
|
4
|
+
{
|
|
5
|
+
"templates":
|
|
6
|
+
[
|
|
7
|
+
{
|
|
8
|
+
"id": "f0dc546a8f3705e3e8d861dee5efa363",
|
|
9
|
+
"name": "New template",
|
|
10
|
+
"ownerId": 115,
|
|
11
|
+
"ownerGuid": "67e9cf57a2b9da4d",
|
|
12
|
+
"reminderTime": 1,
|
|
13
|
+
"stepExpireTime": 3,
|
|
14
|
+
"templateExpireTime": 6,
|
|
15
|
+
"ownerShouldSign": true,
|
|
16
|
+
"orderedSignature": false,
|
|
17
|
+
"emailSubject": "",
|
|
18
|
+
"emailBody": "",
|
|
19
|
+
"documentsCount": 0,
|
|
20
|
+
"documentsPages": 0,
|
|
21
|
+
"recipients":
|
|
22
|
+
[
|
|
23
|
+
{
|
|
24
|
+
"id": "1252fbc7c4704d6ff8535a9daeaaff0e",
|
|
25
|
+
"firstName": "John",
|
|
26
|
+
"lastName": "Smith",
|
|
27
|
+
"email": "test@test.com",
|
|
28
|
+
"userId": 115,
|
|
29
|
+
"userGuid": "67e9cf57a2b9da4d",
|
|
30
|
+
"order": 32767,
|
|
31
|
+
"roleId": 2
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"result": {
|
|
3
|
+
"users":
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"nickname": "test@test.com",
|
|
7
|
+
"firstname": "First",
|
|
8
|
+
"lastname": "Last",
|
|
9
|
+
"pkey": "iwhfsfy8sdufh9hfsfsd9",
|
|
10
|
+
"pswd_salt": null,
|
|
11
|
+
"claimed_id": null,
|
|
12
|
+
"token": null,
|
|
13
|
+
"storage": null,
|
|
14
|
+
"photo": null,
|
|
15
|
+
"active": false,
|
|
16
|
+
"news_eanbled": false,
|
|
17
|
+
"signedupOn": 1335963525287,
|
|
18
|
+
"roles": null,
|
|
19
|
+
"id": 85,
|
|
20
|
+
"guid": "8sd7tfsdf",
|
|
21
|
+
"primary_email": "test@test.com"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"status": "Ok",
|
|
26
|
+
"error_message": null
|
|
27
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
shared_examples_for GroupDocs::Signature::DocumentMethods do
|
|
2
|
+
|
|
3
|
+
describe '#documents!' do
|
|
4
|
+
before(:each) do
|
|
5
|
+
mock_api_server(load_json('template_get_documents'))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'accepts access credentials hash' do
|
|
9
|
+
lambda do
|
|
10
|
+
subject.documents!(client_id: 'client_id', private_key: 'private_key')
|
|
11
|
+
end.should_not raise_error(ArgumentError)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'returns array of GroupDocs::Document objects' do
|
|
15
|
+
documents = subject.documents!
|
|
16
|
+
documents.should be_an(Array)
|
|
17
|
+
documents.each do |document|
|
|
18
|
+
document.should be_a(GroupDocs::Document)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#add_document!' do
|
|
24
|
+
let(:document) do
|
|
25
|
+
GroupDocs::Document.new(file: GroupDocs::Storage::File.new)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
before(:each) do
|
|
29
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'accepts access credentials hash' do
|
|
33
|
+
lambda do
|
|
34
|
+
subject.add_document!(document, {}, client_id: 'client_id', private_key: 'private_key')
|
|
35
|
+
end.should_not raise_error(ArgumentError)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'accepts options hash' do
|
|
39
|
+
lambda do
|
|
40
|
+
subject.add_document!(document, order: 1)
|
|
41
|
+
end.should_not raise_error(ArgumentError)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'raises error if document is not GroupDocs::Document object' do
|
|
45
|
+
-> { subject.add_document!('Document') }.should raise_error(ArgumentError)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe '#remove_document!' do
|
|
50
|
+
let(:document) do
|
|
51
|
+
GroupDocs::Document.new(file: GroupDocs::Storage::File.new)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
before(:each) do
|
|
55
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'accepts access credentials hash' do
|
|
59
|
+
lambda do
|
|
60
|
+
subject.remove_document!(document, client_id: 'client_id', private_key: 'private_key')
|
|
61
|
+
end.should_not raise_error(ArgumentError)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'raises error if document is not GroupDocs::Document object' do
|
|
65
|
+
-> { subject.remove_document!('Document') }.should raise_error(ArgumentError)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
shared_examples_for GroupDocs::Signature::EntityFields do
|
|
2
|
+
|
|
3
|
+
it { should respond_to(:id) }
|
|
4
|
+
it { should respond_to(:id=) }
|
|
5
|
+
it { should respond_to(:name) }
|
|
6
|
+
it { should respond_to(:name=) }
|
|
7
|
+
it { should respond_to(:ownerId) }
|
|
8
|
+
it { should respond_to(:ownerId=) }
|
|
9
|
+
it { should respond_to(:ownerGuid) }
|
|
10
|
+
it { should respond_to(:ownerGuid=) }
|
|
11
|
+
it { should respond_to(:reminderTime) }
|
|
12
|
+
it { should respond_to(:reminderTime=) }
|
|
13
|
+
it { should respond_to(:stepExpireTime) }
|
|
14
|
+
it { should respond_to(:stepExpireTime=) }
|
|
15
|
+
it { should respond_to(:ownerShouldSign) }
|
|
16
|
+
it { should respond_to(:ownerShouldSign=) }
|
|
17
|
+
it { should respond_to(:orderedSignature) }
|
|
18
|
+
it { should respond_to(:orderedSignature=) }
|
|
19
|
+
it { should respond_to(:emailSubject) }
|
|
20
|
+
it { should respond_to(:emailSubject=) }
|
|
21
|
+
it { should respond_to(:emailBody) }
|
|
22
|
+
it { should respond_to(:emailBody=) }
|
|
23
|
+
it { should respond_to(:documentsCount) }
|
|
24
|
+
it { should respond_to(:documentsCount=) }
|
|
25
|
+
it { should respond_to(:documentsPages) }
|
|
26
|
+
it { should respond_to(:documentsPages=) }
|
|
27
|
+
it { should respond_to(:recipients) }
|
|
28
|
+
it { should respond_to(:recipients=) }
|
|
29
|
+
|
|
30
|
+
it { should have_alias(:owner_id, :ownerId) }
|
|
31
|
+
it { should have_alias(:owner_id=, :ownerId=) }
|
|
32
|
+
it { should have_alias(:owner_guid, :ownerGuid) }
|
|
33
|
+
it { should have_alias(:owner_guid=, :ownerGuid=) }
|
|
34
|
+
it { should have_alias(:reminder_time, :reminderTime) }
|
|
35
|
+
it { should have_alias(:reminder_time=, :reminderTime=) }
|
|
36
|
+
it { should have_alias(:step_expire_time, :stepExpireTime) }
|
|
37
|
+
it { should have_alias(:step_expire_time=, :stepExpireTime=) }
|
|
38
|
+
# owner_should_sign is overwritten
|
|
39
|
+
it { should have_alias(:owner_should_sign=, :ownerShouldSign=) }
|
|
40
|
+
# ordered_signature is overwritten
|
|
41
|
+
it { should have_alias(:ordered_signature=, :orderedSignature=) }
|
|
42
|
+
it { should have_alias(:email_subject, :emailSubject) }
|
|
43
|
+
it { should have_alias(:email_subject=, :emailSubject=) }
|
|
44
|
+
it { should have_alias(:email_body, :emailBody) }
|
|
45
|
+
it { should have_alias(:email_body=, :emailBody=) }
|
|
46
|
+
it { should have_alias(:documents_count, :documentsCount) }
|
|
47
|
+
it { should have_alias(:documents_count=, :documentsCount=) }
|
|
48
|
+
it { should have_alias(:documents_pages, :documentsPages) }
|
|
49
|
+
it { should have_alias(:documents_pages=, :documentsPages=) }
|
|
50
|
+
|
|
51
|
+
describe '#recipients=' do
|
|
52
|
+
it 'converts each recipient to GroupDocs::Signature::Recipient object if hash is passed' do
|
|
53
|
+
subject.recipients = [{ nickname: 'John' }]
|
|
54
|
+
recipients = subject.recipients
|
|
55
|
+
recipients.should be_an(Array)
|
|
56
|
+
recipients.each do |recipient|
|
|
57
|
+
recipient.should be_a(GroupDocs::Signature::Recipient)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'saves each recipient if it is GroupDocs::Signature::Recipient object' do
|
|
62
|
+
recipient1 = GroupDocs::Signature::Recipient.new(nickname: 'recipient1')
|
|
63
|
+
recipient2 = GroupDocs::Signature::Recipient.new(nickname: 'recipient2')
|
|
64
|
+
subject.recipients = [recipient1, recipient2]
|
|
65
|
+
subject.recipients.should include(recipient1)
|
|
66
|
+
subject.recipients.should include(recipient2)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'does nothing if nil is passed' do
|
|
70
|
+
lambda do
|
|
71
|
+
subject.recipients = nil
|
|
72
|
+
end.should_not change(subject, :recipients)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe '#owner_should_sign' do
|
|
77
|
+
it 'returns true if owner should sign' do
|
|
78
|
+
subject.owner_should_sign = 1
|
|
79
|
+
subject.owner_should_sign.should be_true
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe '#ordered_signature' do
|
|
84
|
+
it 'returns :ordered for ordered entity' do
|
|
85
|
+
subject.owner_should_sign = 1
|
|
86
|
+
subject.ordered_signature.should == :ordered
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
shared_examples_for GroupDocs::Signature::EntityMethods do
|
|
2
|
+
|
|
3
|
+
describe '.get!' do
|
|
4
|
+
before(:each) do
|
|
5
|
+
mock_api_server(load_json("#{subject.send(:class_name)}_get"))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'accepts access credentials hash' do
|
|
9
|
+
lambda do
|
|
10
|
+
described_class.get!("j5498fre9fje9f", client_id: 'client_id', private_key: 'private_key')
|
|
11
|
+
end.should_not raise_error(ArgumentError)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "returns #{described_class} objects" do
|
|
15
|
+
described_class.get!("j5498fre9fje9f").should be_a(described_class)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# GroupDocs::Signature::Form overwrites #create! so we should not run default specs for it
|
|
20
|
+
unless described_class == GroupDocs::Signature::Form
|
|
21
|
+
describe '#create!' do
|
|
22
|
+
before(:each) do
|
|
23
|
+
mock_api_server(load_json("#{subject.send(:class_name)}_get"))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'accepts access credentials hash' do
|
|
27
|
+
lambda do
|
|
28
|
+
subject.create!({}, client_id: 'client_id', private_key: 'private_key')
|
|
29
|
+
end.should_not raise_error(ArgumentError)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'accepts options hash' do
|
|
33
|
+
lambda do
|
|
34
|
+
subject.create!(template_id: 'aodfh43yr9834hf943h')
|
|
35
|
+
end.should_not raise_error(ArgumentError)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'uses hashed version of self as request body' do
|
|
39
|
+
subject.should_receive(:to_hash)
|
|
40
|
+
subject.create!
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'updates identifier of entity' do
|
|
44
|
+
lambda do
|
|
45
|
+
subject.create!
|
|
46
|
+
end.should change(subject, :id)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe '#modify!' do
|
|
52
|
+
before(:each) do
|
|
53
|
+
mock_api_server(load_json("#{subject.send(:class_name)}_get"))
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'accepts access credentials hash' do
|
|
57
|
+
lambda do
|
|
58
|
+
subject.modify!(client_id: 'client_id', private_key: 'private_key')
|
|
59
|
+
end.should_not raise_error(ArgumentError)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'uses hashed version of self as request body' do
|
|
63
|
+
subject.should_receive(:to_hash)
|
|
64
|
+
subject.modify!
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#rename!' do
|
|
69
|
+
before(:each) do
|
|
70
|
+
mock_api_server(%({ "status": "Ok", "result": { "#{subject.send(:class_name)}": null }}))
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'accepts access credentials hash' do
|
|
74
|
+
lambda do
|
|
75
|
+
subject.rename!('Name', client_id: 'client_id', private_key: 'private_key')
|
|
76
|
+
end.should_not raise_error(ArgumentError)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# alter params for form
|
|
80
|
+
if described_class == GroupDocs::Signature::Form
|
|
81
|
+
it 'uses new_name as parameter' do
|
|
82
|
+
api = stub(GroupDocs::Api::Request)
|
|
83
|
+
api.stub!(execute!: {})
|
|
84
|
+
GroupDocs::Api::Request.stub(new: api)
|
|
85
|
+
api.should_receive(:add_params).with(new_name: 'Name')
|
|
86
|
+
subject.rename!('Name')
|
|
87
|
+
end
|
|
88
|
+
else
|
|
89
|
+
it 'uses name as parameter' do
|
|
90
|
+
api = stub(GroupDocs::Api::Request)
|
|
91
|
+
api.stub!(execute!: {})
|
|
92
|
+
GroupDocs::Api::Request.stub(new: api)
|
|
93
|
+
api.should_receive(:add_params).with(name: 'Name')
|
|
94
|
+
subject.rename!('Name')
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'updates name of template' do
|
|
99
|
+
lambda do
|
|
100
|
+
subject.rename!('Name')
|
|
101
|
+
end.should change(subject, :name)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe '#delete!' do
|
|
106
|
+
before(:each) do
|
|
107
|
+
mock_api_server(%({ "status": "Ok", "result": { "#{subject.send(:class_name)}": null }}))
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'accepts access credentials hash' do
|
|
111
|
+
lambda do
|
|
112
|
+
subject.delete!(client_id: 'client_id', private_key: 'private_key')
|
|
113
|
+
end.should_not raise_error(ArgumentError)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
shared_examples_for GroupDocs::Signature::FieldMethods do
|
|
2
|
+
|
|
3
|
+
describe '#fields!' do
|
|
4
|
+
let(:document) { GroupDocs::Document.new(file: GroupDocs::Storage::File.new) }
|
|
5
|
+
let(:recipient) { GroupDocs::Signature::Recipient.new }
|
|
6
|
+
|
|
7
|
+
before(:each) do
|
|
8
|
+
mock_api_server(load_json('signature_fields_get'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'accepts access credentials hash' do
|
|
12
|
+
lambda do
|
|
13
|
+
subject.fields!(document, recipient, client_id: 'client_id', private_key: 'private_key')
|
|
14
|
+
end.should_not raise_error(ArgumentError)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'raises error if document is not GroupDocs::Document object' do
|
|
18
|
+
-> { subject.fields!('Document', recipient) }.should raise_error(ArgumentError)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
|
22
|
+
-> { subject.fields!(document, 'Recipient') }.should raise_error(ArgumentError)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'returns array of GroupDocs::Signature::Field objects' do
|
|
26
|
+
fields = subject.fields!(document, recipient)
|
|
27
|
+
fields.should be_an(Array)
|
|
28
|
+
fields.each do |field|
|
|
29
|
+
field.should be_a(GroupDocs::Signature::Field)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '#add_field!' do
|
|
35
|
+
let(:field) { GroupDocs::Signature::Field.new(location: { location_x: 0.1, page: 1 }) }
|
|
36
|
+
let(:document) { GroupDocs::Document.new(file: GroupDocs::Storage::File.new) }
|
|
37
|
+
let(:recipient) { GroupDocs::Signature::Recipient.new }
|
|
38
|
+
|
|
39
|
+
before(:each) do
|
|
40
|
+
mock_api_server(load_json('signature_field_add'))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'accepts access credentials hash' do
|
|
44
|
+
lambda do
|
|
45
|
+
subject.add_field!(field, document, recipient, client_id: 'client_id', private_key: 'private_key')
|
|
46
|
+
end.should_not raise_error(ArgumentError)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'raises error if field is not GroupDocs::Signature::Field object' do
|
|
50
|
+
-> { subject.add_field!('Field', document, recipient) }.should raise_error(ArgumentError)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'raises error if document is not GroupDocs::Document object' do
|
|
54
|
+
-> { subject.add_field!(field, 'Document', recipient) }.should raise_error(ArgumentError)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
|
58
|
+
-> { subject.add_field!(field, document, 'Recipient') }.should raise_error(ArgumentError)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'raises error if field does not specify location' do
|
|
62
|
+
field = GroupDocs::Signature::Field.new
|
|
63
|
+
-> { subject.add_field!(field, document, recipient) }.should raise_error(ArgumentError)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'uses field, field location and forcedNewField flag as payload' do
|
|
67
|
+
hash_one = {}
|
|
68
|
+
payload = {}
|
|
69
|
+
location = {}
|
|
70
|
+
field.should_receive(:to_hash).and_return(payload)
|
|
71
|
+
field.location.should_receive(:to_hash).and_return(location)
|
|
72
|
+
payload.should_receive(:merge!).with(location).and_return(payload)
|
|
73
|
+
payload.should_receive(:merge!).with(forceNewField: true).and_return({})
|
|
74
|
+
subject.add_field!(field, document, recipient)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe '#modify_field!' do
|
|
79
|
+
let(:field) { GroupDocs::Signature::Field.new }
|
|
80
|
+
let(:document) { GroupDocs::Document.new(file: GroupDocs::Storage::File.new) }
|
|
81
|
+
|
|
82
|
+
before(:each) do
|
|
83
|
+
mock_api_server(load_json('signature_field_add'))
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'accepts access credentials hash' do
|
|
87
|
+
lambda do
|
|
88
|
+
subject.modify_field!(field, document, client_id: 'client_id', private_key: 'private_key')
|
|
89
|
+
end.should_not raise_error(ArgumentError)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'raises error if field is not GroupDocs::Signature::Field object' do
|
|
93
|
+
-> { subject.modify_field!('Field', document) }.should raise_error(ArgumentError)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'raises error if document is not GroupDocs::Document object' do
|
|
97
|
+
-> { subject.modify_field!(field, 'Document') }.should raise_error(ArgumentError)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'uses field and first field location as payload' do
|
|
101
|
+
payload = {}
|
|
102
|
+
location = {}
|
|
103
|
+
locations = [location]
|
|
104
|
+
field.should_receive(:to_hash).and_return(payload)
|
|
105
|
+
payload.should_receive(:delete).with(:locations).and_return(payload)
|
|
106
|
+
field.should_receive(:locations).and_return(locations)
|
|
107
|
+
locations.should_receive(:first).and_return(location)
|
|
108
|
+
payload.should_receive(:merge!).with(location).and_return(payload)
|
|
109
|
+
subject.modify_field!(field, document)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe '#delete_field!' do
|
|
114
|
+
let(:field) do
|
|
115
|
+
GroupDocs::Signature::Field.new
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
before(:each) do
|
|
119
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it 'raises error if field is not GroupDocs::Signature::Field object' do
|
|
123
|
+
-> { subject.delete_field!('Field') }.should raise_error(ArgumentError)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it 'accepts access credentials hash' do
|
|
127
|
+
lambda do
|
|
128
|
+
subject.delete_field!(field, client_id: 'client_id', private_key: 'private_key')
|
|
129
|
+
end.should_not raise_error(ArgumentError)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe '#modify_field_location!' do
|
|
134
|
+
let(:field) { GroupDocs::Signature::Field.new }
|
|
135
|
+
let(:document) { GroupDocs::Document.new(file: GroupDocs::Storage::File.new) }
|
|
136
|
+
let(:recipient) { GroupDocs::Signature::Recipient.new }
|
|
137
|
+
let(:location) { GroupDocs::Signature::Field::Location.new }
|
|
138
|
+
|
|
139
|
+
before(:each) do
|
|
140
|
+
mock_api_server(load_json('signature_field_add'))
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it 'raises error if location is not GroupDocs::Signature::Field::Location object' do
|
|
144
|
+
-> { subject.modify_field_location!('Location', field, document, recipient) }.should raise_error(ArgumentError)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'raises error if field is not GroupDocs::Signature::Field object' do
|
|
148
|
+
-> { subject.modify_field_location!(location, 'Field', document, recipient) }.should raise_error(ArgumentError)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it 'raises error if document is not GroupDocs::Document object' do
|
|
152
|
+
-> { subject.modify_field_location!(location, field, 'Document', recipient) }.should raise_error(ArgumentError)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
|
|
156
|
+
-> { subject.modify_field_location!(location, field, document, 'Recipient') }.should raise_error(ArgumentError)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'accepts access credentials hash' do
|
|
160
|
+
lambda do
|
|
161
|
+
subject.modify_field_location!(location, field, document, recipient, client_id: 'client_id', private_key: 'private_key')
|
|
162
|
+
end.should_not raise_error(ArgumentError)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
describe '#delete_field_location!' do
|
|
167
|
+
let(:field) { GroupDocs::Signature::Field.new }
|
|
168
|
+
let(:location) { GroupDocs::Signature::Field::Location.new }
|
|
169
|
+
|
|
170
|
+
before(:each) do
|
|
171
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it 'raises error if location is not GroupDocs::Signature::Field::Location object' do
|
|
175
|
+
-> { subject.delete_field_location!('Location', field) }.should raise_error(ArgumentError)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it 'raises error if field is not GroupDocs::Signature::Field object' do
|
|
179
|
+
-> { subject.delete_field_location!(location, 'Field') }.should raise_error(ArgumentError)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it 'accepts access credentials hash' do
|
|
183
|
+
lambda do
|
|
184
|
+
subject.delete_field_location!(location, field, client_id: 'client_id', private_key: 'private_key')
|
|
185
|
+
end.should_not raise_error(ArgumentError)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|