gooddata 0.6.15 → 0.6.16
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/lib/gooddata/bricks/middleware/fs_download_middleware.rb +42 -0
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +8 -12
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +10 -13
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +7 -2
- data/lib/gooddata/core/rest.rb +7 -8
- data/lib/gooddata/helpers/data_helper.rb +81 -0
- data/lib/gooddata/helpers/global_helpers.rb +1 -1
- data/lib/gooddata/models/domain.rb +22 -48
- data/lib/gooddata/models/membership.rb +2 -0
- data/lib/gooddata/models/metadata/attribute.rb +1 -1
- data/lib/gooddata/models/metadata/dataset.rb +1 -1
- data/lib/gooddata/models/process.rb +3 -2
- data/lib/gooddata/models/profile.rb +8 -4
- data/lib/gooddata/models/project.rb +128 -80
- data/lib/gooddata/models/project_role.rb +26 -0
- data/lib/gooddata/models/user_filters/user_filter_builder.rb +10 -9
- data/lib/gooddata/rest/client.rb +2 -4
- data/lib/gooddata/rest/connection.rb +3 -2
- data/lib/gooddata/version.rb +1 -1
- data/spec/helpers/project_helper.rb +1 -1
- data/spec/integration/project_spec.rb +10 -5
- data/spec/integration/rest_spec.rb +4 -4
- data/spec/integration/user_filters_spec.rb +2 -1
- data/spec/unit/models/metric_spec.rb +9 -9
- data/spec/unit/models/project_spec.rb +0 -272
- data/spec/unit/models/unit_project.rb +122 -0
- metadata +4 -1
data/lib/gooddata/rest/client.rb
CHANGED
@@ -224,8 +224,7 @@ module GoodData
|
|
224
224
|
@connection.get uri, opts, & block
|
225
225
|
end
|
226
226
|
|
227
|
-
|
228
|
-
def get_project_webdav_path(_file, opts = { :project => GoodData.project })
|
227
|
+
def project_webdav_path(opts = { :project => GoodData.project })
|
229
228
|
p = opts[:project]
|
230
229
|
fail ArgumentError, 'No :project specified' if p.nil?
|
231
230
|
|
@@ -236,8 +235,7 @@ module GoodData
|
|
236
235
|
URI.join(u.to_s.chomp(u.path.to_s), '/project-uploads/', "#{project.pid}/")
|
237
236
|
end
|
238
237
|
|
239
|
-
|
240
|
-
def get_user_webdav_path(_file, opts = { :project => GoodData.project })
|
238
|
+
def user_webdav_path(opts = { :project => GoodData.project })
|
241
239
|
p = opts[:project]
|
242
240
|
fail ArgumentError, 'No :project specified' if p.nil?
|
243
241
|
|
@@ -12,6 +12,7 @@ module GoodData
|
|
12
12
|
DEFAULT_URL = 'https://secure.gooddata.com'
|
13
13
|
LOGIN_PATH = '/gdc/account/login'
|
14
14
|
TOKEN_PATH = '/gdc/account/token'
|
15
|
+
KEYS_TO_SCRUB = [:password, :verifyPassword, :authorizationToken]
|
15
16
|
|
16
17
|
DEFAULT_HEADERS = {
|
17
18
|
:content_type => :json,
|
@@ -258,7 +259,7 @@ module GoodData
|
|
258
259
|
# @param uri [String] Target URI
|
259
260
|
def put(uri, data, options = {})
|
260
261
|
payload = data.is_a?(Hash) ? data.to_json : data
|
261
|
-
GoodData.logger.debug "PUT: #{@server.url}#{uri}, #{scrub_params(data,
|
262
|
+
GoodData.logger.debug "PUT: #{@server.url}#{uri}, #{scrub_params(data, KEYS_TO_SCRUB)}"
|
262
263
|
profile "PUT #{uri}" do
|
263
264
|
b = proc { @server[uri].put payload, cookies }
|
264
265
|
process_response(options, &b)
|
@@ -269,7 +270,7 @@ module GoodData
|
|
269
270
|
#
|
270
271
|
# @param uri [String] Target URI
|
271
272
|
def post(uri, data, options = {})
|
272
|
-
GoodData.logger.debug "POST: #{@server.url}#{uri}, #{scrub_params(data,
|
273
|
+
GoodData.logger.debug "POST: #{@server.url}#{uri}, #{scrub_params(data, KEYS_TO_SCRUB)}"
|
273
274
|
profile "POST #{uri}" do
|
274
275
|
payload = data.is_a?(Hash) ? data.to_json : data
|
275
276
|
b = proc { @server[uri].post payload, cookies }
|
data/lib/gooddata/version.rb
CHANGED
@@ -16,7 +16,7 @@ module ProjectHelper
|
|
16
16
|
GoodData::Project[PROJECT_ID, opts]
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.delete_old_projects(opts = {:client => GoodData.connection})
|
19
|
+
def self.delete_old_projects(opts = { :client => GoodData.connection })
|
20
20
|
projects = opts[:client].projects
|
21
21
|
projects.each do |project|
|
22
22
|
next if project.json['project']['meta']['author'] != client.user.uri
|
@@ -52,15 +52,15 @@ describe GoodData::Project, :constraint => 'slow' do
|
|
52
52
|
end
|
53
53
|
@domain.create_users(users.map {|u| u[:user]})
|
54
54
|
res = @project.add_users(users, domain: @domain)
|
55
|
-
links = res.map {|i| i[:
|
55
|
+
links = res.map {|i| i[:uri]}
|
56
56
|
expect(@project.members?(links).all?).to be_truthy
|
57
|
-
# users.map { |r| r[:user] }.each { |u| u.delete }
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
61
60
|
describe '#import_users' do
|
62
61
|
it "Updates user's name and surname and removes the users" do
|
63
62
|
users = (1..2).to_a.map { |x| ProjectHelper.create_random_user(@client) }
|
63
|
+
@domain.create_users(users)
|
64
64
|
@project.import_users(users, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
65
65
|
expect(@domain.members?(users)).to be_truthy
|
66
66
|
expect(@project.members?(users)).to be_truthy
|
@@ -70,6 +70,7 @@ describe GoodData::Project, :constraint => 'slow' do
|
|
70
70
|
bill.first_name = 'buffalo'
|
71
71
|
bill.last_name = 'bill'
|
72
72
|
# import
|
73
|
+
@domain.create_users(users, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
73
74
|
@project.import_users(users, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
74
75
|
# it should be updated
|
75
76
|
bill_changed = @domain.get_user(bill)
|
@@ -88,16 +89,19 @@ describe GoodData::Project, :constraint => 'slow' do
|
|
88
89
|
# Add additional user while changing Buffalos surname and role.
|
89
90
|
bill.last_name = 'Billie'
|
90
91
|
other_guy = ProjectHelper.create_random_user(@client)
|
92
|
+
additional_batch = [bill, other_guy]
|
93
|
+
|
94
|
+
@domain.create_users(additional_batch, domain: @domain)
|
95
|
+
@project.import_users(additional_batch.map { |u| {user: u, role: u.role} }, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
91
96
|
|
92
|
-
additional_batch = [bill, other_guy].map { |u| {user: u, role: u.role} }
|
93
|
-
@project.import_users(additional_batch, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
94
97
|
expect(@project.members.count).to eq 3
|
95
98
|
expect(@project.member?(bill)).to be_truthy
|
96
|
-
expect(@project.members?(users - additional_batch
|
99
|
+
expect(@project.members?(users - additional_batch).any?).to be_falsey
|
97
100
|
end
|
98
101
|
|
99
102
|
it "Updates user's role in a project" do
|
100
103
|
users = (1..5).to_a.map { |x| ProjectHelper.create_random_user(@client).to_hash }
|
104
|
+
@domain.create_users(users, domain: @domain)
|
101
105
|
@project.import_users(users, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
102
106
|
|
103
107
|
expect(@project.members?(users)).to be_truthy
|
@@ -115,6 +119,7 @@ describe GoodData::Project, :constraint => 'slow' do
|
|
115
119
|
uh[:role] = 'editor'
|
116
120
|
|
117
121
|
users = (1..5).to_a.map { |x| ProjectHelper.create_random_user(@client).to_hash } + [uh]
|
122
|
+
@domain.create_users(users, domain: @domain)
|
118
123
|
expect(@project.member?(u)).to be_truthy
|
119
124
|
expect(u.role.title).to eq 'Admin'
|
120
125
|
@project.import_users(users, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
@@ -15,9 +15,9 @@ describe GoodData do
|
|
15
15
|
@client.disconnect
|
16
16
|
end
|
17
17
|
|
18
|
-
describe '#
|
18
|
+
describe '#project_webdav_path' do
|
19
19
|
it 'Returns path' do
|
20
|
-
@client.
|
20
|
+
@client.project_webdav_path(:project => @project)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -201,9 +201,9 @@ describe GoodData do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
|
204
|
-
describe '#
|
204
|
+
describe '#user_webdav_path' do
|
205
205
|
it 'Gets the path' do
|
206
|
-
@client.
|
206
|
+
@client.user_webdav_path(:project => @project)
|
207
207
|
end
|
208
208
|
end
|
209
209
|
end
|
@@ -27,6 +27,7 @@ describe "User filters implementation", :constraint => 'slow' do
|
|
27
27
|
GoodData::Model.upload_data(devs_data, blueprint, 'devs', :client => @client, :project => @project)
|
28
28
|
# blueprint.find_dataset('devs').upload(devs_data)
|
29
29
|
end
|
30
|
+
|
30
31
|
end
|
31
32
|
|
32
33
|
after(:all) do
|
@@ -84,7 +85,7 @@ describe "User filters implementation", :constraint => 'slow' do
|
|
84
85
|
expect(@project.data_permissions.first.pretty_expression).to eq "[Dev] IN ([tomas@gooddata.com])"
|
85
86
|
end
|
86
87
|
|
87
|
-
it "should fail when asked to set a value not in the
|
88
|
+
it "should fail when asked to set a value not in the project" do
|
88
89
|
filters = [
|
89
90
|
[ConnectionHelper::DEFAULT_USERNAME, @label.uri, '%^&*( nonexistent value', 'tomas@gooddata.com'],
|
90
91
|
[ConnectionHelper::DEFAULT_USERNAME, @label.uri, 'tomas@gooddata.com']]
|
@@ -48,7 +48,7 @@ describe GoodData::Metric do
|
|
48
48
|
{'content' =>
|
49
49
|
{'format' => '#,##0',
|
50
50
|
'expression' =>
|
51
|
-
"SELECT SUM([#{USED_METRIC.uri})"},
|
51
|
+
"SELECT SUM([#{USED_METRIC.uri}])"},
|
52
52
|
'meta' =>
|
53
53
|
{'author' => '/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248',
|
54
54
|
'uri' => '/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/252',
|
@@ -69,27 +69,27 @@ describe GoodData::Metric do
|
|
69
69
|
|
70
70
|
describe '#contain?' do
|
71
71
|
it 'should say it contains a depending metric if it does' do
|
72
|
-
@instance.contain?(USED_METRIC).
|
72
|
+
expect(@instance.contain?(USED_METRIC)).to eq true
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'should say it contains a depending object which is given as a string if it does' do
|
76
|
-
@instance.contain?(USED_METRIC).
|
76
|
+
expect(@instance.contain?(USED_METRIC)).to eq true
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'should be able to replace an object if the object is used in the expression' do
|
80
|
-
|
80
|
+
skip('resolve mutating constant if I init from it')
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'should be able to return an expression of the metric' do
|
84
|
-
@instance.expression.
|
84
|
+
expect(@instance.expression).to eq "SELECT SUM([#{USED_METRIC.uri}])"
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'should be able to replace an object if the object is used in the expression' do
|
88
|
-
@instance.contain?(USED_METRIC).
|
89
|
-
@instance.contain?(UNUSED_METRIC).
|
88
|
+
expect(@instance.contain?(USED_METRIC)).to be_truthy
|
89
|
+
expect(@instance.contain?(UNUSED_METRIC)).to be_falsey
|
90
90
|
@instance.replace(USED_METRIC, UNUSED_METRIC)
|
91
|
-
@instance.contain?(USED_METRIC).
|
92
|
-
@instance.contain?(UNUSED_METRIC).
|
91
|
+
expect(@instance.contain?(USED_METRIC)).to be_falsey
|
92
|
+
expect(@instance.contain?(UNUSED_METRIC)).to be_truthy
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require 'pmap'
|
4
3
|
require 'gooddata'
|
5
4
|
|
6
5
|
describe GoodData::Project, :constraint => 'slow' do
|
@@ -146,19 +145,6 @@ describe GoodData::Project, :constraint => 'slow' do
|
|
146
145
|
end
|
147
146
|
end
|
148
147
|
|
149
|
-
# describe '#processes' do
|
150
|
-
# it 'Returns the processes' do
|
151
|
-
# @project.deploy_process('./spec/data/ruby_process',
|
152
|
-
# type: 'RUBY',
|
153
|
-
# name: 'Test ETL Process')
|
154
|
-
# processes = @project.processes
|
155
|
-
# expect(processes).to be_a_kind_of(Array)
|
156
|
-
# binding.pry
|
157
|
-
# expect(processes.count).to eq 1
|
158
|
-
# expect(processes.map(&:project).uniq).to eq [@project]
|
159
|
-
# end
|
160
|
-
# end
|
161
|
-
|
162
148
|
describe '#roles' do
|
163
149
|
it 'Returns array of GoodData::ProjectRole' do
|
164
150
|
roles = @project.roles
|
@@ -169,262 +155,4 @@ describe GoodData::Project, :constraint => 'slow' do
|
|
169
155
|
end
|
170
156
|
end
|
171
157
|
end
|
172
|
-
|
173
|
-
# describe '#users' do
|
174
|
-
# it 'Returns array of GoodData::Users' do
|
175
|
-
#
|
176
|
-
# invitations = @project.invitations
|
177
|
-
# expect(invitations).to_not be_nil
|
178
|
-
# expect(invitations).to be_instance_of(Array)
|
179
|
-
#
|
180
|
-
# users = @project.users
|
181
|
-
# expect(users).to be_instance_of(Array)
|
182
|
-
#
|
183
|
-
# users.each do |user|
|
184
|
-
# expect(user).to be_instance_of(GoodData::Membership)
|
185
|
-
#
|
186
|
-
# roles = user.roles
|
187
|
-
# expect(roles).to_not be_nil
|
188
|
-
# expect(roles).to be_instance_of(Array)
|
189
|
-
#
|
190
|
-
# roles.each do |role|
|
191
|
-
# expect(role).to be_instance_of(GoodData::ProjectRole)
|
192
|
-
# end
|
193
|
-
#
|
194
|
-
# permissions = user.permissions
|
195
|
-
# expect(permissions).to_not be_nil
|
196
|
-
# expect(permissions).to_not be_nil
|
197
|
-
# expect(permissions).to be_instance_of(Hash)
|
198
|
-
#
|
199
|
-
# # invitations = user.invitations
|
200
|
-
# # invitations.should_not be_nil
|
201
|
-
#
|
202
|
-
# if (user.email == 'tomas.korcak@gooddata.com')
|
203
|
-
# projects = user.projects
|
204
|
-
# expect(projects).to_not be_nil
|
205
|
-
# expect(projects).to be_instance_of(Array)
|
206
|
-
#
|
207
|
-
# projects.each do |project|
|
208
|
-
# expect(project).to be_instance_of(GoodData::Project)
|
209
|
-
# end
|
210
|
-
# end
|
211
|
-
# end
|
212
|
-
# end
|
213
|
-
# end
|
214
|
-
#
|
215
|
-
# describe '#add_user' do
|
216
|
-
# it 'Adding user without domain should fail if it is not in the project' do
|
217
|
-
# user = ProjectHelper.create_random_user(@client)
|
218
|
-
# expect do
|
219
|
-
# @project.add_user(user, 'Admin')
|
220
|
-
# end.to raise_exception(ArgumentError)
|
221
|
-
# end
|
222
|
-
#
|
223
|
-
# it 'Adding user with domain should be added to a project' do
|
224
|
-
# user = ProjectHelper.create_random_user(@client)
|
225
|
-
# @domain.create_users([user])
|
226
|
-
# res = @project.add_user(user, 'Admin', domain: @domain)
|
227
|
-
# expect(@project.member?(res['projectUsersUpdateResult']['successful'].first)).to be_truthy
|
228
|
-
# end
|
229
|
-
# end
|
230
|
-
#
|
231
|
-
# describe '#add_users' do
|
232
|
-
# it 'Adding user without domain should fail if it is not in the project' do
|
233
|
-
# users = (1..5).to_a.map do |x|
|
234
|
-
# {
|
235
|
-
# user: ProjectHelper.create_random_user(@client),
|
236
|
-
# role: 'Admin'
|
237
|
-
# }
|
238
|
-
# end
|
239
|
-
# res = @project.add_users(users)
|
240
|
-
# expect(res.all? { |x| x[:type] == :error }).to eq true
|
241
|
-
# end
|
242
|
-
#
|
243
|
-
# it 'Adding users with domain should pass and users should be added to domain' do
|
244
|
-
# users = (1..5).to_a.map do |x|
|
245
|
-
# {
|
246
|
-
# user: ProjectHelper.create_random_user(@client),
|
247
|
-
# role: 'Admin'
|
248
|
-
# }
|
249
|
-
# end
|
250
|
-
# @domain.create_users(users.map {|u| u[:user]})
|
251
|
-
# res = @project.add_users(users, domain: @domain)
|
252
|
-
# links = res.map {|i| i[:result]['projectUsersUpdateResult']['successful'].first}
|
253
|
-
# expect(@project.members?(links).all?).to be_truthy
|
254
|
-
# # users.map { |r| r[:user] }.each { |u| u.delete }
|
255
|
-
# end
|
256
|
-
# end
|
257
|
-
#
|
258
|
-
# describe '#import_users' do
|
259
|
-
# it "Updates user's name and surname and removes the users" do
|
260
|
-
# users = (1..2).to_a.map { |x| ProjectHelper.create_random_user(@client) }
|
261
|
-
# @project.import_users(users, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
262
|
-
# expect(@domain.members?(users)).to be_truthy
|
263
|
-
# expect(@project.members?(users)).to be_truthy
|
264
|
-
# expect(@project.members.count).to eq 3
|
265
|
-
# # update some user stuff
|
266
|
-
# bill = users[0]
|
267
|
-
# bill.first_name = 'buffalo'
|
268
|
-
# bill.last_name = 'bill'
|
269
|
-
# # import
|
270
|
-
# @project.import_users(users, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
271
|
-
# # it should be updated
|
272
|
-
# bill_changed = @domain.get_user(bill)
|
273
|
-
# expect(bill_changed.first_name).to eql('buffalo')
|
274
|
-
# expect(bill_changed.last_name).to eql('bill')
|
275
|
-
# expect(@project.members?(users)).to be_truthy
|
276
|
-
# expect(@project.members.count).to eq 3
|
277
|
-
# expect(@project.member?(bill_changed)).to be_truthy
|
278
|
-
#
|
279
|
-
# # remove everybody but buffalo bill.
|
280
|
-
# @project.import_users([bill], domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
281
|
-
# expect(@project.members.count).to eq 2
|
282
|
-
# expect(@project.member?(bill)).to be_truthy
|
283
|
-
# expect(@project.members?(users - [bill]).any?).to be_falsey
|
284
|
-
#
|
285
|
-
# # Add additional user while changing Buffalos surname and role.
|
286
|
-
# bill.last_name = 'Billie'
|
287
|
-
# other_guy = ProjectHelper.create_random_user(@client)
|
288
|
-
#
|
289
|
-
# additional_batch = [bill, other_guy].map { |u| {user: u, role: u.role} }
|
290
|
-
# @project.import_users(additional_batch, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
291
|
-
# expect(@project.members.count).to eq 3
|
292
|
-
# expect(@project.member?(bill)).to be_truthy
|
293
|
-
# expect(@project.members?(users - additional_batch.map {|x| x[:user]}).any?).to be_falsey
|
294
|
-
# end
|
295
|
-
#
|
296
|
-
# it "Updates user's role in a project" do
|
297
|
-
# users = (1..5).to_a.map { |x| ProjectHelper.create_random_user(@client).to_hash }
|
298
|
-
# @project.import_users(users, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
299
|
-
#
|
300
|
-
# expect(@project.members?(users)).to be_truthy
|
301
|
-
# user_role_changed = users[1]
|
302
|
-
# users_unchanged = users - [user_role_changed]
|
303
|
-
# new_role = users[1][:role] = users[1][:role] == "admin" ? "editor" : "admin"
|
304
|
-
# @project.import_users(users, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
305
|
-
# expect(@project.get_user(user_role_changed).role.identifier).to eql("#{new_role}Role")
|
306
|
-
# expect(users_unchanged.map {|u| @project.get_user(u)}.map(&:role).map(&:title).uniq).to eq ['Editor']
|
307
|
-
# end
|
308
|
-
#
|
309
|
-
# it "ignores user from both project and end state batch when whitelisted" do
|
310
|
-
# u = @project.get_user(ConnectionHelper::DEFAULT_USERNAME)
|
311
|
-
# uh = u.to_hash
|
312
|
-
# uh[:role] = 'editor'
|
313
|
-
#
|
314
|
-
# users = (1..5).to_a.map { |x| ProjectHelper.create_random_user(@client).to_hash } + [uh]
|
315
|
-
# expect(@project.member?(u)).to be_truthy
|
316
|
-
# expect(u.role.title).to eq 'Admin'
|
317
|
-
# @project.import_users(users, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
318
|
-
# expect(@project.member?(u)).to be_truthy
|
319
|
-
# expect(@project.members?(users).all?).to be_truthy
|
320
|
-
# expect(@project.get_user(ConnectionHelper::DEFAULT_USERNAME).role.title).to eq 'Admin'
|
321
|
-
# end
|
322
|
-
#
|
323
|
-
# end
|
324
|
-
#
|
325
|
-
# describe '#set_user_roles' do
|
326
|
-
# it 'Properly updates user roles as needed' do
|
327
|
-
# users_to_import = @domain.users.sample(5).map {|u| { user: u, role: 'admin' }}
|
328
|
-
# @project.import_users(users_to_import, domain: @domain, whitelists: [/gem_tester@gooddata.com/])
|
329
|
-
# users_without_owner = @project.users.reject { |u| u.login == ConnectionHelper::DEFAULT_USERNAME }.pselect { |u| u.role.title == 'Admin' }
|
330
|
-
#
|
331
|
-
# user_to_change = users_without_owner.sample
|
332
|
-
# @project.set_user_roles(user_to_change, 'editor')
|
333
|
-
# expect(user_to_change.role.title).to eq 'Editor'
|
334
|
-
# @project.set_user_roles(user_to_change, 'admin')
|
335
|
-
# expect(user_to_change.role.title).to eq 'Admin'
|
336
|
-
#
|
337
|
-
# # Try different notation
|
338
|
-
# @project.set_users_roles([user: user_to_change, role: 'editor'])
|
339
|
-
# expect(user_to_change.role.title).to eq 'Editor'
|
340
|
-
# @project.set_users_roles([user: user_to_change, role: 'admin'])
|
341
|
-
# expect(user_to_change.role.title).to eq 'Admin'
|
342
|
-
# end
|
343
|
-
#
|
344
|
-
# it 'Properly updates user roles when user specified by email and :roles specified as array of string with role names' do
|
345
|
-
# # pick non deleted users that are not owner and have other roles than admin or editor
|
346
|
-
# users = @project.users
|
347
|
-
# users_without_owner = users
|
348
|
-
# .reject { |u| u.login == ConnectionHelper::DEFAULT_USERNAME }
|
349
|
-
# .reject { |u| u.login =~ /^deleted/ }
|
350
|
-
# .pselect { |u| u.role.title =~ /^(Admin|Editor)/ }
|
351
|
-
#
|
352
|
-
# # take 10 users that we will exercise
|
353
|
-
# users_to_change = users_without_owner.sample(10)
|
354
|
-
#
|
355
|
-
# # alternate roles and prepare structure
|
356
|
-
# logins = users_to_change.map(&:login)
|
357
|
-
# roles = users_to_change.map { |u| u.role.title == 'Admin' ? ['Editor'] : ['Admin'] }
|
358
|
-
#
|
359
|
-
# list = users_to_change.map do |u|
|
360
|
-
# {
|
361
|
-
# :user => u.login,
|
362
|
-
# :roles => u.role.title == 'Admin' ? ['Editor'] : ['Admin']
|
363
|
-
# }
|
364
|
-
# end
|
365
|
-
#
|
366
|
-
# # set the roles
|
367
|
-
# res = @project.set_users_roles(list)
|
368
|
-
# expect(res.length).to equal(list.length)
|
369
|
-
# expect(logins.map {|l| users.find {|u| u.login == l}}.pmap {|u| u.role.title}).to eq roles.flatten
|
370
|
-
# end
|
371
|
-
#
|
372
|
-
# it 'Properly updates user roles when user specified by email and :roles specified as string with role name' do
|
373
|
-
# users = @project.users
|
374
|
-
# users_without_owner = users
|
375
|
-
# .reject { |u| u.login == ConnectionHelper::DEFAULT_USERNAME }
|
376
|
-
# .reject(&:deleted?)
|
377
|
-
# .pselect { |u| u.role.title =~ /^(Admin|Editor)/ }
|
378
|
-
#
|
379
|
-
# users_to_change = users_without_owner.sample(10)
|
380
|
-
#
|
381
|
-
# logins = users_to_change.map(&:login)
|
382
|
-
# roles = users_to_change.map { |u| u.role.title == 'Admin' ? 'Editor' : 'Admin' }
|
383
|
-
#
|
384
|
-
# list = users_to_change.map do |u|
|
385
|
-
# {
|
386
|
-
# :user => u.login,
|
387
|
-
# :roles => u.role.title == 'Admin' ? 'Editor' : 'Admin'
|
388
|
-
# }
|
389
|
-
# end
|
390
|
-
#
|
391
|
-
# res = @project.set_users_roles(list)
|
392
|
-
# expect(res.length).to equal(list.length)
|
393
|
-
# expect(logins.map {|l| users.find {|u| u.login == l}}.pmap {|u| u.role.title}).to eq roles.flatten
|
394
|
-
#
|
395
|
-
# end
|
396
|
-
# end
|
397
|
-
#
|
398
|
-
# describe '#summary' do
|
399
|
-
# it 'Properly gets summary of project' do
|
400
|
-
# res = @project.summary
|
401
|
-
# expect(res).to include(ProjectHelper::PROJECT_SUMMARY)
|
402
|
-
# end
|
403
|
-
# end
|
404
|
-
#
|
405
|
-
# describe '#title' do
|
406
|
-
# it 'Properly gets title of project' do
|
407
|
-
# res = @project.title
|
408
|
-
# expect(res).to include(ProjectHelper::PROJECT_TITLE)
|
409
|
-
# end
|
410
|
-
# end
|
411
|
-
#
|
412
|
-
# describe 'enabling and disabling users' do
|
413
|
-
# it 'should be able to enable and disable a user' do
|
414
|
-
# users_without_owner = @project.users
|
415
|
-
# .reject { |u| u.login == ConnectionHelper::DEFAULT_USERNAME }
|
416
|
-
# .reject(&:deleted?)
|
417
|
-
# .select(&:enabled?)
|
418
|
-
# user = users_without_owner.sample
|
419
|
-
# expect(user.enabled?).to be_truthy
|
420
|
-
# expect(user.disabled?).to be_falsey
|
421
|
-
# user.disable
|
422
|
-
# expect(user.disabled?).to be_truthy
|
423
|
-
# expect(user.enabled?).to be_falsey
|
424
|
-
# user.enable
|
425
|
-
# expect(user.enabled?).to be_truthy
|
426
|
-
# expect(user.disabled?).to be_falsey
|
427
|
-
# expect(user.project).not_to be_nil
|
428
|
-
# end
|
429
|
-
# end
|
430
158
|
end
|