groupdocs 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. data/.travis.yml +0 -0
  2. data/CHANGELOG.md +22 -0
  3. data/Gemfile +0 -0
  4. data/README.md +4 -2
  5. data/Rakefile +0 -0
  6. data/examples/README.md +0 -0
  7. data/examples/annotations/Gemfile +0 -0
  8. data/examples/annotations/app.rb +0 -0
  9. data/groupdocs.gemspec +0 -0
  10. data/lib/groupdocs/api/entity.rb +0 -0
  11. data/lib/groupdocs/api/helpers/access_mode_helper.rb +0 -0
  12. data/lib/groupdocs/api/helpers/access_rights_helper.rb +54 -0
  13. data/lib/groupdocs/api/helpers/byte_flag_helper.rb +49 -0
  14. data/lib/groupdocs/api/helpers/credentials_helper.rb +0 -0
  15. data/lib/groupdocs/api/helpers/path_helper.rb +0 -0
  16. data/lib/groupdocs/api/helpers/rest_helper.rb +0 -0
  17. data/lib/groupdocs/api/helpers/status_helper.rb +0 -0
  18. data/lib/groupdocs/api/helpers/url_helper.rb +0 -0
  19. data/lib/groupdocs/api/helpers.rb +2 -1
  20. data/lib/groupdocs/api/request.rb +0 -0
  21. data/lib/groupdocs/api.rb +0 -0
  22. data/lib/groupdocs/datasource/field.rb +0 -0
  23. data/lib/groupdocs/datasource.rb +0 -0
  24. data/lib/groupdocs/document/annotation/reply.rb +0 -0
  25. data/lib/groupdocs/document/annotation/reviewer.rb +60 -0
  26. data/lib/groupdocs/document/annotation.rb +19 -44
  27. data/lib/groupdocs/document/change.rb +0 -0
  28. data/lib/groupdocs/document/field.rb +0 -0
  29. data/lib/groupdocs/document/metadata.rb +0 -0
  30. data/lib/groupdocs/document/rectangle.rb +0 -0
  31. data/lib/groupdocs/document/view.rb +0 -0
  32. data/lib/groupdocs/document.rb +129 -0
  33. data/lib/groupdocs/errors.rb +0 -0
  34. data/lib/groupdocs/job.rb +53 -1
  35. data/lib/groupdocs/questionnaire/execution.rb +0 -0
  36. data/lib/groupdocs/questionnaire/page.rb +0 -0
  37. data/lib/groupdocs/questionnaire/question/answer.rb +0 -0
  38. data/lib/groupdocs/questionnaire/question.rb +0 -0
  39. data/lib/groupdocs/questionnaire.rb +0 -0
  40. data/lib/groupdocs/signature/contact.rb +0 -0
  41. data/lib/groupdocs/signature/envelope/log.rb +0 -0
  42. data/lib/groupdocs/signature/envelope.rb +0 -0
  43. data/lib/groupdocs/signature/field/location.rb +0 -0
  44. data/lib/groupdocs/signature/field.rb +0 -0
  45. data/lib/groupdocs/signature/form.rb +0 -0
  46. data/lib/groupdocs/signature/list.rb +0 -0
  47. data/lib/groupdocs/signature/recipient.rb +0 -0
  48. data/lib/groupdocs/signature/role.rb +0 -0
  49. data/lib/groupdocs/signature/shared/document_methods.rb +0 -0
  50. data/lib/groupdocs/signature/shared/entity_fields.rb +0 -0
  51. data/lib/groupdocs/signature/shared/entity_methods.rb +0 -0
  52. data/lib/groupdocs/signature/shared/field_methods.rb +0 -0
  53. data/lib/groupdocs/signature/shared/recipient_methods.rb +0 -0
  54. data/lib/groupdocs/signature/shared/resource_methods.rb +0 -0
  55. data/lib/groupdocs/signature/shared.rb +0 -0
  56. data/lib/groupdocs/signature/template.rb +0 -0
  57. data/lib/groupdocs/signature.rb +0 -0
  58. data/lib/groupdocs/storage/file.rb +0 -0
  59. data/lib/groupdocs/storage/folder.rb +0 -0
  60. data/lib/groupdocs/storage/package.rb +0 -0
  61. data/lib/groupdocs/storage.rb +0 -0
  62. data/lib/groupdocs/subscription/limit.rb +0 -0
  63. data/lib/groupdocs/subscription.rb +0 -0
  64. data/lib/groupdocs/user.rb +31 -4
  65. data/lib/groupdocs/version.rb +1 -1
  66. data/lib/groupdocs.rb +0 -0
  67. data/spec/groupdocs/api/entity_spec.rb +0 -0
  68. data/spec/groupdocs/api/helpers/access_mode_helper_spec.rb +0 -1
  69. data/spec/groupdocs/api/helpers/access_rights_helper_spec.rb +43 -0
  70. data/spec/groupdocs/api/helpers/byte_flag_helper_spec.rb +23 -0
  71. data/spec/groupdocs/api/helpers/credentials_helpers_spec.rb +0 -0
  72. data/spec/groupdocs/api/helpers/path_helper_spec.rb +0 -0
  73. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +0 -0
  74. data/spec/groupdocs/api/helpers/status_helper_spec.rb +0 -0
  75. data/spec/groupdocs/api/helpers/url_helper_spec.rb +0 -0
  76. data/spec/groupdocs/api/request_spec.rb +0 -0
  77. data/spec/groupdocs/datasource/field_spec.rb +0 -0
  78. data/spec/groupdocs/datasource_spec.rb +0 -0
  79. data/spec/groupdocs/document/annotation/reply_spec.rb +0 -0
  80. data/spec/groupdocs/document/annotation/reviewer_spec.rb +57 -0
  81. data/spec/groupdocs/document/annotation_spec.rb +12 -44
  82. data/spec/groupdocs/document/change_spec.rb +0 -0
  83. data/spec/groupdocs/document/field_spec.rb +0 -0
  84. data/spec/groupdocs/document/metadata_spec.rb +0 -0
  85. data/spec/groupdocs/document/rectangle_spec.rb +0 -0
  86. data/spec/groupdocs/document/view_spec.rb +0 -0
  87. data/spec/groupdocs/document_spec.rb +138 -0
  88. data/spec/groupdocs/errors_spec.rb +0 -0
  89. data/spec/groupdocs/job_spec.rb +42 -0
  90. data/spec/groupdocs/questionnaire/execution_spec.rb +0 -0
  91. data/spec/groupdocs/questionnaire/page_spec.rb +0 -0
  92. data/spec/groupdocs/questionnaire/question/answer_spec.rb +0 -0
  93. data/spec/groupdocs/questionnaire/question_spec.rb +0 -0
  94. data/spec/groupdocs/questionnaire_spec.rb +0 -0
  95. data/spec/groupdocs/signature/contact_spec.rb +0 -0
  96. data/spec/groupdocs/signature/envelope/log_spec.rb +0 -0
  97. data/spec/groupdocs/signature/envelope_spec.rb +0 -0
  98. data/spec/groupdocs/signature/field/location_spec.rb +0 -0
  99. data/spec/groupdocs/signature/field_spec.rb +0 -0
  100. data/spec/groupdocs/signature/form_spec.rb +0 -0
  101. data/spec/groupdocs/signature/list_spec.rb +0 -0
  102. data/spec/groupdocs/signature/recipient_spec.rb +0 -0
  103. data/spec/groupdocs/signature/role_spec.rb +0 -0
  104. data/spec/groupdocs/signature/template_spec.rb +0 -0
  105. data/spec/groupdocs/signature_spec.rb +0 -0
  106. data/spec/groupdocs/storage/file_spec.rb +0 -0
  107. data/spec/groupdocs/storage/folder_spec.rb +0 -0
  108. data/spec/groupdocs/storage/package_spec.rb +0 -0
  109. data/spec/groupdocs/storage_spec.rb +0 -0
  110. data/spec/groupdocs/subscription/limit_spec.rb +0 -0
  111. data/spec/groupdocs/subscription_spec.rb +0 -0
  112. data/spec/groupdocs/user_spec.rb +62 -37
  113. data/spec/groupdocs_spec.rb +0 -0
  114. data/spec/spec_helper.rb +0 -0
  115. data/spec/support/files/envelope.zip +0 -0
  116. data/spec/support/files/resume.pdf +0 -0
  117. data/spec/support/json/annotation_access_set.json +0 -0
  118. data/spec/support/json/annotation_collaborators_get.json +0 -0
  119. data/spec/support/json/annotation_collaborators_set.json +0 -0
  120. data/spec/support/json/annotation_create.json +0 -0
  121. data/spec/support/json/annotation_list.json +0 -0
  122. data/spec/support/json/annotation_move.json +0 -0
  123. data/spec/support/json/annotation_remove.json +0 -0
  124. data/spec/support/json/annotation_replies_create.json +0 -0
  125. data/spec/support/json/annotation_replies_get.json +0 -0
  126. data/spec/support/json/annotation_reviewers_get.json +18 -0
  127. data/spec/support/json/comparison_changes.json +0 -0
  128. data/spec/support/json/comparison_compare.json +0 -0
  129. data/spec/support/json/comparison_document.json +0 -0
  130. data/spec/support/json/contact_add.json +0 -0
  131. data/spec/support/json/contacts_get.json +0 -0
  132. data/spec/support/json/contacts_import.json +0 -0
  133. data/spec/support/json/datasource_add.json +0 -0
  134. data/spec/support/json/datasource_get.json +0 -0
  135. data/spec/support/json/datasource_remove.json +0 -0
  136. data/spec/support/json/datasource_update.json +0 -0
  137. data/spec/support/json/document_access_info_get.json +0 -0
  138. data/spec/support/json/document_convert.json +0 -0
  139. data/spec/support/json/document_datasource.json +0 -0
  140. data/spec/support/json/document_fields.json +0 -0
  141. data/spec/support/json/document_formats.json +0 -0
  142. data/spec/support/json/document_metadata.json +0 -0
  143. data/spec/support/json/document_questionnaire_create.json +0 -0
  144. data/spec/support/json/document_questionnaires.json +0 -0
  145. data/spec/support/json/document_sharers_remove.json +0 -0
  146. data/spec/support/json/document_sharers_set.json +0 -0
  147. data/spec/support/json/document_views.json +0 -0
  148. data/spec/support/json/envelope_get.json +0 -0
  149. data/spec/support/json/envelope_logs.json +0 -0
  150. data/spec/support/json/envelopes_all.json +0 -0
  151. data/spec/support/json/envelopes_resources.json +0 -0
  152. data/spec/support/json/file_compress.json +0 -0
  153. data/spec/support/json/file_copy.json +0 -0
  154. data/spec/support/json/file_delete.json +0 -0
  155. data/spec/support/json/file_move.json +0 -0
  156. data/spec/support/json/file_upload.json +0 -0
  157. data/spec/support/json/folder_create.json +0 -0
  158. data/spec/support/json/folder_delete.json +0 -0
  159. data/spec/support/json/folder_list.json +0 -0
  160. data/spec/support/json/folder_move.json +0 -0
  161. data/spec/support/json/folder_sharers_get.json +0 -0
  162. data/spec/support/json/folder_sharers_remove.json +0 -0
  163. data/spec/support/json/folder_sharers_set.json +0 -0
  164. data/spec/support/json/form_get.json +0 -0
  165. data/spec/support/json/forms_all.json +0 -0
  166. data/spec/support/json/job_add_url.json +0 -0
  167. data/spec/support/json/job_create.json +0 -0
  168. data/spec/support/json/job_documents.json +0 -0
  169. data/spec/support/json/job_file_add.json +0 -0
  170. data/spec/support/json/job_get.json +0 -0
  171. data/spec/support/json/job_update.json +0 -0
  172. data/spec/support/json/jobs_get.json +0 -0
  173. data/spec/support/json/list_add.json +0 -0
  174. data/spec/support/json/lists_get.json +0 -0
  175. data/spec/support/json/package_create.json +0 -0
  176. data/spec/support/json/questionnaire_create.json +0 -0
  177. data/spec/support/json/questionnaire_datasources.json +0 -0
  178. data/spec/support/json/questionnaire_execution_create.json +0 -0
  179. data/spec/support/json/questionnaire_execution_status_set.json +0 -0
  180. data/spec/support/json/questionnaire_execution_update.json +0 -0
  181. data/spec/support/json/questionnaire_executions.json +0 -0
  182. data/spec/support/json/questionnaire_get.json +0 -0
  183. data/spec/support/json/questionnaire_remove.json +0 -0
  184. data/spec/support/json/questionnaire_update.json +0 -0
  185. data/spec/support/json/questionnaires_get.json +0 -0
  186. data/spec/support/json/signature_create.json +0 -0
  187. data/spec/support/json/signature_field_add.json +0 -0
  188. data/spec/support/json/signature_fields_get.json +0 -0
  189. data/spec/support/json/signature_roles_get.json +0 -0
  190. data/spec/support/json/signatures_get.json +0 -0
  191. data/spec/support/json/storage_info.json +0 -0
  192. data/spec/support/json/subscription_plan_get.json +0 -0
  193. data/spec/support/json/subscription_plans_get.json +0 -0
  194. data/spec/support/json/template_get.json +0 -0
  195. data/spec/support/json/template_get_documents.json +0 -0
  196. data/spec/support/json/template_get_recipients.json +0 -0
  197. data/spec/support/json/templates_all.json +0 -0
  198. data/spec/support/json/user_profile_get.json +0 -0
  199. data/spec/support/json/user_users_get.json +0 -0
  200. data/spec/support/shared_examples/api/entity.rb +0 -0
  201. data/spec/support/shared_examples/api/helpers/access_mode_helper.rb +0 -0
  202. data/spec/support/shared_examples/api/helpers/status_helper.rb +0 -0
  203. data/spec/support/shared_examples/signature/shared/document_methods.rb +0 -0
  204. data/spec/support/shared_examples/signature/shared/entity_fields.rb +0 -0
  205. data/spec/support/shared_examples/signature/shared/entity_methods.rb +0 -0
  206. data/spec/support/shared_examples/signature/shared/field_methods.rb +0 -0
  207. data/spec/support/shared_examples/signature/shared/recipient_methods.rb +0 -0
  208. data/spec/support/shared_examples/signature/shared/resource_methods.rb +0 -0
  209. metadata +72 -24
  210. data/lib/groupdocs/api/helpers/actions_helper.rb +0 -48
  211. data/spec/groupdocs/api/helpers/actions_helper_spec.rb +0 -37
@@ -1,6 +1,8 @@
1
1
  module GroupDocs
2
2
  class User < Api::Entity
3
3
 
4
+ include Api::Helpers::AccessRights
5
+
4
6
  #
5
7
  # Returns current user profile.
6
8
  #
@@ -54,12 +56,37 @@ module GroupDocs
54
56
  attr_accessor :news_enabled
55
57
  # @attr [Time] signed_up_on
56
58
  attr_accessor :signed_up_on
59
+ # @attr [Integer] color
60
+ attr_accessor :color
61
+ # @attr [String] customEmailMessage
62
+ attr_accessor :customEmailMessage
57
63
 
58
64
  # Human-readable accessors
59
- alias_method :first_name, :firstname
60
- alias_method :first_name=, :firstname=
61
- alias_method :last_name, :lastname
62
- alias_method :last_name=, :lastname=
65
+ alias_method :first_name, :firstname
66
+ alias_method :first_name=, :firstname=
67
+ alias_method :last_name, :lastname
68
+ alias_method :last_name=, :lastname=
69
+ alias_method :custom_email_message, :customEmailMessage
70
+ alias_method :custom_email_message=, :customEmailMessage=
71
+
72
+ #
73
+ # Converts access rights to human-readable format flag.
74
+ # @return [Array<Symbol>]
75
+ #
76
+ def access_rights
77
+ convert_byte_to_access_rights @access_rights if @access_rights
78
+ end
79
+
80
+ #
81
+ # Converts access rights to machine-readable format flag.
82
+ # @param [Array<Symbol>] rights
83
+ #
84
+ def access_rights=(rights)
85
+ if rights.is_a?(Array)
86
+ rights = convert_access_rights_to_byte(rights)
87
+ end
88
+ @access_rights = rights
89
+ end
63
90
 
64
91
  #
65
92
  # Converts timestamp which is return by API server to Time object.
@@ -1,3 +1,3 @@
1
1
  module GroupDocs
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end # GroupDocs
data/lib/groupdocs.rb CHANGED
File without changes
File without changes
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GroupDocs::Api::Helpers::AccessMode do
4
-
5
4
  subject do
6
5
  GroupDocs::Storage::Folder.new
7
6
  end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Api::Helpers::AccessRights do
4
+ subject do
5
+ GroupDocs::User.new
6
+ end
7
+
8
+ describe '#convert_access_rights_to_byte' do
9
+ let(:rights) { %w(export view proof download) }
10
+
11
+ it 'raises error if rights is not an array' do
12
+ -> { subject.send(:convert_access_rights_to_byte, :export) }.should raise_error(ArgumentError)
13
+ end
14
+
15
+ it 'raises error if right is unknown' do
16
+ -> { subject.send(:convert_access_rights_to_byte, %w(unknown)) }.should raise_error(ArgumentError)
17
+ end
18
+
19
+ it 'converts each right to Symbol' do
20
+ rights.each do |right|
21
+ symbol = right.to_sym
22
+ right.should_receive(:to_sym).and_return(symbol)
23
+ end
24
+ subject.send(:convert_access_rights_to_byte, rights)
25
+ end
26
+
27
+ it 'returns correct byte flag' do
28
+ subject.send(:convert_access_rights_to_byte, rights).should == 15
29
+ end
30
+ end
31
+
32
+ describe '#convert_byte_to_access_rights' do
33
+ let(:rights) { %w(export view proof) }
34
+
35
+ it 'raises error if rights is not an integer' do
36
+ -> { subject.send(:convert_byte_to_access_rights, :export) }.should raise_error(ArgumentError)
37
+ end
38
+
39
+ it 'returns correct rights array flag' do
40
+ subject.send(:convert_byte_to_access_rights, 13).should =~ rights.map(&:to_sym)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Api::Helpers::ByteFlag do
4
+ subject do
5
+ GroupDocs::User.new
6
+ end
7
+
8
+ let(:value_to_byte) { GroupDocs::Api::Helpers::AccessRights::ACCESS_RIGHTS }
9
+
10
+ describe '#byte_from_array' do
11
+ it 'returns correct byte flag' do
12
+ values = value_to_byte.map { |k, _| k }
13
+ subject.byte_from_array(values, value_to_byte).should == 15
14
+ end
15
+ end
16
+
17
+ describe '#array_from_byte' do
18
+ it 'returns correct byte flag' do
19
+ values = subject.array_from_byte(15, value_to_byte)
20
+ values.should =~ value_to_byte.map { |k, _| k }
21
+ end
22
+ end
23
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Document::Annotation::Reviewer do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ describe '.all!' do
8
+ before(:each) do
9
+ mock_api_server(load_json('annotation_reviewers_get'))
10
+ end
11
+
12
+ it 'accepts access credentials hash' do
13
+ lambda do
14
+ described_class.all!(client_id: 'client_id', private_key: 'private_key')
15
+ end.should_not raise_error(ArgumentError)
16
+ end
17
+
18
+ it 'returns an array of GroupDocs::Document::Annotation::Reviewer objects' do
19
+ reviewers = described_class.all!
20
+ reviewers.should be_an(Array)
21
+ reviewers.each do |reviewer|
22
+ reviewer.should be_a(GroupDocs::Document::Annotation::Reviewer)
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '.set!' do
28
+ before(:each) do
29
+ mock_api_server(load_json('annotation_reviewers_get'))
30
+ end
31
+
32
+ let!(:reviewers) { [described_class.new(email_address: 'test@test.com')] }
33
+
34
+ it 'accepts access credentials hash' do
35
+ lambda do
36
+ described_class.set!(reviewers, client_id: 'client_id', private_key: 'private_key')
37
+ end.should_not raise_error(ArgumentError)
38
+ end
39
+
40
+ it 'uses hashed version of reviewers' do
41
+ reviewers.each do |reviewer|
42
+ reviewer.should_receive(:to_hash)
43
+ end
44
+ described_class.set! reviewers
45
+ end
46
+ end
47
+
48
+ it { should respond_to(:emailAddress) }
49
+ it { should respond_to(:emailAddress=) }
50
+ it { should respond_to(:FullName) }
51
+ it { should respond_to(:FullName=) }
52
+
53
+ it { should have_alias(:email_address, :emailAddress) }
54
+ it { should have_alias(:email_address=, :emailAddress=) }
55
+ it { should have_alias(:full_name, :FullName) }
56
+ it { should have_alias(:full_name=, :FullName=) }
57
+ end
@@ -184,50 +184,6 @@ describe GroupDocs::Document::Annotation do
184
184
  end
185
185
  end
186
186
 
187
- describe '#collaborators!' do
188
- before(:each) do
189
- mock_api_server(load_json('annotation_collaborators_get'))
190
- end
191
-
192
- it 'accepts access credentials hash' do
193
- lambda do
194
- subject.collaborators!(client_id: 'client_id', private_key: 'private_key')
195
- end.should_not raise_error(ArgumentError)
196
- end
197
-
198
- it 'returns an array of GroupDocs::User objects' do
199
- users = subject.collaborators!
200
- users.should be_an(Array)
201
- users.each do |user|
202
- user.should be_a(GroupDocs::User)
203
- end
204
- end
205
- end
206
-
207
- describe '#collaborators_set!' do
208
- before(:each) do
209
- mock_api_server(load_json('annotation_collaborators_set'))
210
- end
211
-
212
- it 'accepts access credentials hash' do
213
- lambda do
214
- subject.collaborators_set!(%w(test1@email.com), client_id: 'client_id', private_key: 'private_key')
215
- end.should_not raise_error(ArgumentError)
216
- end
217
-
218
- it 'returns an array of GroupDocs::User objects' do
219
- users = subject.collaborators_set!(%w(test1@email.com))
220
- users.should be_an(Array)
221
- users.each do |user|
222
- user.should be_a(GroupDocs::User)
223
- end
224
- end
225
-
226
- it 'is aliased to #collaborators=' do
227
- subject.should have_alias(:collaborators=, :collaborators_set!)
228
- end
229
- end
230
-
231
187
  describe '#remove!' do
232
188
  before(:each) do
233
189
  mock_api_server(load_json('annotation_remove'))
@@ -265,6 +221,18 @@ describe GroupDocs::Document::Annotation do
265
221
  end
266
222
  end
267
223
 
224
+ describe '#move_marker!' do
225
+ before(:each) do
226
+ mock_api_server('{ "status": "Ok", "result": {}}')
227
+ end
228
+
229
+ it 'accepts access credentials hash' do
230
+ lambda do
231
+ subject.move_marker!(10, 10, client_id: 'client_id', private_key: 'private_key')
232
+ end.should_not raise_error(ArgumentError)
233
+ end
234
+ end
235
+
268
236
  describe '#set_access!' do
269
237
  before(:each) do
270
238
  mock_api_server(load_json('annotation_access_set'))
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -494,6 +494,144 @@ describe GroupDocs::Document do
494
494
  end
495
495
  end
496
496
 
497
+
498
+ describe '#collaborators!' do
499
+ before(:each) do
500
+ mock_api_server(load_json('annotation_collaborators_get'))
501
+ end
502
+
503
+ it 'accepts access credentials hash' do
504
+ lambda do
505
+ subject.collaborators!(client_id: 'client_id', private_key: 'private_key')
506
+ end.should_not raise_error(ArgumentError)
507
+ end
508
+
509
+ it 'returns an array of GroupDocs::User objects' do
510
+ users = subject.collaborators!
511
+ users.should be_an(Array)
512
+ users.each do |user|
513
+ user.should be_a(GroupDocs::User)
514
+ end
515
+ end
516
+ end
517
+
518
+ describe '#set_collaborators!' do
519
+ before(:each) do
520
+ mock_api_server(load_json('annotation_collaborators_set'))
521
+ end
522
+
523
+ it 'accepts access credentials hash' do
524
+ lambda do
525
+ subject.set_collaborators!(%w(test1@email.com), 1, client_id: 'client_id', private_key: 'private_key')
526
+ end.should_not raise_error(ArgumentError)
527
+ end
528
+
529
+ it 'accepts version' do
530
+ lambda do
531
+ subject.set_collaborators!(%w(test1@email.com), 1)
532
+ end.should_not raise_error(ArgumentError)
533
+ end
534
+
535
+ it 'returns an array of GroupDocs::User objects' do
536
+ users = subject.set_collaborators!(%w(test1@email.com))
537
+ users.should be_an(Array)
538
+ users.each do |user|
539
+ user.should be_a(GroupDocs::User)
540
+ end
541
+ end
542
+ end
543
+
544
+ describe '#add_collaborator!' do
545
+ before(:each) do
546
+ mock_api_server(load_json('annotation_collaborators_get'))
547
+ end
548
+
549
+ let!(:collaborator) { GroupDocs::User.new }
550
+
551
+ it 'accepts access credentials hash' do
552
+ lambda do
553
+ subject.add_collaborator!(collaborator, client_id: 'client_id', private_key: 'private_key')
554
+ end.should_not raise_error(ArgumentError)
555
+ end
556
+
557
+ it 'uses hashed version of collaborator as request body' do
558
+ collaborator.should_receive(:to_hash)
559
+ subject.add_collaborator! collaborator
560
+ end
561
+
562
+ it 'raises error if collaborator is not an instance of GroupDocs::User' do
563
+ -> { subject.add_collaborator!('collaborator') }.should raise_error(ArgumentError)
564
+ end
565
+ end
566
+
567
+ describe '#set_reviewers!' do
568
+ before(:each) do
569
+ mock_api_server('{ "status": "Ok", "result": {}}')
570
+ end
571
+
572
+ let!(:reviewers) { [GroupDocs::User.new, GroupDocs::User.new] }
573
+
574
+ it 'accepts access credentials hash' do
575
+ lambda do
576
+ subject.set_reviewers!(reviewers, client_id: 'client_id', private_key: 'private_key')
577
+ end.should_not raise_error(ArgumentError)
578
+ end
579
+
580
+ it 'uses hashed version of each reviewer as request body' do
581
+ reviewers.each do |reviewer|
582
+ reviewer.should_receive(:to_hash)
583
+ end
584
+ subject.set_reviewers! reviewers
585
+ end
586
+ end
587
+
588
+ describe '#shared_link_access_rights!' do
589
+ before(:each) do
590
+ mock_api_server('{ "status": "Ok", "result": { "accessRights": 15 }}')
591
+ end
592
+
593
+ it 'accepts access credentials hash' do
594
+ lambda do
595
+ subject.shared_link_access_rights!(client_id: 'client_id', private_key: 'private_key')
596
+ end.should_not raise_error(ArgumentError)
597
+ end
598
+
599
+ it 'converts response byte flag into array of access rights' do
600
+ subject.should_receive(:convert_byte_to_access_rights).with(15)
601
+ subject.shared_link_access_rights!
602
+ end
603
+
604
+ it 'returns array of access rights symbols' do
605
+ access_rights = subject.shared_link_access_rights!
606
+ access_rights.should be_an(Array)
607
+ access_rights.each do |access_right|
608
+ access_right.should be_a(Symbol)
609
+ end
610
+ end
611
+
612
+ it 'returns empty array if access rights is null' do
613
+ mock_api_server('{ "status": "Ok", "result": { "accessRights": null }}')
614
+ subject.shared_link_access_rights!.should be_empty
615
+ end
616
+ end
617
+
618
+ describe '#set_shared_link_access_rights!' do
619
+ before(:each) do
620
+ mock_api_server('{ "status": "Ok", "result": {}}')
621
+ end
622
+
623
+ it 'accepts access credentials hash' do
624
+ lambda do
625
+ subject.set_shared_link_access_rights!(%w(view), client_id: 'client_id', private_key: 'private_key')
626
+ end.should_not raise_error(ArgumentError)
627
+ end
628
+
629
+ it 'converts array of access rights into byte flag' do
630
+ subject.should_receive(:convert_access_rights_to_byte).with(%w(view))
631
+ subject.set_shared_link_access_rights! %w(view)
632
+ end
633
+ end
634
+
497
635
  describe '#method_missing' do
498
636
  it 'passes unknown methods to file object' do
499
637
  -> { subject.name }.should_not raise_error(NoMethodError)
File without changes
@@ -268,9 +268,51 @@ describe GroupDocs::Job do
268
268
  mock_api_server(load_json('job_update'))
269
269
  end
270
270
 
271
+ it 'accepts access credentials hash' do
272
+ lambda do
273
+ subject.update!({}, client_id: 'client_id', private_key: 'private_key')
274
+ end.should_not raise_error(ArgumentError)
275
+ end
276
+
271
277
  it 'parses status' do
272
278
  subject.should_receive(:parse_status).with(:draft).and_return(-1)
273
279
  subject.update!(status: :draft)
274
280
  end
275
281
  end
282
+
283
+ describe '#delete!' do
284
+ before(:each) do
285
+ mock_api_server('{ "status": "Ok", "result": {} }')
286
+ end
287
+
288
+ it 'accepts access credentials hash' do
289
+ lambda do
290
+ subject.delete!(client_id: 'client_id', private_key: 'private_key')
291
+ end.should_not raise_error(ArgumentError)
292
+ end
293
+ end
294
+
295
+ describe '#convert_actions_to_byte' do
296
+ let(:actions) { %w(convert compare) }
297
+
298
+ it 'raises error if actions is not an array' do
299
+ -> { described_class.convert_actions_to_byte(:export) }.should raise_error(ArgumentError)
300
+ end
301
+
302
+ it 'raises error if action is unknown' do
303
+ -> { described_class.convert_actions_to_byte(%w(unknown)) }.should raise_error(ArgumentError)
304
+ end
305
+
306
+ it 'converts each action to Symbol' do
307
+ actions.each do |action|
308
+ symbol = action.to_sym
309
+ action.should_receive(:to_sym).and_return(symbol)
310
+ end
311
+ described_class.convert_actions_to_byte(actions)
312
+ end
313
+
314
+ it 'returns correct byte flag' do
315
+ described_class.convert_actions_to_byte(actions).should == 257
316
+ end
317
+ end
276
318
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -20,46 +20,71 @@ describe GroupDocs::User do
20
20
  end
21
21
  end
22
22
 
23
- it { should respond_to(:id) }
24
- it { should respond_to(:id=) }
25
- it { should respond_to(:guid) }
26
- it { should respond_to(:guid=) }
27
- it { should respond_to(:nickname) }
28
- it { should respond_to(:nickname=) }
29
- it { should respond_to(:firstname) }
30
- it { should respond_to(:firstname=) }
31
- it { should respond_to(:lastname) }
32
- it { should respond_to(:lastname=) }
33
- it { should respond_to(:primary_email) }
34
- it { should respond_to(:primary_email=) }
35
- it { should respond_to(:private_key) }
36
- it { should respond_to(:private_key=) }
37
- it { should respond_to(:password_salt) }
38
- it { should respond_to(:password_salt=) }
39
- it { should respond_to(:claimed_id) }
40
- it { should respond_to(:claimed_id=) }
41
- it { should respond_to(:token) }
42
- it { should respond_to(:token=) }
43
- it { should respond_to(:storage) }
44
- it { should respond_to(:storage=) }
45
- it { should respond_to(:photo) }
46
- it { should respond_to(:photo=) }
47
- it { should respond_to(:active) }
48
- it { should respond_to(:active=) }
49
- it { should respond_to(:news_enabled) }
50
- it { should respond_to(:news_enabled=) }
51
- it { should respond_to(:signed_up_on) }
52
- it { should respond_to(:signed_up_on=) }
53
-
54
- it { should have_alias(:first_name, :firstname) }
55
- it { should have_alias(:first_name=, :firstname=) }
56
- it { should have_alias(:last_name, :lastname) }
57
- it { should have_alias(:last_name=, :lastname=) }
58
-
59
- it { should have_alias(:pkey=, :private_key=) }
23
+ it { should respond_to(:id) }
24
+ it { should respond_to(:id=) }
25
+ it { should respond_to(:guid) }
26
+ it { should respond_to(:guid=) }
27
+ it { should respond_to(:nickname) }
28
+ it { should respond_to(:nickname=) }
29
+ it { should respond_to(:firstname) }
30
+ it { should respond_to(:firstname=) }
31
+ it { should respond_to(:lastname) }
32
+ it { should respond_to(:lastname=) }
33
+ it { should respond_to(:primary_email) }
34
+ it { should respond_to(:primary_email=) }
35
+ it { should respond_to(:private_key) }
36
+ it { should respond_to(:private_key=) }
37
+ it { should respond_to(:password_salt) }
38
+ it { should respond_to(:password_salt=) }
39
+ it { should respond_to(:claimed_id) }
40
+ it { should respond_to(:claimed_id=) }
41
+ it { should respond_to(:token) }
42
+ it { should respond_to(:token=) }
43
+ it { should respond_to(:storage) }
44
+ it { should respond_to(:storage=) }
45
+ it { should respond_to(:photo) }
46
+ it { should respond_to(:photo=) }
47
+ it { should respond_to(:active) }
48
+ it { should respond_to(:active=) }
49
+ it { should respond_to(:news_enabled) }
50
+ it { should respond_to(:news_enabled=) }
51
+ it { should respond_to(:signed_up_on) }
52
+ it { should respond_to(:signed_up_on=) }
53
+ it { should respond_to(:color) }
54
+ it { should respond_to(:color=) }
55
+ it { should respond_to(:customEmailMessage) }
56
+ it { should respond_to(:customEmailMessage=) }
57
+
58
+ it { should have_alias(:first_name, :firstname) }
59
+ it { should have_alias(:first_name=, :firstname=) }
60
+ it { should have_alias(:last_name, :lastname) }
61
+ it { should have_alias(:last_name=, :lastname=) }
62
+ it { should have_alias(:custom_email_message, :customEmailMessage) }
63
+ it { should have_alias(:custom_email_message=, :customEmailMessage=) }
64
+
65
+ it { should have_alias(:pkey=, :private_key=) }
60
66
  it { should have_alias(:pswd_salt=, :password_salt=) }
61
67
  it { should have_alias(:signedupOn=, :signed_up_on=) }
62
68
 
69
+ describe '#access_rights' do
70
+ it 'returns rights in human-readable format' do
71
+ subject.instance_variable_set(:@access_rights, 15)
72
+ subject.access_rights.should =~ [:export, :view, :proof, :download]
73
+ end
74
+ end
75
+
76
+ describe '#access_rights=' do
77
+ it 'converts rights in machine-readable format if array is passed' do
78
+ subject.access_rights = %w(export view proof download)
79
+ subject.instance_variable_get(:@access_rights).should == 15
80
+ end
81
+
82
+ it 'does nothing if not array is passed' do
83
+ subject.access_rights = 15
84
+ subject.instance_variable_get(:@access_rights).should == 15
85
+ end
86
+ end
87
+
63
88
  describe '#signed_up_on' do
64
89
  it 'returns converted to Time object Unix timestamp' do
65
90
  subject.signed_up_on = 1330450135000
File without changes