groupdocs 0.3.11 → 1.0.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.
Files changed (122) hide show
  1. data/CHANGELOG.md +150 -0
  2. data/README.md +6 -58
  3. data/Rakefile +1 -1
  4. data/examples/README.md +13 -0
  5. data/examples/annotations/Gemfile +5 -0
  6. data/examples/annotations/app.rb +67 -0
  7. data/groupdocs.gemspec +3 -3
  8. data/lib/groupdocs.rb +11 -2
  9. data/lib/groupdocs/api/entity.rb +17 -1
  10. data/lib/groupdocs/api/helpers/path_helper.rb +10 -10
  11. data/lib/groupdocs/api/helpers/rest_helper.rb +7 -2
  12. data/lib/groupdocs/api/helpers/url_helper.rb +2 -4
  13. data/lib/groupdocs/api/request.rb +2 -4
  14. data/lib/groupdocs/datasource.rb +2 -2
  15. data/lib/groupdocs/datasource/field.rb +1 -1
  16. data/lib/groupdocs/document.rb +6 -18
  17. data/lib/groupdocs/document/annotation.rb +25 -2
  18. data/lib/groupdocs/document/annotation/reply.rb +6 -10
  19. data/lib/groupdocs/document/change.rb +1 -1
  20. data/lib/groupdocs/document/field.rb +1 -1
  21. data/lib/groupdocs/document/metadata.rb +1 -1
  22. data/lib/groupdocs/document/rectangle.rb +1 -1
  23. data/lib/groupdocs/document/view.rb +1 -1
  24. data/lib/groupdocs/job.rb +51 -8
  25. data/lib/groupdocs/questionnaire.rb +2 -2
  26. data/lib/groupdocs/questionnaire/execution.rb +1 -1
  27. data/lib/groupdocs/questionnaire/page.rb +1 -1
  28. data/lib/groupdocs/questionnaire/question.rb +1 -1
  29. data/lib/groupdocs/questionnaire/question/answer.rb +1 -1
  30. data/lib/groupdocs/signature.rb +134 -0
  31. data/lib/groupdocs/signature/contact.rb +141 -0
  32. data/lib/groupdocs/signature/envelope.rb +376 -0
  33. data/lib/groupdocs/signature/envelope/log.rb +22 -0
  34. data/lib/groupdocs/signature/field.rb +253 -0
  35. data/lib/groupdocs/signature/field/location.rb +72 -0
  36. data/lib/groupdocs/signature/form.rb +202 -0
  37. data/lib/groupdocs/signature/list.rb +93 -0
  38. data/lib/groupdocs/signature/recipient.rb +47 -0
  39. data/lib/groupdocs/signature/role.rb +84 -0
  40. data/lib/groupdocs/signature/shared.rb +6 -0
  41. data/lib/groupdocs/signature/shared/document_methods.rb +98 -0
  42. data/lib/groupdocs/signature/shared/entity_fields.rb +94 -0
  43. data/lib/groupdocs/signature/shared/entity_methods.rb +145 -0
  44. data/lib/groupdocs/signature/shared/field_methods.rb +282 -0
  45. data/lib/groupdocs/signature/shared/recipient_methods.rb +63 -0
  46. data/lib/groupdocs/signature/shared/resource_methods.rb +65 -0
  47. data/lib/groupdocs/signature/template.rb +104 -0
  48. data/lib/groupdocs/storage/file.rb +69 -62
  49. data/lib/groupdocs/storage/folder.rb +54 -88
  50. data/lib/groupdocs/storage/package.rb +1 -1
  51. data/lib/groupdocs/subscription.rb +113 -0
  52. data/lib/groupdocs/subscription/limit.rb +24 -0
  53. data/lib/groupdocs/user.rb +22 -2
  54. data/lib/groupdocs/version.rb +1 -1
  55. data/spec/groupdocs/api/entity_spec.rb +14 -0
  56. data/spec/groupdocs/api/helpers/path_helper_spec.rb +6 -19
  57. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +9 -0
  58. data/spec/groupdocs/api/request_spec.rb +2 -7
  59. data/spec/groupdocs/datasource_spec.rb +3 -7
  60. data/spec/groupdocs/document/annotation/reply_spec.rb +11 -20
  61. data/spec/groupdocs/document/annotation_spec.rb +35 -31
  62. data/spec/groupdocs/document/field_spec.rb +1 -4
  63. data/spec/groupdocs/document/rectangle_spec.rb +10 -22
  64. data/spec/groupdocs/document_spec.rb +7 -27
  65. data/spec/groupdocs/job_spec.rb +43 -0
  66. data/spec/groupdocs/questionnaire/question_spec.rb +2 -6
  67. data/spec/groupdocs/questionnaire_spec.rb +3 -7
  68. data/spec/groupdocs/signature/contact_spec.rb +129 -0
  69. data/spec/groupdocs/signature/envelope/log_spec.rb +23 -0
  70. data/spec/groupdocs/signature/envelope_spec.rb +296 -0
  71. data/spec/groupdocs/signature/field/location_spec.rb +73 -0
  72. data/spec/groupdocs/signature/field_spec.rb +264 -0
  73. data/spec/groupdocs/signature/form_spec.rb +174 -0
  74. data/spec/groupdocs/signature/list_spec.rb +92 -0
  75. data/spec/groupdocs/signature/recipient_spec.rb +37 -0
  76. data/spec/groupdocs/signature/role_spec.rb +100 -0
  77. data/spec/groupdocs/signature/template_spec.rb +82 -0
  78. data/spec/groupdocs/signature_spec.rb +117 -0
  79. data/spec/groupdocs/storage/file_spec.rb +76 -61
  80. data/spec/groupdocs/storage/folder_spec.rb +43 -90
  81. data/spec/groupdocs/storage/package_spec.rb +1 -2
  82. data/spec/groupdocs/subscription/limit_spec.rb +24 -0
  83. data/spec/groupdocs/subscription_spec.rb +85 -0
  84. data/spec/groupdocs/user_spec.rb +27 -18
  85. data/spec/groupdocs_spec.rb +11 -0
  86. data/spec/spec_helper.rb +10 -1
  87. data/spec/support/files/envelope.zip +0 -0
  88. data/spec/support/json/annotation_access_set.json +11 -0
  89. data/spec/support/json/contact_add.json +12 -0
  90. data/spec/support/json/contacts_get.json +19 -0
  91. data/spec/support/json/contacts_import.json +8 -0
  92. data/spec/support/json/envelope_get.json +46 -0
  93. data/spec/support/json/envelope_logs.json +16 -0
  94. data/spec/support/json/envelopes_all.json +48 -0
  95. data/spec/support/json/envelopes_resources.json +31 -0
  96. data/spec/support/json/form_get.json +21 -0
  97. data/spec/support/json/forms_all.json +23 -0
  98. data/spec/support/json/job_get.json +30 -0
  99. data/spec/support/json/list_add.json +12 -0
  100. data/spec/support/json/lists_get.json +19 -0
  101. data/spec/support/json/signature_create.json +12 -0
  102. data/spec/support/json/signature_field_add.json +25 -0
  103. data/spec/support/json/signature_fields_get.json +27 -0
  104. data/spec/support/json/signature_roles_get.json +17 -0
  105. data/spec/support/json/signatures_get.json +19 -0
  106. data/spec/support/json/subscription_plan_get.json +9 -0
  107. data/spec/support/json/subscription_plans_get.json +17 -0
  108. data/spec/support/json/template_get.json +35 -0
  109. data/spec/support/json/template_get_documents.json +15 -0
  110. data/spec/support/json/template_get_recipients.json +20 -0
  111. data/spec/support/json/templates_all.json +37 -0
  112. data/spec/support/json/user_users_get.json +27 -0
  113. data/spec/support/shared_examples/signature/shared/document_methods.rb +68 -0
  114. data/spec/support/shared_examples/signature/shared/entity_fields.rb +89 -0
  115. data/spec/support/shared_examples/signature/shared/entity_methods.rb +116 -0
  116. data/spec/support/shared_examples/signature/shared/field_methods.rb +188 -0
  117. data/spec/support/shared_examples/signature/shared/recipient_methods.rb +42 -0
  118. data/spec/support/shared_examples/signature/shared/resource_methods.rb +46 -0
  119. metadata +139 -29
  120. data/lib/groupdocs/extensions.rb +0 -1
  121. data/lib/groupdocs/extensions/lookup.rb +0 -52
  122. data/spec/support/shared_examples/extensions/lookup.rb +0 -57
@@ -0,0 +1,113 @@
1
+ module GroupDocs
2
+ class Subscription < Api::Entity
3
+
4
+ require 'groupdocs/subscription/limit'
5
+
6
+ LIMITS = {
7
+ annotations_limit: 'AnnotationsLimit',
8
+ apicalls: 'APICalls',
9
+ apiemails: 'APIEmails',
10
+ assembly_limit: 'AssemblyLimit',
11
+ branded: 'Branded',
12
+ comparison_limit: 'ComparisonLimit',
13
+ conversion_limit: 'ConversionLimit',
14
+ documents_limit: 'DocumentsLimit',
15
+ document_history_limit: 'DocumentHistoryLimit',
16
+ document_size_limit: 'DocumentSizeLimit',
17
+ document_tokens_limit: 'DocumentTokensLimit',
18
+ sharing_limit: 'SharingLimit',
19
+ signature_limit: 'SignatureLimit',
20
+ storage_space_limit: 'StorageSpaceLimit',
21
+ users_limit: 'UsersLimit',
22
+ }
23
+
24
+ #
25
+ # Returns current subscription plan.
26
+ #
27
+ # @example
28
+ # GroupDocs::Subscription.current!.name
29
+ # #=> 'Free'
30
+ #
31
+ # @param [Hash] access Access credentials
32
+ # @option access [String] :client_id
33
+ # @option access [String] :private_key
34
+ # @return [GroupDocs::Subscription]
35
+ #
36
+ def self.current!(access = {})
37
+ json = Api::Request.new do |request|
38
+ request[:access] = access
39
+ request[:method] = :GET
40
+ request[:path] = '/system/{{client_id}}/plan'
41
+ end.execute!
42
+
43
+ new(json)
44
+ end
45
+
46
+ #
47
+ # Returns all subscription plans for family.
48
+ #
49
+ # @param [Hash] access Access credentials
50
+ # @option access [String] :client_id
51
+ # @option access [String] :private_key
52
+ # @return [Array<GroupDocs::Subscription>]
53
+ #
54
+ def self.list!(access = {})
55
+ json = Api::Request.new do |request|
56
+ request[:access] = access
57
+ request[:method] = :GET
58
+ request[:path] = '/system/{{client_id}}/plans/groupdocs'
59
+ end.execute!
60
+
61
+ json[:metrics].map do |plan|
62
+ new(plan)
63
+ end
64
+ end
65
+
66
+ # @attr [Integer] Id
67
+ attr_accessor :Id
68
+ # @attr [String] Name
69
+ attr_accessor :Name
70
+ # @attr [Integer] PricingPlanId
71
+ attr_accessor :PricingPlanId
72
+ # @attr [Integer] Price
73
+ attr_accessor :Price
74
+ # @attr [String] CurrencyCode
75
+ attr_accessor :CurrencyCode
76
+
77
+ # Human-readable accessors
78
+ alias_method :id, :Id
79
+ alias_method :id=, :Id=
80
+ alias_method :name, :Name
81
+ alias_method :name=, :Name=
82
+ alias_method :pricing_plan_id, :PricingPlanId
83
+ alias_method :pricing_plan_id=, :PricingPlanId=
84
+ alias_method :price, :Price
85
+ alias_method :price=, :Price=
86
+ alias_method :currency_code, :CurrencyCode
87
+ alias_method :currency_code=, :CurrencyCode=
88
+
89
+ # Compatibility with response JSON
90
+ alias_method :ref_id=, :id=
91
+
92
+ #
93
+ # Dynamically generate accessors for existing subscription plan limits.
94
+ #
95
+ LIMITS.each do |snake, camel|
96
+ # @attr [GroupDocs::Subscription::Limit] limit
97
+ attr_accessor camel
98
+
99
+ # Human-readable accessors
100
+ alias_method :"#{snake}", :"#{camel}"
101
+ alias_method :"#{snake}=", :"#{camel}="
102
+
103
+ #
104
+ # Converts hash to subscription plan limit.
105
+ # @return [GroupDocs::Subscription::Limit]
106
+ #
107
+ define_method(snake) do
108
+ Limit.new(instance_variable_get(:"@#{camel}"))
109
+ end
110
+ end
111
+
112
+ end # Subscription
113
+ end # GroupDocs
@@ -0,0 +1,24 @@
1
+ module GroupDocs
2
+ class Subscription::Limit < Api::Entity
3
+
4
+ # @attr [Integer] Id
5
+ attr_accessor :Id
6
+ # @attr [Integer] Min
7
+ attr_accessor :Min
8
+ # @attr [Integer] Max
9
+ attr_accessor :Max
10
+ # @attr [String] Description
11
+ attr_accessor :Description
12
+
13
+ # Human-readable accessors
14
+ alias_method :id, :Id
15
+ alias_method :id=, :Id=
16
+ alias_method :min, :Min
17
+ alias_method :min=, :Min=
18
+ alias_method :max, :Max
19
+ alias_method :max=, :Max=
20
+ alias_method :description, :Description
21
+ alias_method :description=, :Description=
22
+
23
+ end # Subscription::Limit
24
+ end # GroupDocs
@@ -1,10 +1,10 @@
1
1
  module GroupDocs
2
- class User < GroupDocs::Api::Entity
2
+ class User < Api::Entity
3
3
 
4
4
  #
5
5
  # Returns current user profile.
6
6
  #
7
- # @example Get fill
7
+ # @example
8
8
  # user = GroupDocs::User.get!
9
9
  # user.first_name
10
10
  # #=> "John"
@@ -97,5 +97,25 @@ module GroupDocs
97
97
  end.execute!
98
98
  end
99
99
 
100
+ #
101
+ # Returns an array of users associated to current user account.
102
+ #
103
+ # @param [Hash] access Access credentials
104
+ # @option access [String] :client_id
105
+ # @option access [String] :private_key
106
+ # @return [Array<GroupDocs::User>]
107
+ #
108
+ def users!(access = {})
109
+ json = Api::Request.new do |request|
110
+ request[:access] = access
111
+ request[:method] = :GET
112
+ request[:path] = '/mgmt/{{client_id}}/account/users'
113
+ end.execute!
114
+
115
+ json[:users].map do |user|
116
+ GroupDocs::User.new(user)
117
+ end
118
+ end
119
+
100
120
  end # User
101
121
  end # GroupDocs
@@ -1,3 +1,3 @@
1
1
  module GroupDocs
2
- VERSION = '0.3.11'
2
+ VERSION = '1.0.0'
3
3
  end # GroupDocs
@@ -65,4 +65,18 @@ describe GroupDocs::Api::Entity do
65
65
  subject.send(:accessor_to_variable, :test_one_and_two).should == :@TestOneAndTwo
66
66
  end
67
67
  end
68
+
69
+ describe '#class_name' do
70
+ it 'returns downcased class name' do
71
+ object = GroupDocs::Storage::File.new
72
+ object.send(:class_name).should == 'file'
73
+ end
74
+ end
75
+
76
+ describe '#pluralized_class_name' do
77
+ it 'returns class name ending with s' do
78
+ object = GroupDocs::Storage::File.new
79
+ object.send(:pluralized_class_name).should == 'files'
80
+ end
81
+ end
68
82
  end
@@ -1,28 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GroupDocs::Api::Helpers::Path do
4
+ subject { GroupDocs::Storage::File.new }
4
5
 
5
- describe '.verify_starts_with_root' do
6
- it 'does not raise error if path starts with /' do
7
- -> { described_class.verify_starts_with_root('/Test') }.should_not raise_error(ArgumentError)
6
+ describe '#prepare_path' do
7
+ it 'removes first / from string' do
8
+ subject.send(:prepare_path, '/test').should == 'test'
8
9
  end
9
10
 
10
- it 'raises error if path does not start with /' do
11
- -> { described_class.verify_starts_with_root('Test') }.should raise_error(ArgumentError)
12
- end
13
- end
14
-
15
- describe '.append_file_name' do
16
- it 'does not change path if filename is present' do
17
- path = '/upload_path/test.pdf'
18
- described_class.append_file_name(path, __FILE__)
19
- path.should == '/upload_path/test.pdf'
20
- end
21
-
22
- it 'appends filename to path if it is not passed' do
23
- path = '/upload_path'
24
- described_class.append_file_name(path, __FILE__)
25
- path.should == "/upload_path/#{File.basename(__FILE__)}"
11
+ it 'removes two or more / from string' do
12
+ subject.send(:prepare_path, 'test1//test2///test3').should == 'test1/test2/test3'
26
13
  end
27
14
  end
28
15
  end
@@ -79,6 +79,15 @@ describe GroupDocs::Api::Helpers::REST do
79
79
  subject.send(:prepare_request)
80
80
  end.should change { subject.options[:headers][:content_type] }.to('application/json')
81
81
  end
82
+
83
+ it 'allows sending payload as plain text' do
84
+ subject.options[:method] = :POST
85
+ subject.options[:request_body] = 'test'
86
+ subject.options[:plain] = true
87
+ subject.send(:prepare_request)
88
+ subject.options[:request_body].should == 'test'
89
+ subject.options[:headers][:content_type].should_not == 'application/json'
90
+ end
82
91
  end
83
92
 
84
93
  describe '#send_request' do
@@ -40,17 +40,12 @@ describe GroupDocs::Api::Request do
40
40
  describe '#execute!' do
41
41
  before(:each) do
42
42
  GroupDocs.stub(private_key: 'private_key')
43
- subject.options[:method] = :get
44
- subject.options[:path] = '/folders'
43
+ subject.options[:method] = :get
44
+ subject.options[:path] = '/folders'
45
45
  subject.options[:headers] = {}
46
46
  mock_api_server('{"status":"Ok"}')
47
47
  end
48
48
 
49
- it 'normalizes path' do
50
- subject.should_receive(:normalize_path)
51
- subject.execute!
52
- end
53
-
54
49
  it 'parses path' do
55
50
  subject.should_receive(:parse_path)
56
51
  subject.execute!
@@ -44,12 +44,8 @@ describe GroupDocs::DataSource do
44
44
  it { should respond_to(:fields) }
45
45
  it { should respond_to(:fields=) }
46
46
 
47
- it 'has human-readable accessors' do
48
- subject.should respond_to(:description)
49
- subject.should respond_to(:description=)
50
- subject.method(:description).should == subject.method(:descr)
51
- subject.method(:description=).should == subject.method(:descr=)
52
- end
47
+ it { should have_alias(:description, :descr) }
48
+ it { should have_alias(:description=, :descr=) }
53
49
 
54
50
  describe '#created_on' do
55
51
  it 'returns converted to Time object Unix timestamp' do
@@ -118,7 +114,7 @@ describe GroupDocs::DataSource do
118
114
  subject.add!
119
115
  end
120
116
 
121
- it 'adds ID of datasource from response to self' do
117
+ it 'updates identifier of datasource' do
122
118
  lambda do
123
119
  subject.add!
124
120
  end.should change(subject, :id)
@@ -73,24 +73,15 @@ describe GroupDocs::Document::Annotation::Reply do
73
73
  it { should respond_to(:repliedOn) }
74
74
  it { should respond_to(:repliedOn=) }
75
75
 
76
- it 'has human-readable accessors' do
77
- subject.should respond_to(:annotation_guid)
78
- subject.should respond_to(:annotation_guid=)
79
- subject.should respond_to(:user_guid)
80
- subject.should respond_to(:user_guid=)
81
- subject.should respond_to(:user_name)
82
- subject.should respond_to(:user_name=)
83
- subject.should respond_to(:replied_on)
84
- subject.should respond_to(:replied_on=)
85
- subject.method(:annotation_guid).should == subject.method(:annotationGuid)
86
- subject.method(:annotation_guid=).should == subject.method(:annotationGuid=)
87
- subject.method(:user_guid).should == subject.method(:userGuid)
88
- subject.method(:user_guid=).should == subject.method(:userGuid=)
89
- subject.method(:user_name).should == subject.method(:userName)
90
- subject.method(:user_name=).should == subject.method(:userName=)
91
- # Reply#replied_on is overwritten
92
- subject.method(:replied_on=).should == subject.method(:repliedOn=)
93
- end
76
+ it { should have_alias(:annotation_guid, :annotationGuid) }
77
+ it { should have_alias(:annotation_guid=, :annotationGuid=) }
78
+ it { should have_alias(:user_guid, :userGuid) }
79
+ it { should have_alias(:user_guid=, :userGuid=) }
80
+ it { should have_alias(:user_name, :userName) }
81
+ it { should have_alias(:user_name=, :userName=) }
82
+ # Reply#replied_on is overwritten
83
+ it { should have_alias(:replied_on=, :repliedOn=) }
84
+
94
85
 
95
86
  describe '#initialize' do
96
87
  it 'raises error if annotation is not specified' do
@@ -137,7 +128,7 @@ describe GroupDocs::Document::Annotation::Reply do
137
128
 
138
129
  describe '#edit!' do
139
130
  before(:each) do
140
- mock_api_server('{"result": {}, "status": "Ok", "error_message": null}')
131
+ mock_api_server('{ "result": {}, "status": "Ok" }')
141
132
  end
142
133
 
143
134
  it 'accepts access credentials hash' do
@@ -149,7 +140,7 @@ describe GroupDocs::Document::Annotation::Reply do
149
140
 
150
141
  describe '#remove!' do
151
142
  before(:each) do
152
- mock_api_server('{"result": {}, "status": "Ok", "error_message": null}')
143
+ mock_api_server('{ "result": {}, "status": "Ok" }')
153
144
  end
154
145
 
155
146
  it 'accepts access credentials hash' do
@@ -21,6 +21,8 @@ describe GroupDocs::Document::Annotation do
21
21
  it { should respond_to(:sessionGuid=) }
22
22
  it { should respond_to(:documentGuid) }
23
23
  it { should respond_to(:documentGuid=) }
24
+ it { should respond_to(:creatorGuid) }
25
+ it { should respond_to(:creatorGuid=) }
24
26
  it { should respond_to(:replyGuid) }
25
27
  it { should respond_to(:replyGuid=) }
26
28
  it { should respond_to(:createdOn) }
@@ -36,35 +38,21 @@ describe GroupDocs::Document::Annotation do
36
38
  it { should respond_to(:annotationPosition) }
37
39
  it { should respond_to(:annotationPosition=) }
38
40
 
39
- it 'has human-readable accessors' do
40
- subject.should respond_to(:session_guid)
41
- subject.should respond_to(:session_guid=)
42
- subject.should respond_to(:document_guid)
43
- subject.should respond_to(:document_guid=)
44
- subject.should respond_to(:reply_guid)
45
- subject.should respond_to(:reply_guid=)
46
- subject.should respond_to(:created_on)
47
- subject.should respond_to(:created_on=)
48
- subject.should respond_to(:annotation_position)
49
- subject.should respond_to(:annotation_position=)
50
- subject.should respond_to(:position)
51
- subject.method(:session_guid).should == subject.method(:sessionGuid)
52
- subject.method(:session_guid=).should == subject.method(:sessionGuid=)
53
- subject.method(:document_guid).should == subject.method(:documentGuid)
54
- subject.method(:document_guid=).should == subject.method(:documentGuid=)
55
- subject.method(:reply_guid).should == subject.method(:replyGuid)
56
- subject.method(:reply_guid=).should == subject.method(:replyGuid=)
57
- # Annotation#created_on is overwritten
58
- subject.method(:created_on=).should == subject.method(:createdOn=)
59
- subject.method(:annotation_position).should == subject.method(:annotationPosition)
60
- subject.method(:annotation_position=).should == subject.method(:annotationPosition=)
61
- subject.method(:position).should == subject.method(:annotation_position)
62
- end
63
-
64
- it 'is compatible with response JSON' do
65
- subject.should respond_to(:annotationGuid=)
66
- subject.method(:annotationGuid=).should == subject.method(:guid=)
67
- end
41
+ it { should have_alias(:session_guid, :sessionGuid) }
42
+ it { should have_alias(:session_guid=, :sessionGuid=) }
43
+ it { should have_alias(:document_guid, :documentGuid) }
44
+ it { should have_alias(:document_guid=, :documentGuid=) }
45
+ it { should have_alias(:creator_guid, :creatorGuid) }
46
+ it { should have_alias(:creator_guid=, :creatorGuid=) }
47
+ it { should have_alias(:reply_guid, :replyGuid) }
48
+ it { should have_alias(:reply_guid=, :replyGuid=) }
49
+ # Annotation#created_on is overwritten
50
+ it { should have_alias(:created_on=, :createdOn=) }
51
+ it { should have_alias(:annotation_position, :annotationPosition) }
52
+ it { should have_alias(:annotation_position=, :annotationPosition=) }
53
+ it { should have_alias(:position, :annotation_position) }
54
+
55
+ it { should have_alias(:annotationGuid=, :guid=) }
68
56
 
69
57
  describe '#initialize' do
70
58
  it 'raises error if document is not specified' do
@@ -236,8 +224,7 @@ describe GroupDocs::Document::Annotation do
236
224
  end
237
225
 
238
226
  it 'is aliased to #collaborators=' do
239
- subject.should respond_to(:collaborators=)
240
- subject.method(:collaborators=).should == subject.method(:collaborators_set!)
227
+ subject.should have_alias(:collaborators=, :collaborators_set!)
241
228
  end
242
229
  end
243
230
 
@@ -277,4 +264,21 @@ describe GroupDocs::Document::Annotation do
277
264
  end.should change(subject, :annotation_position).to(x: 10, y: 10)
278
265
  end
279
266
  end
267
+
268
+ describe '#set_access!' do
269
+ before(:each) do
270
+ mock_api_server(load_json('annotation_access_set'))
271
+ end
272
+
273
+ it 'accepts access credentials hash' do
274
+ lambda do
275
+ subject.set_access!(:private, client_id: 'client_id', private_key: 'private_key')
276
+ end.should_not raise_error(ArgumentError)
277
+ end
278
+
279
+ it 'updates annotation access mode' do
280
+ subject.set_access!(:private)
281
+ subject.access.should == :private
282
+ end
283
+ end
280
284
  end
@@ -13,10 +13,7 @@ describe GroupDocs::Document::Field do
13
13
  it { should respond_to(:rectangle) }
14
14
  it { should respond_to(:rectangle=) }
15
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
16
+ it { should have_alias(:rect=, :rectangle=) }
20
17
 
21
18
  describe '#rectangle=' do
22
19
  it 'converts passed hash to GroupDocs::Document::Rectangle object' do