boxr 1.6.0 → 1.7.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.
- checksums.yaml +4 -4
- data/boxr.gemspec +2 -2
- data/lib/boxr/users.rb +20 -8
- data/lib/boxr/version.rb +1 -1
- data/spec/boxr/collaborations_spec.rb +37 -0
- data/spec/boxr/comments_spec.rb +34 -0
- data/spec/boxr/files_spec.rb +123 -0
- data/spec/boxr/folders_spec.rb +72 -0
- data/spec/boxr/groups_spec.rb +65 -0
- data/spec/boxr/metadata_spec.rb +52 -0
- data/spec/boxr/search_spec.rb +12 -0
- data/spec/boxr/tasks_spec.rb +58 -0
- data/spec/boxr/users_spec.rb +52 -0
- data/spec/boxr/watermarking_spec.rb +33 -0
- data/spec/boxr/web_links_spec.rb +22 -0
- data/spec/boxr_spec.rb +3 -553
- data/spec/spec_helper.rb +30 -1
- metadata +31 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1c90479b5424ad7460328707aa758fa10738a99db0e76ab2186625ad64e53d5
|
4
|
+
data.tar.gz: 0b961dc8b412f39ea89f1de347b7dd3cce1aac242a7d44087942c60aa8b73f48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca107dd177c1b7c4acc6e55967a4d218e75e59290558d875c1a34e78023f92ca07581acd9c573840644152dae4c0f554e11b926023bc2c530900f235d122d72a
|
7
|
+
data.tar.gz: a18e866940e903c941a2a0169acf59ea38a2038701afdd0874bf985b47f956d946c7f465ae3ad1b32bdef0be72676a76c51d88b6bbe37555ad9f5571912194be
|
data/boxr.gemspec
CHANGED
@@ -25,11 +25,11 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.1"
|
26
26
|
spec.add_development_dependency "simplecov", "~> 0.9"
|
27
27
|
spec.add_development_dependency "dotenv", "~> 0.11"
|
28
|
-
spec.add_development_dependency "awesome_print"
|
28
|
+
spec.add_development_dependency "awesome_print", "~> 1.8"
|
29
29
|
spec.add_development_dependency "lru_redux", "~> 0.8"
|
30
30
|
|
31
31
|
spec.add_runtime_dependency "httpclient", "~> 2.8"
|
32
32
|
spec.add_runtime_dependency "hashie", "~> 3.5"
|
33
33
|
spec.add_runtime_dependency "addressable", "~> 2.3"
|
34
|
-
spec.add_runtime_dependency "jwt", "
|
34
|
+
spec.add_runtime_dependency "jwt", ">= 1.4"
|
35
35
|
end
|
data/lib/boxr/users.rb
CHANGED
@@ -4,7 +4,7 @@ module Boxr
|
|
4
4
|
def current_user(fields: [])
|
5
5
|
uri = "#{USERS_URI}/me"
|
6
6
|
query = build_fields_query(fields, USER_FIELDS_QUERY)
|
7
|
-
|
7
|
+
|
8
8
|
user, response = get(uri, query: query)
|
9
9
|
user
|
10
10
|
end
|
@@ -14,7 +14,7 @@ module Boxr
|
|
14
14
|
user_id = ensure_id(user_id)
|
15
15
|
uri = "#{USERS_URI}/#{user_id}"
|
16
16
|
query = build_fields_query(fields, USER_FIELDS_QUERY)
|
17
|
-
|
17
|
+
|
18
18
|
user, response = get(uri, query: query)
|
19
19
|
user
|
20
20
|
end
|
@@ -30,7 +30,7 @@ module Boxr
|
|
30
30
|
else
|
31
31
|
query[:offset] = offset
|
32
32
|
query[:limit] = limit
|
33
|
-
|
33
|
+
|
34
34
|
users, response = get(uri, query: query)
|
35
35
|
users['entries']
|
36
36
|
end
|
@@ -49,7 +49,7 @@ module Boxr
|
|
49
49
|
attributes[:language] = language unless language.nil?
|
50
50
|
attributes[:is_sync_enabled] = is_sync_enabled unless is_sync_enabled.nil?
|
51
51
|
attributes[:job_title] = job_title unless job_title.nil?
|
52
|
-
attributes[:phone] = phone unless phone.nil?
|
52
|
+
attributes[:phone] = phone unless phone.nil?
|
53
53
|
attributes[:address] = address unless address.nil?
|
54
54
|
attributes[:space_amount] = space_amount unless space_amount.nil?
|
55
55
|
attributes[:tracking_codes] = tracking_codes unless tracking_codes.nil?
|
@@ -57,7 +57,7 @@ module Boxr
|
|
57
57
|
attributes[:is_external_collab_restricted] = is_external_collab_restricted unless is_external_collab_restricted.nil?
|
58
58
|
attributes[:status] = status unless status.nil?
|
59
59
|
attributes[:timezone] = timezone unless timezone.nil?
|
60
|
-
attributes[:is_exempt_from_device_limits] = is_exempt_from_device_limits unless is_exempt_from_device_limits.nil?
|
60
|
+
attributes[:is_exempt_from_device_limits] = is_exempt_from_device_limits unless is_exempt_from_device_limits.nil?
|
61
61
|
attributes[:is_exempt_from_login_verification] = is_exempt_from_login_verification unless is_exempt_from_login_verification.nil?
|
62
62
|
attributes[:is_platform_access_only] = is_platform_access_only unless is_platform_access_only.nil?
|
63
63
|
|
@@ -73,9 +73,9 @@ module Boxr
|
|
73
73
|
user_id = ensure_id(user)
|
74
74
|
uri = "#{USERS_URI}/#{user_id}"
|
75
75
|
query = {notify: notify} unless notify.nil?
|
76
|
-
|
76
|
+
|
77
77
|
attributes = {}
|
78
|
-
attributes[:enterprise] = nil if enterprise.nil? #this is a special condition where setting this to nil means to roll this user out of the enterprise
|
78
|
+
attributes[:enterprise] = nil if enterprise.nil? #this is a special condition where setting this to nil means to roll this user out of the enterprise
|
79
79
|
attributes[:name] = name unless name.nil?
|
80
80
|
attributes[:role] = role unless role.nil?
|
81
81
|
attributes[:language] = language unless language.nil?
|
@@ -108,6 +108,18 @@ module Boxr
|
|
108
108
|
result
|
109
109
|
end
|
110
110
|
|
111
|
+
# As of writing, API only supports a root source folder (0)
|
112
|
+
def move_users_folder(user, source_folder = 0, destination_user)
|
113
|
+
user_id = ensure_id(user)
|
114
|
+
destination_user_id = ensure_id(destination_user)
|
115
|
+
source_folder_id = ensure_id(source_folder)
|
116
|
+
uri = "#{USERS_URI}/#{user_id}/folders/#{source_folder_id}"
|
117
|
+
attributes = {owned_by: {id: destination_user_id}}
|
118
|
+
|
119
|
+
folder, response = put(uri, attributes)
|
120
|
+
folder
|
121
|
+
end
|
122
|
+
|
111
123
|
def email_aliases_for_user(user)
|
112
124
|
user_id = ensure_id(user)
|
113
125
|
uri = "#{USERS_URI}/#{user_id}/email_aliases"
|
@@ -135,4 +147,4 @@ module Boxr
|
|
135
147
|
end
|
136
148
|
|
137
149
|
end
|
138
|
-
end
|
150
|
+
end
|
data/lib/boxr/version.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
#rake spec SPEC_OPTS="-e \"invokes collaborations operations"\"
|
4
|
+
describe 'collaborations operations' do
|
5
|
+
it "invokes collaborations operations" do
|
6
|
+
puts "add collaboration"
|
7
|
+
collaboration = BOX_CLIENT.add_collaboration(@test_folder, {id: @test_user.id, type: :user}, :viewer_uploader)
|
8
|
+
expect(collaboration.accessible_by.id).to eq(@test_user.id)
|
9
|
+
COLLABORATION = collaboration
|
10
|
+
|
11
|
+
puts "inspect collaboration"
|
12
|
+
collaboration = BOX_CLIENT.collaboration(COLLABORATION)
|
13
|
+
expect(collaboration.id).to eq(COLLABORATION.id)
|
14
|
+
|
15
|
+
puts "edit collaboration"
|
16
|
+
collaboration = BOX_CLIENT.edit_collaboration(COLLABORATION, role: "viewer uploader")
|
17
|
+
expect(collaboration.role).to eq("viewer uploader")
|
18
|
+
|
19
|
+
puts "inspect folder collaborations"
|
20
|
+
collaborations = BOX_CLIENT.folder_collaborations(@test_folder)
|
21
|
+
expect(collaborations.count).to eq(1)
|
22
|
+
expect(collaborations[0].id).to eq(COLLABORATION.id)
|
23
|
+
|
24
|
+
puts "remove collaboration"
|
25
|
+
result = BOX_CLIENT.remove_collaboration(COLLABORATION)
|
26
|
+
expect(result).to eq({})
|
27
|
+
collaborations = BOX_CLIENT.folder_collaborations(@test_folder)
|
28
|
+
expect(collaborations.count).to eq(0)
|
29
|
+
|
30
|
+
puts "inspect pending collaborations"
|
31
|
+
pending_collaborations = BOX_CLIENT.pending_collaborations
|
32
|
+
expect(pending_collaborations).to eq([])
|
33
|
+
|
34
|
+
puts "add invalid collaboration"
|
35
|
+
expect { BOX_CLIENT.add_collaboration(@test_folder, {id: @test_user.id, type: :user}, :invalid_role)}.to raise_error
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
#rake spec SPEC_OPTS="-e \"invokes comment operations"\"
|
4
|
+
describe 'comment operations' do
|
5
|
+
it "invokes comment operations" do
|
6
|
+
new_file = BOX_CLIENT.upload_file("./spec/test_files/#{TEST_FILE_NAME}", @test_folder)
|
7
|
+
test_file = new_file
|
8
|
+
|
9
|
+
puts "add comment to file"
|
10
|
+
comment = BOX_CLIENT.add_comment_to_file(test_file, message: COMMENT_MESSAGE)
|
11
|
+
expect(comment.message).to eq(COMMENT_MESSAGE)
|
12
|
+
COMMENT = comment
|
13
|
+
|
14
|
+
puts "reply to comment"
|
15
|
+
reply = BOX_CLIENT.reply_to_comment(COMMENT, message: REPLY_MESSAGE)
|
16
|
+
expect(reply.message).to eq(REPLY_MESSAGE)
|
17
|
+
|
18
|
+
puts "get file comments"
|
19
|
+
comments = BOX_CLIENT.file_comments(test_file)
|
20
|
+
expect(comments.count).to eq(2)
|
21
|
+
|
22
|
+
puts "update a comment"
|
23
|
+
comment = BOX_CLIENT.change_comment(COMMENT, CHANGED_COMMENT_MESSAGE)
|
24
|
+
expect(comment.message).to eq(CHANGED_COMMENT_MESSAGE)
|
25
|
+
|
26
|
+
puts "get comment info"
|
27
|
+
comment = BOX_CLIENT.comment(COMMENT)
|
28
|
+
expect(comment.id).to eq(COMMENT.id)
|
29
|
+
|
30
|
+
puts "delete comment"
|
31
|
+
result = BOX_CLIENT.delete_comment(COMMENT)
|
32
|
+
expect(result).to eq({})
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
#rake spec SPEC_OPTS="-e \"invokes file operations"\"
|
4
|
+
describe "file operations" do
|
5
|
+
it "invokes file operations" do
|
6
|
+
puts "upload a file"
|
7
|
+
new_file = BOX_CLIENT.upload_file("./spec/test_files/#{TEST_FILE_NAME}", @test_folder)
|
8
|
+
expect(new_file.name).to eq(TEST_FILE_NAME)
|
9
|
+
test_file = new_file
|
10
|
+
|
11
|
+
puts "upload a file with custom name"
|
12
|
+
new_file = BOX_CLIENT.upload_file("./spec/test_files/#{TEST_FILE_NAME}", @test_folder, name: TEST_FILE_NAME_CUSTOM)
|
13
|
+
expect(new_file.name).to eq(TEST_FILE_NAME_CUSTOM)
|
14
|
+
|
15
|
+
puts "get file using path"
|
16
|
+
file = BOX_CLIENT.file_from_path("/#{TEST_FOLDER_NAME}/#{TEST_FILE_NAME}")
|
17
|
+
expect(file.id).to eq(test_file.id)
|
18
|
+
|
19
|
+
puts "get file download url"
|
20
|
+
download_url = BOX_CLIENT.download_url(test_file)
|
21
|
+
expect(download_url).to start_with("https://")
|
22
|
+
|
23
|
+
puts "get file info"
|
24
|
+
file_info = BOX_CLIENT.file(test_file)
|
25
|
+
expect(file_info.id).to eq(test_file.id)
|
26
|
+
|
27
|
+
puts "get file preview link"
|
28
|
+
preview_url = BOX_CLIENT.preview_url(test_file)
|
29
|
+
expect(preview_url).to start_with("https://")
|
30
|
+
|
31
|
+
puts "update file"
|
32
|
+
new_description = 'this file is used to test Boxr'
|
33
|
+
tags = ['tag one','tag two']
|
34
|
+
updated_file_info = BOX_CLIENT.update_file(test_file, description: new_description, tags: tags)
|
35
|
+
expect(updated_file_info.description).to eq(new_description)
|
36
|
+
tag_file_info = BOX_CLIENT.file(updated_file_info, fields: [:tags])
|
37
|
+
expect(tag_file_info.tags.length).to eq(2)
|
38
|
+
|
39
|
+
puts "lock file"
|
40
|
+
expires_at_utc = Time.now.utc + (60*60*24) #one day from now
|
41
|
+
locked_file = BOX_CLIENT.lock_file(test_file, expires_at: expires_at_utc, is_download_prevented: true)
|
42
|
+
locked_file = BOX_CLIENT.file(locked_file, fields: [:lock])
|
43
|
+
expect(locked_file.lock.type).to eq('lock')
|
44
|
+
expect(locked_file.lock.expires_at).to_not be_nil
|
45
|
+
expect(locked_file.lock.is_download_prevented).to eq(true)
|
46
|
+
|
47
|
+
puts "unlock file"
|
48
|
+
unlocked_file = BOX_CLIENT.unlock_file(locked_file)
|
49
|
+
unlocked_file = BOX_CLIENT.file(unlocked_file, fields: [:lock])
|
50
|
+
expect(unlocked_file.lock).to be_nil
|
51
|
+
|
52
|
+
puts "download file"
|
53
|
+
file = BOX_CLIENT.download_file(test_file)
|
54
|
+
f = File.open("./spec/test_files/#{DOWNLOADED_TEST_FILE_NAME}", 'w+')
|
55
|
+
f.write(file)
|
56
|
+
f.close
|
57
|
+
expect(FileUtils.identical?("./spec/test_files/#{TEST_FILE_NAME}","./spec/test_files/#{DOWNLOADED_TEST_FILE_NAME}")).to eq(true)
|
58
|
+
File.delete("./spec/test_files/#{DOWNLOADED_TEST_FILE_NAME}")
|
59
|
+
|
60
|
+
puts "upload new version of file"
|
61
|
+
new_version = BOX_CLIENT.upload_new_version_of_file("./spec/test_files/#{TEST_FILE_NAME}", test_file)
|
62
|
+
expect(new_version.id).to eq(test_file.id)
|
63
|
+
|
64
|
+
puts "inspect versions of file"
|
65
|
+
versions = BOX_CLIENT.versions_of_file(test_file)
|
66
|
+
expect(versions.count).to eq(1) #the reason this is 1 instead of 2 is that Box considers 'versions' to be a versions other than 'current'
|
67
|
+
v1 = versions.first
|
68
|
+
|
69
|
+
puts "promote old version of file"
|
70
|
+
newer_version = BOX_CLIENT.promote_old_version_of_file(test_file, v1)
|
71
|
+
versions = BOX_CLIENT.versions_of_file(test_file)
|
72
|
+
expect(versions.count).to eq(2)
|
73
|
+
|
74
|
+
puts "delete old version of file"
|
75
|
+
result = BOX_CLIENT.delete_old_version_of_file(test_file,v1)
|
76
|
+
versions = BOX_CLIENT.versions_of_file(test_file)
|
77
|
+
expect(versions.count).to eq(2) #this is still 2 because with Box you can restore a trashed old version
|
78
|
+
|
79
|
+
puts "get file thumbnail"
|
80
|
+
thumb = BOX_CLIENT.thumbnail(test_file)
|
81
|
+
expect(thumb).not_to be_nil
|
82
|
+
|
83
|
+
puts "create shared link for file"
|
84
|
+
updated_file = BOX_CLIENT.create_shared_link_for_file(test_file, access: :open)
|
85
|
+
expect(updated_file.shared_link.access).to eq("open")
|
86
|
+
|
87
|
+
puts "create password-protected shared link for file"
|
88
|
+
updated_file = BOX_CLIENT.create_shared_link_for_file(test_file, password: 'password')
|
89
|
+
expect(updated_file.shared_link.is_password_enabled).to eq(true)
|
90
|
+
|
91
|
+
puts "disable shared link for file"
|
92
|
+
updated_file = BOX_CLIENT.disable_shared_link_for_file(test_file)
|
93
|
+
expect(updated_file.shared_link).to be_nil
|
94
|
+
|
95
|
+
puts "copy file"
|
96
|
+
new_file_name = "copy of #{TEST_FILE_NAME}"
|
97
|
+
new_file = BOX_CLIENT.copy_file(test_file, @test_folder, name: new_file_name)
|
98
|
+
expect(new_file.name).to eq(new_file_name)
|
99
|
+
NEW_FILE = new_file
|
100
|
+
|
101
|
+
puts "move file"
|
102
|
+
new_folder = BOX_CLIENT.create_folder(SUB_FOLDER_NAME, @test_folder)
|
103
|
+
test_file = BOX_CLIENT.move_file(test_file, new_folder.id)
|
104
|
+
expect(test_file.parent.id).to eq(new_folder.id)
|
105
|
+
|
106
|
+
puts "delete file"
|
107
|
+
result = BOX_CLIENT.delete_file(NEW_FILE)
|
108
|
+
expect(result).to eq({})
|
109
|
+
|
110
|
+
puts "get trashed file info"
|
111
|
+
trashed_file = BOX_CLIENT.trashed_file(NEW_FILE)
|
112
|
+
expect(trashed_file.item_status).to eq("trashed")
|
113
|
+
|
114
|
+
puts "restore trashed file"
|
115
|
+
restored_file = BOX_CLIENT.restore_trashed_file(NEW_FILE)
|
116
|
+
expect(restored_file.item_status).to eq("active")
|
117
|
+
|
118
|
+
puts "trash and permanently delete file"
|
119
|
+
BOX_CLIENT.delete_file(NEW_FILE)
|
120
|
+
result = BOX_CLIENT.delete_trashed_file(NEW_FILE)
|
121
|
+
expect(result).to eq({})
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# rake spec SPEC_OPTS="-e \"invokes folder operations"\"
|
4
|
+
describe "folder operations" do
|
5
|
+
it 'invokes folder operations' do
|
6
|
+
puts "get folder using path"
|
7
|
+
folder = BOX_CLIENT.folder_from_path(TEST_FOLDER_NAME)
|
8
|
+
expect(folder.id).to eq(@test_folder.id)
|
9
|
+
|
10
|
+
puts "get folder info"
|
11
|
+
folder = BOX_CLIENT.folder(@test_folder)
|
12
|
+
expect(folder.id).to eq(@test_folder.id)
|
13
|
+
|
14
|
+
puts "create new folder"
|
15
|
+
new_folder = BOX_CLIENT.create_folder(SUB_FOLDER_NAME, @test_folder)
|
16
|
+
expect(new_folder).to be_a BoxrMash
|
17
|
+
SUB_FOLDER = new_folder
|
18
|
+
|
19
|
+
puts "update folder"
|
20
|
+
updated_folder = BOX_CLIENT.update_folder(SUB_FOLDER, description: SUB_FOLDER_DESCRIPTION)
|
21
|
+
expect(updated_folder.description).to eq(SUB_FOLDER_DESCRIPTION)
|
22
|
+
|
23
|
+
puts "copy folder"
|
24
|
+
new_folder = BOX_CLIENT.copy_folder(SUB_FOLDER,@test_folder, name: "copy of #{SUB_FOLDER_NAME}")
|
25
|
+
expect(new_folder).to be_a BoxrMash
|
26
|
+
SUB_FOLDER_COPY = new_folder
|
27
|
+
|
28
|
+
puts "create shared link for folder"
|
29
|
+
updated_folder = BOX_CLIENT.create_shared_link_for_folder(@test_folder, access: :open)
|
30
|
+
expect(updated_folder.shared_link.access).to eq("open")
|
31
|
+
|
32
|
+
puts "create password-protected shared link for folder"
|
33
|
+
updated_folder = BOX_CLIENT.create_shared_link_for_folder(@test_folder, password: 'password')
|
34
|
+
expect(updated_folder.shared_link.is_password_enabled).to eq(true)
|
35
|
+
shared_link = updated_folder.shared_link.url
|
36
|
+
|
37
|
+
puts "inspect shared link"
|
38
|
+
shared_item = BOX_CLIENT.shared_item(shared_link)
|
39
|
+
expect(shared_item.id).to eq(@test_folder.id)
|
40
|
+
|
41
|
+
puts "disable shared link for folder"
|
42
|
+
updated_folder = BOX_CLIENT.disable_shared_link_for_folder(@test_folder)
|
43
|
+
expect(updated_folder.shared_link).to be_nil
|
44
|
+
|
45
|
+
puts "move folder"
|
46
|
+
folder_to_move = BOX_CLIENT.create_folder("Folder to move", @test_folder)
|
47
|
+
folder_to_move_into = BOX_CLIENT.create_folder("Folder to move into", @test_folder)
|
48
|
+
folder_to_move = BOX_CLIENT.move_folder(folder_to_move, folder_to_move_into)
|
49
|
+
expect(folder_to_move.parent.id).to eq(folder_to_move_into.id)
|
50
|
+
|
51
|
+
puts "delete folder"
|
52
|
+
result = BOX_CLIENT.delete_folder(SUB_FOLDER_COPY, recursive: true)
|
53
|
+
expect(result).to eq ({})
|
54
|
+
|
55
|
+
puts "inspect the trash"
|
56
|
+
trash = BOX_CLIENT.trash()
|
57
|
+
expect(trash).to be_a Array
|
58
|
+
|
59
|
+
puts "inspect trashed folder"
|
60
|
+
trashed_folder = BOX_CLIENT.trashed_folder(SUB_FOLDER_COPY)
|
61
|
+
expect(trashed_folder.item_status).to eq("trashed")
|
62
|
+
|
63
|
+
puts "restore trashed folder"
|
64
|
+
restored_folder = BOX_CLIENT.restore_trashed_folder(SUB_FOLDER_COPY)
|
65
|
+
expect(restored_folder.item_status).to eq("active")
|
66
|
+
|
67
|
+
puts "trash and permanently delete folder"
|
68
|
+
BOX_CLIENT.delete_folder(SUB_FOLDER_COPY, recursive: true)
|
69
|
+
result = BOX_CLIENT.delete_trashed_folder(SUB_FOLDER_COPY)
|
70
|
+
expect(result).to eq({})
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
#rake spec SPEC_OPTS="-e \"invokes group operations"\"
|
4
|
+
describe 'group operations' do
|
5
|
+
it "invokes group operations" do
|
6
|
+
puts "create group"
|
7
|
+
group = BOX_CLIENT.create_group(TEST_GROUP_NAME)
|
8
|
+
expect(group.name).to eq(TEST_GROUP_NAME)
|
9
|
+
|
10
|
+
puts "inspect groups"
|
11
|
+
groups = BOX_CLIENT.groups
|
12
|
+
test_group = groups.find{|g| g.name == TEST_GROUP_NAME}
|
13
|
+
expect(test_group).to_not be_nil
|
14
|
+
|
15
|
+
puts "update group"
|
16
|
+
new_name = "Test Boxr Group Renamed"
|
17
|
+
group = BOX_CLIENT.update_group(test_group, new_name)
|
18
|
+
expect(group.name).to eq(new_name)
|
19
|
+
group = BOX_CLIENT.rename_group(test_group,TEST_GROUP_NAME)
|
20
|
+
expect(group.name).to eq(TEST_GROUP_NAME)
|
21
|
+
|
22
|
+
puts "add user to group"
|
23
|
+
group_membership = BOX_CLIENT.add_user_to_group(@test_user, test_group)
|
24
|
+
expect(group_membership.user.id).to eq(@test_user.id)
|
25
|
+
expect(group_membership.group.id).to eq(test_group.id)
|
26
|
+
membership = group_membership
|
27
|
+
|
28
|
+
puts "inspect group membership"
|
29
|
+
group_membership = BOX_CLIENT.group_membership(membership)
|
30
|
+
expect(group_membership.id).to eq(membership.id)
|
31
|
+
|
32
|
+
puts "inspect group memberships"
|
33
|
+
group_memberships = BOX_CLIENT.group_memberships(test_group)
|
34
|
+
expect(group_memberships.count).to eq(1)
|
35
|
+
expect(group_memberships.first.id).to eq(membership.id)
|
36
|
+
|
37
|
+
puts "inspect group memberships for a user"
|
38
|
+
group_memberships = BOX_CLIENT.group_memberships_for_user(@test_user)
|
39
|
+
expect(group_memberships.count).to eq(1)
|
40
|
+
expect(group_memberships.first.id).to eq(membership.id)
|
41
|
+
|
42
|
+
puts "inspect group memberships for me"
|
43
|
+
#this is whatever user your developer token is tied to
|
44
|
+
group_memberships = BOX_CLIENT.group_memberships_for_me
|
45
|
+
expect(group_memberships).to be_a(Array)
|
46
|
+
|
47
|
+
puts "update group membership"
|
48
|
+
group_membership = BOX_CLIENT.update_group_membership(membership, :admin)
|
49
|
+
expect(group_membership.role).to eq("admin")
|
50
|
+
|
51
|
+
puts "delete group membership"
|
52
|
+
result = BOX_CLIENT.delete_group_membership(membership)
|
53
|
+
expect(result).to eq({})
|
54
|
+
group_memberships = BOX_CLIENT.group_memberships_for_user(@test_user)
|
55
|
+
expect(group_memberships.count).to eq(0)
|
56
|
+
|
57
|
+
puts "inspect group collaborations"
|
58
|
+
group_collaboration = BOX_CLIENT.add_collaboration(@test_folder, {id: test_group.id, type: :group}, :editor)
|
59
|
+
expect(group_collaboration.accessible_by.id).to eq(test_group.id)
|
60
|
+
|
61
|
+
puts "delete group"
|
62
|
+
response = BOX_CLIENT.delete_group(test_group)
|
63
|
+
expect(response).to eq({})
|
64
|
+
end
|
65
|
+
end
|