gooddata 0.6.11 → 0.6.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +34 -1
- data/CLI.md +1 -1
- data/authors.sh +4 -0
- data/lib/gooddata.rb +1 -1
- data/lib/gooddata/cli/commands/api_cmd.rb +0 -2
- data/lib/gooddata/cli/commands/auth_cmd.rb +0 -3
- data/lib/gooddata/cli/commands/console_cmd.rb +1 -2
- data/lib/gooddata/cli/commands/domain_cmd.rb +0 -2
- data/lib/gooddata/cli/commands/process_cmd.rb +0 -2
- data/lib/gooddata/cli/commands/project_cmd.rb +0 -2
- data/lib/gooddata/cli/commands/projects_cmd.rb +0 -2
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +2 -3
- data/lib/gooddata/cli/commands/scaffold_cmd.rb +0 -3
- data/lib/gooddata/cli/commands/user_cmd.rb +0 -2
- data/lib/gooddata/cli/shared.rb +1 -2
- data/lib/gooddata/commands/datawarehouse.rb +24 -0
- data/lib/gooddata/commands/process.rb +0 -1
- data/lib/gooddata/commands/project.rb +1 -1
- data/lib/gooddata/commands/scaffold.rb +0 -1
- data/lib/gooddata/core/connection.rb +376 -0
- data/lib/gooddata/core/logging.rb +13 -0
- data/lib/gooddata/core/rest.rb +40 -16
- data/lib/gooddata/exceptions/user_in_different_domain.rb +11 -0
- data/lib/gooddata/extensions/enumerable.rb +8 -0
- data/lib/gooddata/goodzilla/goodzilla.rb +24 -0
- data/lib/gooddata/helpers/global_helpers.rb +126 -12
- data/lib/gooddata/mixins/author.rb +11 -5
- data/lib/gooddata/mixins/is_dimension.rb +13 -0
- data/lib/gooddata/mixins/md_object_indexer.rb +17 -1
- data/lib/gooddata/mixins/md_object_query.rb +10 -2
- data/lib/gooddata/mixins/md_relations.rb +2 -2
- data/lib/gooddata/mixins/rest_resource.rb +1 -0
- data/lib/gooddata/models/data_result.rb +0 -1
- data/lib/gooddata/models/datawarehouse.rb +90 -0
- data/lib/gooddata/models/domain.rb +202 -76
- data/lib/gooddata/models/execution.rb +11 -0
- data/lib/gooddata/models/from_wire.rb +4 -4
- data/lib/gooddata/models/invitation.rb +0 -5
- data/lib/gooddata/models/membership.rb +121 -91
- data/lib/gooddata/models/metadata.rb +1 -2
- data/lib/gooddata/models/metadata/attribute.rb +7 -0
- data/lib/gooddata/models/metadata/dashboard.rb +1 -1
- data/lib/gooddata/models/metadata/dimension.rb +52 -0
- data/lib/gooddata/models/metadata/fact.rb +1 -1
- data/lib/gooddata/models/metadata/label.rb +21 -7
- data/lib/gooddata/models/metadata/metric.rb +1 -23
- data/lib/gooddata/models/metadata/report.rb +2 -2
- data/lib/gooddata/models/metadata/report_definition.rb +22 -2
- data/lib/gooddata/models/metadata/variable.rb +81 -0
- data/lib/gooddata/models/model.rb +2 -1
- data/lib/gooddata/models/process.rb +3 -4
- data/lib/gooddata/models/profile.rb +50 -82
- data/lib/gooddata/models/project.rb +170 -213
- data/lib/gooddata/models/project_blueprint.rb +14 -5
- data/lib/gooddata/models/project_creator.rb +2 -2
- data/lib/gooddata/models/schedule.rb +10 -8
- data/lib/gooddata/models/to_wire.rb +2 -2
- data/lib/gooddata/models/user_filters/mandatory_user_filter.rb +67 -0
- data/lib/gooddata/models/user_filters/user_filter.rb +96 -0
- data/lib/gooddata/models/user_filters/user_filter_builder.rb +409 -0
- data/lib/gooddata/{rest/connections/connections.rb → models/user_filters/user_filters.rb} +1 -0
- data/lib/gooddata/models/user_filters/variable_user_filter.rb +14 -0
- data/lib/gooddata/rest/client.rb +32 -21
- data/lib/gooddata/rest/connection.rb +283 -11
- data/lib/gooddata/rest/connections/rest_client_connection.rb +47 -109
- data/lib/gooddata/version.rb +1 -1
- data/spec/data/column_based_permissions.csv +7 -0
- data/spec/data/column_based_permissions2.csv +6 -0
- data/spec/data/hello_world_process/hello_world.rb +3 -1
- data/spec/data/line_based_permissions.csv +3 -0
- data/spec/data/m_n_model/blueprint.json +76 -0
- data/spec/data/{model_view.json → wire_models/model_view.json} +0 -0
- data/spec/data/wire_models/nu_model.json +3046 -0
- data/spec/helpers/process_helper.rb +2 -2
- data/spec/helpers/project_helper.rb +29 -0
- data/spec/helpers/schedule_helper.rb +1 -1
- data/spec/integration/command_datawarehouse_spec.rb +32 -0
- data/spec/integration/create_project_spec.rb +0 -1
- data/spec/integration/full_process_schedule_spec.rb +13 -5
- data/spec/integration/full_project_spec.rb +2 -1
- data/spec/integration/over_to_user_filters_spec.rb +92 -0
- data/spec/integration/project_spec.rb +233 -0
- data/spec/integration/rest_spec.rb +209 -0
- data/spec/integration/user_filters_spec.rb +193 -0
- data/spec/integration/variables_spec.rb +196 -0
- data/spec/unit/commands/command_auth_spec.rb +0 -7
- data/spec/unit/commands/command_process_spec.rb +10 -13
- data/spec/unit/core/connection_spec.rb +0 -19
- data/spec/unit/helpers/global_helpers_spec.rb +57 -0
- data/spec/unit/models/domain_spec.rb +80 -40
- data/spec/unit/models/from_wire_spec.rb +8 -1
- data/spec/unit/models/params_spec.rb +6 -6
- data/spec/unit/models/profile_spec.rb +23 -22
- data/spec/unit/models/project_blueprint_spec.rb +1 -6
- data/spec/unit/models/project_spec.rb +331 -286
- data/spec/unit/models/schedule_spec.rb +39 -14
- data/spec/unit/models/user_filters_spec.rb +89 -0
- data/spec/unit/models/variable_spec.rb +259 -0
- metadata +31 -7
- data/lib/gooddata/rest/connections/dummy_connection.rb +0 -52
- data/spec/unit/core/rest_spec.rb +0 -106
@@ -64,7 +64,6 @@ describe GoodData::Model::ProjectBlueprint do
|
|
64
64
|
d.add_attribute("id", :title => "My Id")
|
65
65
|
d.add_fact("amount", :title => "Amount")
|
66
66
|
end
|
67
|
-
|
68
67
|
bp1 = GoodData::Model::ProjectBlueprint.new(builder)
|
69
68
|
bp1.valid?.should == true
|
70
69
|
|
@@ -90,7 +89,7 @@ describe GoodData::Model::ProjectBlueprint do
|
|
90
89
|
end
|
91
90
|
|
92
91
|
it 'should be able to tell me if ceratain dataset by name is in the blueprint' do
|
93
|
-
@blueprint.dataset?('devs').should
|
92
|
+
@blueprint.dataset?('devs').should be_truthy
|
94
93
|
end
|
95
94
|
|
96
95
|
it 'should tell you it has anchor when it does' do
|
@@ -237,8 +236,4 @@ describe GoodData::Model::ProjectBlueprint do
|
|
237
236
|
merged1 = @blueprint.merge(dataset)
|
238
237
|
merged2 = dataset.merge(@blueprint)
|
239
238
|
end
|
240
|
-
|
241
|
-
it "should generate manifest" do
|
242
|
-
m = GoodData::Model::ToManifest.to_manifest(@blueprint.to_hash)
|
243
|
-
end
|
244
239
|
end
|
@@ -1,65 +1,39 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'pmap'
|
4
|
-
|
5
4
|
require 'gooddata'
|
6
5
|
|
7
|
-
describe GoodData::Project do
|
8
|
-
before(:
|
6
|
+
describe GoodData::Project, :constraint => 'slow' do
|
7
|
+
before(:all) do
|
9
8
|
@client = ConnectionHelper::create_default_connection
|
9
|
+
@project = ProjectHelper.get_default_project(:client => @client)
|
10
|
+
@domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
|
10
11
|
end
|
11
12
|
|
12
|
-
after(:
|
13
|
+
after(:all) do
|
13
14
|
@client.disconnect
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
'email' => row[2],
|
22
|
-
'login' => row[2],
|
23
|
-
'firstname' => row[0],
|
24
|
-
'lastname' => row[1],
|
25
|
-
|
26
|
-
# Following lines are ugly hack
|
27
|
-
'role' => row[6],
|
28
|
-
'password' => CryptoHelper.generate_password,
|
29
|
-
'domain' => row[9],
|
30
|
-
|
31
|
-
# And following lines are even much more ugly hack
|
32
|
-
# 'sso_provider' => '',
|
33
|
-
# 'authentication_modes' => ['sso', 'password']
|
34
|
-
},
|
35
|
-
'meta' => {}
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
GoodData::Membership.new(json)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#[]' do
|
44
|
-
it 'Accepts :all parameter' do
|
45
|
-
projects = GoodData::Project[:all, :client => @client]
|
46
|
-
projects.should_not be_nil
|
47
|
-
projects.should be_a_kind_of(Array)
|
17
|
+
describe 'projects' do
|
18
|
+
it 'Can get all projects' do
|
19
|
+
projects = @client.projects
|
20
|
+
expect(projects).to_not be_nil
|
21
|
+
expect(projects).to be_a_kind_of(Array)
|
48
22
|
projects.pmap do |project|
|
49
23
|
expect(project).to be_an_instance_of(GoodData::Project)
|
50
24
|
end
|
51
25
|
end
|
52
26
|
|
53
27
|
it 'Returns project if ID passed' do
|
54
|
-
project
|
55
|
-
project.
|
56
|
-
project.
|
28
|
+
expect(@project).to_not be_nil
|
29
|
+
expect(@project).to be_a_kind_of(GoodData::Project)
|
30
|
+
expect(@project.pid).to eq @project.pid
|
57
31
|
end
|
58
32
|
|
59
33
|
it 'Returns project if URL passed' do
|
60
|
-
project
|
61
|
-
project.
|
62
|
-
project.
|
34
|
+
expect(@project).to_not be_nil
|
35
|
+
expect(@project).to be_a_kind_of(GoodData::Project)
|
36
|
+
expect(@project.pid).to eq @project.pid
|
63
37
|
end
|
64
38
|
|
65
39
|
it 'Throws an exception when invalid format of URL passed' do
|
@@ -71,120 +45,123 @@ describe GoodData::Project do
|
|
71
45
|
describe '#all' do
|
72
46
|
it 'Returns all projects' do
|
73
47
|
projects = GoodData::Project.all(:client => @client)
|
74
|
-
projects.
|
75
|
-
projects.
|
48
|
+
expect(projects).to_not be_nil
|
49
|
+
expect(projects).to be_a_kind_of(Array)
|
76
50
|
end
|
77
51
|
end
|
78
52
|
|
79
53
|
describe '#get_role_by_identifier' do
|
80
54
|
it 'Looks up for role by identifier' do
|
81
|
-
|
82
|
-
role
|
83
|
-
role.
|
84
|
-
role.should be_a_kind_of(GoodData::ProjectRole)
|
55
|
+
role = @project.get_role_by_identifier('readOnlyUserRole')
|
56
|
+
expect(role).to_not be_nil
|
57
|
+
expect(role).to be_a_kind_of(GoodData::ProjectRole)
|
85
58
|
end
|
86
59
|
end
|
87
60
|
|
88
61
|
describe '#get_role_by_summary' do
|
89
62
|
it 'Looks up for role by summary' do
|
90
|
-
|
91
|
-
role
|
92
|
-
role.
|
93
|
-
role.should be_a_kind_of(GoodData::ProjectRole)
|
63
|
+
role = @project.get_role_by_summary('read only user role')
|
64
|
+
expect(role).to_not be_nil
|
65
|
+
expect(role).to be_a_kind_of(GoodData::ProjectRole)
|
94
66
|
end
|
95
67
|
end
|
96
68
|
|
97
69
|
describe '#get_role_by_title' do
|
98
70
|
it 'Looks up for role by title' do
|
99
|
-
|
100
|
-
role
|
101
|
-
role.
|
102
|
-
role.should be_a_kind_of(GoodData::ProjectRole)
|
71
|
+
role = @project.get_role_by_title('Viewer')
|
72
|
+
expect(role).to_not be_nil
|
73
|
+
expect(role).to be_a_kind_of(GoodData::ProjectRole)
|
103
74
|
end
|
104
75
|
end
|
105
76
|
|
106
77
|
describe "#member" do
|
107
|
-
it 'Returns GoodData::Membership when looking for existing user using
|
108
|
-
|
109
|
-
res = project.member('svarovsky+gem_tester@gooddata.com')
|
78
|
+
it 'Returns GoodData::Membership when looking for existing user using login' do
|
79
|
+
res = @project.get_user('svarovsky+gem_tester@gooddata.com')
|
110
80
|
expect(res).to be_instance_of(GoodData::Membership)
|
111
81
|
end
|
112
82
|
|
113
83
|
it 'Returns GoodData::Membership when looking for existing user using URL' do
|
114
|
-
|
115
|
-
res = project.member(ConnectionHelper::DEFAULT_USER_URL)
|
84
|
+
res = @project.get_user(ConnectionHelper::DEFAULT_USER_URL)
|
116
85
|
expect(res).to be_instance_of(GoodData::Membership)
|
117
86
|
end
|
118
87
|
|
119
88
|
it 'Returns GoodData::Membership when looking for existing user using GoodData::Profile' do
|
120
|
-
|
121
|
-
|
122
|
-
res = project.member(user)
|
89
|
+
user = @project.members.first
|
90
|
+
res = @project.get_user(user)
|
123
91
|
expect(res).to be_instance_of(GoodData::Membership)
|
124
92
|
end
|
125
93
|
|
126
94
|
it 'Returns null for non-existing user' do
|
127
|
-
|
128
|
-
res
|
129
|
-
res.should be_nil
|
95
|
+
res = @project.get_user('john.doe@gooddata.com')
|
96
|
+
expect(res).to be_nil
|
130
97
|
end
|
131
98
|
end
|
132
99
|
|
133
100
|
describe "#member?" do
|
134
|
-
it 'Returns true when looking for existing user using
|
135
|
-
|
136
|
-
res
|
137
|
-
res.should be_true
|
101
|
+
it 'Returns true when looking for existing user using login' do
|
102
|
+
res = @project.member?('svarovsky+gem_tester@gooddata.com')
|
103
|
+
expect(res).to be_truthy
|
138
104
|
end
|
139
105
|
|
140
106
|
it 'Returns true when looking for existing user using URL' do
|
141
|
-
|
142
|
-
res
|
143
|
-
res.should be_true
|
107
|
+
res = @project.member?(ConnectionHelper::DEFAULT_USER_URL)
|
108
|
+
expect(res).to be_truthy
|
144
109
|
end
|
145
110
|
|
146
111
|
it 'Returns true when looking for existing user using GoodData::Profile' do
|
147
|
-
|
148
|
-
|
149
|
-
res
|
150
|
-
res.should be_true
|
112
|
+
user = @project.members.first
|
113
|
+
res = @project.member?(user)
|
114
|
+
expect(res).to be_truthy
|
151
115
|
end
|
152
116
|
|
153
117
|
it 'Returns false for non-existing user' do
|
154
|
-
|
155
|
-
res
|
156
|
-
res.should be_false
|
118
|
+
res = @project.member?('john.doe@gooddata.com')
|
119
|
+
expect(res).to be_falsey
|
157
120
|
end
|
158
121
|
|
159
122
|
it 'Returns true for existing user when using optional list' do
|
160
|
-
|
161
|
-
|
162
|
-
res
|
163
|
-
res.should be_true
|
123
|
+
list = @project.members
|
124
|
+
res = @project.member?('svarovsky+gem_tester@gooddata.com', list)
|
125
|
+
expect(res).to be_truthy
|
164
126
|
end
|
165
127
|
|
166
128
|
it 'Returns false for non-existing user when using optional list' do
|
167
|
-
project = ProjectHelper.get_default_project(:client => @client)
|
168
129
|
list = []
|
169
|
-
res = project.member?('svarovsky+gem_tester@gooddata.com', list)
|
170
|
-
res.
|
130
|
+
res = @project.member?('svarovsky+gem_tester@gooddata.com', list)
|
131
|
+
expect(res).to be_falsey
|
171
132
|
end
|
172
133
|
end
|
173
134
|
|
174
|
-
describe '#
|
175
|
-
it 'Returns
|
135
|
+
describe '#members?' do
|
136
|
+
it 'Returns array of bools when looking for existing users using GoodData::Profile' do
|
137
|
+
users = @project.members.take(10)
|
138
|
+
res = @project.members?(users)
|
139
|
+
expect(res.all?).to be_truthy
|
140
|
+
end
|
176
141
|
|
177
|
-
|
178
|
-
|
179
|
-
|
142
|
+
it 'Support variety of inputs' do
|
143
|
+
users = @project.members.take(1)
|
144
|
+
res = @project.members?(users + ['john.doe@gooddata.com'])
|
145
|
+
expect(res).to eq [true, false]
|
180
146
|
end
|
181
147
|
end
|
182
148
|
|
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
|
+
|
183
162
|
describe '#roles' do
|
184
163
|
it 'Returns array of GoodData::ProjectRole' do
|
185
|
-
|
186
|
-
project = ProjectHelper.get_default_project(:client => @client)
|
187
|
-
roles = project.roles
|
164
|
+
roles = @project.roles
|
188
165
|
expect(roles).to be_instance_of(Array)
|
189
166
|
|
190
167
|
roles.each do |role|
|
@@ -193,193 +170,261 @@ describe GoodData::Project do
|
|
193
170
|
end
|
194
171
|
end
|
195
172
|
|
196
|
-
describe '#users' do
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
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
|
+
end
|