groupdocs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/README.md +141 -0
- data/Rakefile +9 -0
- data/groupdocs.gemspec +28 -0
- data/lib/groupdocs.rb +53 -0
- data/lib/groupdocs/api.rb +3 -0
- data/lib/groupdocs/api/entity.rb +113 -0
- data/lib/groupdocs/api/helpers.rb +5 -0
- data/lib/groupdocs/api/helpers/access_helper.rb +56 -0
- data/lib/groupdocs/api/helpers/actions_helper.rb +48 -0
- data/lib/groupdocs/api/helpers/rest_helper.rb +89 -0
- data/lib/groupdocs/api/helpers/status_helper.rb +48 -0
- data/lib/groupdocs/api/helpers/url_helper.rb +89 -0
- data/lib/groupdocs/api/request.rb +73 -0
- data/lib/groupdocs/api/sugar/lookup.rb +48 -0
- data/lib/groupdocs/datasource.rb +162 -0
- data/lib/groupdocs/datasource/field.rb +44 -0
- data/lib/groupdocs/document.rb +513 -0
- data/lib/groupdocs/document/annotation.rb +215 -0
- data/lib/groupdocs/document/annotation/reply.rb +167 -0
- data/lib/groupdocs/document/change.rb +35 -0
- data/lib/groupdocs/document/field.rb +27 -0
- data/lib/groupdocs/document/metadata.rb +26 -0
- data/lib/groupdocs/document/rectangle.rb +24 -0
- data/lib/groupdocs/document/view.rb +36 -0
- data/lib/groupdocs/errors.rb +10 -0
- data/lib/groupdocs/job.rb +201 -0
- data/lib/groupdocs/questionnaire.rb +221 -0
- data/lib/groupdocs/questionnaire/execution.rb +120 -0
- data/lib/groupdocs/questionnaire/page.rb +43 -0
- data/lib/groupdocs/questionnaire/question.rb +75 -0
- data/lib/groupdocs/questionnaire/question/answer.rb +10 -0
- data/lib/groupdocs/storage.rb +37 -0
- data/lib/groupdocs/storage/file.rb +248 -0
- data/lib/groupdocs/storage/folder.rb +314 -0
- data/lib/groupdocs/storage/package.rb +42 -0
- data/lib/groupdocs/user.rb +50 -0
- data/lib/groupdocs/version.rb +3 -0
- data/spec/groupdocs/api/entity_spec.rb +54 -0
- data/spec/groupdocs/api/helpers/access_helper_spec.rb +89 -0
- data/spec/groupdocs/api/helpers/actions_helper_spec.rb +51 -0
- data/spec/groupdocs/api/helpers/rest_helper_spec.rb +187 -0
- data/spec/groupdocs/api/helpers/status_helper_spec.rb +85 -0
- data/spec/groupdocs/api/helpers/url_helper_spec.rb +93 -0
- data/spec/groupdocs/api/request_spec.rb +85 -0
- data/spec/groupdocs/datasource/field_spec.rb +50 -0
- data/spec/groupdocs/datasource_spec.rb +156 -0
- data/spec/groupdocs/document/annotation/reply_spec.rb +179 -0
- data/spec/groupdocs/document/annotation_spec.rb +226 -0
- data/spec/groupdocs/document/change_spec.rb +35 -0
- data/spec/groupdocs/document/field_spec.rb +31 -0
- data/spec/groupdocs/document/metadata_spec.rb +26 -0
- data/spec/groupdocs/document/rectangle_spec.rb +34 -0
- data/spec/groupdocs/document/view_spec.rb +36 -0
- data/spec/groupdocs/document_spec.rb +509 -0
- data/spec/groupdocs/errors_spec.rb +7 -0
- data/spec/groupdocs/job_spec.rb +196 -0
- data/spec/groupdocs/questionnaire/execution_spec.rb +136 -0
- data/spec/groupdocs/questionnaire/page_spec.rb +50 -0
- data/spec/groupdocs/questionnaire/question/answer_spec.rb +11 -0
- data/spec/groupdocs/questionnaire/question_spec.rb +84 -0
- data/spec/groupdocs/questionnaire_spec.rb +217 -0
- data/spec/groupdocs/storage/file_spec.rb +242 -0
- data/spec/groupdocs/storage/folder_spec.rb +310 -0
- data/spec/groupdocs/storage/package_spec.rb +41 -0
- data/spec/groupdocs/storage_spec.rb +27 -0
- data/spec/groupdocs/user_spec.rb +53 -0
- data/spec/groupdocs_spec.rb +56 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/support/files/resume.pdf +0 -0
- data/spec/support/json/annotation_collaborators_set.json +16 -0
- data/spec/support/json/annotation_create.json +12 -0
- data/spec/support/json/annotation_list.json +32 -0
- data/spec/support/json/annotation_remove.json +9 -0
- data/spec/support/json/annotation_replies_create.json +9 -0
- data/spec/support/json/annotation_replies_get.json +25 -0
- data/spec/support/json/comparison_changes.json +46 -0
- data/spec/support/json/comparison_compare.json +8 -0
- data/spec/support/json/comparison_document.json +10 -0
- data/spec/support/json/datasource_add.json +8 -0
- data/spec/support/json/datasource_get.json +22 -0
- data/spec/support/json/datasource_remove.json +8 -0
- data/spec/support/json/datasource_update.json +8 -0
- data/spec/support/json/document_access_info_get.json +14 -0
- data/spec/support/json/document_convert.json +8 -0
- data/spec/support/json/document_datasource.json +10 -0
- data/spec/support/json/document_fields.json +34 -0
- data/spec/support/json/document_formats.json +8 -0
- data/spec/support/json/document_metadata.json +15 -0
- data/spec/support/json/document_questionnaire_create.json +9 -0
- data/spec/support/json/document_questionnaires.json +23 -0
- data/spec/support/json/document_sharers_remove.json +8 -0
- data/spec/support/json/document_sharers_set.json +16 -0
- data/spec/support/json/document_views.json +32 -0
- data/spec/support/json/file_compress.json +8 -0
- data/spec/support/json/file_copy.json +14 -0
- data/spec/support/json/file_delete.json +5 -0
- data/spec/support/json/file_move.json +14 -0
- data/spec/support/json/file_upload.json +8 -0
- data/spec/support/json/folder_create.json +8 -0
- data/spec/support/json/folder_delete.json +5 -0
- data/spec/support/json/folder_list.json +21 -0
- data/spec/support/json/folder_move.json +8 -0
- data/spec/support/json/folder_sharers_get.json +16 -0
- data/spec/support/json/folder_sharers_remove.json +8 -0
- data/spec/support/json/folder_sharers_set.json +16 -0
- data/spec/support/json/job_add_url.json +8 -0
- data/spec/support/json/job_create.json +8 -0
- data/spec/support/json/job_documents.json +39 -0
- data/spec/support/json/job_file_add.json +8 -0
- data/spec/support/json/job_update.json +7 -0
- data/spec/support/json/jobs_get.json +52 -0
- data/spec/support/json/package_create.json +7 -0
- data/spec/support/json/questionnaire_create.json +8 -0
- data/spec/support/json/questionnaire_datasources.json +26 -0
- data/spec/support/json/questionnaire_execution_create.json +9 -0
- data/spec/support/json/questionnaire_execution_status_set.json +8 -0
- data/spec/support/json/questionnaire_execution_update.json +8 -0
- data/spec/support/json/questionnaire_executions.json +24 -0
- data/spec/support/json/questionnaire_get.json +14 -0
- data/spec/support/json/questionnaire_remove.json +8 -0
- data/spec/support/json/questionnaire_update.json +8 -0
- data/spec/support/json/questionnaires_get.json +22 -0
- data/spec/support/json/storage_info.json +10 -0
- data/spec/support/shared_examples/api/entity.rb +37 -0
- data/spec/support/shared_examples/api/helpers/status_helper.rb +12 -0
- data/spec/support/shared_examples/api/sugar/lookup.rb +57 -0
- metadata +356 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GroupDocs::Document::Annotation do
|
|
4
|
+
|
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
|
6
|
+
|
|
7
|
+
subject do
|
|
8
|
+
file = GroupDocs::Storage::File.new
|
|
9
|
+
document = GroupDocs::Document.new(file: file)
|
|
10
|
+
described_class.new(document: document)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it { should respond_to(:document) }
|
|
14
|
+
it { should respond_to(:document=) }
|
|
15
|
+
it { should respond_to(:id) }
|
|
16
|
+
it { should respond_to(:id=) }
|
|
17
|
+
it { should respond_to(:guid) }
|
|
18
|
+
it { should respond_to(:guid=) }
|
|
19
|
+
it { should respond_to(:sessionGuid) }
|
|
20
|
+
it { should respond_to(:sessionGuid=) }
|
|
21
|
+
it { should respond_to(:documentGuid) }
|
|
22
|
+
it { should respond_to(:documentGuid=) }
|
|
23
|
+
it { should respond_to(:replyGuid) }
|
|
24
|
+
it { should respond_to(:replyGuid=) }
|
|
25
|
+
it { should respond_to(:createdOn) }
|
|
26
|
+
it { should respond_to(:createdOn=) }
|
|
27
|
+
it { should respond_to(:type) }
|
|
28
|
+
it { should respond_to(:type=) }
|
|
29
|
+
it { should respond_to(:access) }
|
|
30
|
+
it { should respond_to(:access=) }
|
|
31
|
+
it { should respond_to(:box) }
|
|
32
|
+
it { should respond_to(:box=) }
|
|
33
|
+
it { should respond_to(:replies) }
|
|
34
|
+
it { should respond_to(:replies=) }
|
|
35
|
+
|
|
36
|
+
it 'has human-readable accessors' do
|
|
37
|
+
subject.should respond_to(:session_guid)
|
|
38
|
+
subject.should respond_to(:session_guid=)
|
|
39
|
+
subject.should respond_to(:document_guid)
|
|
40
|
+
subject.should respond_to(:document_guid=)
|
|
41
|
+
subject.should respond_to(:reply_guid)
|
|
42
|
+
subject.should respond_to(:reply_guid=)
|
|
43
|
+
subject.should respond_to(:created_on)
|
|
44
|
+
subject.should respond_to(:created_on=)
|
|
45
|
+
subject.method(:session_guid).should == subject.method(:sessionGuid)
|
|
46
|
+
subject.method(:session_guid=).should == subject.method(:sessionGuid=)
|
|
47
|
+
subject.method(:document_guid).should == subject.method(:documentGuid)
|
|
48
|
+
subject.method(:document_guid=).should == subject.method(:documentGuid=)
|
|
49
|
+
subject.method(:reply_guid).should == subject.method(:replyGuid)
|
|
50
|
+
subject.method(:reply_guid=).should == subject.method(:replyGuid=)
|
|
51
|
+
# Annotation#created_on is overwritten
|
|
52
|
+
subject.method(:created_on=).should == subject.method(:createdOn=)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'is compatible with response JSON' do
|
|
56
|
+
subject.should respond_to(:annotationGuid=)
|
|
57
|
+
subject.method(:annotationGuid=).should == subject.method(:guid=)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#initialize' do
|
|
61
|
+
it 'raises error if document is not specified' do
|
|
62
|
+
-> { described_class.new }.should raise_error(ArgumentError)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'raises error if document is not an instance of GroupDocs::Document' do
|
|
66
|
+
-> { described_class.new(document: '') }.should raise_error(ArgumentError)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe '#type=' do
|
|
71
|
+
it 'saves type in machine readable format if symbol is passed' do
|
|
72
|
+
subject.type = :area
|
|
73
|
+
subject.instance_variable_get(:@type).should == 1
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'does nothing if parameter is not symbol' do
|
|
77
|
+
subject.type = 1
|
|
78
|
+
subject.instance_variable_get(:@type).should == 1
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'raises error if type is unknown' do
|
|
82
|
+
-> { subject.type = :unknown }.should raise_error(ArgumentError)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe '#type' do
|
|
87
|
+
it 'returns type in human-readable format' do
|
|
88
|
+
subject.type = 1
|
|
89
|
+
subject.type.should == :area
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
describe '#created_on' do
|
|
94
|
+
it 'returns converted to Time object Unix timestamp' do
|
|
95
|
+
subject.created_on = 1332950825
|
|
96
|
+
subject.created_on.should be_a(Time)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'divides timestamp by 1000 because it is in milliseconds' do
|
|
100
|
+
subject.created_on = 1332950825000
|
|
101
|
+
subject.created_on.should == Time.at(1332950825)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe '#box=' do
|
|
106
|
+
it 'converts passed hash to GroupDocs::Document::Rectangle object' do
|
|
107
|
+
subject.box = { X: 0.90, Y: 0.05, Width: 0.06745, Height: 0.005967 }
|
|
108
|
+
subject.box.should be_a(GroupDocs::Document::Rectangle)
|
|
109
|
+
subject.box.x.should == 0.90
|
|
110
|
+
subject.box.y.should == 0.05
|
|
111
|
+
subject.box.w.should == 0.06745
|
|
112
|
+
subject.box.h.should == 0.005967
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe '#replies=' do
|
|
117
|
+
it 'converts each reply to GroupDocs::Document::Annotation::Reply object if hash is passed' do
|
|
118
|
+
subject.replies = [{ }]
|
|
119
|
+
replies = subject.replies
|
|
120
|
+
replies.should be_an(Array)
|
|
121
|
+
replies.each do |reply|
|
|
122
|
+
reply.should be_a(GroupDocs::Document::Annotation::Reply)
|
|
123
|
+
reply.annotation.should == subject
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it 'saves each reply if it is GroupDocs::Document::Annotation::Reply object' do
|
|
128
|
+
reply1 = GroupDocs::Document::Annotation::Reply.new(annotation: subject)
|
|
129
|
+
reply2 = GroupDocs::Document::Annotation::Reply.new(annotation: subject)
|
|
130
|
+
subject.replies = [reply1, reply2]
|
|
131
|
+
subject.replies.should include(reply1)
|
|
132
|
+
subject.replies.should include(reply2)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'does nothing if nil is passed' do
|
|
136
|
+
lambda do
|
|
137
|
+
subject.replies = nil
|
|
138
|
+
end.should_not change(subject, :replies)
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
describe '#add_reply' do
|
|
143
|
+
it 'raises error if reply is not GroupDocs::Document::Annotation::Reply object' do
|
|
144
|
+
-> { subject.add_reply('Reply') }.should raise_error(ArgumentError)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'saves reply' do
|
|
148
|
+
reply = GroupDocs::Document::Annotation::Reply.new(annotation: subject)
|
|
149
|
+
subject.add_reply(reply)
|
|
150
|
+
subject.replies.should == [reply]
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
describe '#create!' do
|
|
155
|
+
before(:each) do
|
|
156
|
+
mock_api_server(load_json('annotation_create'))
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'accepts access credentials hash' do
|
|
160
|
+
lambda do
|
|
161
|
+
subject.create!(client_id: 'client_id', private_key: 'private_key')
|
|
162
|
+
end.should_not raise_error(ArgumentError)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it 'uses hashed version of self as request body' do
|
|
166
|
+
subject.should_receive(:to_hash).and_return({})
|
|
167
|
+
subject.create!
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'updated self with response values' do
|
|
171
|
+
lambda do
|
|
172
|
+
subject.create!
|
|
173
|
+
end.should change {
|
|
174
|
+
subject.id
|
|
175
|
+
subject.guid
|
|
176
|
+
subject.document_guid
|
|
177
|
+
subject.reply_guid
|
|
178
|
+
subject.session_guid
|
|
179
|
+
}
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
describe '#collaborators_set!' do
|
|
184
|
+
before(:each) do
|
|
185
|
+
mock_api_server(load_json('annotation_collaborators_set'))
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it 'accepts access credentials hash' do
|
|
189
|
+
lambda do
|
|
190
|
+
subject.collaborators_set!(%w(test1@email.com), client_id: 'client_id', private_key: 'private_key')
|
|
191
|
+
end.should_not raise_error(ArgumentError)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
it 'returns an array of GroupDocs::User objects' do
|
|
195
|
+
users = subject.collaborators_set!(%w(test1@email.com))
|
|
196
|
+
users.should be_an(Array)
|
|
197
|
+
users.each do |user|
|
|
198
|
+
user.should be_a(GroupDocs::User)
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it 'is aliased to #collaborators=' do
|
|
203
|
+
subject.should respond_to(:collaborators=)
|
|
204
|
+
subject.method(:collaborators=).should == subject.method(:collaborators_set!)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
describe '#remove!' do
|
|
209
|
+
before(:each) do
|
|
210
|
+
mock_api_server(load_json('annotation_remove'))
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it 'accepts access credentials hash' do
|
|
214
|
+
lambda do
|
|
215
|
+
subject.remove!(client_id: 'client_id', private_key: 'private_key')
|
|
216
|
+
end.should_not raise_error(ArgumentError)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
describe '#replies!' do
|
|
221
|
+
it 'calls GroupDocs::Document::Annotation::Reply.get!' do
|
|
222
|
+
GroupDocs::Document::Annotation::Reply.should_receive(:get!).with(subject, {}, {})
|
|
223
|
+
subject.replies!
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GroupDocs::Document::Change do
|
|
4
|
+
|
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
|
6
|
+
|
|
7
|
+
it { should respond_to(:id) }
|
|
8
|
+
it { should respond_to(:id=) }
|
|
9
|
+
it { should respond_to(:type) }
|
|
10
|
+
it { should respond_to(:type=) }
|
|
11
|
+
it { should respond_to(:box) }
|
|
12
|
+
it { should respond_to(:box=) }
|
|
13
|
+
it { should respond_to(:text) }
|
|
14
|
+
it { should respond_to(:text=) }
|
|
15
|
+
it { should respond_to(:page) }
|
|
16
|
+
it { should respond_to(:page=) }
|
|
17
|
+
|
|
18
|
+
describe '#type' do
|
|
19
|
+
it 'returns type as symbol' do
|
|
20
|
+
subject.type = 'delete'
|
|
21
|
+
subject.type.should == :delete
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '#box=' do
|
|
26
|
+
it 'converts passed hash to GroupDocs::Document::Rectangle object' do
|
|
27
|
+
subject.box = { X: 0.90, Y: 0.05, Width: 0.06745, Height: 0.005967 }
|
|
28
|
+
subject.box.should be_a(GroupDocs::Document::Rectangle)
|
|
29
|
+
subject.box.x.should == 0.90
|
|
30
|
+
subject.box.y.should == 0.05
|
|
31
|
+
subject.box.w.should == 0.06745
|
|
32
|
+
subject.box.h.should == 0.005967
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GroupDocs::Document::Field do
|
|
4
|
+
|
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
|
6
|
+
|
|
7
|
+
it { should respond_to(:page) }
|
|
8
|
+
it { should respond_to(:page=) }
|
|
9
|
+
it { should respond_to(:name) }
|
|
10
|
+
it { should respond_to(:name=) }
|
|
11
|
+
it { should respond_to(:type) }
|
|
12
|
+
it { should respond_to(:type=) }
|
|
13
|
+
it { should respond_to(:rectangle) }
|
|
14
|
+
it { should respond_to(:rectangle=) }
|
|
15
|
+
|
|
16
|
+
it 'is compatible with response JSON' do
|
|
17
|
+
subject.should respond_to(:rect=)
|
|
18
|
+
subject.method(:rect=).should == subject.method(:rectangle=)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#rectangle=' do
|
|
22
|
+
it 'converts passed hash to GroupDocs::Document::Rectangle object' do
|
|
23
|
+
subject.rectangle = { X: 0.90, Y: 0.05, Width: 0.06745, Height: 0.005967 }
|
|
24
|
+
subject.rectangle.should be_a(GroupDocs::Document::Rectangle)
|
|
25
|
+
subject.rectangle.x.should == 0.90
|
|
26
|
+
subject.rectangle.y.should == 0.05
|
|
27
|
+
subject.rectangle.w.should == 0.06745
|
|
28
|
+
subject.rectangle.h.should == 0.005967
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GroupDocs::Document::MetaData do
|
|
4
|
+
|
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
|
6
|
+
|
|
7
|
+
it { should respond_to(:id) }
|
|
8
|
+
it { should respond_to(:id=) }
|
|
9
|
+
it { should respond_to(:guid) }
|
|
10
|
+
it { should respond_to(:guid=) }
|
|
11
|
+
it { should respond_to(:page_count) }
|
|
12
|
+
it { should respond_to(:page_count=) }
|
|
13
|
+
it { should respond_to(:views_count) }
|
|
14
|
+
it { should respond_to(:views_count=) }
|
|
15
|
+
it { should respond_to(:last_view) }
|
|
16
|
+
it { should respond_to(:last_view=) }
|
|
17
|
+
|
|
18
|
+
describe '#last_view=' do
|
|
19
|
+
it 'converts passed hash to GroupDocs::Document::View object' do
|
|
20
|
+
subject.last_view = { document: { id: 1, name: 'test.pdf' } }
|
|
21
|
+
subject.last_view.should be_a(GroupDocs::Document::View)
|
|
22
|
+
subject.last_view.document.id.should == 1
|
|
23
|
+
subject.last_view.document.name.should == 'test.pdf'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GroupDocs::Document::Rectangle do
|
|
4
|
+
|
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
|
6
|
+
|
|
7
|
+
it { should respond_to(:X) }
|
|
8
|
+
it { should respond_to(:X=) }
|
|
9
|
+
it { should respond_to(:Y) }
|
|
10
|
+
it { should respond_to(:Y=) }
|
|
11
|
+
it { should respond_to(:Width) }
|
|
12
|
+
it { should respond_to(:Width=) }
|
|
13
|
+
it { should respond_to(:Height) }
|
|
14
|
+
it { should respond_to(:Height=) }
|
|
15
|
+
|
|
16
|
+
it 'has human-readable accessors' do
|
|
17
|
+
subject.should respond_to(:x)
|
|
18
|
+
subject.should respond_to(:x=)
|
|
19
|
+
subject.should respond_to(:y)
|
|
20
|
+
subject.should respond_to(:y=)
|
|
21
|
+
subject.should respond_to(:w)
|
|
22
|
+
subject.should respond_to(:w=)
|
|
23
|
+
subject.should respond_to(:h)
|
|
24
|
+
subject.should respond_to(:h=)
|
|
25
|
+
subject.method(:x).should == subject.method(:X)
|
|
26
|
+
subject.method(:x=).should == subject.method(:X=)
|
|
27
|
+
subject.method(:y).should == subject.method(:Y)
|
|
28
|
+
subject.method(:y=).should == subject.method(:Y=)
|
|
29
|
+
subject.method(:w).should == subject.method(:Width)
|
|
30
|
+
subject.method(:w=).should == subject.method(:Width=)
|
|
31
|
+
subject.method(:h).should == subject.method(:Height)
|
|
32
|
+
subject.method(:h=).should == subject.method(:Height=)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GroupDocs::Document::View do
|
|
4
|
+
|
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
|
6
|
+
|
|
7
|
+
it { should respond_to(:document) }
|
|
8
|
+
it { should respond_to(:document=) }
|
|
9
|
+
it { should respond_to(:short_url) }
|
|
10
|
+
it { should respond_to(:short_url=) }
|
|
11
|
+
it { should respond_to(:viewed_on) }
|
|
12
|
+
it { should respond_to(:viewed_on=) }
|
|
13
|
+
|
|
14
|
+
describe '#document=' do
|
|
15
|
+
it 'sets document if GroupDocs::Document object is passed' do
|
|
16
|
+
document = GroupDocs::Document.new(file: GroupDocs::Storage::File.new)
|
|
17
|
+
subject.document = document
|
|
18
|
+
subject.document.should == document
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'creates new GroupDocs::Document object from passed hash' do
|
|
22
|
+
subject.document = { id: 1, name: 'test.pdf' }
|
|
23
|
+
document = subject.document
|
|
24
|
+
document.should be_a(GroupDocs::Document)
|
|
25
|
+
document.id.should == 1
|
|
26
|
+
document.name.should == 'test.pdf'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '#viewed_on' do
|
|
31
|
+
it 'returns converted to Time object Unix timestamp' do
|
|
32
|
+
subject.viewed_on = 1330450135
|
|
33
|
+
subject.viewed_on.should be_a(Time)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GroupDocs::Document do
|
|
4
|
+
|
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
|
6
|
+
include_examples GroupDocs::Api::Sugar::Lookup
|
|
7
|
+
include_examples GroupDocs::Api::Helpers::Status
|
|
8
|
+
|
|
9
|
+
subject do
|
|
10
|
+
file = GroupDocs::Storage::File.new
|
|
11
|
+
described_class.new(file: file)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '.views!' do
|
|
15
|
+
before(:each) do
|
|
16
|
+
mock_api_server(load_json('document_views'))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'accepts access credentials hash' do
|
|
20
|
+
lambda do
|
|
21
|
+
described_class.views!({}, client_id: 'client_id', private_key: 'private_key')
|
|
22
|
+
end.should_not raise_error(ArgumentError)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'adds page index option by default' do
|
|
26
|
+
GroupDocs::Api::Request.any_instance.should_receive(:add_params).with({ page_index: 0 })
|
|
27
|
+
described_class.views!
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'returns an array of GroupDocs::Document::View objects' do
|
|
31
|
+
views = described_class.views!
|
|
32
|
+
views.should be_an(Array)
|
|
33
|
+
views.each do |view|
|
|
34
|
+
view.should be_a(GroupDocs::Document::View)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '.all!' do
|
|
40
|
+
it 'accepts access credentials hash' do
|
|
41
|
+
lambda do
|
|
42
|
+
described_class.all!('/', client_id: 'client_id', private_key: 'private_key')
|
|
43
|
+
end.should_not raise_error(ArgumentError)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'calls GroupDocs::Storage::File.all! and converts each file to document' do
|
|
47
|
+
file1 = GroupDocs::Storage::File.new
|
|
48
|
+
file2 = GroupDocs::Storage::File.new
|
|
49
|
+
GroupDocs::Storage::File.should_receive(:all!).with('/', {}).and_return([file1, file2])
|
|
50
|
+
file1.should_receive(:to_document).and_return(described_class.new(file: file1))
|
|
51
|
+
file2.should_receive(:to_document).and_return(described_class.new(file: file2))
|
|
52
|
+
described_class.all!
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it { should respond_to(:file) }
|
|
57
|
+
it { should respond_to(:file=) }
|
|
58
|
+
it { should respond_to(:process_date) }
|
|
59
|
+
it { should respond_to(:process_date=) }
|
|
60
|
+
it { should respond_to(:outputs) }
|
|
61
|
+
it { should respond_to(:outputs=) }
|
|
62
|
+
|
|
63
|
+
it 'is compatible with response JSON' do
|
|
64
|
+
subject.should respond_to(:proc_date=)
|
|
65
|
+
subject.method(:proc_date=).should == subject.method(:process_date=)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#process_date' do
|
|
69
|
+
it 'returns converted to Time object Unix timestamp' do
|
|
70
|
+
subject.process_date = 1330450135
|
|
71
|
+
subject.process_date.should be_a(Time)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe '#initialize' do
|
|
76
|
+
it 'raises error if file is not specified' do
|
|
77
|
+
-> { described_class.new }.should raise_error(ArgumentError)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'raises error if file is not an instance of GroupDocs::Storage::File' do
|
|
81
|
+
-> { described_class.new(file: '') }.should raise_error(ArgumentError)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe '#access_mode!' do
|
|
86
|
+
before(:each) do
|
|
87
|
+
mock_api_server(load_json('document_access_info_get'))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'accepts access credentials hash' do
|
|
91
|
+
lambda do
|
|
92
|
+
subject.access_mode!(client_id: 'client_id', private_key: 'private_key')
|
|
93
|
+
end.should_not raise_error(ArgumentError)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'returns access mode in human readable presentation' do
|
|
97
|
+
subject.should_receive(:parse_access_mode).with(0).and_return(:private)
|
|
98
|
+
subject.access_mode!.should == :private
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe '#access_mode_set!' do
|
|
103
|
+
before(:each) do
|
|
104
|
+
mock_api_server('{"status": "Ok", "result": {"access": 0 }}')
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'accepts access credentials hash' do
|
|
108
|
+
lambda do
|
|
109
|
+
subject.access_mode_set!(:private, client_id: 'client_id', private_key: 'private_key')
|
|
110
|
+
end.should_not raise_error(ArgumentError)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'sets corresponding access mode and determines set' do
|
|
114
|
+
subject.should_receive(:parse_access_mode).with(:private).and_return(0)
|
|
115
|
+
subject.should_receive(:parse_access_mode).with(0).and_return(:private)
|
|
116
|
+
subject.access_mode_set!(:private)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it 'returns set of access modes' do
|
|
120
|
+
subject.access_mode_set!(:private).should == :private
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it 'is aliased to #access_mode=' do
|
|
124
|
+
subject.should respond_to(:access_mode=)
|
|
125
|
+
subject.method(:access_mode=).should == subject.method(:access_mode_set!)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
describe '#formats!' do
|
|
130
|
+
before(:each) do
|
|
131
|
+
mock_api_server(load_json('document_formats'))
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'accepts access credentials hash' do
|
|
135
|
+
lambda do
|
|
136
|
+
subject.formats!(client_id: 'client_id', private_key: 'private_key')
|
|
137
|
+
end.should_not raise_error(ArgumentError)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'returns an array of symbols' do
|
|
141
|
+
formats = subject.formats!
|
|
142
|
+
formats.should be_an(Array)
|
|
143
|
+
formats.each do |format|
|
|
144
|
+
format.should be_a(Symbol)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
describe '#metadata!' do
|
|
150
|
+
before(:each) do
|
|
151
|
+
mock_api_server(load_json('document_metadata'))
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it 'accepts access credentials hash' do
|
|
155
|
+
lambda do
|
|
156
|
+
subject.metadata!(client_id: 'client_id', private_key: 'private_key')
|
|
157
|
+
end.should_not raise_error(ArgumentError)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it 'returns GroupDocs::Document::MetaData object' do
|
|
161
|
+
subject.metadata!.should be_a(GroupDocs::Document::MetaData)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it 'sets last view as GroupDocs::Document::View object if document was viewed at least once' do
|
|
165
|
+
subject.metadata!.last_view.should be_a(GroupDocs::Document::View)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'uses self document in last view object' do
|
|
169
|
+
subject.metadata!.last_view.document.should == subject
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it 'does not set last view if document has never been viewed' do
|
|
173
|
+
mock_api_server('{"status": "Ok", "result": {"last_view": null }}')
|
|
174
|
+
subject.metadata!.last_view.should be_nil
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
describe '#fields!' do
|
|
179
|
+
before(:each) do
|
|
180
|
+
mock_api_server(load_json('document_fields'))
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
it 'accepts access credentials hash' do
|
|
184
|
+
lambda do
|
|
185
|
+
subject.fields!(client_id: 'client_id', private_key: 'private_key')
|
|
186
|
+
end.should_not raise_error(ArgumentError)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it 'returns array of GroupDocs::Document::Field objects' do
|
|
190
|
+
fields = subject.fields!
|
|
191
|
+
fields.should be_an(Array)
|
|
192
|
+
fields.each do |field|
|
|
193
|
+
field.should be_a(GroupDocs::Document::Field)
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
describe '#sharers!' do
|
|
199
|
+
before(:each) do
|
|
200
|
+
mock_api_server(load_json('document_access_info_get'))
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
it 'accepts access credentials hash' do
|
|
204
|
+
lambda do
|
|
205
|
+
subject.sharers!(client_id: 'client_id', private_key: 'private_key')
|
|
206
|
+
end.should_not raise_error(ArgumentError)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
it 'returns an array of GroupDocs::User objects' do
|
|
210
|
+
users = subject.sharers!
|
|
211
|
+
users.should be_an(Array)
|
|
212
|
+
users.each do |user|
|
|
213
|
+
user.should be_a(GroupDocs::User)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
describe '#sharers_set!' do
|
|
219
|
+
before(:each) do
|
|
220
|
+
mock_api_server(load_json('document_sharers_set'))
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
it 'accepts access credentials hash' do
|
|
224
|
+
lambda do
|
|
225
|
+
subject.sharers_set!(%w(test1@email.com), client_id: 'client_id', private_key: 'private_key')
|
|
226
|
+
end.should_not raise_error(ArgumentError)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
it 'returns an array of GroupDocs::User objects' do
|
|
230
|
+
users = subject.sharers_set!(%w(test1@email.com))
|
|
231
|
+
users.should be_an(Array)
|
|
232
|
+
users.each do |user|
|
|
233
|
+
user.should be_a(GroupDocs::User)
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
it 'clears sharers if empty array is passed' do
|
|
238
|
+
subject.should_receive(:sharers_clear!)
|
|
239
|
+
subject.sharers_set!([])
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
it 'clears sharers if nil is passed' do
|
|
243
|
+
subject.should_receive(:sharers_clear!)
|
|
244
|
+
subject.sharers_set!(nil)
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
describe '#sharers_clear!' do
|
|
249
|
+
before(:each) do
|
|
250
|
+
mock_api_server(load_json('document_sharers_remove'))
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
it 'accepts access credentials hash' do
|
|
254
|
+
lambda do
|
|
255
|
+
subject.sharers_clear!(client_id: 'client_id', private_key: 'private_key')
|
|
256
|
+
end.should_not raise_error(ArgumentError)
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
it 'clears sharers list and returns nil' do
|
|
260
|
+
subject.sharers_clear!.should be_nil
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
describe '#convert!' do
|
|
265
|
+
before(:each) do
|
|
266
|
+
mock_api_server(load_json('document_convert'))
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
it 'accepts access credentials hash' do
|
|
270
|
+
lambda do
|
|
271
|
+
subject.convert!(:pdf, {}, client_id: 'client_id', private_key: 'private_key')
|
|
272
|
+
end.should_not raise_error(ArgumentError)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
it 'accepts options hash' do
|
|
276
|
+
lambda do
|
|
277
|
+
subject.convert!(:pdf, email_results: true)
|
|
278
|
+
end.should_not raise_error(ArgumentError)
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
it 'returns GroupDocs::Job object' do
|
|
282
|
+
subject.convert!(:pdf).should be_a(GroupDocs::Job)
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
describe '#questionnaires!' do
|
|
287
|
+
before(:each) do
|
|
288
|
+
mock_api_server(load_json('document_questionnaires'))
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
it 'accepts access credentials hash' do
|
|
292
|
+
lambda do
|
|
293
|
+
subject.questionnaires!(client_id: 'client_id', private_key: 'private_key')
|
|
294
|
+
end.should_not raise_error(ArgumentError)
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
it 'returns an array of GroupDocs::Questionnaire objects' do
|
|
298
|
+
questionnaires = subject.questionnaires!
|
|
299
|
+
questionnaires.should be_an(Array)
|
|
300
|
+
questionnaires.each do |questionnaire|
|
|
301
|
+
questionnaire.should be_a(GroupDocs::Questionnaire)
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
describe '#add_questionnaire!' do
|
|
307
|
+
let(:questionnaire) do
|
|
308
|
+
GroupDocs::Questionnaire.new(id: 1)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
it 'accepts access credentials hash' do
|
|
312
|
+
lambda do
|
|
313
|
+
subject.add_questionnaire!(questionnaire, client_id: 'client_id', private_key: 'private_key')
|
|
314
|
+
end.should_not raise_error(ArgumentError)
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
|
|
318
|
+
-> { subject.add_questionnaire!('Questionnaire') }.should raise_error(ArgumentError)
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
describe '#create_questionnaire!' do
|
|
323
|
+
before(:each) do
|
|
324
|
+
mock_api_server(load_json('document_questionnaire_create'))
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
let(:questionnaire) do
|
|
328
|
+
GroupDocs::Questionnaire.new(name: 'Q1')
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
it 'accepts access credentials hash' do
|
|
332
|
+
lambda do
|
|
333
|
+
subject.create_questionnaire!(questionnaire, client_id: 'client_id', private_key: 'private_key')
|
|
334
|
+
end.should_not raise_error(ArgumentError)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
|
|
338
|
+
-> { subject.create_questionnaire!('Questionnaire') }.should raise_error(ArgumentError)
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
it 'returns GroupDocs::Questionnaire object' do
|
|
342
|
+
subject.create_questionnaire!(questionnaire).should be_a(GroupDocs::Questionnaire)
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
it 'uses hashed version of questionnaire as request body' do
|
|
346
|
+
questionnaire.should_receive(:to_hash)
|
|
347
|
+
subject.create_questionnaire!(questionnaire)
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
it 'adds ID from response to questionnaire' do
|
|
351
|
+
lambda do
|
|
352
|
+
subject.create_questionnaire!(questionnaire)
|
|
353
|
+
end.should change(questionnaire, :id)
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
describe '#remove_questionnaire!' do
|
|
358
|
+
let(:questionnaire) do
|
|
359
|
+
GroupDocs::Questionnaire.new(id: 1)
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
it 'accepts access credentials hash' do
|
|
363
|
+
lambda do
|
|
364
|
+
subject.remove_questionnaire!(questionnaire, client_id: 'client_id', private_key: 'private_key')
|
|
365
|
+
end.should_not raise_error(ArgumentError)
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
it 'raises error if questionnaire is not GroupDocs::Questionnaire object' do
|
|
369
|
+
-> { subject.remove_questionnaire!('Questionnaire') }.should raise_error(ArgumentError)
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
describe '#datasource!' do
|
|
374
|
+
before(:each) do
|
|
375
|
+
mock_api_server(load_json('document_datasource'))
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
let(:datasource) do
|
|
379
|
+
GroupDocs::DataSource.new(id: 1)
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
it 'accepts access credentials hash' do
|
|
383
|
+
lambda do
|
|
384
|
+
subject.datasource!(datasource, { new_type: 1, email_results: false }, client_id: 'client_id', private_key: 'private_key')
|
|
385
|
+
end.should_not raise_error(ArgumentError)
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
it 'raises error if datasource is not GroupDocs::Datasource object' do
|
|
389
|
+
-> { subject.datasource!('Datasource') }.should raise_error(ArgumentError)
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
it 'raises error if :new_type option is not passed' do
|
|
393
|
+
-> { subject.datasource!(datasource, email_results: false) }.should raise_error(ArgumentError)
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
it 'raises error if :email_results option is not passed' do
|
|
397
|
+
-> { subject.datasource!(datasource, new_type: :doc) }.should raise_error(ArgumentError)
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
it 'returns GroupDocs::Job object' do
|
|
401
|
+
job = subject.datasource!(datasource, new_type: :doc, email_results: false)
|
|
402
|
+
job.should be_a(GroupDocs::Job)
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
describe '#annotations!' do
|
|
407
|
+
before(:each) do
|
|
408
|
+
mock_api_server(load_json('annotation_list'))
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
it 'accepts access credentials hash' do
|
|
412
|
+
lambda do
|
|
413
|
+
subject.annotations!(client_id: 'client_id', private_key: 'private_key')
|
|
414
|
+
end.should_not raise_error(ArgumentError)
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
it 'returns array of GroupDocs::Document::Annotation objects' do
|
|
418
|
+
annotations = subject.annotations!
|
|
419
|
+
annotations.should be_an(Array)
|
|
420
|
+
annotations.each do |annotation|
|
|
421
|
+
annotation.should be_a(GroupDocs::Document::Annotation)
|
|
422
|
+
end
|
|
423
|
+
end
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
describe '#details!' do
|
|
427
|
+
before(:each) do
|
|
428
|
+
mock_api_server(load_json('comparison_document'))
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
it 'accepts access credentials hash' do
|
|
432
|
+
lambda do
|
|
433
|
+
subject.details!(client_id: 'client_id', private_key: 'private_key')
|
|
434
|
+
end.should_not raise_error(ArgumentError)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
it 'returns hash of document details' do
|
|
438
|
+
subject.details!.should be_a(Hash)
|
|
439
|
+
end
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
describe '#compare!' do
|
|
443
|
+
before(:each) do
|
|
444
|
+
mock_api_server(load_json('comparison_compare'))
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
let(:document) do
|
|
448
|
+
GroupDocs::Document.new(file: GroupDocs::Storage::File.new)
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
it 'accepts access credentials hash' do
|
|
452
|
+
lambda do
|
|
453
|
+
subject.compare!(document, client_id: 'client_id', private_key: 'private_key')
|
|
454
|
+
end.should_not raise_error(ArgumentError)
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
it 'raises error if document is not GroupDocs::Document object' do
|
|
458
|
+
-> { subject.compare!('Document') }.should raise_error(ArgumentError)
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
it 'returns GroupDocs::Job object' do
|
|
462
|
+
subject.compare!(document).should be_a(GroupDocs::Job)
|
|
463
|
+
end
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
describe '#changes!' do
|
|
467
|
+
before(:each) do
|
|
468
|
+
mock_api_server(load_json('comparison_changes'))
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
it 'accepts access credentials hash' do
|
|
472
|
+
lambda do
|
|
473
|
+
subject.changes!(client_id: 'client_id', private_key: 'private_key')
|
|
474
|
+
end.should_not raise_error(ArgumentError)
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
it 'returns array of GroupDocs::Document::Change objects' do
|
|
478
|
+
changes = subject.changes!
|
|
479
|
+
changes.should be_an(Array)
|
|
480
|
+
changes.each do |change|
|
|
481
|
+
change.should be_a(GroupDocs::Document::Change)
|
|
482
|
+
end
|
|
483
|
+
end
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
describe '#method_missing' do
|
|
487
|
+
it 'passes unknown methods to file object' do
|
|
488
|
+
-> { subject.name }.should_not raise_error(NoMethodError)
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
it 'raises NoMethodError if neither self nor file responds to method' do
|
|
492
|
+
-> { subject.unknown_method }.should raise_error(NoMethodError)
|
|
493
|
+
end
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
describe '#respond_to?' do
|
|
497
|
+
it 'returns true if self responds to method' do
|
|
498
|
+
subject.respond_to?(:metadata!).should be_true
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
it 'returns true if file object responds to method' do
|
|
502
|
+
subject.respond_to?(:name).should be_true
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
it 'returns false if neither self nor file responds to method' do
|
|
506
|
+
subject.respond_to?(:unknown).should be_false
|
|
507
|
+
end
|
|
508
|
+
end
|
|
509
|
+
end
|