groupdocs 0.3.11 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/CHANGELOG.md +150 -0
  2. data/README.md +6 -58
  3. data/Rakefile +1 -1
  4. data/examples/README.md +13 -0
  5. data/examples/annotations/Gemfile +5 -0
  6. data/examples/annotations/app.rb +67 -0
  7. data/groupdocs.gemspec +3 -3
  8. data/lib/groupdocs.rb +11 -2
  9. data/lib/groupdocs/api/entity.rb +17 -1
  10. data/lib/groupdocs/api/helpers/path_helper.rb +10 -10
  11. data/lib/groupdocs/api/helpers/rest_helper.rb +7 -2
  12. data/lib/groupdocs/api/helpers/url_helper.rb +2 -4
  13. data/lib/groupdocs/api/request.rb +2 -4
  14. data/lib/groupdocs/datasource.rb +2 -2
  15. data/lib/groupdocs/datasource/field.rb +1 -1
  16. data/lib/groupdocs/document.rb +6 -18
  17. data/lib/groupdocs/document/annotation.rb +25 -2
  18. data/lib/groupdocs/document/annotation/reply.rb +6 -10
  19. data/lib/groupdocs/document/change.rb +1 -1
  20. data/lib/groupdocs/document/field.rb +1 -1
  21. data/lib/groupdocs/document/metadata.rb +1 -1
  22. data/lib/groupdocs/document/rectangle.rb +1 -1
  23. data/lib/groupdocs/document/view.rb +1 -1
  24. data/lib/groupdocs/job.rb +51 -8
  25. data/lib/groupdocs/questionnaire.rb +2 -2
  26. data/lib/groupdocs/questionnaire/execution.rb +1 -1
  27. data/lib/groupdocs/questionnaire/page.rb +1 -1
  28. data/lib/groupdocs/questionnaire/question.rb +1 -1
  29. data/lib/groupdocs/questionnaire/question/answer.rb +1 -1
  30. data/lib/groupdocs/signature.rb +134 -0
  31. data/lib/groupdocs/signature/contact.rb +141 -0
  32. data/lib/groupdocs/signature/envelope.rb +376 -0
  33. data/lib/groupdocs/signature/envelope/log.rb +22 -0
  34. data/lib/groupdocs/signature/field.rb +253 -0
  35. data/lib/groupdocs/signature/field/location.rb +72 -0
  36. data/lib/groupdocs/signature/form.rb +202 -0
  37. data/lib/groupdocs/signature/list.rb +93 -0
  38. data/lib/groupdocs/signature/recipient.rb +47 -0
  39. data/lib/groupdocs/signature/role.rb +84 -0
  40. data/lib/groupdocs/signature/shared.rb +6 -0
  41. data/lib/groupdocs/signature/shared/document_methods.rb +98 -0
  42. data/lib/groupdocs/signature/shared/entity_fields.rb +94 -0
  43. data/lib/groupdocs/signature/shared/entity_methods.rb +145 -0
  44. data/lib/groupdocs/signature/shared/field_methods.rb +282 -0
  45. data/lib/groupdocs/signature/shared/recipient_methods.rb +63 -0
  46. data/lib/groupdocs/signature/shared/resource_methods.rb +65 -0
  47. data/lib/groupdocs/signature/template.rb +104 -0
  48. data/lib/groupdocs/storage/file.rb +69 -62
  49. data/lib/groupdocs/storage/folder.rb +54 -88
  50. data/lib/groupdocs/storage/package.rb +1 -1
  51. data/lib/groupdocs/subscription.rb +113 -0
  52. data/lib/groupdocs/subscription/limit.rb +24 -0
  53. data/lib/groupdocs/user.rb +22 -2
  54. data/lib/groupdocs/version.rb +1 -1
  55. data/spec/groupdocs/api/entity_spec.rb +14 -0
  56. data/spec/groupdocs/api/helpers/path_helper_spec.rb +6 -19
  57. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +9 -0
  58. data/spec/groupdocs/api/request_spec.rb +2 -7
  59. data/spec/groupdocs/datasource_spec.rb +3 -7
  60. data/spec/groupdocs/document/annotation/reply_spec.rb +11 -20
  61. data/spec/groupdocs/document/annotation_spec.rb +35 -31
  62. data/spec/groupdocs/document/field_spec.rb +1 -4
  63. data/spec/groupdocs/document/rectangle_spec.rb +10 -22
  64. data/spec/groupdocs/document_spec.rb +7 -27
  65. data/spec/groupdocs/job_spec.rb +43 -0
  66. data/spec/groupdocs/questionnaire/question_spec.rb +2 -6
  67. data/spec/groupdocs/questionnaire_spec.rb +3 -7
  68. data/spec/groupdocs/signature/contact_spec.rb +129 -0
  69. data/spec/groupdocs/signature/envelope/log_spec.rb +23 -0
  70. data/spec/groupdocs/signature/envelope_spec.rb +296 -0
  71. data/spec/groupdocs/signature/field/location_spec.rb +73 -0
  72. data/spec/groupdocs/signature/field_spec.rb +264 -0
  73. data/spec/groupdocs/signature/form_spec.rb +174 -0
  74. data/spec/groupdocs/signature/list_spec.rb +92 -0
  75. data/spec/groupdocs/signature/recipient_spec.rb +37 -0
  76. data/spec/groupdocs/signature/role_spec.rb +100 -0
  77. data/spec/groupdocs/signature/template_spec.rb +82 -0
  78. data/spec/groupdocs/signature_spec.rb +117 -0
  79. data/spec/groupdocs/storage/file_spec.rb +76 -61
  80. data/spec/groupdocs/storage/folder_spec.rb +43 -90
  81. data/spec/groupdocs/storage/package_spec.rb +1 -2
  82. data/spec/groupdocs/subscription/limit_spec.rb +24 -0
  83. data/spec/groupdocs/subscription_spec.rb +85 -0
  84. data/spec/groupdocs/user_spec.rb +27 -18
  85. data/spec/groupdocs_spec.rb +11 -0
  86. data/spec/spec_helper.rb +10 -1
  87. data/spec/support/files/envelope.zip +0 -0
  88. data/spec/support/json/annotation_access_set.json +11 -0
  89. data/spec/support/json/contact_add.json +12 -0
  90. data/spec/support/json/contacts_get.json +19 -0
  91. data/spec/support/json/contacts_import.json +8 -0
  92. data/spec/support/json/envelope_get.json +46 -0
  93. data/spec/support/json/envelope_logs.json +16 -0
  94. data/spec/support/json/envelopes_all.json +48 -0
  95. data/spec/support/json/envelopes_resources.json +31 -0
  96. data/spec/support/json/form_get.json +21 -0
  97. data/spec/support/json/forms_all.json +23 -0
  98. data/spec/support/json/job_get.json +30 -0
  99. data/spec/support/json/list_add.json +12 -0
  100. data/spec/support/json/lists_get.json +19 -0
  101. data/spec/support/json/signature_create.json +12 -0
  102. data/spec/support/json/signature_field_add.json +25 -0
  103. data/spec/support/json/signature_fields_get.json +27 -0
  104. data/spec/support/json/signature_roles_get.json +17 -0
  105. data/spec/support/json/signatures_get.json +19 -0
  106. data/spec/support/json/subscription_plan_get.json +9 -0
  107. data/spec/support/json/subscription_plans_get.json +17 -0
  108. data/spec/support/json/template_get.json +35 -0
  109. data/spec/support/json/template_get_documents.json +15 -0
  110. data/spec/support/json/template_get_recipients.json +20 -0
  111. data/spec/support/json/templates_all.json +37 -0
  112. data/spec/support/json/user_users_get.json +27 -0
  113. data/spec/support/shared_examples/signature/shared/document_methods.rb +68 -0
  114. data/spec/support/shared_examples/signature/shared/entity_fields.rb +89 -0
  115. data/spec/support/shared_examples/signature/shared/entity_methods.rb +116 -0
  116. data/spec/support/shared_examples/signature/shared/field_methods.rb +188 -0
  117. data/spec/support/shared_examples/signature/shared/recipient_methods.rb +42 -0
  118. data/spec/support/shared_examples/signature/shared/resource_methods.rb +46 -0
  119. metadata +139 -29
  120. data/lib/groupdocs/extensions.rb +0 -1
  121. data/lib/groupdocs/extensions/lookup.rb +0 -52
  122. data/spec/support/shared_examples/extensions/lookup.rb +0 -57
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Signature::Field::Location do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ it { should respond_to(:id) }
8
+ it { should respond_to(:id=) }
9
+ it { should respond_to(:documentId) }
10
+ it { should respond_to(:documentId=) }
11
+ it { should respond_to(:fieldId) }
12
+ it { should respond_to(:fieldId=) }
13
+ it { should respond_to(:page) }
14
+ it { should respond_to(:page=) }
15
+ it { should respond_to(:locationX) }
16
+ it { should respond_to(:locationX=) }
17
+ it { should respond_to(:locationY) }
18
+ it { should respond_to(:locationY=) }
19
+ it { should respond_to(:locationWidth) }
20
+ it { should respond_to(:locationWidth=) }
21
+ it { should respond_to(:locationHeight) }
22
+ it { should respond_to(:locationHeight=) }
23
+ it { should respond_to(:fontName) }
24
+ it { should respond_to(:fontName=) }
25
+ it { should respond_to(:fontColor) }
26
+ it { should respond_to(:fontColor=) }
27
+ it { should respond_to(:fontSize) }
28
+ it { should respond_to(:fontSize=) }
29
+ it { should respond_to(:fontBold) }
30
+ it { should respond_to(:fontBold=) }
31
+ it { should respond_to(:fontItalic) }
32
+ it { should respond_to(:fontItalic=) }
33
+ it { should respond_to(:fontUnderline) }
34
+ it { should respond_to(:fontUnderline=) }
35
+
36
+ it { should have_alias(:document_id, :documentId) }
37
+ it { should have_alias(:document_id=, :documentId=) }
38
+ it { should have_alias(:field_id, :fieldId) }
39
+ it { should have_alias(:field_id=, :fieldId=) }
40
+ it { should have_alias(:location_x, :locationX) }
41
+ it { should have_alias(:location_x=, :locationX=) }
42
+ it { should have_alias(:x, :locationX) }
43
+ it { should have_alias(:x=, :locationX=) }
44
+ it { should have_alias(:location_y, :locationY) }
45
+ it { should have_alias(:location_y=, :locationY=) }
46
+ it { should have_alias(:y, :locationY) }
47
+ it { should have_alias(:y=, :locationY=) }
48
+ it { should have_alias(:location_w, :locationWidth) }
49
+ it { should have_alias(:location_w=, :locationWidth=) }
50
+ it { should have_alias(:location_width, :locationWidth) }
51
+ it { should have_alias(:location_width=, :locationWidth=) }
52
+ it { should have_alias(:w, :locationWidth) }
53
+ it { should have_alias(:w=, :locationWidth=) }
54
+ it { should have_alias(:location_h, :locationHeight) }
55
+ it { should have_alias(:location_h=, :locationHeight=) }
56
+ it { should have_alias(:location_height, :locationHeight) }
57
+ it { should have_alias(:location_height=, :locationHeight=) }
58
+ it { should have_alias(:h, :locationHeight) }
59
+ it { should have_alias(:h=, :locationHeight=) }
60
+ it { should have_alias(:font_name, :fontName) }
61
+ it { should have_alias(:font_name=, :fontName=) }
62
+ it { should have_alias(:font_color, :fontColor) }
63
+ it { should have_alias(:font_color=, :fontColor=) }
64
+ it { should have_alias(:font_size, :fontSize) }
65
+ it { should have_alias(:font_size=, :fontSize=) }
66
+ it { should have_alias(:font_bold, :fontBold) }
67
+ it { should have_alias(:font_bold=, :fontBold=) }
68
+ it { should have_alias(:font_italic, :fontItalic) }
69
+ it { should have_alias(:font_italic=, :fontItalic=) }
70
+ it { should have_alias(:font_underline, :fontUnderline) }
71
+ it { should have_alias(:font_underline=, :fontUnderline=) }
72
+
73
+ end
@@ -0,0 +1,264 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Signature::Field do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ describe '.get!' do
8
+ before(:each) do
9
+ mock_api_server(load_json('signature_fields_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(ArgumentError)
16
+ end
17
+
18
+ it 'allows passing options' do
19
+ -> { described_class.get!(id: "dsaoij3928ukr03") }.should_not raise_error(ArgumentError)
20
+ end
21
+
22
+ it 'returns array of GroupDocs::Signature::Field objects' do
23
+ fields = described_class.get!
24
+ fields.should be_an(Array)
25
+ fields.each do |field|
26
+ field.should be_a(GroupDocs::Signature::Field)
27
+ end
28
+ end
29
+ end
30
+
31
+ it { should respond_to(:id) }
32
+ it { should respond_to(:id=) }
33
+ it { should respond_to(:templateId) }
34
+ it { should respond_to(:templateId=) }
35
+ it { should respond_to(:recipientId) }
36
+ it { should respond_to(:recipientId=) }
37
+ it { should respond_to(:signatureFieldId) }
38
+ it { should respond_to(:signatureFieldId=) }
39
+ it { should respond_to(:graphSizeW) }
40
+ it { should respond_to(:graphSizeW=) }
41
+ it { should respond_to(:graphSizeW) }
42
+ it { should respond_to(:graphSizeW=) }
43
+ it { should respond_to(:graphSizeH) }
44
+ it { should respond_to(:graphSizeH=) }
45
+ it { should respond_to(:graphSizeH) }
46
+ it { should respond_to(:graphSizeH=) }
47
+ it { should respond_to(:getDataFrom) }
48
+ it { should respond_to(:getDataFrom=) }
49
+ it { should respond_to(:regularExpression) }
50
+ it { should respond_to(:regularExpression=) }
51
+ it { should respond_to(:fontName) }
52
+ it { should respond_to(:fontName=) }
53
+ it { should respond_to(:fontColor) }
54
+ it { should respond_to(:fontColor=) }
55
+ it { should respond_to(:fontSize) }
56
+ it { should respond_to(:fontSize=) }
57
+ it { should respond_to(:fontBold) }
58
+ it { should respond_to(:fontBold=) }
59
+ it { should respond_to(:fontItalic) }
60
+ it { should respond_to(:fontItalic=) }
61
+ it { should respond_to(:fontUnderline) }
62
+ it { should respond_to(:fontUnderline=) }
63
+ it { should respond_to(:isSystem) }
64
+ it { should respond_to(:isSystem=) }
65
+ it { should respond_to(:fieldType) }
66
+ it { should respond_to(:fieldType=) }
67
+ it { should respond_to(:acceptableValues) }
68
+ it { should respond_to(:acceptableValues=) }
69
+ it { should respond_to(:defaultValue) }
70
+ it { should respond_to(:defaultValue=) }
71
+ it { should respond_to(:tooltip) }
72
+ it { should respond_to(:tooltip=) }
73
+ it { should respond_to(:input) }
74
+ it { should respond_to(:input=) }
75
+ it { should respond_to(:order) }
76
+ it { should respond_to(:order=) }
77
+ it { should respond_to(:textRows) }
78
+ it { should respond_to(:textRows=) }
79
+ it { should respond_to(:textColumns) }
80
+ it { should respond_to(:textColumns=) }
81
+ it { should respond_to(:location) }
82
+ it { should respond_to(:location=) }
83
+ it { should respond_to(:locations) }
84
+ it { should respond_to(:locations=) }
85
+
86
+ it { should have_alias(:template_id, :templateId) }
87
+ it { should have_alias(:template_id=, :templateId=) }
88
+ it { should have_alias(:recipient_id, :recipientId) }
89
+ it { should have_alias(:recipient_id=, :recipientId=) }
90
+ it { should have_alias(:signature_field_id, :signatureFieldId) }
91
+ it { should have_alias(:signature_field_id=, :signatureFieldId=) }
92
+ it { should have_alias(:graph_size_w, :graphSizeW) }
93
+ it { should have_alias(:graph_size_w=, :graphSizeW=) }
94
+ it { should have_alias(:graph_size_width, :graphSizeW) }
95
+ it { should have_alias(:graph_size_width=, :graphSizeW=) }
96
+ it { should have_alias(:graph_size_h, :graphSizeH) }
97
+ it { should have_alias(:graph_size_h=, :graphSizeH=) }
98
+ it { should have_alias(:graph_size_height, :graphSizeH) }
99
+ it { should have_alias(:graph_size_height=, :graphSizeH=) }
100
+ it { should have_alias(:get_data_from, :getDataFrom) }
101
+ it { should have_alias(:get_data_from=, :getDataFrom=) }
102
+ it { should have_alias(:regular_expression, :regularExpression) }
103
+ it { should have_alias(:regular_expression=, :regularExpression=) }
104
+ it { should have_alias(:font_name, :fontName) }
105
+ it { should have_alias(:font_name=, :fontName=) }
106
+ it { should have_alias(:font_color, :fontColor) }
107
+ it { should have_alias(:font_color=, :fontColor=) }
108
+ it { should have_alias(:font_size, :fontSize) }
109
+ it { should have_alias(:font_size=, :fontSize=) }
110
+ it { should have_alias(:font_bold, :fontBold) }
111
+ it { should have_alias(:font_bold=, :fontBold=) }
112
+ it { should have_alias(:font_italic, :fontItalic) }
113
+ it { should have_alias(:font_italic=, :fontItalic=) }
114
+ it { should have_alias(:font_underline, :fontUnderline) }
115
+ it { should have_alias(:font_underline=, :fontUnderline=) }
116
+ it { should have_alias(:is_system, :isSystem) }
117
+ it { should have_alias(:is_system=, :isSystem=) }
118
+ it { should have_alias(:acceptable_values, :acceptableValues) }
119
+ it { should have_alias(:acceptable_values=, :acceptableValues=) }
120
+ it { should have_alias(:default_value, :defaultValue) }
121
+ it { should have_alias(:default_value=, :defaultValue=) }
122
+ it { should have_alias(:text_rows, :textRows) }
123
+ it { should have_alias(:text_rows=, :textRows=) }
124
+ it { should have_alias(:text_columns, :textColumns) }
125
+ it { should have_alias(:text_columns=, :textColumns=) }
126
+
127
+ describe '#location=' do
128
+ it 'converts location to GroupDocs::Signature::Field::Location object if hash is passed' do
129
+ subject.location = { id: 'location1' }
130
+ subject.location.should be_a(GroupDocs::Signature::Field::Location)
131
+ end
132
+
133
+ it 'saves each location if it is GroupDocs::Signature::Field::Location object' do
134
+ location = GroupDocs::Signature::Field::Location.new(id: 'location')
135
+ subject.location = location
136
+ subject.location.should == location
137
+ end
138
+
139
+ it 'appends location to locations if it is not empty' do
140
+ location1 = GroupDocs::Signature::Field::Location.new(id: 'location1')
141
+ location2 = GroupDocs::Signature::Field::Location.new(id: 'location2')
142
+ subject.locations = [location1]
143
+ subject.location = location2
144
+ subject.locations.should == [location1, location2]
145
+ end
146
+
147
+ it 'creates locations if it is empty' do
148
+ subject.locations = nil
149
+ location = GroupDocs::Signature::Field::Location.new(id: 'location')
150
+ subject.location = location
151
+ subject.locations.should == [location]
152
+ end
153
+
154
+ it 'does nothing if nil is passed' do
155
+ lambda do
156
+ subject.location = nil
157
+ end.should_not change(subject, :location)
158
+ end
159
+ end
160
+
161
+ describe '#locations=' do
162
+ it 'converts each location to GroupDocs::Signature::Field::Location object if hash is passed' do
163
+ subject.locations = [{ id: 'location1' }]
164
+ locations = subject.locations
165
+ locations.should be_an(Array)
166
+ locations.each do |location|
167
+ location.should be_a(GroupDocs::Signature::Field::Location)
168
+ end
169
+ end
170
+
171
+ it 'saves each location if it is GroupDocs::Signature::Field::Location object' do
172
+ location1 = GroupDocs::Signature::Field::Location.new(id: 'location1')
173
+ location2 = GroupDocs::Signature::Field::Location.new(id: 'location2')
174
+ subject.locations = [location1, location2]
175
+ subject.locations.should include(location1)
176
+ subject.locations.should include(location2)
177
+ end
178
+
179
+ it 'does nothing if nil is passed' do
180
+ lambda do
181
+ subject.locations = nil
182
+ end.should_not change(subject, :locations)
183
+ end
184
+ end
185
+
186
+ describe '#field_type=' do
187
+ it 'converts field type in machine-readable format if symbol is passed' do
188
+ subject.field_type = :multiline
189
+ subject.instance_variable_get(:@fieldType).should == 3
190
+ end
191
+
192
+ it 'saves field type as is if not a symbol is passed' do
193
+ subject.field_type = 3
194
+ subject.instance_variable_get(:@fieldType).should == 3
195
+ end
196
+
197
+ it 'is aliased to #type=' do
198
+ subject.should have_alias(:type=, :field_type=)
199
+ end
200
+ end
201
+
202
+ describe '#field_type' do
203
+ it 'returns field type in human-readable format' do
204
+ subject.field_type = :multiline
205
+ subject.field_type.should == :multiline
206
+ end
207
+
208
+ it 'is aliased to #type' do
209
+ subject.should have_alias(:type, :field_type)
210
+ end
211
+ end
212
+
213
+ describe '#create!' do
214
+ before(:each) do
215
+ mock_api_server(load_json('signature_field_add'))
216
+ end
217
+
218
+ it 'accepts access credentials hash' do
219
+ lambda do
220
+ subject.create!(client_id: 'client_id', private_key: 'private_key')
221
+ end.should_not raise_error(ArgumentError)
222
+ end
223
+
224
+ it 'uses hashed version of self as request body' do
225
+ subject.should_receive(:to_hash)
226
+ subject.create!
227
+ end
228
+
229
+ it 'updates identifier of field' do
230
+ lambda do
231
+ subject.create!
232
+ end.should change(subject, :id)
233
+ end
234
+ end
235
+
236
+ describe '#modify!' do
237
+ before(:each) do
238
+ mock_api_server(load_json('signature_field_add'))
239
+ end
240
+
241
+ it 'accepts access credentials hash' do
242
+ lambda do
243
+ subject.modify!(client_id: 'client_id', private_key: 'private_key')
244
+ end.should_not raise_error(ArgumentError)
245
+ end
246
+
247
+ it 'uses hashed version of self as request body' do
248
+ subject.should_receive(:to_hash)
249
+ subject.modify!
250
+ end
251
+ end
252
+
253
+ describe '#delete!' do
254
+ before(:each) do
255
+ mock_api_server('{ "status": "Ok", "result": { "field": null }}')
256
+ end
257
+
258
+ it 'accepts access credentials hash' do
259
+ lambda do
260
+ subject.delete!(client_id: 'client_id', private_key: 'private_key')
261
+ end.should_not raise_error(ArgumentError)
262
+ end
263
+ end
264
+ end
@@ -0,0 +1,174 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Signature::Form do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+ include_examples GroupDocs::Signature::EntityMethods
7
+ include_examples GroupDocs::Signature::ResourceMethods
8
+
9
+ describe '.all!' do
10
+ before(:each) do
11
+ mock_api_server(load_json('forms_all'))
12
+ end
13
+
14
+ it 'accepts access credentials hash' do
15
+ lambda do
16
+ described_class.all!({}, client_id: 'client_id', private_key: 'private_key')
17
+ end.should_not raise_error(ArgumentError)
18
+ end
19
+
20
+ it 'allows passing options' do
21
+ -> { described_class.all!(page: 1, count: 3) }.should_not raise_error(ArgumentError)
22
+ end
23
+
24
+ it 'returns array of GroupDocs::Signature::Form objects' do
25
+ forms = described_class.all!
26
+ forms.should be_an(Array)
27
+ forms.each do |form|
28
+ form.should be_a(GroupDocs::Signature::Form)
29
+ end
30
+ end
31
+ end
32
+
33
+ it { should respond_to(:id) }
34
+ it { should respond_to(:id=) }
35
+ it { should respond_to(:name) }
36
+ it { should respond_to(:name=) }
37
+ it { should respond_to(:ownerGuid) }
38
+ it { should respond_to(:ownerGuid=) }
39
+ it { should respond_to(:templateGuid) }
40
+ it { should respond_to(:templateGuid=) }
41
+ it { should respond_to(:createdTimeStamp) }
42
+ it { should respond_to(:createdTimeStamp=) }
43
+ it { should respond_to(:statusDateTime) }
44
+ it { should respond_to(:statusDateTime=) }
45
+ it { should respond_to(:documentsCount) }
46
+ it { should respond_to(:documentsCount=) }
47
+ it { should respond_to(:documentsPages) }
48
+ it { should respond_to(:documentsPages=) }
49
+ it { should respond_to(:participantsCount) }
50
+ it { should respond_to(:participantsCount=) }
51
+ it { should respond_to(:fieldsInFinalFileName) }
52
+ it { should respond_to(:fieldsInFinalFileName=) }
53
+ it { should respond_to(:canParticipantDownloadForm) }
54
+ it { should respond_to(:canParticipantDownloadForm=) }
55
+ it { should respond_to(:status) }
56
+ it { should respond_to(:status=) }
57
+
58
+ it { should have_alias(:owner_guid, :ownerGuid) }
59
+ it { should have_alias(:owner_guid=, :ownerGuid=) }
60
+ it { should have_alias(:template_guid, :templateGuid) }
61
+ it { should have_alias(:template_guid=, :templateGuid=) }
62
+ it { should have_alias(:created_time_stamp, :createdTimeStamp) }
63
+ it { should have_alias(:created_time_stamp=, :createdTimeStamp=) }
64
+ it { should have_alias(:status_date_time, :statusDateTime) }
65
+ it { should have_alias(:status_date_time=, :statusDateTime=) }
66
+ it { should have_alias(:documents_count, :documentsCount) }
67
+ it { should have_alias(:documents_count=, :documentsCount=) }
68
+ it { should have_alias(:documents_pages, :documentsPages) }
69
+ it { should have_alias(:documents_pages=, :documentsPages=) }
70
+ it { should have_alias(:participants_count, :participantsCount) }
71
+ it { should have_alias(:participants_count=, :participantsCount=) }
72
+ it { should have_alias(:fields_in_final_file_name, :fieldsInFinalFileName) }
73
+ it { should have_alias(:fields_in_final_file_name=, :fieldsInFinalFileName=) }
74
+ it { should have_alias(:can_participant_download_form, :canParticipantDownloadForm) }
75
+ it { should have_alias(:can_participant_download_form=, :canParticipantDownloadForm=) }
76
+
77
+ describe '#status' do
78
+ it 'converts status to human-readable format' do
79
+ subject.status = 1
80
+ subject.status.should == :in_progress
81
+ end
82
+ end
83
+
84
+ describe '#create!' do
85
+ let(:template) { GroupDocs::Signature::Template.new }
86
+
87
+ before(:each) do
88
+ mock_api_server(load_json('form_get'))
89
+ end
90
+
91
+ it 'accepts access credentials hash' do
92
+ lambda do
93
+ subject.create!(template, {}, client_id: 'client_id', private_key: 'private_key')
94
+ end.should_not raise_error(ArgumentError)
95
+ end
96
+
97
+ it 'accepts options hash' do
98
+ lambda do
99
+ subject.create!(template, assembly_id: 'aodfh43yr9834hf943h')
100
+ end.should_not raise_error(ArgumentError)
101
+ end
102
+
103
+ it 'uses hashed version of self as request body' do
104
+ subject.should_receive(:to_hash)
105
+ subject.create!(template)
106
+ end
107
+
108
+ it 'updates identifier of entity' do
109
+ lambda do
110
+ subject.create!(template)
111
+ end.should change(subject, :id)
112
+ end
113
+
114
+ it 'raises error if template is not GroupDocs::Signature::Template object' do
115
+ -> { subject.create!('Template') }.should raise_error(ArgumentError)
116
+ end
117
+ end
118
+
119
+ describe '#documents!' do
120
+ before(:each) do
121
+ mock_api_server(load_json('template_get_documents'))
122
+ end
123
+
124
+ it 'accepts access credentials hash' do
125
+ lambda do
126
+ subject.documents!(client_id: 'client_id', private_key: 'private_key')
127
+ end.should_not raise_error(ArgumentError)
128
+ end
129
+
130
+ it 'returns array of GroupDocs::Document objects' do
131
+ documents = subject.documents!
132
+ documents.should be_an(Array)
133
+ documents.each do |document|
134
+ document.should be_a(GroupDocs::Document)
135
+ end
136
+ end
137
+ end
138
+
139
+ describe '#publish!' do
140
+ before(:each) do
141
+ mock_api_server('{ "status": "Ok", "result": {}}')
142
+ end
143
+
144
+ it 'accepts access credentials hash' do
145
+ lambda do
146
+ subject.publish!(client_id: 'client_id', private_key: 'private_key')
147
+ end.should_not raise_error(ArgumentError)
148
+ end
149
+ end
150
+
151
+ describe '#complete!' do
152
+ before(:each) do
153
+ mock_api_server('{ "status": "Ok", "result": {}}')
154
+ end
155
+
156
+ it 'accepts access credentials hash' do
157
+ lambda do
158
+ subject.complete!(client_id: 'client_id', private_key: 'private_key')
159
+ end.should_not raise_error(ArgumentError)
160
+ end
161
+ end
162
+
163
+ describe '#archive!' do
164
+ before(:each) do
165
+ mock_api_server('{ "status": "Ok", "result": {}}')
166
+ end
167
+
168
+ it 'accepts access credentials hash' do
169
+ lambda do
170
+ subject.archive!(client_id: 'client_id', private_key: 'private_key')
171
+ end.should_not raise_error(ArgumentError)
172
+ end
173
+ end
174
+ end