groupdocs 1.1.0 → 1.2.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/CHANGELOG.md +41 -0
- data/examples/README.md +2 -3
- data/examples/api-samples/Gemfile +5 -0
- data/examples/api-samples/Gemfile.lock +27 -0
- data/examples/api-samples/README.md +12 -0
- data/examples/api-samples/app.rb +17 -0
- data/examples/api-samples/public/css/style.css +166 -0
- data/examples/api-samples/samples/sample1.rb +17 -0
- data/examples/api-samples/samples/sample10.rb +36 -0
- data/examples/api-samples/samples/sample2.rb +19 -0
- data/examples/api-samples/samples/sample3.rb +23 -0
- data/examples/api-samples/samples/sample4.rb +31 -0
- data/examples/api-samples/samples/sample5.rb +44 -0
- data/examples/api-samples/samples/sample6.rb +3 -0
- data/examples/api-samples/samples/sample7.rb +33 -0
- data/examples/api-samples/samples/sample8.rb +40 -0
- data/examples/api-samples/samples/sample9.rb +22 -0
- data/examples/api-samples/views/index.haml +23 -0
- data/examples/api-samples/views/layout.haml +7 -0
- data/examples/api-samples/views/sample1.haml +71 -0
- data/examples/api-samples/views/sample10.haml +69 -0
- data/examples/api-samples/views/sample2.haml +59 -0
- data/examples/api-samples/views/sample3.haml +62 -0
- data/examples/api-samples/views/sample4.haml +58 -0
- data/examples/api-samples/views/sample5.haml +62 -0
- data/examples/api-samples/views/sample6.haml +145 -0
- data/examples/api-samples/views/sample7.haml +59 -0
- data/examples/api-samples/views/sample8.haml +75 -0
- data/examples/api-samples/views/sample9.haml +61 -0
- data/examples/{annotations → viewer}/Gemfile +0 -0
- data/examples/viewer/app.rb +52 -0
- data/groupdocs.gemspec +5 -4
- data/lib/groupdocs/api.rb +1 -0
- data/lib/groupdocs/api/entity.rb +2 -0
- data/lib/groupdocs/api/helpers.rb +2 -0
- data/lib/groupdocs/api/helpers/accessor_helper.rb +30 -0
- data/lib/groupdocs/api/helpers/mime_helper.rb +21 -0
- data/lib/groupdocs/api/helpers/rest_helper.rb +3 -2
- data/lib/groupdocs/api/request.rb +1 -3
- data/lib/groupdocs/datasource.rb +1 -2
- data/lib/groupdocs/document.rb +133 -3
- data/lib/groupdocs/document/annotation.rb +14 -13
- data/lib/groupdocs/document/annotation/reply.rb +4 -8
- data/lib/groupdocs/document/annotation/reviewer.rb +2 -4
- data/lib/groupdocs/document/field.rb +10 -8
- data/lib/groupdocs/document/rectangle.rb +10 -18
- data/lib/groupdocs/job.rb +1 -1
- data/lib/groupdocs/questionnaire.rb +138 -44
- data/lib/groupdocs/questionnaire/collector.rb +262 -0
- data/lib/groupdocs/questionnaire/execution.rb +93 -10
- data/lib/groupdocs/questionnaire/question.rb +1 -2
- data/lib/groupdocs/signature.rb +16 -24
- data/lib/groupdocs/signature/contact.rb +2 -4
- data/lib/groupdocs/signature/envelope.rb +3 -6
- data/lib/groupdocs/signature/envelope/log.rb +2 -4
- data/lib/groupdocs/signature/field.rb +21 -42
- data/lib/groupdocs/signature/field/location.rb +18 -36
- data/lib/groupdocs/signature/form.rb +9 -18
- data/lib/groupdocs/signature/list.rb +1 -2
- data/lib/groupdocs/signature/recipient.rb +3 -6
- data/lib/groupdocs/signature/role.rb +4 -8
- data/lib/groupdocs/signature/shared/entity_fields.rb +12 -20
- data/lib/groupdocs/signature/template.rb +1 -2
- data/lib/groupdocs/storage/file.rb +3 -1
- data/lib/groupdocs/storage/folder.rb +7 -1
- data/lib/groupdocs/subscription.rb +6 -12
- data/lib/groupdocs/subscription/limit.rb +4 -8
- data/lib/groupdocs/user.rb +3 -6
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/api/helpers/accessor_helper_spec.rb +16 -0
- data/spec/groupdocs/api/helpers/mime_helper_spec.rb +16 -0
- data/spec/groupdocs/api/helpers/rest_helper_spec.rb +4 -0
- data/spec/groupdocs/api/request_spec.rb +3 -5
- data/spec/groupdocs/datasource/field_spec.rb +3 -6
- data/spec/groupdocs/datasource_spec.rb +8 -15
- data/spec/groupdocs/document/annotation/reply_spec.rb +13 -24
- data/spec/groupdocs/document/annotation/reviewer_spec.rb +5 -9
- data/spec/groupdocs/document/annotation_spec.rb +35 -40
- data/spec/groupdocs/document/change_spec.rb +6 -11
- data/spec/groupdocs/document/field_spec.rb +13 -13
- data/spec/groupdocs/document/metadata_spec.rb +5 -10
- data/spec/groupdocs/document/rectangle_spec.rb +6 -18
- data/spec/groupdocs/document/view_spec.rb +3 -6
- data/spec/groupdocs/document_spec.rb +123 -10
- data/spec/groupdocs/job_spec.rb +9 -18
- data/spec/groupdocs/questionnaire/collector_spec.rb +201 -0
- data/spec/groupdocs/questionnaire/execution_spec.rb +91 -23
- data/spec/groupdocs/questionnaire/page_spec.rb +3 -6
- data/spec/groupdocs/questionnaire/question/answer_spec.rb +2 -4
- data/spec/groupdocs/questionnaire/question_spec.rb +7 -14
- data/spec/groupdocs/questionnaire_spec.rb +117 -41
- data/spec/groupdocs/signature/contact_spec.rb +9 -17
- data/spec/groupdocs/signature/envelope/log_spec.rb +8 -16
- data/spec/groupdocs/signature/envelope_spec.rb +9 -17
- data/spec/groupdocs/signature/field/location_spec.rb +32 -65
- data/spec/groupdocs/signature/field_spec.rb +48 -95
- data/spec/groupdocs/signature/form_spec.rb +22 -43
- data/spec/groupdocs/signature/list_spec.rb +6 -11
- data/spec/groupdocs/signature/recipient_spec.rb +11 -22
- data/spec/groupdocs/signature/role_spec.rb +11 -21
- data/spec/groupdocs/signature/template_spec.rb +2 -4
- data/spec/groupdocs/signature_spec.rb +28 -54
- data/spec/groupdocs/storage/file_spec.rb +14 -26
- data/spec/groupdocs/storage/folder_spec.rb +16 -22
- data/spec/groupdocs/storage/package_spec.rb +2 -4
- data/spec/groupdocs/subscription/limit_spec.rb +8 -16
- data/spec/groupdocs/subscription_spec.rb +11 -22
- data/spec/groupdocs/user_spec.rb +21 -41
- data/spec/groupdocs_spec.rb +4 -8
- data/spec/spec_helper.rb +12 -0
- data/spec/support/files/signature.png +0 -0
- data/spec/support/json/annotation_list.json +6 -6
- data/spec/support/json/comparison_changes.json +8 -8
- data/spec/support/json/document_fields.json +8 -8
- data/spec/support/json/document_page_images_get.json +20 -0
- data/spec/support/json/questionnaire_collector.json +17 -0
- data/spec/support/json/questionnaire_collectors.json +38 -0
- data/spec/support/json/questionnaire_collectors_add.json +10 -0
- data/spec/support/json/questionnaire_create.json +3 -1
- data/spec/support/json/{questionnaire_execution_create.json → questionnaire_execution_add.json} +1 -1
- data/spec/support/json/questionnaire_get.json +3 -0
- data/spec/support/json/questionnaires_get.json +36 -18
- data/spec/support/json/sign_documents.json +16 -0
- data/spec/support/json/templates_get.json +21 -0
- data/spec/support/shared_examples/api/entity.rb +2 -0
- data/spec/support/shared_examples/api/helpers/access_mode_helper.rb +1 -2
- data/spec/support/shared_examples/api/helpers/status_helper.rb +1 -2
- data/spec/support/shared_examples/signature/shared/entity_fields.rb +22 -43
- metadata +82 -16
- data/examples/annotations/app.rb +0 -67
|
@@ -4,16 +4,11 @@ describe GroupDocs::Document::Change do
|
|
|
4
4
|
|
|
5
5
|
it_behaves_like GroupDocs::Api::Entity
|
|
6
6
|
|
|
7
|
-
it { should
|
|
8
|
-
it { should
|
|
9
|
-
it { should
|
|
10
|
-
it { should
|
|
11
|
-
it { should
|
|
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=) }
|
|
7
|
+
it { should have_accessor(:id) }
|
|
8
|
+
it { should have_accessor(:type) }
|
|
9
|
+
it { should have_accessor(:box) }
|
|
10
|
+
it { should have_accessor(:text) }
|
|
11
|
+
it { should have_accessor(:page) }
|
|
17
12
|
|
|
18
13
|
describe '#type' do
|
|
19
14
|
it 'returns type as symbol' do
|
|
@@ -24,7 +19,7 @@ describe GroupDocs::Document::Change do
|
|
|
24
19
|
|
|
25
20
|
describe '#box=' do
|
|
26
21
|
it 'converts passed hash to GroupDocs::Document::Rectangle object' do
|
|
27
|
-
subject.box = {
|
|
22
|
+
subject.box = { x: 0.90, y: 0.05, width: 0.06745, height: 0.005967 }
|
|
28
23
|
subject.box.should be_a(GroupDocs::Document::Rectangle)
|
|
29
24
|
subject.box.x.should == 0.90
|
|
30
25
|
subject.box.y.should == 0.05
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe GroupDocs::Document::Field do
|
|
4
|
-
|
|
5
4
|
it_behaves_like GroupDocs::Api::Entity
|
|
6
5
|
|
|
7
|
-
it { should
|
|
8
|
-
it { should
|
|
9
|
-
it { should
|
|
10
|
-
it { should
|
|
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 { should have_alias(:rect=, :rectangle=) }
|
|
6
|
+
it { should have_accessor(:page) }
|
|
7
|
+
it { should have_accessor(:name) }
|
|
8
|
+
it { should have_accessor(:type) }
|
|
9
|
+
it { should have_accessor(:rect) }
|
|
17
10
|
|
|
18
|
-
describe '#
|
|
11
|
+
describe '#rect=' do
|
|
19
12
|
it 'converts passed hash to GroupDocs::Document::Rectangle object' do
|
|
20
|
-
subject.
|
|
13
|
+
subject.rect = { x: 0.90, y: 0.05, width: 0.06745, height: 0.005967 }
|
|
21
14
|
subject.rectangle.should be_a(GroupDocs::Document::Rectangle)
|
|
22
15
|
subject.rectangle.x.should == 0.90
|
|
23
16
|
subject.rectangle.y.should == 0.05
|
|
24
17
|
subject.rectangle.w.should == 0.06745
|
|
25
18
|
subject.rectangle.h.should == 0.005967
|
|
26
19
|
end
|
|
20
|
+
|
|
21
|
+
it 'does nothing when nil is passed' do
|
|
22
|
+
subject.rect = nil
|
|
23
|
+
subject.rectangle.should be_nil
|
|
24
|
+
end
|
|
27
25
|
end
|
|
26
|
+
|
|
27
|
+
it { should alias_accessor(:rectangle, :rect) }
|
|
28
28
|
end
|
|
@@ -4,16 +4,11 @@ describe GroupDocs::Document::MetaData do
|
|
|
4
4
|
|
|
5
5
|
it_behaves_like GroupDocs::Api::Entity
|
|
6
6
|
|
|
7
|
-
it { should
|
|
8
|
-
it { should
|
|
9
|
-
it { should
|
|
10
|
-
it { should
|
|
11
|
-
it { should
|
|
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=) }
|
|
7
|
+
it { should have_accessor(:id) }
|
|
8
|
+
it { should have_accessor(:guid) }
|
|
9
|
+
it { should have_accessor(:page_count) }
|
|
10
|
+
it { should have_accessor(:views_count) }
|
|
11
|
+
it { should have_accessor(:last_view) }
|
|
17
12
|
|
|
18
13
|
describe '#last_view=' do
|
|
19
14
|
it 'converts passed hash to GroupDocs::Document::View object' do
|
|
@@ -4,23 +4,11 @@ describe GroupDocs::Document::Rectangle do
|
|
|
4
4
|
|
|
5
5
|
it_behaves_like GroupDocs::Api::Entity
|
|
6
6
|
|
|
7
|
-
it { should
|
|
8
|
-
it { should
|
|
9
|
-
it { should
|
|
10
|
-
it { should
|
|
11
|
-
it { should respond_to(:Width) }
|
|
12
|
-
it { should respond_to(:Width=) }
|
|
13
|
-
it { should respond_to(:Height) }
|
|
14
|
-
it { should respond_to(:Height=) }
|
|
7
|
+
it { should have_accessor(:x) }
|
|
8
|
+
it { should have_accessor(:y) }
|
|
9
|
+
it { should have_accessor(:width) }
|
|
10
|
+
it { should have_accessor(:height) }
|
|
15
11
|
|
|
16
|
-
it { should
|
|
17
|
-
it { should
|
|
18
|
-
it { should have_alias(:y, :Y) }
|
|
19
|
-
it { should have_alias(:y=, :Y=) }
|
|
20
|
-
it { should have_alias(:w, :Width) }
|
|
21
|
-
it { should have_alias(:w=, :Width=) }
|
|
22
|
-
it { should have_alias(:width, :w) }
|
|
23
|
-
it { should have_alias(:h, :Height) }
|
|
24
|
-
it { should have_alias(:h=, :Height=) }
|
|
25
|
-
it { should have_alias(:height, :h) }
|
|
12
|
+
it { should alias_accessor(:w, :width) }
|
|
13
|
+
it { should alias_accessor(:h, :height) }
|
|
26
14
|
end
|
|
@@ -4,12 +4,9 @@ describe GroupDocs::Document::View do
|
|
|
4
4
|
|
|
5
5
|
it_behaves_like GroupDocs::Api::Entity
|
|
6
6
|
|
|
7
|
-
it { should
|
|
8
|
-
it { should
|
|
9
|
-
it { should
|
|
10
|
-
it { should respond_to(:short_url=) }
|
|
11
|
-
it { should respond_to(:viewed_on) }
|
|
12
|
-
it { should respond_to(:viewed_on=) }
|
|
7
|
+
it { should have_accessor(:document) }
|
|
8
|
+
it { should have_accessor(:short_url) }
|
|
9
|
+
it { should have_accessor(:viewed_on) }
|
|
13
10
|
|
|
14
11
|
describe '#document=' do
|
|
15
12
|
it 'sets document if GroupDocs::Document object is passed' do
|
|
@@ -30,16 +30,103 @@ describe GroupDocs::Document do
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
describe '.templates!' do
|
|
34
|
+
before(:each) do
|
|
35
|
+
mock_api_server(load_json('templates_get'))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'accepts access credentials hash' do
|
|
39
|
+
lambda do
|
|
40
|
+
described_class.templates!(client_id: 'client_id', private_key: 'private_key')
|
|
41
|
+
end.should_not raise_error(ArgumentError)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'returns an array of GroupDocs::Document objects' do
|
|
45
|
+
templates = described_class.templates!
|
|
46
|
+
templates.should be_an(Array)
|
|
47
|
+
templates.each do |template|
|
|
48
|
+
template.should be_a(GroupDocs::Document)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe '.sign_documents!' do
|
|
54
|
+
before(:each) do
|
|
55
|
+
mock_api_server(load_json('sign_documents'))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
let(:documents) do
|
|
59
|
+
[GroupDocs::Document.new(file: GroupDocs::Storage::File.new(name: 'Document1', local_path: __FILE__)),
|
|
60
|
+
GroupDocs::Document.new(file: GroupDocs::Storage::File.new(name: 'Document2', local_path: 'spec/support/files/resume.pdf'))]
|
|
61
|
+
end
|
|
62
|
+
let(:signatures) { [GroupDocs::Signature.new(name: 'John Smith', image_path: 'spec/support/files/signature.png', position: {})] }
|
|
63
|
+
|
|
64
|
+
it 'accepts access credentials hash' do
|
|
65
|
+
lambda do
|
|
66
|
+
described_class.sign_documents!(documents, signatures, {}, client_id: 'client_id', private_key: 'private_key')
|
|
67
|
+
end.should_not raise_error(ArgumentError)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'raises error if document is not GroupDocs::Document object' do
|
|
71
|
+
-> { described_class.sign_documents!(['Document'], signatures) }.should raise_error(ArgumentError)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'raises error if document file does not have name' do
|
|
75
|
+
documents = [GroupDocs::Document.new(file: GroupDocs::Storage::File.new(local_path: __FILE__))]
|
|
76
|
+
-> { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'raises error if document file does not have local path' do
|
|
80
|
+
documents = [GroupDocs::Document.new(file: GroupDocs::Storage::File.new(name: 'Document'))]
|
|
81
|
+
-> { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'raises error if signature is not GroupDocs::Signature object' do
|
|
85
|
+
-> { described_class.sign_documents!(documents, ['Signature']) }.should raise_error(ArgumentError)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'raises error if signature does not have name' do
|
|
89
|
+
signatures = [GroupDocs::Signature.new(image_path: __FILE__, position: {})]
|
|
90
|
+
-> { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'raises error if signature does not have image path' do
|
|
94
|
+
signatures = [GroupDocs::Signature.new(name: 'John Smith', position: {})]
|
|
95
|
+
-> { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'raises error if signature does not have position' do
|
|
99
|
+
signatures = [GroupDocs::Signature.new(name: 'John Smith', image_path: __FILE__)]
|
|
100
|
+
-> { described_class.sign_documents!(documents, signatures) }.should raise_error(ArgumentError)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'detects each document and signature file MIME type' do
|
|
104
|
+
documents.each { |document| described_class.should_receive(:mime_type).with(document.file.local_path).once }
|
|
105
|
+
signatures.each { |signature| described_class.should_receive(:mime_type).with(signature.image_path).once }
|
|
106
|
+
described_class.sign_documents!(documents, signatures)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'returns array of GroupDocs::Document.objects' do
|
|
110
|
+
signed_documents = described_class.sign_documents!(documents, signatures)
|
|
111
|
+
signed_documents.should be_an(Array)
|
|
112
|
+
signed_documents.each do |document|
|
|
113
|
+
document.should be_a(GroupDocs::Document)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'calculates file name for each signed document' do
|
|
118
|
+
signed_documents = described_class.sign_documents!(documents, signatures)
|
|
119
|
+
signed_documents[0].file.name.should == "#{documents[0].file.name}_signed.pdf"
|
|
120
|
+
signed_documents[1].file.name.should == "#{documents[1].file.name}_signed.pdf"
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it { should have_accessor(:file) }
|
|
125
|
+
it { should have_accessor(:process_date) }
|
|
126
|
+
it { should have_accessor(:outputs) }
|
|
127
|
+
it { should have_accessor(:output_formats) }
|
|
128
|
+
it { should have_accessor(:order) }
|
|
129
|
+
it { should have_accessor(:field_count) }
|
|
43
130
|
|
|
44
131
|
it { should have_alias(:access_mode=, :access_mode_set!) }
|
|
45
132
|
|
|
@@ -91,6 +178,32 @@ describe GroupDocs::Document do
|
|
|
91
178
|
end
|
|
92
179
|
end
|
|
93
180
|
|
|
181
|
+
describe '#page_images!' do
|
|
182
|
+
before(:each) do
|
|
183
|
+
mock_api_server(load_json('document_page_images_get'))
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it 'accepts access credentials hash' do
|
|
187
|
+
lambda do
|
|
188
|
+
subject.page_images!(640, 480, {}, client_id: 'client_id', private_key: 'private_key')
|
|
189
|
+
end.should_not raise_error(ArgumentError)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
it 'accepts options hash' do
|
|
193
|
+
lambda do
|
|
194
|
+
subject.page_images!(640, 480, first_page: 0, page_count: 1)
|
|
195
|
+
end.should_not raise_error(ArgumentError)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it 'returns array of URLs' do
|
|
199
|
+
urls = subject.page_images!(640, 480)
|
|
200
|
+
urls.should be_an(Array)
|
|
201
|
+
urls.each do |url|
|
|
202
|
+
url.should be_a(String)
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
94
207
|
describe '#access_mode!' do
|
|
95
208
|
before(:each) do
|
|
96
209
|
mock_api_server(load_json('document_access_info_get'))
|
data/spec/groupdocs/job_spec.rb
CHANGED
|
@@ -80,24 +80,15 @@ describe GroupDocs::Job do
|
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
it { should
|
|
84
|
-
it { should
|
|
85
|
-
it { should
|
|
86
|
-
it { should
|
|
87
|
-
it { should
|
|
88
|
-
it { should
|
|
89
|
-
it { should
|
|
90
|
-
it { should
|
|
91
|
-
it { should
|
|
92
|
-
it { should respond_to(:actions=) }
|
|
93
|
-
it { should respond_to(:email_results) }
|
|
94
|
-
it { should respond_to(:email_results=) }
|
|
95
|
-
it { should respond_to(:url_only) }
|
|
96
|
-
it { should respond_to(:url_only=) }
|
|
97
|
-
it { should respond_to(:documents) }
|
|
98
|
-
it { should respond_to(:documents=) }
|
|
99
|
-
it { should respond_to(:requested_time) }
|
|
100
|
-
it { should respond_to(:requested_time=) }
|
|
83
|
+
it { should have_accessor(:id) }
|
|
84
|
+
it { should have_accessor(:guid) }
|
|
85
|
+
it { should have_accessor(:name) }
|
|
86
|
+
it { should have_accessor(:priority) }
|
|
87
|
+
it { should have_accessor(:actions) }
|
|
88
|
+
it { should have_accessor(:email_results) }
|
|
89
|
+
it { should have_accessor(:url_only) }
|
|
90
|
+
it { should have_accessor(:documents) }
|
|
91
|
+
it { should have_accessor(:requested_time) }
|
|
101
92
|
|
|
102
93
|
describe '#documents=' do
|
|
103
94
|
let(:response) do
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GroupDocs::Questionnaire::Collector do
|
|
4
|
+
|
|
5
|
+
it_behaves_like GroupDocs::Api::Entity
|
|
6
|
+
include_examples GroupDocs::Api::Helpers::Status
|
|
7
|
+
|
|
8
|
+
subject do
|
|
9
|
+
questionnaire = GroupDocs::Questionnaire.new
|
|
10
|
+
described_class.new(questionnaire: questionnaire)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe '.get!' do
|
|
14
|
+
before(:each) do
|
|
15
|
+
mock_api_server(load_json('questionnaire_collector'))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'accepts access credentials hash' do
|
|
19
|
+
lambda do
|
|
20
|
+
described_class.get!('9fh349hfdskf', client_id: 'client_id', private_key: 'private_key')
|
|
21
|
+
end.should_not raise_error(ArgumentError)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'returns GroupDocs::Questionnaire::Collector object' do
|
|
25
|
+
described_class.get!('9fh349hfdskf').should be_a(GroupDocs::Questionnaire::Collector)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it { should have_accessor(:id) }
|
|
30
|
+
it { should have_accessor(:guid) }
|
|
31
|
+
it { should have_accessor(:questionnaire) }
|
|
32
|
+
it { should have_accessor(:questionnaire_id) }
|
|
33
|
+
it { should have_accessor(:type) }
|
|
34
|
+
it { should have_accessor(:resolved_executions) }
|
|
35
|
+
it { should have_accessor(:emails) }
|
|
36
|
+
it { should have_accessor(:modified) }
|
|
37
|
+
|
|
38
|
+
describe '#initialize' do
|
|
39
|
+
it 'raises error if questionnaire is not specified' do
|
|
40
|
+
-> { described_class.new }.should raise_error(ArgumentError)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'raises error if questionnaire is not an instance of GroupDocs::Questionnaire' do
|
|
44
|
+
-> { described_class.new(questionnaire: '') }.should raise_error(ArgumentError)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe '#type=' do
|
|
49
|
+
it 'saves type in machine readable format if symbol is passed' do
|
|
50
|
+
subject.type = :binary
|
|
51
|
+
subject.instance_variable_get(:@type).should == 'Binary'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'does nothing if parameter is not symbol' do
|
|
55
|
+
subject.type = 'Binary'
|
|
56
|
+
subject.instance_variable_get(:@type).should == 'Binary'
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#type' do
|
|
61
|
+
it 'returns converted to human-readable format type' do
|
|
62
|
+
subject.should_receive(:parse_status).with('Embedded').and_return(:embedded)
|
|
63
|
+
subject.type = 'Embedded'
|
|
64
|
+
subject.type.should == :embedded
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#modified' do
|
|
69
|
+
it 'returns converted to Time object Unix timestamp' do
|
|
70
|
+
subject.modified = 1330450135000
|
|
71
|
+
subject.modified.should == Time.at(1330450135)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe '#add!' do
|
|
76
|
+
before(:each) do
|
|
77
|
+
mock_api_server(load_json('questionnaire_collectors_add'))
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'accepts access credentials hash' do
|
|
81
|
+
lambda do
|
|
82
|
+
subject.add!(client_id: 'client_id', private_key: 'private_key')
|
|
83
|
+
end.should_not raise_error(ArgumentError)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'gets questionnaire id' do
|
|
87
|
+
subject.questionnaire.should_receive(:guid)
|
|
88
|
+
subject.add!
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'updates id and guid with response' do
|
|
92
|
+
lambda do
|
|
93
|
+
subject.add!
|
|
94
|
+
end.should change {
|
|
95
|
+
subject.id
|
|
96
|
+
subject.guid
|
|
97
|
+
}
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe '#update!' do
|
|
102
|
+
before(:each) do
|
|
103
|
+
mock_api_server('{ "status": "Ok", "result": { "collector_id": 123456 }}')
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'accepts access credentials hash' do
|
|
107
|
+
lambda do
|
|
108
|
+
subject.update!(client_id: 'client_id', private_key: 'private_key')
|
|
109
|
+
end.should_not raise_error(ArgumentError)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe '#remove!' do
|
|
114
|
+
before(:each) do
|
|
115
|
+
mock_api_server('{ "status": "Ok", "result": {}}')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'accepts access credentials hash' do
|
|
119
|
+
lambda do
|
|
120
|
+
subject.remove!(client_id: 'client_id', private_key: 'private_key')
|
|
121
|
+
end.should_not raise_error(ArgumentError)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
describe '#executions!' do
|
|
126
|
+
before(:each) do
|
|
127
|
+
mock_api_server(load_json('questionnaire_executions'))
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'accepts access credentials hash' do
|
|
131
|
+
lambda do
|
|
132
|
+
subject.executions!(client_id: 'client_id', private_key: 'private_key')
|
|
133
|
+
end.should_not raise_error(ArgumentError)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it 'returns an array of GroupDocs::Questionnaire::Execution objects' do
|
|
137
|
+
executions = subject.executions!
|
|
138
|
+
executions.should be_an(Array)
|
|
139
|
+
executions.each do |execution|
|
|
140
|
+
execution.should be_a(GroupDocs::Questionnaire::Execution)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
describe '#add_execution!' do
|
|
146
|
+
before(:each) do
|
|
147
|
+
mock_api_server(load_json('questionnaire_execution_add'))
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
let(:execution) { GroupDocs::Questionnaire::Execution.new }
|
|
151
|
+
|
|
152
|
+
it 'accepts access credentials hash' do
|
|
153
|
+
lambda do
|
|
154
|
+
subject.add_execution!(execution, client_id: 'client_id', private_key: 'private_key')
|
|
155
|
+
end.should_not raise_error(ArgumentError)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it 'raises error if execution is not GroupDocs::Questionnaire::Execution object' do
|
|
159
|
+
-> { subject.add_execution!('Execution') }.should raise_error(ArgumentError)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it 'uses hashed version of execution along with executive payload' do
|
|
163
|
+
execution.should_receive(:to_hash)
|
|
164
|
+
subject.add_execution!(execution)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it 'returns GroupDocs::Questionnaire::Execution object' do
|
|
168
|
+
subject.add_execution!(execution).should be_a(GroupDocs::Questionnaire::Execution)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
describe '#fill!' do
|
|
173
|
+
before(:each) do
|
|
174
|
+
mock_api_server(load_json('document_datasource'))
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
let(:datasource) do
|
|
178
|
+
GroupDocs::DataSource.new(id: 1)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it 'accepts access credentials hash' do
|
|
182
|
+
lambda do
|
|
183
|
+
subject.fill!(datasource, {}, client_id: 'client_id', private_key: 'private_key')
|
|
184
|
+
end.should_not raise_error(ArgumentError)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it 'accepts options hash' do
|
|
188
|
+
lambda do
|
|
189
|
+
subject.fill!(datasource, new_type: :pdf)
|
|
190
|
+
end.should_not raise_error(ArgumentError)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it 'raises error if datasource is not GroupDocs::Datasource object' do
|
|
194
|
+
-> { subject.fill!('Datasource') }.should raise_error(ArgumentError)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it 'returns GroupDocs::Job object' do
|
|
198
|
+
subject.fill!(datasource).should be_a(GroupDocs::Job)
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|