groupdocs 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.travis.yml +4 -0
  2. data/CHANGELOG.md +32 -0
  3. data/examples/api-samples/public/css/style.css +123 -67
  4. data/examples/api-samples/public/images/help.png +0 -0
  5. data/examples/api-samples/public/images/info.png +0 -0
  6. data/examples/api-samples/public/templates/base-simple_source.html +192 -0
  7. data/examples/api-samples/public/templates/testdocument.html +101 -0
  8. data/examples/api-samples/public/templates/welcome.htm +137 -0
  9. data/examples/api-samples/samples/sample18.rb +134 -31
  10. data/examples/api-samples/views/sample18.haml +127 -9
  11. data/lib/groupdocs/api/request.rb +1 -1
  12. data/lib/groupdocs/document.rb +6 -3
  13. data/lib/groupdocs/signature.rb +6 -0
  14. data/lib/groupdocs/signature/contact.rb +42 -0
  15. data/lib/groupdocs/signature/envelope.rb +71 -0
  16. data/lib/groupdocs/signature/field.rb +21 -2
  17. data/lib/groupdocs/signature/form.rb +162 -9
  18. data/lib/groupdocs/signature/role.rb +5 -31
  19. data/lib/groupdocs/signature/shared/document_methods.rb +2 -1
  20. data/lib/groupdocs/signature/shared/entity_fields.rb +6 -16
  21. data/lib/groupdocs/signature/shared/entity_methods.rb +2 -2
  22. data/lib/groupdocs/signature/shared/field_methods.rb +56 -2
  23. data/lib/groupdocs/storage.rb +1 -0
  24. data/lib/groupdocs/storage/provider.rb +32 -0
  25. data/lib/groupdocs/user.rb +66 -0
  26. data/lib/groupdocs/version.rb +1 -1
  27. data/spec/groupdocs/signature/contact_spec.rb +21 -0
  28. data/spec/groupdocs/signature/envelope_spec.rb +53 -1
  29. data/spec/groupdocs/signature/field_spec.rb +19 -1
  30. data/spec/groupdocs/signature/form_spec.rb +47 -11
  31. data/spec/groupdocs/signature/role_spec.rb +4 -47
  32. data/spec/groupdocs/signature_spec.rb +4 -0
  33. data/spec/groupdocs/storage/provider_spec.rb +22 -0
  34. data/spec/groupdocs/user_spec.rb +54 -0
  35. data/spec/support/json/user_embed_key.json +39 -0
  36. data/spec/support/json/user_providers.json +31 -0
  37. data/spec/support/json/user_roles.json +25 -0
  38. data/spec/support/shared_examples/signature/shared/entity_fields.rb +14 -26
  39. data/spec/support/shared_examples/signature/shared/field_methods.rb +58 -34
  40. metadata +18 -4
@@ -4,6 +4,8 @@ describe GroupDocs::Signature::Form do
4
4
 
5
5
  it_behaves_like GroupDocs::Api::Entity
6
6
  include_examples GroupDocs::Signature::EntityMethods
7
+ include_examples GroupDocs::Signature::DocumentMethods
8
+ include_examples GroupDocs::Signature::FieldMethods
7
9
  include_examples GroupDocs::Signature::ResourceMethods
8
10
 
9
11
  describe '.all!' do
@@ -42,6 +44,8 @@ describe GroupDocs::Signature::Form do
42
44
  it { should have_accessor(:fieldsInFinalFileName) }
43
45
  it { should have_accessor(:canParticipantDownloadForm) }
44
46
  it { should have_accessor(:status) }
47
+ it { should have_accessor(:watermarkText) }
48
+ it { should have_accessor(:watermarkImage) }
45
49
 
46
50
  it { should alias_accessor(:owner_guid, :ownerGuid) }
47
51
  it { should alias_accessor(:template_guid, :templateGuid) }
@@ -50,8 +54,9 @@ describe GroupDocs::Signature::Form do
50
54
  it { should alias_accessor(:documents_count, :documentsCount) }
51
55
  it { should alias_accessor(:documents_pages, :documentsPages) }
52
56
  it { should alias_accessor(:participants_count, :participantsCount) }
53
- it { should alias_accessor(:fields_in_final_file_name, :fieldsInFinalFileName) }
54
57
  it { should alias_accessor(:can_participant_download_form, :canParticipantDownloadForm) }
58
+ it { should alias_accessor(:watermark_text, :watermarkText) }
59
+ it { should alias_accessor(:watermark_image, :watermarkImage) }
55
60
 
56
61
  describe '#status' do
57
62
  it 'converts status to human-readable format' do
@@ -60,39 +65,52 @@ describe GroupDocs::Signature::Form do
60
65
  end
61
66
  end
62
67
 
63
- describe '#create!' do
64
- let(:template) { GroupDocs::Signature::Template.new }
68
+ describe '#fields_in_final_file_name=' do
69
+ it 'converts field names in machine-readable format if array is passed' do
70
+ subject.fields_in_final_file_name = %w(on off)
71
+ subject.instance_variable_get(:@fieldsInFinalFileName).should == 'on,off'
72
+ end
73
+
74
+ it 'saves field names as is if not an array is passed' do
75
+ subject.fields_in_final_file_name = 'on,off'
76
+ subject.instance_variable_get(:@fieldsInFinalFileName).should == 'on,off'
77
+ end
78
+ end
79
+
80
+ describe '#fields_in_final_file_name' do
81
+ it 'returns field names in human-readable format' do
82
+ subject.fields_in_final_file_name = %w(on off)
83
+ subject.fields_in_final_file_name.should == %w(on off)
84
+ end
85
+ end
65
86
 
87
+ describe '#create!' do
66
88
  before(:each) do
67
89
  mock_api_server(load_json('form_get'))
68
90
  end
69
91
 
70
92
  it 'accepts access credentials hash' do
71
93
  lambda do
72
- subject.create!(template, {}, :client_id => 'client_id', :private_key => 'private_key')
94
+ subject.create!({}, :client_id => 'client_id', :private_key => 'private_key')
73
95
  end.should_not raise_error(ArgumentError)
74
96
  end
75
97
 
76
98
  it 'accepts options hash' do
77
99
  lambda do
78
- subject.create!(template, :assembly_id => 'aodfh43yr9834hf943h')
100
+ subject.create!(:assembly_id => 'aodfh43yr9834hf943h')
79
101
  end.should_not raise_error(ArgumentError)
80
102
  end
81
103
 
82
104
  it 'uses hashed version of self as request body' do
83
105
  subject.should_receive(:to_hash)
84
- subject.create!(template)
106
+ subject.create!
85
107
  end
86
108
 
87
109
  it 'updates identifier of entity' do
88
110
  lambda do
89
- subject.create!(template)
111
+ subject.create!
90
112
  end.should change(subject, :id)
91
113
  end
92
-
93
- it 'raises error if template is not GroupDocs::Signature::Template object' do
94
- lambda { subject.create!('Template') }.should raise_error(ArgumentError)
95
- end
96
114
  end
97
115
 
98
116
  describe '#documents!' do
@@ -150,4 +168,22 @@ describe GroupDocs::Signature::Form do
150
168
  end.should_not raise_error(ArgumentError)
151
169
  end
152
170
  end
171
+
172
+ describe '#update_from_template!' do
173
+ let(:template) { GroupDocs::Signature::Template.new }
174
+
175
+ before(:each) do
176
+ mock_api_server('{ "status": "Ok", "result": {}}')
177
+ end
178
+
179
+ it 'raises error if template is not GroupDocs::Signature::Template object' do
180
+ lambda { subject.update_from_template!('Template') }.should raise_error(ArgumentError)
181
+ end
182
+
183
+ it 'accepts access credentials hash' do
184
+ lambda do
185
+ subject.update_from_template!(template, :client_id => 'client_id', :private_key => 'private_key')
186
+ end.should_not raise_error(ArgumentError)
187
+ end
188
+ end
153
189
  end
@@ -40,51 +40,8 @@ describe GroupDocs::Signature::Role do
40
40
  it { should alias_accessor(:can_annotate, :canAnnotate) }
41
41
  it { should alias_accessor(:can_delegate, :canDelegate) }
42
42
 
43
- describe '#can_edit?' do
44
- it 'returns true if role can edit' do
45
- subject.can_edit = 1
46
- subject.can_edit?.should be_true
47
- end
48
-
49
- it 'returns false if role cannot edit' do
50
- subject.can_edit = 0
51
- subject.can_edit?.should be_false
52
- end
53
- end
54
-
55
- describe '#can_sign?' do
56
- it 'returns true if role can sign' do
57
- subject.can_sign = 1
58
- subject.can_sign?.should be_true
59
- end
60
-
61
- it 'returns false if role cannot sign' do
62
- subject.can_sign = 0
63
- subject.can_sign?.should be_false
64
- end
65
- end
66
-
67
- describe '#can_annotate?' do
68
- it 'returns true if role can annotate' do
69
- subject.can_annotate = 1
70
- subject.can_annotate?.should be_true
71
- end
72
-
73
- it 'returns false if role cannot annotate' do
74
- subject.can_annotate = 0
75
- subject.can_annotate?.should be_false
76
- end
77
- end
78
-
79
- describe '#can_delegate?' do
80
- it 'returns true if role can delegate' do
81
- subject.can_delegate = 1
82
- subject.can_delegate?.should be_true
83
- end
84
-
85
- it 'returns false if role cannot delegate' do
86
- subject.can_delegate = 0
87
- subject.can_delegate?.should be_false
88
- end
89
- end
43
+ it { should have_alias(:can_edit?, :can_edit) }
44
+ it { should have_alias(:can_sign?, :can_sign) }
45
+ it { should have_alias(:can_annotate?, :can_annotate) }
46
+ it { should have_alias(:can_delegate?, :can_delegate) }
90
47
  end
@@ -38,6 +38,8 @@ describe GroupDocs::Signature do
38
38
  it { should have_accessor(:initialsImageFileId) }
39
39
  it { should have_accessor(:signatureImageUrl) }
40
40
  it { should have_accessor(:initialsImageUrl) }
41
+ it { should have_accessor(:signatureData) }
42
+ it { should have_accessor(:initialsData) }
41
43
  it { should have_accessor(:createdTimeStamp) }
42
44
  it { should have_accessor(:image_path) }
43
45
 
@@ -52,6 +54,8 @@ describe GroupDocs::Signature do
52
54
  it { should alias_accessor(:initials_image_file_id, :initialsImageFileId) }
53
55
  it { should alias_accessor(:signature_image_url, :signatureImageUrl) }
54
56
  it { should alias_accessor(:initials_image_url, :initialsImageUrl) }
57
+ it { should alias_accessor(:signature_data, :signatureData) }
58
+ it { should alias_accessor(:initials_data, :initialsData) }
55
59
  it { should alias_accessor(:created_time_stamp, :createdTimeStamp) }
56
60
 
57
61
  describe '#create!' do
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Storage::Provider do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ it { should have_accessor(:id) }
8
+ it { should have_accessor(:provider) }
9
+ it { should have_accessor(:type) }
10
+ it { should have_accessor(:token) }
11
+ it { should have_accessor(:publicKey) }
12
+ it { should have_accessor(:privateKey) }
13
+ it { should have_accessor(:rootFolder) }
14
+ it { should have_accessor(:isPrimary) }
15
+ it { should have_accessor(:serviceHost) }
16
+
17
+ it { should alias_accessor(:public_key, :publicKey) }
18
+ it { should alias_accessor(:private_key, :privateKey) }
19
+ it { should alias_accessor(:root_folder, :rootFolder) }
20
+ it { should alias_accessor(:is_primary, :isPrimary) }
21
+ it { should alias_accessor(:service_host, :serviceHost) }
22
+ end
@@ -42,6 +42,42 @@ describe GroupDocs::User do
42
42
  end
43
43
  end
44
44
 
45
+ describe '.embed_key!' do
46
+ before(:each) do
47
+ mock_api_server(load_json('user_embed_key'))
48
+ end
49
+
50
+ it 'accepts access credentials hash' do
51
+ lambda do
52
+ described_class.embed_key!('test-area', :client_id => 'client_id', :private_key => 'private_key')
53
+ end.should_not raise_error(ArgumentError)
54
+ end
55
+
56
+ it 'returns new user embed key for defined area' do
57
+ result = described_class.embed_key!('test-area')
58
+ result.should be_a(String)
59
+ end
60
+ end
61
+
62
+ describe '.providers!' do
63
+ before(:each) do
64
+ mock_api_server(load_json('user_providers'))
65
+ end
66
+
67
+ it 'accepts access credentials hash' do
68
+ lambda do
69
+ described_class.providers!(:client_id => 'client_id', :private_key => 'private_key')
70
+ end.should_not raise_error(ArgumentError)
71
+ end
72
+
73
+ it 'returns array of GroupDocs::Storage::Provider' do
74
+ providers = described_class.providers!
75
+ providers.should be_an(Array)
76
+ providers.each do |provider|
77
+ provider.should be_a(GroupDocs::Storage::Provider)
78
+ end
79
+ end
80
+ end
45
81
  it { should have_accessor(:id) }
46
82
  it { should have_accessor(:guid) }
47
83
  it { should have_accessor(:nickname) }
@@ -130,4 +166,22 @@ describe GroupDocs::User do
130
166
  end
131
167
  end
132
168
  end
169
+
170
+ describe '#roles!' do
171
+ before(:each) do
172
+ mock_api_server(load_json('user_roles'))
173
+ end
174
+
175
+ it 'accepts access credentials hash' do
176
+ lambda do
177
+ subject.roles!(:client_id => 'client_id', :private_key => 'private_key')
178
+ end.should_not raise_error(ArgumentError)
179
+ end
180
+
181
+ it 'returns array' do
182
+ roles = subject.roles!
183
+ roles.should be_an(Array)
184
+ end
185
+ end
186
+
133
187
  end
@@ -0,0 +1,39 @@
1
+ {
2
+ "result": {
3
+ "key": {
4
+ "user": {
5
+ "nickname": "test@test.com",
6
+ "firstname": "First",
7
+ "lastname": "Last",
8
+ "pkey": "iwhfsfy8sdufh9hfsfsd9",
9
+ "pswd_salt": null,
10
+ "claimed_id": null,
11
+ "token": null,
12
+ "storage": null,
13
+ "photo": null,
14
+ "active": false,
15
+ "trial": false,
16
+ "news_eanbled": null,
17
+ "alerts_eanbled": null,
18
+ "support_eanbled": null,
19
+ "support_email": null,
20
+ "annotation_branded": null,
21
+ "viewer_branded": null,
22
+ "signedupOn": 1335963525287,
23
+ "signedinOn": 1335963525287,
24
+ "signin_count": 0,
25
+ "roles": null,
26
+ "id": 85,
27
+ "guid": "8sd7tfsdf",
28
+ "primary_email": "test@test.com"
29
+ },
30
+ "guid": "60a06ef8f23a49cf807977f1444fbdd8",
31
+ "area": "test-area",
32
+ "active": true,
33
+ "hit_count": 0
34
+ }
35
+ },
36
+ "status": "Ok",
37
+ "error_message": null,
38
+ "composedOn": 1359383495765
39
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "result": {
3
+ "providers": [
4
+ {
5
+ "id": 38,
6
+ "provider": "Dropbox",
7
+ "type": "Shared",
8
+ "token": "lWYWx1ZU9mc3RyaW5nc3RyaW5nPjwvQXJyYXlPZktleVZhbHVlT2Z",
9
+ "publicKey": "kfmwehvfusotcgk",
10
+ "privateKey": "swaurn5gnfrbh1s",
11
+ "rootFolder": null,
12
+ "isPrimary": false,
13
+ "serviceHost": null
14
+ },
15
+ {
16
+ "id": 54,
17
+ "provider": "BoxNet",
18
+ "type": "Shared",
19
+ "token": "Nnc2MDB3NzFncXBnMjk1YXVidXk2aGd1bnRnemlibWI=",
20
+ "publicKey": null,
21
+ "privateKey": "fyypebzyu9tpe4753utoe1fcru",
22
+ "rootFolder": null,
23
+ "isPrimary": false,
24
+ "serviceHost": null
25
+ }]
26
+ },
27
+ "status": "Ok",
28
+ "error_message": null,
29
+ "composedOn": 1365653541727
30
+ }
31
+
@@ -0,0 +1,25 @@
1
+ {
2
+ "result": {
3
+ "roles": [
4
+ {
5
+ "id": 1,
6
+ "name": "SysAdmin"
7
+ },
8
+ {
9
+ "id": 2,
10
+ "name": "Admin"
11
+ },
12
+ {
13
+ "id": 3,
14
+ "name": "User"
15
+ },
16
+ {
17
+ "id": 4,
18
+ "name": "Guest"
19
+ }
20
+ ]
21
+ },
22
+ "status": "Ok",
23
+ "error_message": null,
24
+ "composedOn": 1365660243257
25
+ }
@@ -13,19 +13,21 @@ shared_examples_for GroupDocs::Signature::EntityFields do
13
13
  it { should have_accessor(:documentsCount) }
14
14
  it { should have_accessor(:documentsPages) }
15
15
  it { should have_accessor(:recipients) }
16
+ it { should have_accessor(:watermarkText) }
17
+ it { should have_accessor(:watermarkImage) }
16
18
 
17
- it { should alias_accessor(:owner_id, :ownerId) }
18
- it { should alias_accessor(:owner_guid, :ownerGuid) }
19
- it { should alias_accessor(:reminder_time, :reminderTime) }
20
- it { should alias_accessor(:step_expire_time, :stepExpireTime) }
21
- # owner_should_sign is overwritten
22
- it { should have_alias(:owner_should_sign=, :ownerShouldSign=) }
23
- # ordered_signature is overwritten
24
- it { should have_alias(:ordered_signature=, :orderedSignature=) }
25
- it { should alias_accessor(:email_subject, :emailSubject) }
26
- it { should alias_accessor(:email_body, :emailBody) }
27
- it { should alias_accessor(:documents_count, :documentsCount) }
28
- it { should alias_accessor(:documents_pages, :documentsPages) }
19
+ it { should alias_accessor(:owner_id, :ownerId) }
20
+ it { should alias_accessor(:owner_guid, :ownerGuid) }
21
+ it { should alias_accessor(:reminder_time, :reminderTime) }
22
+ it { should alias_accessor(:step_expire_time, :stepExpireTime) }
23
+ it { should alias_accessor(:owner_should_sign, :ownerShouldSign) }
24
+ it { should alias_accessor(:ordered_signature, :orderedSignature) }
25
+ it { should alias_accessor(:email_subject, :emailSubject) }
26
+ it { should alias_accessor(:email_body, :emailBody) }
27
+ it { should alias_accessor(:documents_count, :documentsCount) }
28
+ it { should alias_accessor(:documents_pages, :documentsPages) }
29
+ it { should alias_accessor(:watermark_text, :watermarkText) }
30
+ it { should alias_accessor(:watermark_image, :watermarkImage) }
29
31
 
30
32
  describe '#recipients=' do
31
33
  it 'converts each recipient to GroupDocs::Signature::Recipient object if hash is passed' do
@@ -51,18 +53,4 @@ shared_examples_for GroupDocs::Signature::EntityFields do
51
53
  end.should_not change(subject, :recipients)
52
54
  end
53
55
  end
54
-
55
- describe '#owner_should_sign' do
56
- it 'returns true if owner should sign' do
57
- subject.owner_should_sign = 1
58
- subject.owner_should_sign.should be_true
59
- end
60
- end
61
-
62
- describe '#ordered_signature' do
63
- it 'returns :ordered for ordered entity' do
64
- subject.owner_should_sign = 1
65
- subject.ordered_signature.should == :ordered
66
- end
67
- end
68
56
  end
@@ -1,4 +1,12 @@
1
1
  shared_examples_for GroupDocs::Signature::FieldMethods do
2
+ let(:args) do
3
+ case described_class.name
4
+ when 'GroupDocs::Signature::Form'
5
+ [document]
6
+ when 'GroupDocs::Signature::Template', 'GroupDocs::Signature::Envelope'
7
+ [document, recipient]
8
+ end
9
+ end
2
10
 
3
11
  describe '#fields!' do
4
12
  let(:document) { GroupDocs::Document.new(:file => GroupDocs::Storage::File.new) }
@@ -10,20 +18,12 @@ shared_examples_for GroupDocs::Signature::FieldMethods do
10
18
 
11
19
  it 'accepts access credentials hash' do
12
20
  lambda do
13
- subject.fields!(document, recipient, :client_id => 'client_id', :private_key => 'private_key')
21
+ subject.fields!(*args, :client_id => 'client_id', :private_key => 'private_key')
14
22
  end.should_not raise_error(ArgumentError)
15
23
  end
16
24
 
17
- it 'raises error if document is not GroupDocs::Document object' do
18
- lambda { 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
- lambda { subject.fields!(document, 'Recipient') }.should raise_error(ArgumentError)
23
- end
24
-
25
25
  it 'returns array of GroupDocs::Signature::Field objects' do
26
- fields = subject.fields!(document, recipient)
26
+ fields = subject.fields!(*args)
27
27
  fields.should be_an(Array)
28
28
  fields.each do |field|
29
29
  field.should be_a(GroupDocs::Signature::Field)
@@ -42,25 +42,17 @@ shared_examples_for GroupDocs::Signature::FieldMethods do
42
42
 
43
43
  it 'accepts access credentials hash' do
44
44
  lambda do
45
- subject.add_field!(field, document, recipient, { :force_new_field => false }, :client_id => 'client_id', :private_key => 'private_key')
45
+ subject.add_field!(field, *args, { :force_new_field => false }, :client_id => 'client_id', :private_key => 'private_key')
46
46
  end.should_not raise_error(ArgumentError)
47
47
  end
48
48
 
49
49
  it 'raises error if field is not GroupDocs::Signature::Field object' do
50
- lambda { 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
- lambda { 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
- lambda { subject.add_field!(field, document, 'Recipient') }.should raise_error(ArgumentError)
50
+ lambda { subject.add_field!('Field', *args) }.should raise_error(ArgumentError)
59
51
  end
60
52
 
61
53
  it 'raises error if field does not specify location' do
62
54
  field = GroupDocs::Signature::Field.new
63
- lambda { subject.add_field!(field, document, recipient) }.should raise_error(ArgumentError)
55
+ lambda { subject.add_field!(field, *args) }.should raise_error(ArgumentError)
64
56
  end
65
57
 
66
58
  it 'uses field and field locationas payload' do
@@ -71,7 +63,7 @@ shared_examples_for GroupDocs::Signature::FieldMethods do
71
63
  field.location.should_receive(:to_hash).and_return(location)
72
64
  payload.should_receive(:merge!).with(location).and_return(payload)
73
65
  payload.should_receive(:merge!).with(:forceNewField => true).and_return({})
74
- subject.add_field!(field, document, recipient)
66
+ subject.add_field!(field, *args)
75
67
  end
76
68
 
77
69
  it 'allows overriding force new field flag' do
@@ -82,7 +74,7 @@ shared_examples_for GroupDocs::Signature::FieldMethods do
82
74
  field.location.should_receive(:to_hash).and_return(location)
83
75
  payload.should_receive(:merge!).with(location).and_return(payload)
84
76
  payload.should_receive(:merge!).with(:forceNewField => false).and_return({})
85
- subject.add_field!(field, document, recipient, :force_new_field => false)
77
+ subject.add_field!(field, *args, :force_new_field => false)
86
78
  end
87
79
  end
88
80
 
@@ -121,6 +113,46 @@ shared_examples_for GroupDocs::Signature::FieldMethods do
121
113
  end
122
114
  end
123
115
 
116
+ describe '#assign_field!' do
117
+ case described_class.name
118
+ when 'GroupDocs::Signature::Form'
119
+ it 'does not have #assign_field! method' do
120
+ subject.methods.should_not include(:assign_field!)
121
+ end
122
+ when 'GroupDocs::Signature::Template', 'GroupDocs::Signature::Envelope'
123
+ let(:field) { GroupDocs::Signature::Field.new }
124
+ let(:document) { GroupDocs::Document.new(:file => GroupDocs::Storage::File.new) }
125
+ let(:assign_from) { GroupDocs::Signature::Recipient.new }
126
+ let(:assign_to) { GroupDocs::Signature::Recipient.new }
127
+
128
+ before(:each) do
129
+ mock_api_server(load_json('signature_field_add'))
130
+ end
131
+
132
+ it 'accepts access credentials hash' do
133
+ lambda do
134
+ subject.assign_field!(field, document, assign_from, assign_to, :client_id => 'client_id', :private_key => 'private_key')
135
+ end.should_not raise_error(ArgumentError)
136
+ end
137
+
138
+ it 'raises error if field is not GroupDocs::Signature::Field object' do
139
+ lambda { subject.assign_field!('Field', document, assign_from, assign_to) }.should raise_error(ArgumentError)
140
+ end
141
+
142
+ it 'raises error if document is not GroupDocs::Document object' do
143
+ lambda { subject.assign_field!(field, 'Document', assign_from, assign_to) }.should raise_error(ArgumentError)
144
+ end
145
+
146
+ it 'raises error if assign from is not GroupDocs::Signature::Recipient object' do
147
+ lambda { subject.assign_field!(field, document, 'Assign', assign_to) }.should raise_error(ArgumentError)
148
+ end
149
+
150
+ it 'raises error if assign to is not GroupDocs::Signature::Recipient object' do
151
+ lambda { subject.assign_field!(field, document, assign_from, 'Assign') }.should raise_error(ArgumentError)
152
+ end
153
+ end
154
+ end
155
+
124
156
  describe '#delete_field!' do
125
157
  let(:field) do
126
158
  GroupDocs::Signature::Field.new
@@ -152,24 +184,16 @@ shared_examples_for GroupDocs::Signature::FieldMethods do
152
184
  end
153
185
 
154
186
  it 'raises error if location is not GroupDocs::Signature::Field::Location object' do
155
- lambda { subject.modify_field_location!('Location', field, document, recipient) }.should raise_error(ArgumentError)
187
+ lambda { subject.modify_field_location!('Location', field, *args) }.should raise_error(ArgumentError)
156
188
  end
157
189
 
158
190
  it 'raises error if field is not GroupDocs::Signature::Field object' do
159
- lambda { subject.modify_field_location!(location, 'Field', document, recipient) }.should raise_error(ArgumentError)
160
- end
161
-
162
- it 'raises error if document is not GroupDocs::Document object' do
163
- lambda { subject.modify_field_location!(location, field, 'Document', recipient) }.should raise_error(ArgumentError)
164
- end
165
-
166
- it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
167
- lambda { subject.modify_field_location!(location, field, document, 'Recipient') }.should raise_error(ArgumentError)
191
+ lambda { subject.modify_field_location!(location, 'Field', *args) }.should raise_error(ArgumentError)
168
192
  end
169
193
 
170
194
  it 'accepts access credentials hash' do
171
195
  lambda do
172
- subject.modify_field_location!(location, field, document, recipient, :client_id => 'client_id', :private_key => 'private_key')
196
+ subject.modify_field_location!(location, field, *args, :client_id => 'client_id', :private_key => 'private_key')
173
197
  end.should_not raise_error(ArgumentError)
174
198
  end
175
199
  end