groupdocs 1.9.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CHANGELOG.md +13 -0
  2. data/README.md +1 -1
  3. data/examples/api-samples/Gemfile +1 -1
  4. data/examples/api-samples/Gemfile.lock +29 -23
  5. data/examples/api-samples/public/css/style.css +10 -2
  6. data/examples/api-samples/public/docs/sample11.html +11 -7
  7. data/examples/api-samples/samples/sample11.rb +4 -6
  8. data/examples/api-samples/views/_others_samples.haml +231 -91
  9. data/examples/api-samples/views/index.haml +230 -92
  10. data/examples/api-samples/views/sample07.haml +1 -1
  11. data/examples/api-samples/web.rb +1 -0
  12. data/groupdocs.gemspec +2 -2
  13. data/lib/groupdocs/api.rb +1 -0
  14. data/lib/groupdocs/document.rb +12 -0
  15. data/lib/groupdocs/document/annotation.rb +5 -0
  16. data/lib/groupdocs/document/annotation/marker.rb +1 -1
  17. data/lib/groupdocs/document/editor.rb +13 -1
  18. data/lib/groupdocs/document/metadata.rb +6 -0
  19. data/lib/groupdocs/document/option.rb +9 -0
  20. data/lib/groupdocs/signature/form.rb +4 -6
  21. data/lib/groupdocs/storage/file.rb +1 -2
  22. data/lib/groupdocs/version.rb +1 -1
  23. data/spec/groupdocs/api/helpers/access_rights_helper_spec.rb +3 -3
  24. data/spec/groupdocs/api/helpers/byte_flag_helper_spec.rb +2 -2
  25. data/spec/groupdocs/datasource_spec.rb +5 -46
  26. data/spec/groupdocs/document/annotation/reply_spec.rb +5 -5
  27. data/spec/groupdocs/document/annotation/reviewer_spec.rb +2 -2
  28. data/spec/groupdocs/document/annotation_spec.rb +11 -43
  29. data/spec/groupdocs/document_spec.rb +61 -298
  30. data/spec/groupdocs/job_spec.rb +20 -74
  31. data/spec/groupdocs/questionnaire/collector_spec.rb +8 -8
  32. data/spec/groupdocs/questionnaire/execution_spec.rb +6 -6
  33. data/spec/groupdocs/questionnaire_spec.rb +28 -58
  34. data/spec/groupdocs/signature/contact_spec.rb +7 -7
  35. data/spec/groupdocs/signature/envelope_spec.rb +30 -34
  36. data/spec/groupdocs/signature/field_spec.rb +5 -5
  37. data/spec/groupdocs/signature/form_spec.rb +28 -16
  38. data/spec/groupdocs/signature/list_spec.rb +3 -3
  39. data/spec/groupdocs/signature/role_spec.rb +2 -2
  40. data/spec/groupdocs/signature/template_spec.rb +4 -4
  41. data/spec/groupdocs/signature_spec.rb +7 -20
  42. data/spec/groupdocs/storage/file_spec.rb +24 -80
  43. data/spec/groupdocs/storage/folder_spec.rb +14 -14
  44. data/spec/groupdocs/storage/package_spec.rb +2 -2
  45. data/spec/groupdocs/storage_spec.rb +1 -1
  46. data/spec/groupdocs/subscription_spec.rb +4 -123
  47. data/spec/groupdocs/user_spec.rb +14 -243
  48. data/spec/spec_helper.rb +4 -0
  49. data/spec/support/json/annotation_marker_move.json +11 -0
  50. data/spec/support/json/envelope_recipient_add.json +27 -0
  51. data/spec/support/json/job_documents.json +35 -103
  52. data/spec/support/shared_examples/signature/shared/document_methods.rb +4 -4
  53. data/spec/support/shared_examples/signature/shared/entity_methods.rb +10 -10
  54. data/spec/support/shared_examples/signature/shared/field_methods.rb +14 -18
  55. data/spec/support/shared_examples/signature/shared/recipient_methods.rb +3 -3
  56. data/spec/support/shared_examples/signature/shared/resource_methods.rb +2 -2
  57. metadata +13 -7
@@ -12,6 +12,12 @@ module GroupDocs
12
12
  # @attr [Hash] last_view
13
13
  attr_accessor :last_view
14
14
 
15
+ # added in release 2.0.0
16
+ # @attr [String] type
17
+ attr_accessor :type
18
+ # @attr [String] url
19
+ attr_accessor :url
20
+
15
21
  #
16
22
  # Coverts passed hash to GroupDocs::Document::View object.
17
23
  #
@@ -0,0 +1,9 @@
1
+ # added in release 2.0.0
2
+ module GroupDocs
3
+ class Document::TemplateEditorFieldOption < Api::Entity
4
+ # @attr [String] name
5
+ attr_accessor :name
6
+ # @attr [GroupDocs::Document::Rectangle] rect
7
+ attr_accessor :rect
8
+ end # Document::TemplateEditorFieldOption
9
+ end # GroupDocs
@@ -266,19 +266,17 @@ module GroupDocs
266
266
  end
267
267
 
268
268
  #
269
- # Changed in release 1.7.0
269
+ # Changed in release 2.0.0
270
270
  #
271
271
  # Returns an array of fields for document per participant.
272
- #
273
- # @param [GroupDocs::Document] document
272
+ #
274
273
  # @param [Hash] options
275
274
  # @option options [String] :field Field GUID
276
275
  # @param [Hash] access Access credentials
277
276
  # @option access [String] :client_id
278
277
  # @option access [String] :private_key
279
- # @raise [ArgumentError] if document is not GroupDocs::Document
280
278
  #
281
- def fields!(options = {}, access = {})
279
+ def get_fields!(options = {}, access = {})
282
280
 
283
281
  api = Api::Request.new do |request|
284
282
  request[:access] = access
@@ -391,7 +389,7 @@ module GroupDocs
391
389
  Api::Request.new do |request|
392
390
  request[:access] = access
393
391
  request[:method] = :POST
394
- request[:path] = "/signature/{{client_id}}/forms/#{form.id}/templates/#{template.id}"
392
+ request[:path] = "/signature/{{client_id}}/forms/#{id}/templates/#{template.id}"
395
393
  end.execute!
396
394
  end
397
395
 
@@ -30,8 +30,7 @@ module GroupDocs
30
30
  # @option options [String] path Folder path to upload to
31
31
  # @option options [String] name Name of file to be renamed
32
32
  # @option options [String] :description File description
33
- # @option options [String] :callbackUrl will be called after file is uploaded
34
- # @option options [String] :isKeepBothMode
33
+ # @option options [String] :callbackUrl will be called after file is uploaded
35
34
  # @param [Hash] access Access credentials
36
35
  # @option access [String] :client_id
37
36
  # @option access [String] :private_key
@@ -1,3 +1,3 @@
1
1
  module GroupDocs
2
- VERSION = '1.9.0'
2
+ VERSION = '2.0.0'
3
3
  end # GroupDocs
@@ -9,7 +9,7 @@ describe GroupDocs::Api::Helpers::AccessRights do
9
9
  let(:rights) { %w(view annotate download export all) }
10
10
 
11
11
  it 'raises error if rights is not an array' do
12
- lambda { subject.send(:convert_access_rights_to_byte, :view) }.should raise_error(ArgumentError)
12
+ lambda { subject.send(:convert_access_rights_to_byte, :export) }.should raise_error(ArgumentError)
13
13
  end
14
14
 
15
15
  it 'raises error if right is unknown' do
@@ -30,14 +30,14 @@ describe GroupDocs::Api::Helpers::AccessRights do
30
30
  end
31
31
 
32
32
  describe '#convert_byte_to_access_rights' do
33
- let(:rights) { %w(view annotate download export) }
33
+ let(:rights) { %w(download export view) }
34
34
 
35
35
  it 'raises error if rights is not an integer' do
36
36
  lambda { subject.send(:convert_byte_to_access_rights, :export) }.should raise_error(ArgumentError)
37
37
  end
38
38
 
39
39
  it 'returns correct rights array flag' do
40
- subject.send(:convert_byte_to_access_rights, 15).should =~ rights.map(&:to_sym)
40
+ subject.send(:convert_byte_to_access_rights, 13).should =~ rights.map(&:to_sym)
41
41
  end
42
42
  end
43
43
  end
@@ -10,13 +10,13 @@ describe GroupDocs::Api::Helpers::ByteFlag do
10
10
  describe '#byte_from_array' do
11
11
  it 'returns correct byte flag' do
12
12
  values = value_to_byte.map { |k, _| k }
13
- subject.byte_from_array(values, value_to_byte).should == 15
13
+ subject.byte_from_array(values, value_to_byte).should == 46
14
14
  end
15
15
  end
16
16
 
17
17
  describe '#array_from_byte' do
18
18
  it 'returns correct byte flag' do
19
- values = subject.array_from_byte(15, value_to_byte)
19
+ values = subject.array_from_byte(46, value_to_byte)
20
20
  values.should =~ value_to_byte.map { |k, _| k }
21
21
  end
22
22
  end
@@ -12,13 +12,13 @@ describe GroupDocs::DataSource do
12
12
  it 'accepts access credentials hash' do
13
13
  lambda do
14
14
  described_class.get!(1, {}, :client_id => 'client_id', :private_key => 'private_key')
15
- end.should_not raise_error(ArgumentError)
15
+ end.should_not raise_error()
16
16
  end
17
17
 
18
18
  it 'accepts options hash' do
19
19
  lambda do
20
20
  described_class.get!(1, :field => %w(field1 field2))
21
- end.should_not raise_error(ArgumentError)
21
+ end.should_not raise_error()
22
22
  end
23
23
 
24
24
  it 'returns GroupDocs::DataSource object if datasource is found' do
@@ -99,7 +99,7 @@ describe GroupDocs::DataSource do
99
99
  it 'accepts access credentials hash' do
100
100
  lambda do
101
101
  subject.add!(:client_id => 'client_id', :private_key => 'private_key')
102
- end.should_not raise_error(ArgumentError)
102
+ end.should_not raise_error()
103
103
  end
104
104
 
105
105
  it 'uses hashed version of self as request body' do
@@ -122,24 +122,7 @@ describe GroupDocs::DataSource do
122
122
  it 'accepts access credentials hash' do
123
123
  lambda do
124
124
  subject.update!(:client_id => 'client_id', :private_key => 'private_key')
125
- end.should_not raise_error(ArgumentError)
126
- end
127
-
128
- it 'uses hashed version of self as request body' do
129
- subject.should_receive(:to_hash)
130
- subject.add!
131
- end
132
- end
133
-
134
- describe '#update_fields!' do
135
- before(:each) do
136
- mock_api_server(load_json('datasource_update'))
137
- end
138
-
139
- it 'accepts access credentials hash' do
140
- lambda do
141
- subject.update_fields!(:client_id => 'client_id', :private_key => 'private_key')
142
- end.should_not raise_error(ArgumentError)
125
+ end.should_not raise_error()
143
126
  end
144
127
 
145
128
  it 'uses hashed version of self as request body' do
@@ -156,31 +139,7 @@ describe GroupDocs::DataSource do
156
139
  it 'accepts access credentials hash' do
157
140
  lambda do
158
141
  subject.remove!(:client_id => 'client_id', :private_key => 'private_key')
159
- end.should_not raise_error(ArgumentError)
160
- end
161
- end
162
-
163
- describe '#add_datasource!' do
164
- before(:each) do
165
- mock_api_server(load_json('datasource_update'))
166
- end
167
-
168
- it 'accepts access credentials hash' do
169
- lambda do
170
- subject.add_datasource!(job, file_id, datasource, :client_id => 'client_id', :private_key => 'private_key')
171
- end.should_not raise_error(ArgumentError)
172
- end
173
- end
174
-
175
- describe '#add_datasource_fields!' do
176
- before(:each) do
177
- mock_api_server(load_json('datasource_update'))
178
- end
179
-
180
- it 'accepts access credentials hash' do
181
- lambda do
182
- subject.add_datasource_fields!(job, file_id, datasource, :client_id => 'client_id', :private_key => 'private_key')
183
- end.should_not raise_error(ArgumentError)
142
+ end.should_not raise_error()
184
143
  end
185
144
  end
186
145
  end
@@ -24,13 +24,13 @@ describe GroupDocs::Document::Annotation::Reply do
24
24
  it 'accepts access credentials hash' do
25
25
  lambda do
26
26
  described_class.get!(annotation, {}, :client_id => 'client_id', :private_key => 'private_key')
27
- end.should_not raise_error(ArgumentError)
27
+ end.should_not raise_error()
28
28
  end
29
29
 
30
30
  it 'accepts options hash' do
31
31
  lambda do
32
32
  described_class.get!(annotation, :after => Time.now)
33
- end.should_not raise_error(ArgumentError)
33
+ end.should_not raise_error()
34
34
  end
35
35
 
36
36
  it 'raises error if annotation is not an instance of GroupDocs::Document::Annotation' do
@@ -97,7 +97,7 @@ describe GroupDocs::Document::Annotation::Reply do
97
97
  it 'accepts access credentials hash' do
98
98
  lambda do
99
99
  subject.create!(:client_id => 'client_id', :private_key => 'private_key')
100
- end.should_not raise_error(ArgumentError)
100
+ end.should_not raise_error()
101
101
  end
102
102
 
103
103
  it 'gets annotation guid' do
@@ -123,7 +123,7 @@ describe GroupDocs::Document::Annotation::Reply do
123
123
  it 'accepts access credentials hash' do
124
124
  lambda do
125
125
  subject.edit!(:client_id => 'client_id', :private_key => 'private_key')
126
- end.should_not raise_error(ArgumentError)
126
+ end.should_not raise_error()
127
127
  end
128
128
  end
129
129
 
@@ -135,7 +135,7 @@ describe GroupDocs::Document::Annotation::Reply do
135
135
  it 'accepts access credentials hash' do
136
136
  lambda do
137
137
  subject.remove!(:client_id => 'client_id', :private_key => 'private_key')
138
- end.should_not raise_error(ArgumentError)
138
+ end.should_not raise_error()
139
139
  end
140
140
  end
141
141
 
@@ -12,7 +12,7 @@ describe GroupDocs::Document::Annotation::Reviewer do
12
12
  it 'accepts access credentials hash' do
13
13
  lambda do
14
14
  described_class.all!(:client_id => 'client_id', :private_key => 'private_key')
15
- end.should_not raise_error(ArgumentError)
15
+ end.should_not raise_error()
16
16
  end
17
17
 
18
18
  it 'returns an array of GroupDocs::Document::Annotation::Reviewer objects' do
@@ -34,7 +34,7 @@ describe GroupDocs::Document::Annotation::Reviewer do
34
34
  it 'accepts access credentials hash' do
35
35
  lambda do
36
36
  described_class.set!(reviewers, :client_id => 'client_id', :private_key => 'private_key')
37
- end.should_not raise_error(ArgumentError)
37
+ end.should_not raise_error()
38
38
  end
39
39
 
40
40
  it 'uses hashed version of reviewers' do
@@ -33,7 +33,6 @@ describe GroupDocs::Document::Annotation do
33
33
  it { should have_alias(:created_on=, :createdOn=) }
34
34
  it { should alias_accessor(:annotation_position, :annotationPosition) }
35
35
 
36
-
37
36
  it { should have_alias(:annotationGuid=, :guid=) }
38
37
 
39
38
  describe '#initialize' do
@@ -144,14 +143,13 @@ describe GroupDocs::Document::Annotation do
144
143
 
145
144
  it 'accepts access credentials hash' do
146
145
  lambda do
147
- subject.create!('info', :client_id => 'client_id', :private_key => 'private_key')
148
- end.should_not raise_error(ArgumentError)
146
+ subject.create!(%w(info), :client_id => 'client_id', :private_key => 'private_key')
147
+ end.should_not raise_error()
149
148
  end
150
149
 
151
-
152
150
  it 'updated self with response values' do
153
151
  lambda do
154
- subject.create!('info')
152
+ subject.create! :box => '10', :annotationPosition => '100'
155
153
  end.should change {
156
154
  subject.id
157
155
  subject.guid
@@ -170,7 +168,7 @@ describe GroupDocs::Document::Annotation do
170
168
  it 'accepts access credentials hash' do
171
169
  lambda do
172
170
  subject.remove!(:client_id => 'client_id', :private_key => 'private_key')
173
- end.should_not raise_error(ArgumentError)
171
+ end.should_not raise_error()
174
172
  end
175
173
  end
176
174
 
@@ -189,7 +187,7 @@ describe GroupDocs::Document::Annotation do
189
187
  it 'accepts access credentials hash' do
190
188
  lambda do
191
189
  subject.move!(10, 10, :client_id => 'client_id', :private_key => 'private_key')
192
- end.should_not raise_error(ArgumentError)
190
+ end.should_not raise_error()
193
191
  end
194
192
 
195
193
  it 'updates annotation position' do
@@ -204,47 +202,17 @@ describe GroupDocs::Document::Annotation do
204
202
  mock_api_server('{ "status": "Ok", "result": {}}')
205
203
  end
206
204
 
205
+ let(:marker) { GroupDocs::Document::Annotation::MarkerPosition.new(:position => {:x => 1, :y => 1}, :page=>1)}
206
+ 1
207
207
  it 'accepts access credentials hash' do
208
208
  lambda do
209
209
  subject.move_marker!(marker, :client_id => 'client_id', :private_key => 'private_key')
210
- end.should_not raise_error(ArgumentError)
211
- end
212
- end
213
-
214
- describe '#resize!' do
215
- before(:each) do
216
- mock_api_server('{ "status": "Ok", "result": {}}')
210
+ end.should_not raise_error()
217
211
  end
218
-
219
- it 'accepts access credentials hash' do
220
- lambda do
221
- subject.resize!(10, 10, :client_id => 'client_id', :private_key => 'private_key')
222
- end.should_not raise_error(ArgumentError)
212
+ it 'raises error if marker is not GroupDocs::Document::Annotation::MarkerPosition object' do
213
+ lambda { subject.move_marker!(['MarkerPosition']) }.should raise_error(ArgumentError)
223
214
  end
224
- end
225
215
 
226
- describe '#text_info!' do
227
- before(:each) do
228
- mock_api_server('{ "status": "Ok", "result": {}}')
229
- end
230
-
231
- it 'accepts access credentials hash' do
232
- lambda do
233
- subject.text_info!(fieldText, fontFamily, fontSize, :client_id => 'client_id', :private_key => 'private_key')
234
- end.should_not raise_error(ArgumentError)
235
- end
236
- end
237
-
238
- describe '#text_color!' do
239
- before(:each) do
240
- mock_api_server('{ "status": "Ok", "result": {}}')
241
- end
242
-
243
- it 'accepts access credentials hash' do
244
- lambda do
245
- subject.text_color!(font_color :client_id => 'client_id', :private_key => 'private_key')
246
- end.should_not raise_error(ArgumentError)
247
- end
248
216
  end
249
217
 
250
218
  describe '#set_access!' do
@@ -255,7 +223,7 @@ describe GroupDocs::Document::Annotation do
255
223
  it 'accepts access credentials hash' do
256
224
  lambda do
257
225
  subject.set_access!(:private, :client_id => 'client_id', :private_key => 'private_key')
258
- end.should_not raise_error(ArgumentError)
226
+ end.should_not raise_error()
259
227
  end
260
228
 
261
229
  it 'updates annotation access mode' do
@@ -18,7 +18,7 @@ describe GroupDocs::Document do
18
18
  it 'accepts access credentials hash' do
19
19
  lambda do
20
20
  described_class.views!({}, :client_id => 'client_id', :private_key => 'private_key')
21
- end.should_not raise_error(ArgumentError)
21
+ end.should_not raise_error()
22
22
  end
23
23
 
24
24
  it 'returns an array of GroupDocs::Document::View objects' do
@@ -38,7 +38,7 @@ describe GroupDocs::Document do
38
38
  it 'accepts access credentials hash' do
39
39
  lambda do
40
40
  described_class.templates!(:client_id => 'client_id', :private_key => 'private_key')
41
- end.should_not raise_error(ArgumentError)
41
+ end.should_not raise_error()
42
42
  end
43
43
 
44
44
  it 'returns an array of GroupDocs::Document objects' do
@@ -64,7 +64,7 @@ describe GroupDocs::Document do
64
64
  it 'accepts access credentials hash' do
65
65
  lambda do
66
66
  described_class.sign_documents!(documents, signatures, {}, :client_id => 'client_id', :private_key => 'private_key')
67
- end.should_not raise_error(ArgumentError)
67
+ end.should_not raise_error()
68
68
  end
69
69
 
70
70
  it 'raises error if document is not GroupDocs::Document object' do
@@ -105,9 +105,11 @@ describe GroupDocs::Document do
105
105
  signatures.each { |signature| described_class.should_receive(:mime_type).with(signature.image_path).once }
106
106
  described_class.sign_documents!(documents, signatures)
107
107
  end
108
+
109
+
108
110
  end
109
111
 
110
- describe '.metadata!' do
112
+ describe ',metadata!' do
111
113
  before(:each) do
112
114
  mock_api_server(load_json('document_metadata'))
113
115
  end
@@ -115,7 +117,7 @@ describe GroupDocs::Document do
115
117
  it 'accepts access credentials hash' do
116
118
  lambda do
117
119
  described_class.metadata!('document_one.doc', :client_id => 'client_id', :private_key => 'private_key')
118
- end.should_not raise_error(ArgumentError)
120
+ end.should_not raise_error()
119
121
  end
120
122
 
121
123
  it 'returns GroupDocs::Document::MetaData object' do
@@ -226,13 +228,13 @@ describe GroupDocs::Document do
226
228
  it 'accepts access credentials hash' do
227
229
  lambda do
228
230
  subject.page_images!(640, 480, {}, :client_id => 'client_id', :private_key => 'private_key')
229
- end.should_not raise_error(ArgumentError)
231
+ end.should_not raise_error()
230
232
  end
231
233
 
232
234
  it 'accepts options hash' do
233
235
  lambda do
234
236
  subject.page_images!(640, 480, :first_page => 0, :page_count => 1)
235
- end.should_not raise_error(ArgumentError)
237
+ end.should_not raise_error()
236
238
  end
237
239
 
238
240
  it 'returns array of URLs' do
@@ -252,13 +254,13 @@ describe GroupDocs::Document do
252
254
  it 'accepts access credentials hash' do
253
255
  lambda do
254
256
  subject.thumbnails!({}, :client_id => 'client_id', :private_key => 'private_key')
255
- end.should_not raise_error(ArgumentError)
257
+ end.should_not raise_error()
256
258
  end
257
259
 
258
260
  it 'accepts options hash' do
259
261
  lambda do
260
262
  subject.thumbnails!(:page_number => 0, :page_count => 1)
261
- end.should_not raise_error(ArgumentError)
263
+ end.should_not raise_error()
262
264
  end
263
265
 
264
266
  it 'returns array of URLs' do
@@ -278,7 +280,7 @@ describe GroupDocs::Document do
278
280
  it 'accepts access credentials hash' do
279
281
  lambda do
280
282
  subject.access_mode!(:client_id => 'client_id', :private_key => 'private_key')
281
- end.should_not raise_error(ArgumentError)
283
+ end.should_not raise_error()
282
284
  end
283
285
 
284
286
  it 'returns access mode in human readable presentation' do
@@ -295,7 +297,7 @@ describe GroupDocs::Document do
295
297
  it 'accepts access credentials hash' do
296
298
  lambda do
297
299
  subject.access_mode_set!(:private, :client_id => 'client_id', :private_key => 'private_key')
298
- end.should_not raise_error(ArgumentError)
300
+ end.should_not raise_error()
299
301
  end
300
302
 
301
303
  it 'sets corresponding access mode' do
@@ -321,7 +323,7 @@ describe GroupDocs::Document do
321
323
  it 'accepts access credentials hash' do
322
324
  lambda do
323
325
  subject.formats!(:client_id => 'client_id', :private_key => 'private_key')
324
- end.should_not raise_error(ArgumentError)
326
+ end.should_not raise_error()
325
327
  end
326
328
 
327
329
  it 'returns an array of symbols' do
@@ -341,7 +343,7 @@ describe GroupDocs::Document do
341
343
  it 'accepts access credentials hash' do
342
344
  lambda do
343
345
  subject.metadata!(:client_id => 'client_id', :private_key => 'private_key')
344
- end.should_not raise_error(ArgumentError)
346
+ end.should_not raise_error()
345
347
  end
346
348
 
347
349
  it 'returns GroupDocs::Document::MetaData object' do
@@ -352,6 +354,10 @@ describe GroupDocs::Document do
352
354
  subject.metadata!.last_view.should be_a(GroupDocs::Document::View)
353
355
  end
354
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
+
355
361
  it 'does not set last view if document has never been viewed' do
356
362
  mock_api_server('{ "status": "Ok", "result": { "last_view": null }}')
357
363
  subject.metadata!.last_view.should be_nil
@@ -366,7 +372,7 @@ describe GroupDocs::Document do
366
372
  it 'accepts access credentials hash' do
367
373
  lambda do
368
374
  subject.fields!(:client_id => 'client_id', :private_key => 'private_key')
369
- end.should_not raise_error(ArgumentError)
375
+ end.should_not raise_error()
370
376
  end
371
377
 
372
378
  it 'returns array of GroupDocs::Document::Field objects' do
@@ -386,7 +392,7 @@ describe GroupDocs::Document do
386
392
  it 'accepts access credentials hash' do
387
393
  lambda do
388
394
  subject.sharers!(:client_id => 'client_id', :private_key => 'private_key')
389
- end.should_not raise_error(ArgumentError)
395
+ end.should_not raise_error()
390
396
  end
391
397
 
392
398
  it 'returns an array of GroupDocs::User objects' do
@@ -406,7 +412,7 @@ describe GroupDocs::Document do
406
412
  it 'accepts access credentials hash' do
407
413
  lambda do
408
414
  subject.sharers_set!(%w(test1@email.com), :client_id => 'client_id', :private_key => 'private_key')
409
- end.should_not raise_error(ArgumentError)
415
+ end.should_not raise_error()
410
416
  end
411
417
 
412
418
  it 'returns an array of GroupDocs::User objects' do
@@ -436,7 +442,7 @@ describe GroupDocs::Document do
436
442
  it 'accepts access credentials hash' do
437
443
  lambda do
438
444
  subject.sharers_clear!(:client_id => 'client_id', :private_key => 'private_key')
439
- end.should_not raise_error(ArgumentError)
445
+ end.should_not raise_error()
440
446
  end
441
447
 
442
448
  it 'clears sharers list and returns nil' do
@@ -452,13 +458,13 @@ describe GroupDocs::Document do
452
458
  it 'accepts access credentials hash' do
453
459
  lambda do
454
460
  subject.convert!(:pdf, {}, :client_id => 'client_id', :private_key => 'private_key')
455
- end.should_not raise_error(ArgumentError)
461
+ end.should_not raise_error()
456
462
  end
457
463
 
458
464
  it 'accepts options hash' do
459
465
  lambda do
460
466
  subject.convert!(:pdf, :email_results => true)
461
- end.should_not raise_error(ArgumentError)
467
+ end.should_not raise_error()
462
468
  end
463
469
 
464
470
  it 'returns GroupDocs::Job object' do
@@ -474,7 +480,7 @@ describe GroupDocs::Document do
474
480
  it 'accepts access credentials hash' do
475
481
  lambda do
476
482
  subject.questionnaires!(:client_id => 'client_id', :private_key => 'private_key')
477
- end.should_not raise_error(ArgumentError)
483
+ end.should_not raise_error()
478
484
  end
479
485
 
480
486
  it 'returns an array of GroupDocs::Questionnaire objects' do
@@ -487,6 +493,10 @@ describe GroupDocs::Document do
487
493
  end
488
494
 
489
495
  describe '#add_questionnaire!' do
496
+ before(:each) do
497
+ mock_api_server('{ "status": "Ok", "result": {}}')
498
+ end
499
+
490
500
  let(:questionnaire) do
491
501
  GroupDocs::Questionnaire.new(:id => 1)
492
502
  end
@@ -494,7 +504,7 @@ describe GroupDocs::Document do
494
504
  it 'accepts access credentials hash' do
495
505
  lambda do
496
506
  subject.add_questionnaire!(questionnaire, :client_id => 'client_id', :private_key => 'private_key')
497
- end.should_not raise_error(ArgumentError)
507
+ end.should_not raise_error()
498
508
  end
499
509
 
500
510
  it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
@@ -514,7 +524,7 @@ describe GroupDocs::Document do
514
524
  it 'accepts access credentials hash' do
515
525
  lambda do
516
526
  subject.create_questionnaire!(questionnaire, :client_id => 'client_id', :private_key => 'private_key')
517
- end.should_not raise_error(ArgumentError)
527
+ end.should_not raise_error()
518
528
  end
519
529
 
520
530
  it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
@@ -538,6 +548,10 @@ describe GroupDocs::Document do
538
548
  end
539
549
 
540
550
  describe '#remove_questionnaire!' do
551
+ before(:each) do
552
+ mock_api_server('{ "status": "Ok", "result": {}}')
553
+ end
554
+
541
555
  let(:questionnaire) do
542
556
  GroupDocs::Questionnaire.new(:id => 1)
543
557
  end
@@ -545,7 +559,7 @@ describe GroupDocs::Document do
545
559
  it 'accepts access credentials hash' do
546
560
  lambda do
547
561
  subject.remove_questionnaire!(questionnaire, :client_id => 'client_id', :private_key => 'private_key')
548
- end.should_not raise_error(ArgumentError)
562
+ end.should_not raise_error()
549
563
  end
550
564
 
551
565
  it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
@@ -565,44 +579,13 @@ describe GroupDocs::Document do
565
579
  it 'accepts access credentials hash' do
566
580
  lambda do
567
581
  subject.datasource!(datasource, {}, :client_id => 'client_id', :private_key => 'private_key')
568
- end.should_not raise_error(ArgumentError)
582
+ end.should_not raise_error()
569
583
  end
570
584
 
571
585
  it 'accepts options hash' do
572
586
  lambda do
573
587
  subject.datasource!(datasource, :new_type => :pdf)
574
- end.should_not raise_error(ArgumentError)
575
- end
576
-
577
- it 'raises error if datasource is not GroupDocs::Datasource object' do
578
- lambda { subject.datasource!('Datasource') }.should raise_error(ArgumentError)
579
- end
580
-
581
- it 'returns GroupDocs::Job object' do
582
- job = subject.datasource!(datasource)
583
- job.should be_a(GroupDocs::Job)
584
- end
585
- end
586
-
587
- describe '#datasource_fields!' do
588
- before(:each) do
589
- mock_api_server(load_json('document_datasource'))
590
- end
591
-
592
- let(:datasource) do
593
- GroupDocs::DataSource.new(:id => 1)
594
- end
595
-
596
- it 'accepts access credentials hash' do
597
- lambda do
598
- subject.datasource_fields!(datasource, {}, :client_id => 'client_id', :private_key => 'private_key')
599
- end.should_not raise_error(ArgumentError)
600
- end
601
-
602
- it 'accepts options hash' do
603
- lambda do
604
- subject.datasource_fields!(datasource, :new_type => :pdf)
605
- end.should_not raise_error(ArgumentError)
588
+ end.should_not raise_error()
606
589
  end
607
590
 
608
591
  it 'raises error if datasource is not GroupDocs::Datasource object' do
@@ -623,7 +606,7 @@ describe GroupDocs::Document do
623
606
  it 'accepts access credentials hash' do
624
607
  lambda do
625
608
  subject.annotations!(:client_id => 'client_id', :private_key => 'private_key')
626
- end.should_not raise_error(ArgumentError)
609
+ end.should_not raise_error()
627
610
  end
628
611
 
629
612
  it 'returns array of GroupDocs::Document::Annotation objects' do
@@ -648,7 +631,7 @@ describe GroupDocs::Document do
648
631
  it 'accepts access credentials hash' do
649
632
  lambda do
650
633
  subject.details!(:client_id => 'client_id', :private_key => 'private_key')
651
- end.should_not raise_error(ArgumentError)
634
+ end.should_not raise_error()
652
635
  end
653
636
 
654
637
  it 'returns hash of document details' do
@@ -667,13 +650,17 @@ describe GroupDocs::Document do
667
650
 
668
651
  it 'accepts access credentials hash' do
669
652
  lambda do
670
- subject.compare!(document, callback, :client_id => 'client_id', :private_key => 'private_key')
671
- end.should_not raise_error(ArgumentError)
653
+ subject.compare!(document, 'callback', :client_id => 'client_id', :private_key => 'private_key')
654
+ end.should_not raise_error()
672
655
  end
673
656
 
674
657
  it 'raises error if document is not GroupDocs::Document object' do
675
658
  lambda { subject.compare!('Document') }.should raise_error(ArgumentError)
676
659
  end
660
+
661
+ it 'returns GroupDocs::Job object' do
662
+ subject.compare!(document, 'callback').should be_a(GroupDocs::Job)
663
+ end
677
664
  end
678
665
 
679
666
  describe '#changes!' do
@@ -684,7 +671,7 @@ describe GroupDocs::Document do
684
671
  it 'accepts access credentials hash' do
685
672
  lambda do
686
673
  subject.changes!(:client_id => 'client_id', :private_key => 'private_key')
687
- end.should_not raise_error(ArgumentError)
674
+ end.should_not raise_error()
688
675
  end
689
676
 
690
677
  it 'returns array of GroupDocs::Document::Change objects' do
@@ -696,24 +683,6 @@ describe GroupDocs::Document do
696
683
  end
697
684
  end
698
685
 
699
- describe '#update_changes!' do
700
- before(:each) do
701
- mock_api_server(load_json('comparison_changes'))
702
- end
703
-
704
- it 'accepts access credentials hash' do
705
- lambda do
706
- subject.changes!(options, :client_id => 'client_id', :private_key => 'private_key')
707
- end.should_not raise_error(ArgumentError)
708
- end
709
-
710
- it 'accepts options credentials hash' do
711
- lambda do
712
- subject.changes!(:id => 1, :type => 'delete', :action => '', :page => {}, :box => {}, :text => '')
713
- end.should_not raise_error(ArgumentError)
714
- end
715
- end
716
-
717
686
 
718
687
  describe '#collaborators!' do
719
688
  before(:each) do
@@ -723,7 +692,7 @@ describe GroupDocs::Document do
723
692
  it 'accepts access credentials hash' do
724
693
  lambda do
725
694
  subject.collaborators!(:client_id => 'client_id', :private_key => 'private_key')
726
- end.should_not raise_error(ArgumentError)
695
+ end.should_not raise_error()
727
696
  end
728
697
 
729
698
  it 'returns an array of GroupDocs::User objects' do
@@ -743,13 +712,13 @@ describe GroupDocs::Document do
743
712
  it 'accepts access credentials hash' do
744
713
  lambda do
745
714
  subject.set_collaborators!(%w(test1@email.com), 1, :client_id => 'client_id', :private_key => 'private_key')
746
- end.should_not raise_error(ArgumentError)
715
+ end.should_not raise_error()
747
716
  end
748
717
 
749
718
  it 'accepts version' do
750
719
  lambda do
751
720
  subject.set_collaborators!(%w(test1@email.com), 1)
752
- end.should_not raise_error(ArgumentError)
721
+ end.should_not raise_error()
753
722
  end
754
723
 
755
724
  it 'returns an array of GroupDocs::User objects' do
@@ -763,7 +732,7 @@ describe GroupDocs::Document do
763
732
 
764
733
  describe '#add_collaborator!' do
765
734
  before(:each) do
766
- mock_api_server(load_json('annotation_collaborators_add'))
735
+ mock_api_server(load_json('annotation_collaborators_get'))
767
736
  end
768
737
 
769
738
  let!(:collaborator) { GroupDocs::User.new }
@@ -771,7 +740,7 @@ describe GroupDocs::Document do
771
740
  it 'accepts access credentials hash' do
772
741
  lambda do
773
742
  subject.add_collaborator!(collaborator, :client_id => 'client_id', :private_key => 'private_key')
774
- end.should_not raise_error(ArgumentError)
743
+ end.should_not raise_error()
775
744
  end
776
745
 
777
746
  it 'uses hashed version of collaborator as request body' do
@@ -784,18 +753,6 @@ describe GroupDocs::Document do
784
753
  end
785
754
  end
786
755
 
787
- describe '#remove_collaborators!' do
788
- before(:each) do
789
- mock_api_server(load_json('annotation_collaborators_clear'))
790
- end
791
-
792
- it 'accepts access credentials hash' do
793
- lambda do
794
- subject.remove_collaborators!(reviewerId, :client_id => 'client_id', :private_key => 'private_key')
795
- end.should_not raise_error(ArgumentError)
796
- end
797
- end
798
-
799
756
  describe '#set_reviewers!' do
800
757
  before(:each) do
801
758
  mock_api_server('{ "status": "Ok", "result": {}}')
@@ -806,7 +763,7 @@ describe GroupDocs::Document do
806
763
  it 'accepts access credentials hash' do
807
764
  lambda do
808
765
  subject.set_reviewers!(reviewers, :client_id => 'client_id', :private_key => 'private_key')
809
- end.should_not raise_error(ArgumentError)
766
+ end.should_not raise_error()
810
767
  end
811
768
 
812
769
  it 'uses hashed version of each reviewer as request body' do
@@ -825,7 +782,7 @@ describe GroupDocs::Document do
825
782
  it 'accepts access credentials hash' do
826
783
  lambda do
827
784
  subject.shared_link_access_rights!(:client_id => 'client_id', :private_key => 'private_key')
828
- end.should_not raise_error(ArgumentError)
785
+ end.should_not raise_error()
829
786
  end
830
787
 
831
788
  it 'converts response byte flag into array of access rights' do
@@ -855,7 +812,7 @@ describe GroupDocs::Document do
855
812
  it 'accepts access credentials hash' do
856
813
  lambda do
857
814
  subject.set_shared_link_access_rights!(%w(view), :client_id => 'client_id', :private_key => 'private_key')
858
- end.should_not raise_error(ArgumentError)
815
+ end.should_not raise_error()
859
816
  end
860
817
 
861
818
  it 'converts array of access rights into byte flag' do
@@ -872,13 +829,13 @@ describe GroupDocs::Document do
872
829
  it 'accepts access credentials hash' do
873
830
  lambda do
874
831
  subject.set_session_callback!('http://www.example.com', :client_id => 'client_id', :private_key => 'private_key')
875
- end.should_not raise_error(ArgumentError)
832
+ end.should_not raise_error()
876
833
  end
877
834
  end
878
835
 
879
836
  describe '#method_missing' do
880
837
  it 'passes unknown methods to file object' do
881
- lambda { subject.name }.should_not raise_error(NoMethodError)
838
+ lambda { subject.name }.should_not raise_error()
882
839
  end
883
840
 
884
841
  it 'raises NoMethodError if neither self nor file responds to method' do
@@ -888,209 +845,15 @@ describe GroupDocs::Document do
888
845
 
889
846
  describe '#respond_to?' do
890
847
  it 'returns true if self responds to method' do
891
- subject.respond_to?(:metadata!).should be_true
848
+ subject.respond_to?(:metadata!).should be_truthy
892
849
  end
893
850
 
894
851
  it 'returns true if file object responds to method' do
895
- subject.respond_to?(:name).should be_true
852
+ subject.respond_to?(:name).should be_truthy
896
853
  end
897
854
 
898
855
  it 'returns false if neither self nor file responds to method' do
899
- subject.respond_to?(:unknown).should be_false
900
- end
901
- end
902
-
903
- describe '#password_set!' do
904
- before(:each) do
905
- mock_api_server(load_json('document_password_set'))
906
- end
907
-
908
- it 'accepts access credentials hash' do
909
- lambda do
910
- subject.password_set(%w(password), :client_id => 'client_id', :private_key => 'private_key')
911
- end.should_not raise_error(ArgumentError)
856
+ subject.respond_to?(:unknown).should be_falsey
912
857
  end
913
858
  end
914
-
915
- describe '#user_status_set!' do
916
- before(:each) do
917
- mock_api_server(load_json('document_user_status_set'))
918
- end
919
-
920
- it 'accepts access credentials hash' do
921
- lambda do
922
- subject.user_status_set(%w(status), :client_id => 'client_id', :private_key => 'private_key')
923
- end.should_not raise_error(ArgumentError)
924
- end
925
- end
926
-
927
- describe '#shared_documents!' do
928
- before(:each) do
929
- mock_api_server(load_json('document_shared_documents_get'))
930
- end
931
-
932
- it 'accepts access credentials hash' do
933
- lambda do
934
- subject.shared_documents( :client_id => 'client_id', :private_key => 'private_key')
935
- end.should_not raise_error(ArgumentError)
936
- end
937
- end
938
-
939
- describe '#page_image!' do
940
- before(:each) do
941
- mock_api_server(File.read('spec/support/files/resume.pdf'))
942
- subject.stub(:name => 'resume.pdf')
943
- end
944
-
945
- let(:path) { Dir.tmpdir }
946
-
947
- it 'accepts access credentials hash' do
948
- lambda do
949
- subject.shared_documents( :client_id => 'client_id', :private_key => 'private_key')
950
- end.should_not raise_error(ArgumentError)
951
- end
952
- end
953
-
954
- describe '#page_fixed_html!' do
955
- before(:each) do
956
- mock_api_server(File.read('spec/support/files/resume.pdf'))
957
- subject.stub(:name => 'resume.pdf')
958
- end
959
-
960
- let(:path) { Dir.tmpdir }
961
-
962
- it 'accepts access credentials hash' do
963
- lambda do
964
- subject.shared_documents( :client_id => 'client_id', :private_key => 'private_key')
965
- end.should_not raise_error(ArgumentError)
966
- end
967
- end
968
-
969
- describe '#page_html!' do
970
- before(:each) do
971
- mock_api_server(File.read('spec/support/files/resume.pdf'))
972
- subject.stub(:name => 'resume.pdf')
973
- end
974
-
975
- let(:path) { Dir.tmpdir }
976
-
977
- it 'accepts access credentials hash' do
978
- lambda do
979
- subject.shared_documents( :client_id => 'client_id', :private_key => 'private_key')
980
- end.should_not raise_error(ArgumentError)
981
- end
982
- end
983
-
984
- describe '#editlock!' do
985
- before(:each) do
986
- mock_api_server(load_json('document_edit_lock_get'))
987
- end
988
-
989
- it 'accepts access credentials hash' do
990
- lambda do
991
- subject.editlock!( :client_id => 'client_id', :private_key => 'private_key')
992
- end.should_not raise_error(ArgumentError)
993
- end
994
- end
995
-
996
- describe 'editlock_clear!' do
997
- before(:each) do
998
- mock_api_server(load_json('document_edit_lock_get'))
999
- end
1000
-
1001
- it 'accepts access credentials hash' do
1002
- lambda do
1003
- subject.editlock_clear!( {}, :client_id => 'client_id', :private_key => 'private_key')
1004
- end.should_not raise_error(ArgumentError)
1005
- end
1006
-
1007
- it 'accepts options credentials hash' do
1008
- lambda do
1009
- subject.editlock_clear!(:lockId => 'client_id')
1010
- end.should_not raise_error(ArgumentError)
1011
- end
1012
- end
1013
-
1014
- describe '#tags!' do
1015
- before(:each) do
1016
- mock_api_server(load_json('document_edit_lock_get'))
1017
- end
1018
-
1019
- it 'accepts access credentials hash' do
1020
- lambda do
1021
- subject.tags!( :client_id => 'client_id', :private_key => 'private_key')
1022
- end.should_not raise_error(ArgumentError)
1023
- end
1024
- end
1025
-
1026
- describe '#tags_clear!' do
1027
- before(:each) do
1028
- mock_api_server(load_json('document_editlock_remove'))
1029
- end
1030
-
1031
- it 'accepts access credentials hash' do
1032
- lambda do
1033
- subject.tags_clear!( :client_id => 'client_id', :private_key => 'private_key')
1034
- end.should_not raise_error(ArgumentError)
1035
- end
1036
- end
1037
-
1038
- describe '#tags_set!' do
1039
- before(:each) do
1040
- mock_api_server(load_json('document_edit_lock_get'))
1041
- end
1042
-
1043
- it 'accepts access credentials hash' do
1044
- lambda do
1045
- subject.tags_set!( :client_id => 'client_id', :private_key => 'private_key')
1046
- end.should_not raise_error(ArgumentError)
1047
- end
1048
- end
1049
-
1050
- describe '#content!' do
1051
- before(:each) do
1052
- mock_api_server('{ "status": "Ok", "result": {}}')
1053
- end
1054
-
1055
- it 'accepts access credentials hash' do
1056
- lambda do
1057
- subject.tags_set!(content_type, :client_id => 'client_id', :private_key => 'private_key')
1058
- end.should_not raise_error(ArgumentError)
1059
- end
1060
- end
1061
-
1062
- describe 'page_html_urls!' do
1063
- before(:each) do
1064
- mock_api_server(load_json('document_html_urls'))
1065
- end
1066
-
1067
- it 'accepts access credentials hash' do
1068
- lambda do
1069
- subject.editlock_clear!( {}, :client_id => 'client_id', :private_key => 'private_key')
1070
- end.should_not raise_error(ArgumentError)
1071
- end
1072
-
1073
- it 'accepts options credentials hash' do
1074
- lambda do
1075
- subject.editlock_clear!(:first_page => 0, :page_count => 1)
1076
- end.should_not raise_error(ArgumentError)
1077
- end
1078
- end
1079
-
1080
- describe '#download!' do
1081
- before(:each) do
1082
- mock_api_server(File.read('spec/support/files/resume.pdf'))
1083
- subject.stub(:name => 'resume.pdf')
1084
- end
1085
-
1086
- let(:path) { Dir.tmpdir }
1087
-
1088
- it 'accepts access credentials hash' do
1089
- lambda do
1090
- subject.shared_documents( :client_id => 'client_id', :private_key => 'private_key')
1091
- end.should_not raise_error(ArgumentError)
1092
- end
1093
- end
1094
-
1095
-
1096
859
  end