groupdocs 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (324) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +9 -9
  3. data/CHANGELOG.md +482 -477
  4. data/Gemfile +3 -3
  5. data/LICENSE.txt +21 -21
  6. data/README.md +94 -94
  7. data/Rakefile +9 -9
  8. data/examples/README.md +12 -12
  9. data/examples/api-samples/Gemfile +5 -5
  10. data/examples/api-samples/Gemfile.lock +49 -49
  11. data/examples/api-samples/README.md +23 -23
  12. data/examples/api-samples/public/css/style.css +229 -229
  13. data/examples/api-samples/public/docs/annotation-sample.html +167 -167
  14. data/examples/api-samples/public/docs/docco.css +500 -500
  15. data/examples/api-samples/public/docs/envelope-sample.html +374 -374
  16. data/examples/api-samples/public/docs/sample01.html +181 -181
  17. data/examples/api-samples/public/docs/sample02.html +199 -199
  18. data/examples/api-samples/public/docs/sample03.html +318 -318
  19. data/examples/api-samples/public/docs/sample04.html +217 -217
  20. data/examples/api-samples/public/docs/sample05.html +296 -296
  21. data/examples/api-samples/public/docs/sample06.html +347 -347
  22. data/examples/api-samples/public/docs/sample07.html +209 -209
  23. data/examples/api-samples/public/docs/sample08.html +277 -277
  24. data/examples/api-samples/public/docs/sample09.html +314 -314
  25. data/examples/api-samples/public/docs/sample10.html +270 -270
  26. data/examples/api-samples/public/docs/sample11.html +462 -462
  27. data/examples/api-samples/public/docs/sample12.html +199 -199
  28. data/examples/api-samples/public/docs/sample13.html +201 -201
  29. data/examples/api-samples/public/docs/sample14.html +204 -204
  30. data/examples/api-samples/public/docs/sample15.html +182 -182
  31. data/examples/api-samples/public/docs/sample16.html +234 -234
  32. data/examples/api-samples/public/docs/sample17.html +309 -309
  33. data/examples/api-samples/public/docs/sample18.html +721 -721
  34. data/examples/api-samples/public/docs/sample19.html +631 -631
  35. data/examples/api-samples/public/docs/sample20.html +230 -230
  36. data/examples/api-samples/public/docs/sample21.html +790 -790
  37. data/examples/api-samples/public/docs/sample22.html +408 -408
  38. data/examples/api-samples/public/docs/sample25.html +550 -550
  39. data/examples/api-samples/public/templates/base-simple_source.html +191 -191
  40. data/examples/api-samples/public/templates/testdocument.html +100 -100
  41. data/examples/api-samples/public/templates/welcome.htm +137 -137
  42. data/examples/api-samples/samples/annotation-sample.rb +56 -56
  43. data/examples/api-samples/samples/envelope-sample.rb +133 -133
  44. data/examples/api-samples/samples/sample01.rb +44 -44
  45. data/examples/api-samples/samples/sample02.rb +50 -50
  46. data/examples/api-samples/samples/sample03.rb +79 -79
  47. data/examples/api-samples/samples/sample04.rb +54 -54
  48. data/examples/api-samples/samples/sample05.rb +83 -83
  49. data/examples/api-samples/samples/sample06.rb +86 -86
  50. data/examples/api-samples/samples/sample07.rb +59 -59
  51. data/examples/api-samples/samples/sample08.rb +76 -76
  52. data/examples/api-samples/samples/sample09.rb +85 -85
  53. data/examples/api-samples/samples/sample10.rb +70 -70
  54. data/examples/api-samples/samples/sample11.rb +132 -132
  55. data/examples/api-samples/samples/sample12.rb +48 -48
  56. data/examples/api-samples/samples/sample13.rb +49 -49
  57. data/examples/api-samples/samples/sample14.rb +54 -54
  58. data/examples/api-samples/samples/sample15.rb +43 -43
  59. data/examples/api-samples/samples/sample16.rb +57 -57
  60. data/examples/api-samples/samples/sample17.rb +70 -70
  61. data/examples/api-samples/samples/sample18.rb +190 -190
  62. data/examples/api-samples/samples/sample19.rb +188 -188
  63. data/examples/api-samples/samples/sample20.rb +68 -68
  64. data/examples/api-samples/samples/sample21.rb +212 -212
  65. data/examples/api-samples/samples/sample22.rb +109 -109
  66. data/examples/api-samples/samples/sample25.rb +127 -127
  67. data/examples/api-samples/views/_others_samples.haml +233 -233
  68. data/examples/api-samples/views/annotation_sample.haml +63 -63
  69. data/examples/api-samples/views/envelope_sample.haml +72 -72
  70. data/examples/api-samples/views/index.haml +235 -235
  71. data/examples/api-samples/views/layout.haml +3 -3
  72. data/examples/api-samples/views/sample01.haml +63 -63
  73. data/examples/api-samples/views/sample02.haml +52 -52
  74. data/examples/api-samples/views/sample03.haml +87 -87
  75. data/examples/api-samples/views/sample04.haml +55 -55
  76. data/examples/api-samples/views/sample05.haml +86 -86
  77. data/examples/api-samples/views/sample06.haml +58 -58
  78. data/examples/api-samples/views/sample07.haml +52 -52
  79. data/examples/api-samples/views/sample08.haml +100 -100
  80. data/examples/api-samples/views/sample09.haml +95 -95
  81. data/examples/api-samples/views/sample10.haml +93 -93
  82. data/examples/api-samples/views/sample11.haml +140 -140
  83. data/examples/api-samples/views/sample12.haml +68 -68
  84. data/examples/api-samples/views/sample13.haml +64 -64
  85. data/examples/api-samples/views/sample14.haml +60 -60
  86. data/examples/api-samples/views/sample15.haml +51 -51
  87. data/examples/api-samples/views/sample16.haml +50 -50
  88. data/examples/api-samples/views/sample17.haml +54 -54
  89. data/examples/api-samples/views/sample18.haml +143 -143
  90. data/examples/api-samples/views/sample19.haml +92 -92
  91. data/examples/api-samples/views/sample20.haml +54 -54
  92. data/examples/api-samples/views/sample21.haml +123 -123
  93. data/examples/api-samples/views/sample22.haml +106 -106
  94. data/examples/api-samples/views/sample25.haml +101 -101
  95. data/examples/api-samples/views/sample31.haml +2 -2
  96. data/examples/api-samples/web.rb +20 -20
  97. data/examples/viewer/Gemfile +5 -5
  98. data/examples/viewer/app.rb +52 -52
  99. data/groupdocs.gemspec +31 -31
  100. data/lib/groupdocs.rb +62 -62
  101. data/lib/groupdocs/api.rb +6 -6
  102. data/lib/groupdocs/api/entity.rb +112 -112
  103. data/lib/groupdocs/api/helpers.rb +11 -11
  104. data/lib/groupdocs/api/helpers/access_mode_helper.rb +27 -27
  105. data/lib/groupdocs/api/helpers/access_rights_helper.rb +55 -55
  106. data/lib/groupdocs/api/helpers/accessor_helper.rb +30 -30
  107. data/lib/groupdocs/api/helpers/byte_flag_helper.rb +49 -49
  108. data/lib/groupdocs/api/helpers/credentials_helper.rb +35 -35
  109. data/lib/groupdocs/api/helpers/mime_helper.rb +21 -21
  110. data/lib/groupdocs/api/helpers/path_helper.rb +28 -28
  111. data/lib/groupdocs/api/helpers/rest_helper.rb +99 -99
  112. data/lib/groupdocs/api/helpers/signature_public_helper.rb +22 -22
  113. data/lib/groupdocs/api/helpers/status_helper.rb +27 -27
  114. data/lib/groupdocs/api/helpers/url_helper.rb +101 -101
  115. data/lib/groupdocs/api/request.rb +91 -91
  116. data/lib/groupdocs/datasource.rb +249 -249
  117. data/lib/groupdocs/datasource/field.rb +39 -39
  118. data/lib/groupdocs/document.rb +1550 -1550
  119. data/lib/groupdocs/document/annotation.rb +421 -421
  120. data/lib/groupdocs/document/annotation/reply.rb +173 -173
  121. data/lib/groupdocs/document/annotation/reviewer.rb +66 -66
  122. data/lib/groupdocs/document/change.rb +56 -56
  123. data/lib/groupdocs/document/field.rb +53 -53
  124. data/lib/groupdocs/document/metadata.rb +32 -32
  125. data/lib/groupdocs/document/rectangle.rb +18 -18
  126. data/lib/groupdocs/document/view.rb +36 -36
  127. data/lib/groupdocs/errors.rb +8 -8
  128. data/lib/groupdocs/job.rb +468 -468
  129. data/lib/groupdocs/questionnaire.rb +530 -530
  130. data/lib/groupdocs/questionnaire/collector.rb +335 -335
  131. data/lib/groupdocs/questionnaire/execution.rb +181 -181
  132. data/lib/groupdocs/questionnaire/page.rb +43 -43
  133. data/lib/groupdocs/questionnaire/question.rb +108 -108
  134. data/lib/groupdocs/questionnaire/question/answer.rb +15 -15
  135. data/lib/groupdocs/signature.rb +380 -380
  136. data/lib/groupdocs/signature/contact.rb +181 -181
  137. data/lib/groupdocs/signature/envelope.rb +747 -747
  138. data/lib/groupdocs/signature/envelope/log.rb +20 -20
  139. data/lib/groupdocs/signature/field.rb +286 -286
  140. data/lib/groupdocs/signature/field/location.rb +71 -71
  141. data/lib/groupdocs/signature/form.rb +804 -804
  142. data/lib/groupdocs/signature/list.rb +92 -92
  143. data/lib/groupdocs/signature/recipient.rb +79 -79
  144. data/lib/groupdocs/signature/role.rb +54 -54
  145. data/lib/groupdocs/signature/shared.rb +6 -6
  146. data/lib/groupdocs/signature/shared/document_methods.rb +158 -158
  147. data/lib/groupdocs/signature/shared/entity_fields.rb +76 -76
  148. data/lib/groupdocs/signature/shared/entity_methods.rb +144 -144
  149. data/lib/groupdocs/signature/shared/field_methods.rb +354 -354
  150. data/lib/groupdocs/signature/shared/recipient_methods.rb +75 -75
  151. data/lib/groupdocs/signature/shared/resource_methods.rb +65 -65
  152. data/lib/groupdocs/signature/template.rb +124 -124
  153. data/lib/groupdocs/storage.rb +44 -44
  154. data/lib/groupdocs/storage/file.rb +432 -432
  155. data/lib/groupdocs/storage/folder.rb +288 -288
  156. data/lib/groupdocs/storage/package.rb +48 -48
  157. data/lib/groupdocs/storage/provider.rb +32 -32
  158. data/lib/groupdocs/subscription.rb +323 -323
  159. data/lib/groupdocs/subscription/limit.rb +20 -20
  160. data/lib/groupdocs/user.rb +955 -930
  161. data/lib/groupdocs/version.rb +3 -3
  162. data/spec/groupdocs/api/entity_spec.rb +55 -55
  163. data/spec/groupdocs/api/helpers/access_mode_helper_spec.rb +21 -21
  164. data/spec/groupdocs/api/helpers/access_rights_helper_spec.rb +43 -43
  165. data/spec/groupdocs/api/helpers/accessor_helper_spec.rb +16 -16
  166. data/spec/groupdocs/api/helpers/byte_flag_helper_spec.rb +23 -23
  167. data/spec/groupdocs/api/helpers/credentials_helpers_spec.rb +48 -48
  168. data/spec/groupdocs/api/helpers/mime_helper_spec.rb +16 -16
  169. data/spec/groupdocs/api/helpers/path_helper_spec.rb +15 -15
  170. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +161 -161
  171. data/spec/groupdocs/api/helpers/signature_public_helper_spec.rb +21 -21
  172. data/spec/groupdocs/api/helpers/status_helper_spec.rb +22 -22
  173. data/spec/groupdocs/api/helpers/url_helper_spec.rb +112 -112
  174. data/spec/groupdocs/api/request_spec.rb +112 -112
  175. data/spec/groupdocs/datasource/field_spec.rb +29 -29
  176. data/spec/groupdocs/datasource_spec.rb +145 -145
  177. data/spec/groupdocs/document/annotation/reply_spec.rb +154 -154
  178. data/spec/groupdocs/document/annotation/reviewer_spec.rb +51 -51
  179. data/spec/groupdocs/document/annotation_spec.rb +234 -234
  180. data/spec/groupdocs/document/change_spec.rb +39 -39
  181. data/spec/groupdocs/document/field_spec.rb +28 -28
  182. data/spec/groupdocs/document/metadata_spec.rb +21 -21
  183. data/spec/groupdocs/document/rectangle_spec.rb +14 -14
  184. data/spec/groupdocs/document/view_spec.rb +33 -33
  185. data/spec/groupdocs/document_spec.rb +859 -859
  186. data/spec/groupdocs/errors_spec.rb +7 -7
  187. data/spec/groupdocs/job_spec.rb +323 -323
  188. data/spec/groupdocs/questionnaire/collector_spec.rb +197 -197
  189. data/spec/groupdocs/questionnaire/execution_spec.rb +162 -162
  190. data/spec/groupdocs/questionnaire/page_spec.rb +47 -47
  191. data/spec/groupdocs/questionnaire/question/answer_spec.rb +9 -9
  192. data/spec/groupdocs/questionnaire/question_spec.rb +75 -75
  193. data/spec/groupdocs/questionnaire_spec.rb +295 -295
  194. data/spec/groupdocs/signature/contact_spec.rb +142 -142
  195. data/spec/groupdocs/signature/envelope/log_spec.rb +15 -15
  196. data/spec/groupdocs/signature/envelope_spec.rb +384 -384
  197. data/spec/groupdocs/signature/field/location_spec.rb +40 -40
  198. data/spec/groupdocs/signature/field_spec.rb +235 -235
  199. data/spec/groupdocs/signature/form_spec.rb +205 -205
  200. data/spec/groupdocs/signature/list_spec.rb +87 -87
  201. data/spec/groupdocs/signature/recipient_spec.rb +26 -26
  202. data/spec/groupdocs/signature/role_spec.rb +47 -47
  203. data/spec/groupdocs/signature/template_spec.rb +80 -80
  204. data/spec/groupdocs/signature_spec.rb +194 -194
  205. data/spec/groupdocs/storage/file_spec.rb +303 -303
  206. data/spec/groupdocs/storage/folder_spec.rb +270 -270
  207. data/spec/groupdocs/storage/package_spec.rb +38 -38
  208. data/spec/groupdocs/storage/provider_spec.rb +21 -21
  209. data/spec/groupdocs/storage_spec.rb +27 -27
  210. data/spec/groupdocs/subscription/limit_spec.rb +16 -16
  211. data/spec/groupdocs/subscription_spec.rb +74 -74
  212. data/spec/groupdocs/user_spec.rb +257 -257
  213. data/spec/groupdocs_spec.rb +63 -63
  214. data/spec/spec_helper.rb +73 -73
  215. data/spec/support/json/annotation_access_set.json +11 -11
  216. data/spec/support/json/annotation_collaborators_get.json +16 -16
  217. data/spec/support/json/annotation_collaborators_set.json +16 -16
  218. data/spec/support/json/annotation_create.json +12 -12
  219. data/spec/support/json/annotation_list.json +32 -32
  220. data/spec/support/json/annotation_marker_move.json +10 -10
  221. data/spec/support/json/annotation_move.json +8 -8
  222. data/spec/support/json/annotation_remove.json +9 -9
  223. data/spec/support/json/annotation_replies_create.json +9 -9
  224. data/spec/support/json/annotation_replies_get.json +25 -25
  225. data/spec/support/json/annotation_reviewers_get.json +18 -18
  226. data/spec/support/json/comparison_changes.json +46 -46
  227. data/spec/support/json/comparison_compare.json +8 -8
  228. data/spec/support/json/comparison_document.json +10 -10
  229. data/spec/support/json/contact_add.json +12 -12
  230. data/spec/support/json/contacts_get.json +19 -19
  231. data/spec/support/json/contacts_import.json +8 -8
  232. data/spec/support/json/datasource_add.json +8 -8
  233. data/spec/support/json/datasource_get.json +22 -22
  234. data/spec/support/json/datasource_remove.json +8 -8
  235. data/spec/support/json/datasource_update.json +8 -8
  236. data/spec/support/json/delete_account.json +9 -9
  237. data/spec/support/json/document_access_info_get.json +14 -14
  238. data/spec/support/json/document_convert.json +8 -8
  239. data/spec/support/json/document_datasource.json +10 -10
  240. data/spec/support/json/document_fields.json +34 -34
  241. data/spec/support/json/document_formats.json +8 -8
  242. data/spec/support/json/document_metadata.json +15 -15
  243. data/spec/support/json/document_page_images_get.json +20 -20
  244. data/spec/support/json/document_questionnaire_create.json +9 -9
  245. data/spec/support/json/document_questionnaires.json +23 -23
  246. data/spec/support/json/document_sharers_remove.json +8 -8
  247. data/spec/support/json/document_sharers_set.json +16 -16
  248. data/spec/support/json/document_thumbnails.json +24 -24
  249. data/spec/support/json/document_views.json +32 -32
  250. data/spec/support/json/envelope_get.json +46 -46
  251. data/spec/support/json/envelope_logs.json +16 -16
  252. data/spec/support/json/envelope_recipient_add.json +26 -26
  253. data/spec/support/json/envelopes_all.json +48 -48
  254. data/spec/support/json/envelopes_resources.json +31 -31
  255. data/spec/support/json/file_compress.json +8 -8
  256. data/spec/support/json/file_copy.json +14 -14
  257. data/spec/support/json/file_delete.json +5 -5
  258. data/spec/support/json/file_move.json +14 -14
  259. data/spec/support/json/file_upload.json +8 -8
  260. data/spec/support/json/folder_create.json +8 -8
  261. data/spec/support/json/folder_delete.json +5 -5
  262. data/spec/support/json/folder_list.json +22 -22
  263. data/spec/support/json/folder_move.json +8 -8
  264. data/spec/support/json/folder_sharers_get.json +16 -16
  265. data/spec/support/json/folder_sharers_remove.json +8 -8
  266. data/spec/support/json/folder_sharers_set.json +16 -16
  267. data/spec/support/json/form_get.json +21 -21
  268. data/spec/support/json/forms_all.json +23 -23
  269. data/spec/support/json/job_add_url.json +8 -8
  270. data/spec/support/json/job_create.json +8 -8
  271. data/spec/support/json/job_documents.json +40 -40
  272. data/spec/support/json/job_file_add.json +8 -8
  273. data/spec/support/json/job_get.json +30 -30
  274. data/spec/support/json/job_update.json +7 -7
  275. data/spec/support/json/jobs_get.json +58 -58
  276. data/spec/support/json/list_add.json +12 -12
  277. data/spec/support/json/lists_get.json +19 -19
  278. data/spec/support/json/package_create.json +7 -7
  279. data/spec/support/json/questionnaire_collector.json +17 -17
  280. data/spec/support/json/questionnaire_collectors.json +38 -38
  281. data/spec/support/json/questionnaire_collectors_add.json +10 -10
  282. data/spec/support/json/questionnaire_create.json +10 -10
  283. data/spec/support/json/questionnaire_datasources.json +26 -26
  284. data/spec/support/json/questionnaire_execution_add.json +9 -9
  285. data/spec/support/json/questionnaire_execution_status_set.json +8 -8
  286. data/spec/support/json/questionnaire_execution_update.json +8 -8
  287. data/spec/support/json/questionnaire_executions.json +28 -28
  288. data/spec/support/json/questionnaire_get.json +17 -17
  289. data/spec/support/json/questionnaire_remove.json +8 -8
  290. data/spec/support/json/questionnaire_update.json +8 -8
  291. data/spec/support/json/questionnaires_get.json +40 -40
  292. data/spec/support/json/sign_documents.json +16 -16
  293. data/spec/support/json/signature_create.json +12 -12
  294. data/spec/support/json/signature_field_add.json +25 -25
  295. data/spec/support/json/signature_fields_get.json +27 -27
  296. data/spec/support/json/signature_roles_get.json +17 -17
  297. data/spec/support/json/signatures_get.json +19 -19
  298. data/spec/support/json/storage_info.json +10 -10
  299. data/spec/support/json/subscription_plan_get.json +9 -9
  300. data/spec/support/json/subscription_plans_get.json +17 -17
  301. data/spec/support/json/template_get.json +35 -35
  302. data/spec/support/json/template_get_documents.json +15 -15
  303. data/spec/support/json/template_get_recipients.json +20 -20
  304. data/spec/support/json/templates_all.json +37 -37
  305. data/spec/support/json/templates_get.json +21 -21
  306. data/spec/support/json/update_account.json +10 -10
  307. data/spec/support/json/user_area.json +67 -67
  308. data/spec/support/json/user_embed_key.json +38 -38
  309. data/spec/support/json/user_get_embed_key.json +67 -67
  310. data/spec/support/json/user_login.json +67 -67
  311. data/spec/support/json/user_profile_get.json +24 -24
  312. data/spec/support/json/user_providers.json +31 -31
  313. data/spec/support/json/user_roles.json +25 -25
  314. data/spec/support/json/user_users_get.json +27 -27
  315. data/spec/support/shared_examples/api/entity.rb +39 -39
  316. data/spec/support/shared_examples/api/helpers/access_mode_helper.rb +11 -11
  317. data/spec/support/shared_examples/api/helpers/status_helper.rb +11 -11
  318. data/spec/support/shared_examples/signature/shared/document_methods.rb +68 -68
  319. data/spec/support/shared_examples/signature/shared/entity_fields.rb +56 -56
  320. data/spec/support/shared_examples/signature/shared/entity_methods.rb +116 -116
  321. data/spec/support/shared_examples/signature/shared/field_methods.rb +220 -220
  322. data/spec/support/shared_examples/signature/shared/recipient_methods.rb +46 -46
  323. data/spec/support/shared_examples/signature/shared/resource_methods.rb +46 -46
  324. metadata +35 -55
@@ -1,39 +1,39 @@
1
- require 'spec_helper'
2
-
3
- describe GroupDocs::Document::Change do
4
-
5
- it_behaves_like GroupDocs::Api::Entity
6
-
7
- it { should have_accessor(:id) }
8
- it { should have_accessor(:type) }
9
- it { should have_accessor(:box) }
10
- it { should have_accessor(:text) }
11
- it { should have_accessor(:page) }
12
-
13
- describe '#type' do
14
- it 'returns type as symbol' do
15
- subject.type = 'delete'
16
- subject.type.should == :delete
17
- end
18
- end
19
-
20
- describe '#box=' do
21
- it 'converts passed hash to GroupDocs::Document::Rectangle object' do
22
- subject.box = { :x => 0.90, :y => 0.05, :width => 0.06745, :height => 0.005967 }
23
- subject.box.should be_a(GroupDocs::Document::Rectangle)
24
- subject.box.x.should == 0.90
25
- subject.box.y.should == 0.05
26
- subject.box.w.should == 0.06745
27
- subject.box.h.should == 0.005967
28
- end
29
- end
30
- describe '#page=' do
31
- it 'converts passed hash to GroupDocs::Document::Page object' do
32
- subject.page = { :Id => 1, :Width => 674, :Height => 596 }
33
- subject.page.should be_a(GroupDocs::Document::Page)
34
- subject.page.Id.should == 1
35
- subject.page.Width.should == 674
36
- subject.page.Height.should == 596
37
- end
38
- end
39
- end
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Document::Change do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ it { should have_accessor(:id) }
8
+ it { should have_accessor(:type) }
9
+ it { should have_accessor(:box) }
10
+ it { should have_accessor(:text) }
11
+ it { should have_accessor(:page) }
12
+
13
+ describe '#type' do
14
+ it 'returns type as symbol' do
15
+ subject.type = 'delete'
16
+ subject.type.should == :delete
17
+ end
18
+ end
19
+
20
+ describe '#box=' do
21
+ it 'converts passed hash to GroupDocs::Document::Rectangle object' do
22
+ subject.box = { :x => 0.90, :y => 0.05, :width => 0.06745, :height => 0.005967 }
23
+ subject.box.should be_a(GroupDocs::Document::Rectangle)
24
+ subject.box.x.should == 0.90
25
+ subject.box.y.should == 0.05
26
+ subject.box.w.should == 0.06745
27
+ subject.box.h.should == 0.005967
28
+ end
29
+ end
30
+ describe '#page=' do
31
+ it 'converts passed hash to GroupDocs::Document::Page object' do
32
+ subject.page = { :Id => 1, :Width => 674, :Height => 596 }
33
+ subject.page.should be_a(GroupDocs::Document::Page)
34
+ subject.page.Id.should == 1
35
+ subject.page.Width.should == 674
36
+ subject.page.Height.should == 596
37
+ end
38
+ end
39
+ end
@@ -1,28 +1,28 @@
1
- require 'spec_helper'
2
-
3
- describe GroupDocs::Document::Field do
4
- it_behaves_like GroupDocs::Api::Entity
5
-
6
- it { should have_accessor(:page) }
7
- it { should have_accessor(:name) }
8
- it { should have_accessor(:type) }
9
- it { should have_accessor(:rect) }
10
-
11
- describe '#rect=' do
12
- it 'converts passed hash to GroupDocs::Document::Rectangle object' do
13
- subject.rect = { :x => 0.90, :y => 0.05, :width => 0.06745, :height => 0.005967 }
14
- subject.rectangle.should be_a(GroupDocs::Document::Rectangle)
15
- subject.rectangle.x.should == 0.90
16
- subject.rectangle.y.should == 0.05
17
- subject.rectangle.w.should == 0.06745
18
- subject.rectangle.h.should == 0.005967
19
- end
20
-
21
- it 'does nothing when nil is passed' do
22
- subject.rect = nil
23
- subject.rectangle.should be_nil
24
- end
25
- end
26
-
27
- it { should alias_accessor(:rectangle, :rect) }
28
- end
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Document::Field do
4
+ it_behaves_like GroupDocs::Api::Entity
5
+
6
+ it { should have_accessor(:page) }
7
+ it { should have_accessor(:name) }
8
+ it { should have_accessor(:type) }
9
+ it { should have_accessor(:rect) }
10
+
11
+ describe '#rect=' do
12
+ it 'converts passed hash to GroupDocs::Document::Rectangle object' do
13
+ subject.rect = { :x => 0.90, :y => 0.05, :width => 0.06745, :height => 0.005967 }
14
+ subject.rectangle.should be_a(GroupDocs::Document::Rectangle)
15
+ subject.rectangle.x.should == 0.90
16
+ subject.rectangle.y.should == 0.05
17
+ subject.rectangle.w.should == 0.06745
18
+ subject.rectangle.h.should == 0.005967
19
+ end
20
+
21
+ it 'does nothing when nil is passed' do
22
+ subject.rect = nil
23
+ subject.rectangle.should be_nil
24
+ end
25
+ end
26
+
27
+ it { should alias_accessor(:rectangle, :rect) }
28
+ end
@@ -1,21 +1,21 @@
1
- require 'spec_helper'
2
-
3
- describe GroupDocs::Document::MetaData do
4
-
5
- it_behaves_like GroupDocs::Api::Entity
6
-
7
- it { should have_accessor(:id) }
8
- it { should have_accessor(:guid) }
9
- it { should have_accessor(:page_count) }
10
- it { should have_accessor(:views_count) }
11
- it { should have_accessor(:last_view) }
12
-
13
- describe '#last_view=' do
14
- it 'converts passed hash to GroupDocs::Document::View object' do
15
- subject.last_view = { :document => { :id => 1, :name => 'test.pdf' } }
16
- subject.last_view.should be_a(GroupDocs::Document::View)
17
- subject.last_view.document.file.id.should == 1
18
- subject.last_view.document.file.name.should == 'test.pdf'
19
- end
20
- end
21
- end
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Document::MetaData do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ it { should have_accessor(:id) }
8
+ it { should have_accessor(:guid) }
9
+ it { should have_accessor(:page_count) }
10
+ it { should have_accessor(:views_count) }
11
+ it { should have_accessor(:last_view) }
12
+
13
+ describe '#last_view=' do
14
+ it 'converts passed hash to GroupDocs::Document::View object' do
15
+ subject.last_view = { :document => { :id => 1, :name => 'test.pdf' } }
16
+ subject.last_view.should be_a(GroupDocs::Document::View)
17
+ subject.last_view.document.file.id.should == 1
18
+ subject.last_view.document.file.name.should == 'test.pdf'
19
+ end
20
+ end
21
+ end
@@ -1,14 +1,14 @@
1
- require 'spec_helper'
2
-
3
- describe GroupDocs::Document::Rectangle do
4
-
5
- it_behaves_like GroupDocs::Api::Entity
6
-
7
- it { should have_accessor(:x) }
8
- it { should have_accessor(:y) }
9
- it { should have_accessor(:width) }
10
- it { should have_accessor(:height) }
11
-
12
- it { should alias_accessor(:w, :width) }
13
- it { should alias_accessor(:h, :height) }
14
- end
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Document::Rectangle do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ it { should have_accessor(:x) }
8
+ it { should have_accessor(:y) }
9
+ it { should have_accessor(:width) }
10
+ it { should have_accessor(:height) }
11
+
12
+ it { should alias_accessor(:w, :width) }
13
+ it { should alias_accessor(:h, :height) }
14
+ end
@@ -1,33 +1,33 @@
1
- require 'spec_helper'
2
-
3
- describe GroupDocs::Document::View do
4
-
5
- it_behaves_like GroupDocs::Api::Entity
6
-
7
- it { should have_accessor(:document) }
8
- it { should have_accessor(:short_url) }
9
- it { should have_accessor(:viewed_on) }
10
-
11
- describe '#document=' do
12
- it 'sets document if GroupDocs::Document object is passed' do
13
- document = GroupDocs::Document.new(:file => GroupDocs::Storage::File.new)
14
- subject.document = document
15
- subject.document.should == document
16
- end
17
-
18
- it 'creates new GroupDocs::Document object from passed hash' do
19
- subject.document = { :id => 1, :name => 'test.pdf' }
20
- document = subject.document
21
- document.should be_a(GroupDocs::Document)
22
- document.file.id.should == 1
23
- document.file.name.should == 'test.pdf'
24
- end
25
- end
26
-
27
- describe '#viewed_on' do
28
- it 'returns converted to Time object Unix timestamp' do
29
- subject.viewed_on = 1330450135000
30
- subject.viewed_on.should == Time.at(1330450135)
31
- end
32
- end
33
- end
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Document::View do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ it { should have_accessor(:document) }
8
+ it { should have_accessor(:short_url) }
9
+ it { should have_accessor(:viewed_on) }
10
+
11
+ describe '#document=' do
12
+ it 'sets document if GroupDocs::Document object is passed' do
13
+ document = GroupDocs::Document.new(:file => GroupDocs::Storage::File.new)
14
+ subject.document = document
15
+ subject.document.should == document
16
+ end
17
+
18
+ it 'creates new GroupDocs::Document object from passed hash' do
19
+ subject.document = { :id => 1, :name => 'test.pdf' }
20
+ document = subject.document
21
+ document.should be_a(GroupDocs::Document)
22
+ document.file.id.should == 1
23
+ document.file.name.should == 'test.pdf'
24
+ end
25
+ end
26
+
27
+ describe '#viewed_on' do
28
+ it 'returns converted to Time object Unix timestamp' do
29
+ subject.viewed_on = 1330450135000
30
+ subject.viewed_on.should == Time.at(1330450135)
31
+ end
32
+ end
33
+ end
@@ -1,859 +1,859 @@
1
- require 'spec_helper'
2
-
3
- describe GroupDocs::Document do
4
-
5
- it_behaves_like GroupDocs::Api::Entity
6
- include_examples GroupDocs::Api::Helpers::Status
7
-
8
- subject do
9
- file = GroupDocs::Storage::File.new
10
- described_class.new(:file => file)
11
- end
12
-
13
- describe '.views!' do
14
- before(:each) do
15
- mock_api_server(load_json('document_views'))
16
- end
17
-
18
- it 'accepts access credentials hash' do
19
- lambda do
20
- described_class.views!({}, :client_id => 'client_id', :private_key => 'private_key')
21
- end.should_not raise_error()
22
- end
23
-
24
- it 'returns an array of GroupDocs::Document::View objects' do
25
- views = described_class.views!
26
- views.should be_an(Array)
27
- views.each do |view|
28
- view.should be_a(GroupDocs::Document::View)
29
- end
30
- end
31
- end
32
-
33
- describe '.templates!' do
34
- before(:each) do
35
- mock_api_server(load_json('templates_get'))
36
- end
37
-
38
- it 'accepts access credentials hash' do
39
- lambda do
40
- described_class.templates!(:client_id => 'client_id', :private_key => 'private_key')
41
- end.should_not raise_error()
42
- end
43
-
44
- it 'returns an array of GroupDocs::Document objects' do
45
- templates = described_class.templates!
46
- templates.should be_an(Array)
47
- templates.each do |template|
48
- template.should be_a(GroupDocs::Document)
49
- end
50
- end
51
- end
52
-
53
- describe '.sign_documents!' do
54
- before(:each) do
55
- mock_api_server(load_json('sign_documents'))
56
- end
57
-
58
- let(:documents) do
59
- [GroupDocs::Document.new(:file => GroupDocs::Storage::File.new(:name => 'Document1', :local_path => __FILE__)),
60
- GroupDocs::Document.new(:file => GroupDocs::Storage::File.new(:name => 'Document2', :local_path => 'spec/support/files/resume.pdf'))]
61
- end
62
- let(:signatures) { [GroupDocs::Signature.new(:name => 'John Smith', :image_path => 'spec/support/files/signature.png', :position => {})] }
63
-
64
- it 'accepts access credentials hash' do
65
- lambda do
66
- described_class.sign_documents!(documents, signatures, {}, :client_id => 'client_id', :private_key => 'private_key')
67
- end.should_not raise_error()
68
- end
69
-
70
- it 'raises error if document is not GroupDocs::Document object' do
71
- lambda { described_class.sign_documents!(['Document'], signatures) }.should raise_error(ArgumentError)
72
- end
73
-
74
- it 'raises error if document file does not have name' do
75
- documents = [GroupDocs::Document.new(:file => GroupDocs::Storage::File.new(:local_path => __FILE__))]
76
- lambda { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
77
- end
78
-
79
- it 'raises error if document file does not have local path' do
80
- documents = [GroupDocs::Document.new(:file => GroupDocs::Storage::File.new(:name => 'Document'))]
81
- lambda { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
82
- end
83
-
84
- it 'raises error if signature is not GroupDocs::Signature object' do
85
- lambda { described_class.sign_documents!(documents, ['Signature']) }.should raise_error(ArgumentError)
86
- end
87
-
88
- it 'raises error if signature does not have name' do
89
- signatures = [GroupDocs::Signature.new(:image_path => __FILE__, :position => {})]
90
- lambda { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
91
- end
92
-
93
- it 'raises error if signature does not have image path' do
94
- signatures = [GroupDocs::Signature.new(:name => 'John Smith', :position => {})]
95
- lambda { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
96
- end
97
-
98
- it 'raises error if signature does not have position' do
99
- signatures = [GroupDocs::Signature.new(:name => 'John Smith', :image_path => __FILE__)]
100
- lambda { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
101
- end
102
-
103
- it 'detects each document and signature file MIME type' do
104
- documents.each { |document| described_class.should_receive(:mime_type).with(document.file.local_path).once }
105
- signatures.each { |signature| described_class.should_receive(:mime_type).with(signature.image_path).once }
106
- described_class.sign_documents!(documents, signatures)
107
- end
108
-
109
-
110
- end
111
-
112
- describe ',metadata!' do
113
- before(:each) do
114
- mock_api_server(load_json('document_metadata'))
115
- end
116
-
117
- it 'accepts access credentials hash' do
118
- lambda do
119
- described_class.metadata!('document_one.doc', :client_id => 'client_id', :private_key => 'private_key')
120
- end.should_not raise_error()
121
- end
122
-
123
- it 'returns GroupDocs::Document::MetaData object' do
124
- described_class.metadata!('document_one.doc').should be_a(GroupDocs::Document::MetaData)
125
- end
126
-
127
- it 'sets last view as GroupDocs::Document::View object if document was viewed at least once' do
128
- described_class.metadata!('document_one.doc').last_view.should be_a(GroupDocs::Document::View)
129
- end
130
-
131
- it 'does not set last view if document has never been viewed' do
132
- mock_api_server('{ "status": "Ok", "result": { "last_view": null }}')
133
- described_class.metadata!('document_one.doc').last_view.should be_nil
134
- end
135
- end
136
-
137
- it { should have_accessor(:file) }
138
- it { should have_accessor(:process_date) }
139
- it { should have_accessor(:outputs) }
140
- it { should have_accessor(:output_formats) }
141
- it { should have_accessor(:order) }
142
- it { should have_accessor(:field_count) }
143
- it { should have_accessor(:news_enabled) }
144
- it { should have_accessor(:alerts_enabled) }
145
- it { should have_accessor(:support_enabled) }
146
- it { should have_accessor(:is_real_time_broadcast_enabled) }
147
- it { should have_accessor(:is_scroll_broadcast_enabled) }
148
- it { should have_accessor(:is_zoom_broadcast_enabled) }
149
- it { should have_accessor(:is_annotation_navigation_widget_enabled) }
150
- it { should have_accessor(:is_annotation_zoom_widget_enabled) }
151
- it { should have_accessor(:is_annotation_download_widget_enabled) }
152
- it { should have_accessor(:is_annotation_print_widget_enabled) }
153
- it { should have_accessor(:is_annotation_help_widget_enabled) }
154
- it { should have_accessor(:is_right_panel_enabled) }
155
- it { should have_accessor(:is_thumbnails_panel_enabled) }
156
- it { should have_accessor(:is_toolbar_enabled) }
157
- it { should have_accessor(:is_text_annotation_button_enabled) }
158
- it { should have_accessor(:is_rectangle_annotation_button_enabled) }
159
- it { should have_accessor(:is_point_annotation_button_enabled) }
160
- it { should have_accessor(:is_strikeout_annotation_button_enabled) }
161
- it { should have_accessor(:is_polyline_annotation_button_enabled) }
162
- it { should have_accessor(:is_typewriter_annotation_button_enabled) }
163
- it { should have_accessor(:is_watermark_annotation_button_enabled) }
164
- it { should have_accessor(:is_viewer_navigation_widget_enabled) }
165
- it { should have_accessor(:is_viewer_zoom_widget_enabled) }
166
- it { should have_accessor(:is_viewer_download_widget_enabled) }
167
- it { should have_accessor(:is_viewer_print_widget_enabled) }
168
- it { should have_accessor(:is_viewer_help_widget_enabled) }
169
- it { should have_accessor(:is_standard_header_always_shown) }
170
- it { should have_accessor(:is_annotation_document_name_shown) }
171
- it { should have_accessor(:is_viewer_document_name_shown) }
172
-
173
- it { should have_alias(:access_mode=, :access_mode_set!) }
174
-
175
- describe '#outputs=' do
176
- let(:response) do
177
- [
178
- { :ftype => 1, :guid => 'fhy9yh94u238dgf' },
179
- { :ftype => 2, :guid => 'ofh9rhy9rfohf9s' }
180
- ]
181
- end
182
-
183
- it 'saves outputs as array of GroupDocs::Storage::File objects' do
184
- subject.outputs = response
185
- outputs = subject.outputs
186
- outputs.should be_an(Array)
187
- outputs.each do |output|
188
- output.should be_a(GroupDocs::Storage::File)
189
- end
190
- end
191
-
192
- it 'does nothing if nil is passed' do
193
- lambda do
194
- subject.outputs = nil
195
- end.should_not change(subject, :outputs)
196
- end
197
- end
198
-
199
- describe '#output_formats' do
200
- it 'returns parsed array of output formats' do
201
- subject.output_formats = "pdf,tiff,doc"
202
- subject.output_formats.should == [:pdf, :tiff, :doc]
203
- end
204
- end
205
-
206
- describe '#process_date' do
207
- it 'returns converted to Time object Unix timestamp' do
208
- subject.process_date = 1330450135000
209
- subject.process_date.should == Time.at(1330450135)
210
- end
211
- end
212
-
213
- describe '#initialize' do
214
- it 'raises error if file is not specified' do
215
- lambda { described_class.new }.should raise_error(ArgumentError)
216
- end
217
-
218
- it 'raises error if file is not an instance of GroupDocs::Storage::File' do
219
- lambda { described_class.new(:file => '') }.should raise_error(ArgumentError)
220
- end
221
- end
222
-
223
- describe '#page_images!' do
224
- before(:each) do
225
- mock_api_server(load_json('document_page_images_get'))
226
- end
227
-
228
- it 'accepts access credentials hash' do
229
- lambda do
230
- subject.page_images!(640, 480, {}, :client_id => 'client_id', :private_key => 'private_key')
231
- end.should_not raise_error()
232
- end
233
-
234
- it 'accepts options hash' do
235
- lambda do
236
- subject.page_images!(640, 480, :first_page => 0, :page_count => 1)
237
- end.should_not raise_error()
238
- end
239
-
240
- it 'returns array of URLs' do
241
- urls = subject.page_images!(640, 480)
242
- urls.should be_an(Array)
243
- urls.each do |url|
244
- url.should be_a(String)
245
- end
246
- end
247
- end
248
-
249
- describe '#thumbnails!' do
250
- before(:each) do
251
- mock_api_server(load_json('document_thumbnails'))
252
- end
253
-
254
- it 'accepts access credentials hash' do
255
- lambda do
256
- subject.thumbnails!({}, :client_id => 'client_id', :private_key => 'private_key')
257
- end.should_not raise_error()
258
- end
259
-
260
- it 'accepts options hash' do
261
- lambda do
262
- subject.thumbnails!(:page_number => 0, :page_count => 1)
263
- end.should_not raise_error()
264
- end
265
-
266
- it 'returns array of URLs' do
267
- urls = subject.thumbnails!
268
- urls.should be_an(Array)
269
- urls.each do |url|
270
- url.should be_a(String)
271
- end
272
- end
273
- end
274
-
275
- describe '#access_mode!' do
276
- before(:each) do
277
- mock_api_server(load_json('document_access_info_get'))
278
- end
279
-
280
- it 'accepts access credentials hash' do
281
- lambda do
282
- subject.access_mode!(:client_id => 'client_id', :private_key => 'private_key')
283
- end.should_not raise_error()
284
- end
285
-
286
- it 'returns access mode in human readable presentation' do
287
- subject.should_receive(:parse_access_mode).with('Private').and_return(:private)
288
- subject.access_mode!.should == :private
289
- end
290
- end
291
-
292
- describe '#access_mode_set!' do
293
- before(:each) do
294
- mock_api_server('{"status": "Ok", "result": {"access": "Private" }}')
295
- end
296
-
297
- it 'accepts access credentials hash' do
298
- lambda do
299
- subject.access_mode_set!(:private, :client_id => 'client_id', :private_key => 'private_key')
300
- end.should_not raise_error()
301
- end
302
-
303
- it 'sets corresponding access mode' do
304
- described_class::ACCESS_MODES.should_receive(:[]).with(:private).and_return(0)
305
- subject.should_receive(:parse_access_mode).with('Private').and_return(:private)
306
- subject.access_mode_set!(:private)
307
- end
308
-
309
- it 'returns set of access modes' do
310
- subject.access_mode_set!(:private).should == :private
311
- end
312
-
313
- it 'is aliased to #access_mode=' do
314
- subject.should have_alias(:access_mode=, :access_mode_set!)
315
- end
316
- end
317
-
318
- describe '#formats!' do
319
- before(:each) do
320
- mock_api_server(load_json('document_formats'))
321
- end
322
-
323
- it 'accepts access credentials hash' do
324
- lambda do
325
- subject.formats!(:client_id => 'client_id', :private_key => 'private_key')
326
- end.should_not raise_error()
327
- end
328
-
329
- it 'returns an array of symbols' do
330
- formats = subject.formats!
331
- formats.should be_an(Array)
332
- formats.each do |format|
333
- format.should be_a(Symbol)
334
- end
335
- end
336
- end
337
-
338
- describe '#metadata!' do
339
- before(:each) do
340
- mock_api_server(load_json('document_metadata'))
341
- end
342
-
343
- it 'accepts access credentials hash' do
344
- lambda do
345
- subject.metadata!(:client_id => 'client_id', :private_key => 'private_key')
346
- end.should_not raise_error()
347
- end
348
-
349
- it 'returns GroupDocs::Document::MetaData object' do
350
- subject.metadata!.should be_a(GroupDocs::Document::MetaData)
351
- end
352
-
353
- it 'sets last view as GroupDocs::Document::View object if document was viewed at least once' do
354
- subject.metadata!.last_view.should be_a(GroupDocs::Document::View)
355
- end
356
-
357
- it 'uses self document in last view object' do
358
- subject.metadata!.last_view.document.should be_a(GroupDocs::Document)
359
- end
360
-
361
- it 'does not set last view if document has never been viewed' do
362
- mock_api_server('{ "status": "Ok", "result": { "last_view": null }}')
363
- subject.metadata!.last_view.should be_nil
364
- end
365
- end
366
-
367
- describe '#fields!' do
368
- before(:each) do
369
- mock_api_server(load_json('document_fields'))
370
- end
371
-
372
- it 'accepts access credentials hash' do
373
- lambda do
374
- subject.fields!(:client_id => 'client_id', :private_key => 'private_key')
375
- end.should_not raise_error()
376
- end
377
-
378
- it 'returns array of GroupDocs::Document::Field objects' do
379
- fields = subject.fields!
380
- fields.should be_an(Array)
381
- fields.each do |field|
382
- field.should be_a(GroupDocs::Document::Field)
383
- end
384
- end
385
- end
386
-
387
- describe '#sharers!' do
388
- before(:each) do
389
- mock_api_server(load_json('document_access_info_get'))
390
- end
391
-
392
- it 'accepts access credentials hash' do
393
- lambda do
394
- subject.sharers!(:client_id => 'client_id', :private_key => 'private_key')
395
- end.should_not raise_error()
396
- end
397
-
398
- it 'returns an array of GroupDocs::User objects' do
399
- users = subject.sharers!
400
- users.should be_an(Array)
401
- users.each do |user|
402
- user.should be_a(GroupDocs::User)
403
- end
404
- end
405
- end
406
-
407
- describe '#sharers_set!' do
408
- before(:each) do
409
- mock_api_server(load_json('document_sharers_set'))
410
- end
411
-
412
- it 'accepts access credentials hash' do
413
- lambda do
414
- subject.sharers_set!(%w(test1@email.com), :client_id => 'client_id', :private_key => 'private_key')
415
- end.should_not raise_error()
416
- end
417
-
418
- it 'returns an array of GroupDocs::User objects' do
419
- users = subject.sharers_set!(%w(test1@email.com))
420
- users.should be_an(Array)
421
- users.each do |user|
422
- user.should be_a(GroupDocs::User)
423
- end
424
- end
425
-
426
- it 'clears sharers if empty array is passed' do
427
- subject.should_receive(:sharers_clear!)
428
- subject.sharers_set!([])
429
- end
430
-
431
- it 'clears sharers if nil is passed' do
432
- subject.should_receive(:sharers_clear!)
433
- subject.sharers_set!(nil)
434
- end
435
- end
436
-
437
- describe '#sharers_clear!' do
438
- before(:each) do
439
- mock_api_server(load_json('document_sharers_remove'))
440
- end
441
-
442
- it 'accepts access credentials hash' do
443
- lambda do
444
- subject.sharers_clear!(:client_id => 'client_id', :private_key => 'private_key')
445
- end.should_not raise_error()
446
- end
447
-
448
- it 'clears sharers list and returns nil' do
449
- subject.sharers_clear!.should be_nil
450
- end
451
- end
452
-
453
- describe '#convert!' do
454
- before(:each) do
455
- mock_api_server(load_json('document_convert'))
456
- end
457
-
458
- it 'accepts access credentials hash' do
459
- lambda do
460
- subject.convert!(:pdf, {}, :client_id => 'client_id', :private_key => 'private_key')
461
- end.should_not raise_error()
462
- end
463
-
464
- it 'accepts options hash' do
465
- lambda do
466
- subject.convert!(:pdf, :email_results => true)
467
- end.should_not raise_error()
468
- end
469
-
470
- it 'returns GroupDocs::Job object' do
471
- subject.convert!(:pdf).should be_a(GroupDocs::Job)
472
- end
473
- end
474
-
475
- describe '#questionnaires!' do
476
- before(:each) do
477
- mock_api_server(load_json('document_questionnaires'))
478
- end
479
-
480
- it 'accepts access credentials hash' do
481
- lambda do
482
- subject.questionnaires!(:client_id => 'client_id', :private_key => 'private_key')
483
- end.should_not raise_error()
484
- end
485
-
486
- it 'returns an array of GroupDocs::Questionnaire objects' do
487
- questionnaires = subject.questionnaires!
488
- questionnaires.should be_an(Array)
489
- questionnaires.each do |questionnaire|
490
- questionnaire.should be_a(GroupDocs::Questionnaire)
491
- end
492
- end
493
- end
494
-
495
- describe '#add_questionnaire!' do
496
- before(:each) do
497
- mock_api_server('{ "status": "Ok", "result": {}}')
498
- end
499
-
500
- let(:questionnaire) do
501
- GroupDocs::Questionnaire.new(:id => 1)
502
- end
503
-
504
- it 'accepts access credentials hash' do
505
- lambda do
506
- subject.add_questionnaire!(questionnaire, :client_id => 'client_id', :private_key => 'private_key')
507
- end.should_not raise_error()
508
- end
509
-
510
- it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
511
- lambda { subject.add_questionnaire!('Questionnaire') }.should raise_error(ArgumentError)
512
- end
513
- end
514
-
515
- describe '#create_questionnaire!' do
516
- before(:each) do
517
- mock_api_server(load_json('document_questionnaire_create'))
518
- end
519
-
520
- let(:questionnaire) do
521
- GroupDocs::Questionnaire.new(:name => 'Q1')
522
- end
523
-
524
- it 'accepts access credentials hash' do
525
- lambda do
526
- subject.create_questionnaire!(questionnaire, :client_id => 'client_id', :private_key => 'private_key')
527
- end.should_not raise_error()
528
- end
529
-
530
- it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
531
- lambda { subject.create_questionnaire!('Questionnaire') }.should raise_error(ArgumentError)
532
- end
533
-
534
- it 'returns GroupDocs::Questionnaire object' do
535
- subject.create_questionnaire!(questionnaire).should be_a(GroupDocs::Questionnaire)
536
- end
537
-
538
- it 'uses hashed version of questionnaire as request body' do
539
- questionnaire.should_receive(:to_hash)
540
- subject.create_questionnaire!(questionnaire)
541
- end
542
-
543
- it 'updates ID from response to questionnaire' do
544
- lambda do
545
- subject.create_questionnaire!(questionnaire)
546
- end.should change(questionnaire, :id)
547
- end
548
- end
549
-
550
- describe '#remove_questionnaire!' do
551
- before(:each) do
552
- mock_api_server('{ "status": "Ok", "result": {}}')
553
- end
554
-
555
- let(:questionnaire) do
556
- GroupDocs::Questionnaire.new(:id => 1)
557
- end
558
-
559
- it 'accepts access credentials hash' do
560
- lambda do
561
- subject.remove_questionnaire!(questionnaire, :client_id => 'client_id', :private_key => 'private_key')
562
- end.should_not raise_error()
563
- end
564
-
565
- it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
566
- lambda { subject.remove_questionnaire!('Questionnaire') }.should raise_error(ArgumentError)
567
- end
568
- end
569
-
570
- describe '#datasource!' do
571
- before(:each) do
572
- mock_api_server(load_json('document_datasource'))
573
- end
574
-
575
- let(:datasource) do
576
- GroupDocs::DataSource.new(:id => 1)
577
- end
578
-
579
- it 'accepts access credentials hash' do
580
- lambda do
581
- subject.datasource!(datasource, {}, :client_id => 'client_id', :private_key => 'private_key')
582
- end.should_not raise_error()
583
- end
584
-
585
- it 'accepts options hash' do
586
- lambda do
587
- subject.datasource!(datasource, :new_type => :pdf)
588
- end.should_not raise_error()
589
- end
590
-
591
- it 'raises error if datasource is not GroupDocs::Datasource object' do
592
- lambda { subject.datasource!('Datasource') }.should raise_error(ArgumentError)
593
- end
594
-
595
- it 'returns GroupDocs::Job object' do
596
- job = subject.datasource!(datasource)
597
- job.should be_a(GroupDocs::Job)
598
- end
599
- end
600
-
601
- describe '#annotations!' do
602
- before(:each) do
603
- mock_api_server(load_json('annotation_list'))
604
- end
605
-
606
- it 'accepts access credentials hash' do
607
- lambda do
608
- subject.annotations!(:client_id => 'client_id', :private_key => 'private_key')
609
- end.should_not raise_error()
610
- end
611
-
612
- it 'returns array of GroupDocs::Document::Annotation objects' do
613
- annotations = subject.annotations!
614
- annotations.should be_an(Array)
615
- annotations.each do |annotation|
616
- annotation.should be_a(GroupDocs::Document::Annotation)
617
- end
618
- end
619
-
620
- it 'returns empty array if annotations are null in response' do
621
- mock_api_server('{ "status": "Ok", "result": { "annotations": null }}')
622
- subject.annotations!.should be_empty
623
- end
624
- end
625
-
626
- describe '#details!' do
627
- before(:each) do
628
- mock_api_server(load_json('comparison_document'))
629
- end
630
-
631
- it 'accepts access credentials hash' do
632
- lambda do
633
- subject.details!(:client_id => 'client_id', :private_key => 'private_key')
634
- end.should_not raise_error()
635
- end
636
-
637
- it 'returns hash of document details' do
638
- subject.details!.should be_a(Hash)
639
- end
640
- end
641
-
642
- describe '#compare!' do
643
- before(:each) do
644
- mock_api_server(load_json('comparison_compare'))
645
- end
646
-
647
- let(:document) do
648
- GroupDocs::Document.new(:file => GroupDocs::Storage::File.new)
649
- end
650
-
651
- it 'accepts access credentials hash' do
652
- lambda do
653
- subject.compare!(document, 'callback', :client_id => 'client_id', :private_key => 'private_key')
654
- end.should_not raise_error()
655
- end
656
-
657
- it 'raises error if document is not GroupDocs::Document object' do
658
- lambda { subject.compare!('Document') }.should raise_error(ArgumentError)
659
- end
660
-
661
- it 'returns GroupDocs::Job object' do
662
- subject.compare!(document, 'callback').should be_a(GroupDocs::Job)
663
- end
664
- end
665
-
666
- describe '#changes!' do
667
- before(:each) do
668
- mock_api_server(load_json('comparison_changes'))
669
- end
670
-
671
- it 'accepts access credentials hash' do
672
- lambda do
673
- subject.changes!(:client_id => 'client_id', :private_key => 'private_key')
674
- end.should_not raise_error()
675
- end
676
-
677
- it 'returns array of GroupDocs::Document::Change objects' do
678
- changes = subject.changes!
679
- changes.should be_an(Array)
680
- changes.each do |change|
681
- change.should be_a(GroupDocs::Document::Change)
682
- end
683
- end
684
- end
685
-
686
-
687
- describe '#collaborators!' do
688
- before(:each) do
689
- mock_api_server(load_json('annotation_collaborators_get'))
690
- end
691
-
692
- it 'accepts access credentials hash' do
693
- lambda do
694
- subject.collaborators!(:client_id => 'client_id', :private_key => 'private_key')
695
- end.should_not raise_error()
696
- end
697
-
698
- it 'returns an array of GroupDocs::User objects' do
699
- users = subject.collaborators!
700
- users.should be_an(Array)
701
- users.each do |user|
702
- user.should be_a(GroupDocs::User)
703
- end
704
- end
705
- end
706
-
707
- describe '#set_collaborators!' do
708
- before(:each) do
709
- mock_api_server(load_json('annotation_collaborators_set'))
710
- end
711
-
712
- it 'accepts access credentials hash' do
713
- lambda do
714
- subject.set_collaborators!(%w(test1@email.com), 1, :client_id => 'client_id', :private_key => 'private_key')
715
- end.should_not raise_error()
716
- end
717
-
718
- it 'accepts version' do
719
- lambda do
720
- subject.set_collaborators!(%w(test1@email.com), 1)
721
- end.should_not raise_error()
722
- end
723
-
724
- it 'returns an array of GroupDocs::User objects' do
725
- users = subject.set_collaborators!(%w(test1@email.com))
726
- users.should be_an(Array)
727
- users.each do |user|
728
- user.should be_a(GroupDocs::User)
729
- end
730
- end
731
- end
732
-
733
- describe '#add_collaborator!' do
734
- before(:each) do
735
- mock_api_server(load_json('annotation_collaborators_get'))
736
- end
737
-
738
- let!(:collaborator) { GroupDocs::User.new }
739
-
740
- it 'accepts access credentials hash' do
741
- lambda do
742
- subject.add_collaborator!(collaborator, :client_id => 'client_id', :private_key => 'private_key')
743
- end.should_not raise_error()
744
- end
745
-
746
- it 'uses hashed version of collaborator as request body' do
747
- collaborator.should_receive(:to_hash)
748
- subject.add_collaborator! collaborator
749
- end
750
-
751
- it 'raises error if collaborator is not an instance of GroupDocs::User' do
752
- lambda { subject.add_collaborator!('collaborator') }.should raise_error(ArgumentError)
753
- end
754
- end
755
-
756
- describe '#set_reviewers!' do
757
- before(:each) do
758
- mock_api_server('{ "status": "Ok", "result": {}}')
759
- end
760
-
761
- let!(:reviewers) { [GroupDocs::User.new, GroupDocs::User.new] }
762
-
763
- it 'accepts access credentials hash' do
764
- lambda do
765
- subject.set_reviewers!(reviewers, :client_id => 'client_id', :private_key => 'private_key')
766
- end.should_not raise_error()
767
- end
768
-
769
- it 'uses hashed version of each reviewer as request body' do
770
- reviewers.each do |reviewer|
771
- reviewer.should_receive(:to_hash)
772
- end
773
- subject.set_reviewers! reviewers
774
- end
775
- end
776
-
777
- describe '#shared_link_access_rights!' do
778
- before(:each) do
779
- mock_api_server('{ "status": "Ok", "result": { "accessRights": 15 }}')
780
- end
781
-
782
- it 'accepts access credentials hash' do
783
- lambda do
784
- subject.shared_link_access_rights!(:client_id => 'client_id', :private_key => 'private_key')
785
- end.should_not raise_error()
786
- end
787
-
788
- it 'converts response byte flag into array of access rights' do
789
- subject.should_receive(:convert_byte_to_access_rights).with(15)
790
- subject.shared_link_access_rights!
791
- end
792
-
793
- it 'returns array of access rights symbols' do
794
- access_rights = subject.shared_link_access_rights!
795
- access_rights.should be_an(Array)
796
- access_rights.each do |access_right|
797
- access_right.should be_a(Symbol)
798
- end
799
- end
800
-
801
- it 'returns empty array if access rights is null' do
802
- mock_api_server('{ "status": "Ok", "result": { "accessRights": null }}')
803
- subject.shared_link_access_rights!.should be_empty
804
- end
805
- end
806
-
807
- describe '#set_shared_link_access_rights!' do
808
- before(:each) do
809
- mock_api_server('{ "status": "Ok", "result": {}}')
810
- end
811
-
812
- it 'accepts access credentials hash' do
813
- lambda do
814
- subject.set_shared_link_access_rights!(%w(view), :client_id => 'client_id', :private_key => 'private_key')
815
- end.should_not raise_error()
816
- end
817
-
818
- it 'converts array of access rights into byte flag' do
819
- subject.should_receive(:convert_access_rights_to_byte).with(%w(view))
820
- subject.set_shared_link_access_rights! %w(view)
821
- end
822
- end
823
-
824
- describe '#set_session_callback!' do
825
- before(:each) do
826
- mock_api_server('{ "status": "Ok", "result": {}}')
827
- end
828
-
829
- it 'accepts access credentials hash' do
830
- lambda do
831
- subject.set_session_callback!('http://www.example.com', :client_id => 'client_id', :private_key => 'private_key')
832
- end.should_not raise_error()
833
- end
834
- end
835
-
836
- describe '#method_missing' do
837
- it 'passes unknown methods to file object' do
838
- lambda { subject.name }.should_not raise_error()
839
- end
840
-
841
- it 'raises NoMethodError if neither self nor file responds to method' do
842
- lambda { subject.unknown_method }.should raise_error(NoMethodError)
843
- end
844
- end
845
-
846
- describe '#respond_to?' do
847
- it 'returns true if self responds to method' do
848
- subject.respond_to?(:metadata!).should be_truthy
849
- end
850
-
851
- it 'returns true if file object responds to method' do
852
- subject.respond_to?(:name).should be_truthy
853
- end
854
-
855
- it 'returns false if neither self nor file responds to method' do
856
- subject.respond_to?(:unknown).should be_falsey
857
- end
858
- end
859
- end
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Document do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+ include_examples GroupDocs::Api::Helpers::Status
7
+
8
+ subject do
9
+ file = GroupDocs::Storage::File.new
10
+ described_class.new(:file => file)
11
+ end
12
+
13
+ describe '.views!' do
14
+ before(:each) do
15
+ mock_api_server(load_json('document_views'))
16
+ end
17
+
18
+ it 'accepts access credentials hash' do
19
+ lambda do
20
+ described_class.views!({}, :client_id => 'client_id', :private_key => 'private_key')
21
+ end.should_not raise_error()
22
+ end
23
+
24
+ it 'returns an array of GroupDocs::Document::View objects' do
25
+ views = described_class.views!
26
+ views.should be_an(Array)
27
+ views.each do |view|
28
+ view.should be_a(GroupDocs::Document::View)
29
+ end
30
+ end
31
+ end
32
+
33
+ describe '.templates!' do
34
+ before(:each) do
35
+ mock_api_server(load_json('templates_get'))
36
+ end
37
+
38
+ it 'accepts access credentials hash' do
39
+ lambda do
40
+ described_class.templates!(:client_id => 'client_id', :private_key => 'private_key')
41
+ end.should_not raise_error()
42
+ end
43
+
44
+ it 'returns an array of GroupDocs::Document objects' do
45
+ templates = described_class.templates!
46
+ templates.should be_an(Array)
47
+ templates.each do |template|
48
+ template.should be_a(GroupDocs::Document)
49
+ end
50
+ end
51
+ end
52
+
53
+ describe '.sign_documents!' do
54
+ before(:each) do
55
+ mock_api_server(load_json('sign_documents'))
56
+ end
57
+
58
+ let(:documents) do
59
+ [GroupDocs::Document.new(:file => GroupDocs::Storage::File.new(:name => 'Document1', :local_path => __FILE__)),
60
+ GroupDocs::Document.new(:file => GroupDocs::Storage::File.new(:name => 'Document2', :local_path => 'spec/support/files/resume.pdf'))]
61
+ end
62
+ let(:signatures) { [GroupDocs::Signature.new(:name => 'John Smith', :image_path => 'spec/support/files/signature.png', :position => {})] }
63
+
64
+ it 'accepts access credentials hash' do
65
+ lambda do
66
+ described_class.sign_documents!(documents, signatures, {}, :client_id => 'client_id', :private_key => 'private_key')
67
+ end.should_not raise_error()
68
+ end
69
+
70
+ it 'raises error if document is not GroupDocs::Document object' do
71
+ lambda { described_class.sign_documents!(['Document'], signatures) }.should raise_error(ArgumentError)
72
+ end
73
+
74
+ it 'raises error if document file does not have name' do
75
+ documents = [GroupDocs::Document.new(:file => GroupDocs::Storage::File.new(:local_path => __FILE__))]
76
+ lambda { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
77
+ end
78
+
79
+ it 'raises error if document file does not have local path' do
80
+ documents = [GroupDocs::Document.new(:file => GroupDocs::Storage::File.new(:name => 'Document'))]
81
+ lambda { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
82
+ end
83
+
84
+ it 'raises error if signature is not GroupDocs::Signature object' do
85
+ lambda { described_class.sign_documents!(documents, ['Signature']) }.should raise_error(ArgumentError)
86
+ end
87
+
88
+ it 'raises error if signature does not have name' do
89
+ signatures = [GroupDocs::Signature.new(:image_path => __FILE__, :position => {})]
90
+ lambda { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
91
+ end
92
+
93
+ it 'raises error if signature does not have image path' do
94
+ signatures = [GroupDocs::Signature.new(:name => 'John Smith', :position => {})]
95
+ lambda { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
96
+ end
97
+
98
+ it 'raises error if signature does not have position' do
99
+ signatures = [GroupDocs::Signature.new(:name => 'John Smith', :image_path => __FILE__)]
100
+ lambda { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
101
+ end
102
+
103
+ it 'detects each document and signature file MIME type' do
104
+ documents.each { |document| described_class.should_receive(:mime_type).with(document.file.local_path).once }
105
+ signatures.each { |signature| described_class.should_receive(:mime_type).with(signature.image_path).once }
106
+ described_class.sign_documents!(documents, signatures)
107
+ end
108
+
109
+
110
+ end
111
+
112
+ describe ',metadata!' do
113
+ before(:each) do
114
+ mock_api_server(load_json('document_metadata'))
115
+ end
116
+
117
+ it 'accepts access credentials hash' do
118
+ lambda do
119
+ described_class.metadata!('document_one.doc', :client_id => 'client_id', :private_key => 'private_key')
120
+ end.should_not raise_error()
121
+ end
122
+
123
+ it 'returns GroupDocs::Document::MetaData object' do
124
+ described_class.metadata!('document_one.doc').should be_a(GroupDocs::Document::MetaData)
125
+ end
126
+
127
+ it 'sets last view as GroupDocs::Document::View object if document was viewed at least once' do
128
+ described_class.metadata!('document_one.doc').last_view.should be_a(GroupDocs::Document::View)
129
+ end
130
+
131
+ it 'does not set last view if document has never been viewed' do
132
+ mock_api_server('{ "status": "Ok", "result": { "last_view": null }}')
133
+ described_class.metadata!('document_one.doc').last_view.should be_nil
134
+ end
135
+ end
136
+
137
+ it { should have_accessor(:file) }
138
+ it { should have_accessor(:process_date) }
139
+ it { should have_accessor(:outputs) }
140
+ it { should have_accessor(:output_formats) }
141
+ it { should have_accessor(:order) }
142
+ it { should have_accessor(:field_count) }
143
+ it { should have_accessor(:news_enabled) }
144
+ it { should have_accessor(:alerts_enabled) }
145
+ it { should have_accessor(:support_enabled) }
146
+ it { should have_accessor(:is_real_time_broadcast_enabled) }
147
+ it { should have_accessor(:is_scroll_broadcast_enabled) }
148
+ it { should have_accessor(:is_zoom_broadcast_enabled) }
149
+ it { should have_accessor(:is_annotation_navigation_widget_enabled) }
150
+ it { should have_accessor(:is_annotation_zoom_widget_enabled) }
151
+ it { should have_accessor(:is_annotation_download_widget_enabled) }
152
+ it { should have_accessor(:is_annotation_print_widget_enabled) }
153
+ it { should have_accessor(:is_annotation_help_widget_enabled) }
154
+ it { should have_accessor(:is_right_panel_enabled) }
155
+ it { should have_accessor(:is_thumbnails_panel_enabled) }
156
+ it { should have_accessor(:is_toolbar_enabled) }
157
+ it { should have_accessor(:is_text_annotation_button_enabled) }
158
+ it { should have_accessor(:is_rectangle_annotation_button_enabled) }
159
+ it { should have_accessor(:is_point_annotation_button_enabled) }
160
+ it { should have_accessor(:is_strikeout_annotation_button_enabled) }
161
+ it { should have_accessor(:is_polyline_annotation_button_enabled) }
162
+ it { should have_accessor(:is_typewriter_annotation_button_enabled) }
163
+ it { should have_accessor(:is_watermark_annotation_button_enabled) }
164
+ it { should have_accessor(:is_viewer_navigation_widget_enabled) }
165
+ it { should have_accessor(:is_viewer_zoom_widget_enabled) }
166
+ it { should have_accessor(:is_viewer_download_widget_enabled) }
167
+ it { should have_accessor(:is_viewer_print_widget_enabled) }
168
+ it { should have_accessor(:is_viewer_help_widget_enabled) }
169
+ it { should have_accessor(:is_standard_header_always_shown) }
170
+ it { should have_accessor(:is_annotation_document_name_shown) }
171
+ it { should have_accessor(:is_viewer_document_name_shown) }
172
+
173
+ it { should have_alias(:access_mode=, :access_mode_set!) }
174
+
175
+ describe '#outputs=' do
176
+ let(:response) do
177
+ [
178
+ { :ftype => 1, :guid => 'fhy9yh94u238dgf' },
179
+ { :ftype => 2, :guid => 'ofh9rhy9rfohf9s' }
180
+ ]
181
+ end
182
+
183
+ it 'saves outputs as array of GroupDocs::Storage::File objects' do
184
+ subject.outputs = response
185
+ outputs = subject.outputs
186
+ outputs.should be_an(Array)
187
+ outputs.each do |output|
188
+ output.should be_a(GroupDocs::Storage::File)
189
+ end
190
+ end
191
+
192
+ it 'does nothing if nil is passed' do
193
+ lambda do
194
+ subject.outputs = nil
195
+ end.should_not change(subject, :outputs)
196
+ end
197
+ end
198
+
199
+ describe '#output_formats' do
200
+ it 'returns parsed array of output formats' do
201
+ subject.output_formats = "pdf,tiff,doc"
202
+ subject.output_formats.should == [:pdf, :tiff, :doc]
203
+ end
204
+ end
205
+
206
+ describe '#process_date' do
207
+ it 'returns converted to Time object Unix timestamp' do
208
+ subject.process_date = 1330450135000
209
+ subject.process_date.should == Time.at(1330450135)
210
+ end
211
+ end
212
+
213
+ describe '#initialize' do
214
+ it 'raises error if file is not specified' do
215
+ lambda { described_class.new }.should raise_error(ArgumentError)
216
+ end
217
+
218
+ it 'raises error if file is not an instance of GroupDocs::Storage::File' do
219
+ lambda { described_class.new(:file => '') }.should raise_error(ArgumentError)
220
+ end
221
+ end
222
+
223
+ describe '#page_images!' do
224
+ before(:each) do
225
+ mock_api_server(load_json('document_page_images_get'))
226
+ end
227
+
228
+ it 'accepts access credentials hash' do
229
+ lambda do
230
+ subject.page_images!(640, 480, {}, :client_id => 'client_id', :private_key => 'private_key')
231
+ end.should_not raise_error()
232
+ end
233
+
234
+ it 'accepts options hash' do
235
+ lambda do
236
+ subject.page_images!(640, 480, :first_page => 0, :page_count => 1)
237
+ end.should_not raise_error()
238
+ end
239
+
240
+ it 'returns array of URLs' do
241
+ urls = subject.page_images!(640, 480)
242
+ urls.should be_an(Array)
243
+ urls.each do |url|
244
+ url.should be_a(String)
245
+ end
246
+ end
247
+ end
248
+
249
+ describe '#thumbnails!' do
250
+ before(:each) do
251
+ mock_api_server(load_json('document_thumbnails'))
252
+ end
253
+
254
+ it 'accepts access credentials hash' do
255
+ lambda do
256
+ subject.thumbnails!({}, :client_id => 'client_id', :private_key => 'private_key')
257
+ end.should_not raise_error()
258
+ end
259
+
260
+ it 'accepts options hash' do
261
+ lambda do
262
+ subject.thumbnails!(:page_number => 0, :page_count => 1)
263
+ end.should_not raise_error()
264
+ end
265
+
266
+ it 'returns array of URLs' do
267
+ urls = subject.thumbnails!
268
+ urls.should be_an(Array)
269
+ urls.each do |url|
270
+ url.should be_a(String)
271
+ end
272
+ end
273
+ end
274
+
275
+ describe '#access_mode!' do
276
+ before(:each) do
277
+ mock_api_server(load_json('document_access_info_get'))
278
+ end
279
+
280
+ it 'accepts access credentials hash' do
281
+ lambda do
282
+ subject.access_mode!(:client_id => 'client_id', :private_key => 'private_key')
283
+ end.should_not raise_error()
284
+ end
285
+
286
+ it 'returns access mode in human readable presentation' do
287
+ subject.should_receive(:parse_access_mode).with('Private').and_return(:private)
288
+ subject.access_mode!.should == :private
289
+ end
290
+ end
291
+
292
+ describe '#access_mode_set!' do
293
+ before(:each) do
294
+ mock_api_server('{"status": "Ok", "result": {"access": "Private" }}')
295
+ end
296
+
297
+ it 'accepts access credentials hash' do
298
+ lambda do
299
+ subject.access_mode_set!(:private, :client_id => 'client_id', :private_key => 'private_key')
300
+ end.should_not raise_error()
301
+ end
302
+
303
+ it 'sets corresponding access mode' do
304
+ described_class::ACCESS_MODES.should_receive(:[]).with(:private).and_return(0)
305
+ subject.should_receive(:parse_access_mode).with('Private').and_return(:private)
306
+ subject.access_mode_set!(:private)
307
+ end
308
+
309
+ it 'returns set of access modes' do
310
+ subject.access_mode_set!(:private).should == :private
311
+ end
312
+
313
+ it 'is aliased to #access_mode=' do
314
+ subject.should have_alias(:access_mode=, :access_mode_set!)
315
+ end
316
+ end
317
+
318
+ describe '#formats!' do
319
+ before(:each) do
320
+ mock_api_server(load_json('document_formats'))
321
+ end
322
+
323
+ it 'accepts access credentials hash' do
324
+ lambda do
325
+ subject.formats!(:client_id => 'client_id', :private_key => 'private_key')
326
+ end.should_not raise_error()
327
+ end
328
+
329
+ it 'returns an array of symbols' do
330
+ formats = subject.formats!
331
+ formats.should be_an(Array)
332
+ formats.each do |format|
333
+ format.should be_a(Symbol)
334
+ end
335
+ end
336
+ end
337
+
338
+ describe '#metadata!' do
339
+ before(:each) do
340
+ mock_api_server(load_json('document_metadata'))
341
+ end
342
+
343
+ it 'accepts access credentials hash' do
344
+ lambda do
345
+ subject.metadata!(:client_id => 'client_id', :private_key => 'private_key')
346
+ end.should_not raise_error()
347
+ end
348
+
349
+ it 'returns GroupDocs::Document::MetaData object' do
350
+ subject.metadata!.should be_a(GroupDocs::Document::MetaData)
351
+ end
352
+
353
+ it 'sets last view as GroupDocs::Document::View object if document was viewed at least once' do
354
+ subject.metadata!.last_view.should be_a(GroupDocs::Document::View)
355
+ end
356
+
357
+ it 'uses self document in last view object' do
358
+ subject.metadata!.last_view.document.should be_a(GroupDocs::Document)
359
+ end
360
+
361
+ it 'does not set last view if document has never been viewed' do
362
+ mock_api_server('{ "status": "Ok", "result": { "last_view": null }}')
363
+ subject.metadata!.last_view.should be_nil
364
+ end
365
+ end
366
+
367
+ describe '#fields!' do
368
+ before(:each) do
369
+ mock_api_server(load_json('document_fields'))
370
+ end
371
+
372
+ it 'accepts access credentials hash' do
373
+ lambda do
374
+ subject.fields!(:client_id => 'client_id', :private_key => 'private_key')
375
+ end.should_not raise_error()
376
+ end
377
+
378
+ it 'returns array of GroupDocs::Document::Field objects' do
379
+ fields = subject.fields!
380
+ fields.should be_an(Array)
381
+ fields.each do |field|
382
+ field.should be_a(GroupDocs::Document::Field)
383
+ end
384
+ end
385
+ end
386
+
387
+ describe '#sharers!' do
388
+ before(:each) do
389
+ mock_api_server(load_json('document_access_info_get'))
390
+ end
391
+
392
+ it 'accepts access credentials hash' do
393
+ lambda do
394
+ subject.sharers!(:client_id => 'client_id', :private_key => 'private_key')
395
+ end.should_not raise_error()
396
+ end
397
+
398
+ it 'returns an array of GroupDocs::User objects' do
399
+ users = subject.sharers!
400
+ users.should be_an(Array)
401
+ users.each do |user|
402
+ user.should be_a(GroupDocs::User)
403
+ end
404
+ end
405
+ end
406
+
407
+ describe '#sharers_set!' do
408
+ before(:each) do
409
+ mock_api_server(load_json('document_sharers_set'))
410
+ end
411
+
412
+ it 'accepts access credentials hash' do
413
+ lambda do
414
+ subject.sharers_set!(%w(test1@email.com), :client_id => 'client_id', :private_key => 'private_key')
415
+ end.should_not raise_error()
416
+ end
417
+
418
+ it 'returns an array of GroupDocs::User objects' do
419
+ users = subject.sharers_set!(%w(test1@email.com))
420
+ users.should be_an(Array)
421
+ users.each do |user|
422
+ user.should be_a(GroupDocs::User)
423
+ end
424
+ end
425
+
426
+ it 'clears sharers if empty array is passed' do
427
+ subject.should_receive(:sharers_clear!)
428
+ subject.sharers_set!([])
429
+ end
430
+
431
+ it 'clears sharers if nil is passed' do
432
+ subject.should_receive(:sharers_clear!)
433
+ subject.sharers_set!(nil)
434
+ end
435
+ end
436
+
437
+ describe '#sharers_clear!' do
438
+ before(:each) do
439
+ mock_api_server(load_json('document_sharers_remove'))
440
+ end
441
+
442
+ it 'accepts access credentials hash' do
443
+ lambda do
444
+ subject.sharers_clear!(:client_id => 'client_id', :private_key => 'private_key')
445
+ end.should_not raise_error()
446
+ end
447
+
448
+ it 'clears sharers list and returns nil' do
449
+ subject.sharers_clear!.should be_nil
450
+ end
451
+ end
452
+
453
+ describe '#convert!' do
454
+ before(:each) do
455
+ mock_api_server(load_json('document_convert'))
456
+ end
457
+
458
+ it 'accepts access credentials hash' do
459
+ lambda do
460
+ subject.convert!(:pdf, {}, :client_id => 'client_id', :private_key => 'private_key')
461
+ end.should_not raise_error()
462
+ end
463
+
464
+ it 'accepts options hash' do
465
+ lambda do
466
+ subject.convert!(:pdf, :email_results => true)
467
+ end.should_not raise_error()
468
+ end
469
+
470
+ it 'returns GroupDocs::Job object' do
471
+ subject.convert!(:pdf).should be_a(GroupDocs::Job)
472
+ end
473
+ end
474
+
475
+ describe '#questionnaires!' do
476
+ before(:each) do
477
+ mock_api_server(load_json('document_questionnaires'))
478
+ end
479
+
480
+ it 'accepts access credentials hash' do
481
+ lambda do
482
+ subject.questionnaires!(:client_id => 'client_id', :private_key => 'private_key')
483
+ end.should_not raise_error()
484
+ end
485
+
486
+ it 'returns an array of GroupDocs::Questionnaire objects' do
487
+ questionnaires = subject.questionnaires!
488
+ questionnaires.should be_an(Array)
489
+ questionnaires.each do |questionnaire|
490
+ questionnaire.should be_a(GroupDocs::Questionnaire)
491
+ end
492
+ end
493
+ end
494
+
495
+ describe '#add_questionnaire!' do
496
+ before(:each) do
497
+ mock_api_server('{ "status": "Ok", "result": {}}')
498
+ end
499
+
500
+ let(:questionnaire) do
501
+ GroupDocs::Questionnaire.new(:id => 1)
502
+ end
503
+
504
+ it 'accepts access credentials hash' do
505
+ lambda do
506
+ subject.add_questionnaire!(questionnaire, :client_id => 'client_id', :private_key => 'private_key')
507
+ end.should_not raise_error()
508
+ end
509
+
510
+ it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
511
+ lambda { subject.add_questionnaire!('Questionnaire') }.should raise_error(ArgumentError)
512
+ end
513
+ end
514
+
515
+ describe '#create_questionnaire!' do
516
+ before(:each) do
517
+ mock_api_server(load_json('document_questionnaire_create'))
518
+ end
519
+
520
+ let(:questionnaire) do
521
+ GroupDocs::Questionnaire.new(:name => 'Q1')
522
+ end
523
+
524
+ it 'accepts access credentials hash' do
525
+ lambda do
526
+ subject.create_questionnaire!(questionnaire, :client_id => 'client_id', :private_key => 'private_key')
527
+ end.should_not raise_error()
528
+ end
529
+
530
+ it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
531
+ lambda { subject.create_questionnaire!('Questionnaire') }.should raise_error(ArgumentError)
532
+ end
533
+
534
+ it 'returns GroupDocs::Questionnaire object' do
535
+ subject.create_questionnaire!(questionnaire).should be_a(GroupDocs::Questionnaire)
536
+ end
537
+
538
+ it 'uses hashed version of questionnaire as request body' do
539
+ questionnaire.should_receive(:to_hash)
540
+ subject.create_questionnaire!(questionnaire)
541
+ end
542
+
543
+ it 'updates ID from response to questionnaire' do
544
+ lambda do
545
+ subject.create_questionnaire!(questionnaire)
546
+ end.should change(questionnaire, :id)
547
+ end
548
+ end
549
+
550
+ describe '#remove_questionnaire!' do
551
+ before(:each) do
552
+ mock_api_server('{ "status": "Ok", "result": {}}')
553
+ end
554
+
555
+ let(:questionnaire) do
556
+ GroupDocs::Questionnaire.new(:id => 1)
557
+ end
558
+
559
+ it 'accepts access credentials hash' do
560
+ lambda do
561
+ subject.remove_questionnaire!(questionnaire, :client_id => 'client_id', :private_key => 'private_key')
562
+ end.should_not raise_error()
563
+ end
564
+
565
+ it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
566
+ lambda { subject.remove_questionnaire!('Questionnaire') }.should raise_error(ArgumentError)
567
+ end
568
+ end
569
+
570
+ describe '#datasource!' do
571
+ before(:each) do
572
+ mock_api_server(load_json('document_datasource'))
573
+ end
574
+
575
+ let(:datasource) do
576
+ GroupDocs::DataSource.new(:id => 1)
577
+ end
578
+
579
+ it 'accepts access credentials hash' do
580
+ lambda do
581
+ subject.datasource!(datasource, {}, :client_id => 'client_id', :private_key => 'private_key')
582
+ end.should_not raise_error()
583
+ end
584
+
585
+ it 'accepts options hash' do
586
+ lambda do
587
+ subject.datasource!(datasource, :new_type => :pdf)
588
+ end.should_not raise_error()
589
+ end
590
+
591
+ it 'raises error if datasource is not GroupDocs::Datasource object' do
592
+ lambda { subject.datasource!('Datasource') }.should raise_error(ArgumentError)
593
+ end
594
+
595
+ it 'returns GroupDocs::Job object' do
596
+ job = subject.datasource!(datasource)
597
+ job.should be_a(GroupDocs::Job)
598
+ end
599
+ end
600
+
601
+ describe '#annotations!' do
602
+ before(:each) do
603
+ mock_api_server(load_json('annotation_list'))
604
+ end
605
+
606
+ it 'accepts access credentials hash' do
607
+ lambda do
608
+ subject.annotations!(:client_id => 'client_id', :private_key => 'private_key')
609
+ end.should_not raise_error()
610
+ end
611
+
612
+ it 'returns array of GroupDocs::Document::Annotation objects' do
613
+ annotations = subject.annotations!
614
+ annotations.should be_an(Array)
615
+ annotations.each do |annotation|
616
+ annotation.should be_a(GroupDocs::Document::Annotation)
617
+ end
618
+ end
619
+
620
+ it 'returns empty array if annotations are null in response' do
621
+ mock_api_server('{ "status": "Ok", "result": { "annotations": null }}')
622
+ subject.annotations!.should be_empty
623
+ end
624
+ end
625
+
626
+ describe '#details!' do
627
+ before(:each) do
628
+ mock_api_server(load_json('comparison_document'))
629
+ end
630
+
631
+ it 'accepts access credentials hash' do
632
+ lambda do
633
+ subject.details!(:client_id => 'client_id', :private_key => 'private_key')
634
+ end.should_not raise_error()
635
+ end
636
+
637
+ it 'returns hash of document details' do
638
+ subject.details!.should be_a(Hash)
639
+ end
640
+ end
641
+
642
+ describe '#compare!' do
643
+ before(:each) do
644
+ mock_api_server(load_json('comparison_compare'))
645
+ end
646
+
647
+ let(:document) do
648
+ GroupDocs::Document.new(:file => GroupDocs::Storage::File.new)
649
+ end
650
+
651
+ it 'accepts access credentials hash' do
652
+ lambda do
653
+ subject.compare!(document, 'callback', :client_id => 'client_id', :private_key => 'private_key')
654
+ end.should_not raise_error()
655
+ end
656
+
657
+ it 'raises error if document is not GroupDocs::Document object' do
658
+ lambda { subject.compare!('Document') }.should raise_error(ArgumentError)
659
+ end
660
+
661
+ it 'returns GroupDocs::Job object' do
662
+ subject.compare!(document, 'callback').should be_a(GroupDocs::Job)
663
+ end
664
+ end
665
+
666
+ describe '#changes!' do
667
+ before(:each) do
668
+ mock_api_server(load_json('comparison_changes'))
669
+ end
670
+
671
+ it 'accepts access credentials hash' do
672
+ lambda do
673
+ subject.changes!(:client_id => 'client_id', :private_key => 'private_key')
674
+ end.should_not raise_error()
675
+ end
676
+
677
+ it 'returns array of GroupDocs::Document::Change objects' do
678
+ changes = subject.changes!
679
+ changes.should be_an(Array)
680
+ changes.each do |change|
681
+ change.should be_a(GroupDocs::Document::Change)
682
+ end
683
+ end
684
+ end
685
+
686
+
687
+ describe '#collaborators!' do
688
+ before(:each) do
689
+ mock_api_server(load_json('annotation_collaborators_get'))
690
+ end
691
+
692
+ it 'accepts access credentials hash' do
693
+ lambda do
694
+ subject.collaborators!(:client_id => 'client_id', :private_key => 'private_key')
695
+ end.should_not raise_error()
696
+ end
697
+
698
+ it 'returns an array of GroupDocs::User objects' do
699
+ users = subject.collaborators!
700
+ users.should be_an(Array)
701
+ users.each do |user|
702
+ user.should be_a(GroupDocs::User)
703
+ end
704
+ end
705
+ end
706
+
707
+ describe '#set_collaborators!' do
708
+ before(:each) do
709
+ mock_api_server(load_json('annotation_collaborators_set'))
710
+ end
711
+
712
+ it 'accepts access credentials hash' do
713
+ lambda do
714
+ subject.set_collaborators!(%w(test1@email.com), 1, :client_id => 'client_id', :private_key => 'private_key')
715
+ end.should_not raise_error()
716
+ end
717
+
718
+ it 'accepts version' do
719
+ lambda do
720
+ subject.set_collaborators!(%w(test1@email.com), 1)
721
+ end.should_not raise_error()
722
+ end
723
+
724
+ it 'returns an array of GroupDocs::User objects' do
725
+ users = subject.set_collaborators!(%w(test1@email.com))
726
+ users.should be_an(Array)
727
+ users.each do |user|
728
+ user.should be_a(GroupDocs::User)
729
+ end
730
+ end
731
+ end
732
+
733
+ describe '#add_collaborator!' do
734
+ before(:each) do
735
+ mock_api_server(load_json('annotation_collaborators_get'))
736
+ end
737
+
738
+ let!(:collaborator) { GroupDocs::User.new }
739
+
740
+ it 'accepts access credentials hash' do
741
+ lambda do
742
+ subject.add_collaborator!(collaborator, :client_id => 'client_id', :private_key => 'private_key')
743
+ end.should_not raise_error()
744
+ end
745
+
746
+ it 'uses hashed version of collaborator as request body' do
747
+ collaborator.should_receive(:to_hash)
748
+ subject.add_collaborator! collaborator
749
+ end
750
+
751
+ it 'raises error if collaborator is not an instance of GroupDocs::User' do
752
+ lambda { subject.add_collaborator!('collaborator') }.should raise_error(ArgumentError)
753
+ end
754
+ end
755
+
756
+ describe '#set_reviewers!' do
757
+ before(:each) do
758
+ mock_api_server('{ "status": "Ok", "result": {}}')
759
+ end
760
+
761
+ let!(:reviewers) { [GroupDocs::User.new, GroupDocs::User.new] }
762
+
763
+ it 'accepts access credentials hash' do
764
+ lambda do
765
+ subject.set_reviewers!(reviewers, :client_id => 'client_id', :private_key => 'private_key')
766
+ end.should_not raise_error()
767
+ end
768
+
769
+ it 'uses hashed version of each reviewer as request body' do
770
+ reviewers.each do |reviewer|
771
+ reviewer.should_receive(:to_hash)
772
+ end
773
+ subject.set_reviewers! reviewers
774
+ end
775
+ end
776
+
777
+ describe '#shared_link_access_rights!' do
778
+ before(:each) do
779
+ mock_api_server('{ "status": "Ok", "result": { "accessRights": 15 }}')
780
+ end
781
+
782
+ it 'accepts access credentials hash' do
783
+ lambda do
784
+ subject.shared_link_access_rights!(:client_id => 'client_id', :private_key => 'private_key')
785
+ end.should_not raise_error()
786
+ end
787
+
788
+ it 'converts response byte flag into array of access rights' do
789
+ subject.should_receive(:convert_byte_to_access_rights).with(15)
790
+ subject.shared_link_access_rights!
791
+ end
792
+
793
+ it 'returns array of access rights symbols' do
794
+ access_rights = subject.shared_link_access_rights!
795
+ access_rights.should be_an(Array)
796
+ access_rights.each do |access_right|
797
+ access_right.should be_a(Symbol)
798
+ end
799
+ end
800
+
801
+ it 'returns empty array if access rights is null' do
802
+ mock_api_server('{ "status": "Ok", "result": { "accessRights": null }}')
803
+ subject.shared_link_access_rights!.should be_empty
804
+ end
805
+ end
806
+
807
+ describe '#set_shared_link_access_rights!' do
808
+ before(:each) do
809
+ mock_api_server('{ "status": "Ok", "result": {}}')
810
+ end
811
+
812
+ it 'accepts access credentials hash' do
813
+ lambda do
814
+ subject.set_shared_link_access_rights!(%w(view), :client_id => 'client_id', :private_key => 'private_key')
815
+ end.should_not raise_error()
816
+ end
817
+
818
+ it 'converts array of access rights into byte flag' do
819
+ subject.should_receive(:convert_access_rights_to_byte).with(%w(view))
820
+ subject.set_shared_link_access_rights! %w(view)
821
+ end
822
+ end
823
+
824
+ describe '#set_session_callback!' do
825
+ before(:each) do
826
+ mock_api_server('{ "status": "Ok", "result": {}}')
827
+ end
828
+
829
+ it 'accepts access credentials hash' do
830
+ lambda do
831
+ subject.set_session_callback!('http://www.example.com', :client_id => 'client_id', :private_key => 'private_key')
832
+ end.should_not raise_error()
833
+ end
834
+ end
835
+
836
+ describe '#method_missing' do
837
+ it 'passes unknown methods to file object' do
838
+ lambda { subject.name }.should_not raise_error()
839
+ end
840
+
841
+ it 'raises NoMethodError if neither self nor file responds to method' do
842
+ lambda { subject.unknown_method }.should raise_error(NoMethodError)
843
+ end
844
+ end
845
+
846
+ describe '#respond_to?' do
847
+ it 'returns true if self responds to method' do
848
+ subject.respond_to?(:metadata!).should be_truthy
849
+ end
850
+
851
+ it 'returns true if file object responds to method' do
852
+ subject.respond_to?(:name).should be_truthy
853
+ end
854
+
855
+ it 'returns false if neither self nor file responds to method' do
856
+ subject.respond_to?(:unknown).should be_falsey
857
+ end
858
+ end
859
+ end