gooddata 0.6.53 → 0.6.54
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 +5 -5
- data/.flayignore +6 -0
- data/.gitignore +1 -0
- data/.pronto.yml +3 -0
- data/.rspec +2 -0
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +18 -0
- data/CONTRIBUTING.md +14 -1
- data/DEPENDENCIES.md +324 -253
- data/Dockerfile.jruby +5 -7
- data/Dockerfile.ruby +8 -8
- data/Rakefile +24 -0
- data/ci.rake +47 -0
- data/docker-compose.yml +34 -0
- data/gooddata.gemspec +8 -2
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +0 -3
- data/lib/gooddata/helpers/data_helper.rb +10 -7
- data/lib/gooddata/helpers/global_helpers_params.rb +8 -3
- data/lib/gooddata/lcm/actions/apply_custom_maql.rb +2 -1
- data/lib/gooddata/lcm/actions/associate_clients.rb +10 -1
- data/lib/gooddata/lcm/actions/collect_client_projects.rb +78 -0
- data/lib/gooddata/lcm/actions/collect_clients.rb +20 -6
- data/lib/gooddata/lcm/actions/collect_data_product.rb +62 -0
- data/lib/gooddata/lcm/actions/collect_dynamic_schedule_params.rb +62 -0
- data/lib/gooddata/lcm/actions/{collect_attrs.rb → collect_ldm_objects.rb} +3 -3
- data/lib/gooddata/lcm/actions/collect_meta.rb +6 -3
- data/lib/gooddata/lcm/actions/collect_segment_clients.rb +2 -1
- data/lib/gooddata/lcm/actions/collect_segments.rb +6 -7
- data/lib/gooddata/lcm/actions/collect_tagged_objects.rb +7 -4
- data/lib/gooddata/lcm/actions/create_segment_masters.rb +7 -3
- data/lib/gooddata/lcm/actions/ensure_data_product.rb +53 -0
- data/lib/gooddata/lcm/actions/ensure_technical_users_domain.rb +6 -2
- data/lib/gooddata/lcm/actions/ensure_technical_users_project.rb +30 -18
- data/lib/gooddata/lcm/actions/execute_schedules.rb +128 -0
- data/lib/gooddata/lcm/actions/provision_clients.rb +32 -21
- data/lib/gooddata/lcm/actions/purge_clients.rb +25 -39
- data/lib/gooddata/lcm/actions/rename_existing_client_projects.rb +70 -0
- data/lib/gooddata/lcm/actions/segments_filter.rb +6 -0
- data/lib/gooddata/lcm/actions/synchronize_cas.rb +11 -0
- data/lib/gooddata/lcm/actions/synchronize_clients.rb +2 -1
- data/lib/gooddata/lcm/actions/synchronize_etls_in_segment.rb +34 -15
- data/lib/gooddata/lcm/actions/synchronize_ldm.rb +10 -1
- data/lib/gooddata/lcm/actions/synchronize_new_segments.rb +2 -1
- data/lib/gooddata/lcm/actions/synchronize_processes.rb +4 -7
- data/lib/gooddata/lcm/actions/synchronize_tag_objects.rb +8 -5
- data/lib/gooddata/lcm/actions/synchronize_user_filters.rb +224 -0
- data/lib/gooddata/lcm/actions/synchronize_user_groups.rb +53 -0
- data/lib/gooddata/lcm/actions/synchronize_users.rb +324 -0
- data/lib/gooddata/lcm/dsl/type_dsl.rb +1 -0
- data/lib/gooddata/lcm/helpers/check_helper.rb +4 -0
- data/lib/gooddata/lcm/helpers/tags_helper.rb +4 -3
- data/lib/gooddata/lcm/lcm2.rb +33 -1
- data/lib/gooddata/lcm/types/complex/segment.rb +3 -0
- data/lib/gooddata/lcm/types/complex/update_preference.rb +8 -2
- data/lib/gooddata/lcm/types/special/array.rb +1 -3
- data/lib/gooddata/lcm/types/special/enum.rb +1 -3
- data/lib/gooddata/mixins/md_id_to_uri.rb +0 -1
- data/lib/gooddata/mixins/md_json.rb +2 -2
- data/lib/gooddata/models/blueprint/project_blueprint.rb +15 -0
- data/lib/gooddata/models/blueprint/to_wire.rb +1 -0
- data/lib/gooddata/models/client.rb +21 -9
- data/lib/gooddata/models/data_product.rb +149 -0
- data/lib/gooddata/models/domain.rb +26 -72
- data/lib/gooddata/models/from_wire.rb +2 -0
- data/lib/gooddata/models/metadata/report.rb +9 -3
- data/lib/gooddata/models/metadata/report_definition.rb +2 -2
- data/lib/gooddata/models/model.rb +1 -1
- data/lib/gooddata/models/process.rb +4 -0
- data/lib/gooddata/models/project.rb +58 -35
- data/lib/gooddata/models/project_creator.rb +13 -0
- data/lib/gooddata/models/segment.rb +63 -16
- data/lib/gooddata/models/style_setting.rb +2 -15
- data/lib/gooddata/models/user_group.rb +2 -0
- data/lib/gooddata/rest/connection.rb +32 -9
- data/lib/gooddata/rest/object_factory.rb +0 -25
- data/lib/gooddata/version.rb +1 -1
- data/spec/data/blueprints/invalid_blueprint.json +2 -2
- data/spec/data/blueprints/test_project_model_spec.json +1 -1
- data/spec/data/dynamic_schedule_params_table.csv +7 -0
- data/spec/data/workspace_table.csv +3 -3
- data/spec/environment/staging.rb +3 -3
- data/spec/integration/ads_output_stage_spec.rb +0 -10
- data/spec/integration/clients_spec.rb +1 -1
- data/spec/{unit → integration}/commands/command_projects_spec.rb +0 -0
- data/spec/{unit → integration}/core/connection_spec.rb +0 -0
- data/spec/{unit → integration}/core/logging_spec.rb +0 -0
- data/spec/{unit → integration}/core/project_spec.rb +0 -0
- data/spec/integration/date_dim_switch_spec.rb +13 -0
- data/spec/integration/full_process_schedule_spec.rb +2 -2
- data/spec/integration/helpers_spec.rb +16 -0
- data/spec/integration/lcm_spec.rb +12 -2
- data/spec/integration/mixins/id_to_uri_spec.rb +44 -0
- data/spec/integration/models/data_product_spec.rb +71 -0
- data/spec/{unit → integration}/models/domain_spec.rb +2 -2
- data/spec/{unit → integration}/models/invitation_spec.rb +0 -0
- data/spec/{unit → integration}/models/membership_spec.rb +0 -0
- data/spec/{unit → integration}/models/params_spec.rb +0 -0
- data/spec/{unit → integration}/models/profile_spec.rb +0 -0
- data/spec/{unit → integration}/models/project_role_spec.rb +0 -0
- data/spec/integration/models/project_spec.rb +225 -0
- data/spec/{unit → integration}/models/schedule_spec.rb +0 -0
- data/spec/{unit → integration}/models/unit_project_spec.rb +0 -0
- data/spec/integration/project_spec.rb +40 -5
- data/spec/integration/segments_spec.rb +27 -26
- data/spec/integration/user_filters_spec.rb +1 -1
- data/spec/spec_helper.rb +15 -19
- data/spec/unit/actions/associate_clients_spec.rb +47 -0
- data/spec/unit/actions/collect_client_projects_spec.rb +47 -0
- data/spec/unit/actions/collect_clients_spec.rb +27 -0
- data/spec/unit/actions/collect_data_product_spec.rb +64 -0
- data/spec/unit/actions/collect_dynamic_schedule_params_spec.rb +56 -0
- data/spec/unit/actions/collect_meta_spec.rb +4 -4
- data/spec/unit/actions/collect_segment_clients_spec.rb +44 -3
- data/spec/unit/actions/collect_tagged_objects_spec.rb +20 -4
- data/spec/unit/actions/create_segment_masters_spec.rb +64 -0
- data/spec/unit/actions/ensure_data_product_spec.rb +38 -0
- data/spec/unit/actions/ensure_technical_users_domain_spec.rb +51 -0
- data/spec/unit/actions/ensure_technical_users_project_spec.rb +72 -0
- data/spec/unit/actions/execute_schedules_spec.rb +94 -0
- data/spec/unit/actions/provision_clients_spec.rb +45 -0
- data/spec/unit/actions/purge_clients_spec.rb +47 -0
- data/spec/unit/actions/rename_existing_client_projects_spec.rb +54 -0
- data/spec/unit/actions/segments_filter_spec.rb +46 -0
- data/spec/unit/actions/shared_examples_for_user_actions.rb +10 -0
- data/spec/unit/actions/synchronize_cas_spec.rb +58 -0
- data/spec/unit/actions/synchronize_etls_in_segment_spec.rb +174 -13
- data/spec/unit/actions/synchronize_ldm_spec.rb +57 -0
- data/spec/unit/actions/synchronize_user_filters_spec.rb +142 -0
- data/spec/unit/actions/synchronize_user_groups_spec.rb +49 -0
- data/spec/unit/actions/synchronize_users_spec.rb +76 -0
- data/spec/unit/helpers/data_helper_spec.rb +17 -0
- data/spec/unit/helpers/global_helpers_spec.rb +16 -0
- data/spec/unit/helpers_spec.rb +0 -6
- data/spec/unit/models/blueprint/project_blueprint_spec.rb +21 -4
- data/spec/unit/models/project_creator_spec.rb +16 -0
- data/spec/unit/models/project_spec.rb +66 -197
- metadata +202 -100
- data/PULL_REQUEST_TEMPLATE.md +0 -5
- data/lib/gooddata/bricks/middleware/params_inspect_middleware.rb +0 -21
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
6
|
+
|
|
7
|
+
require 'gooddata/lcm/lcm2'
|
|
8
|
+
require 'gooddata/lcm/actions/synchronize_user_groups'
|
|
9
|
+
|
|
10
|
+
describe GoodData::LCM2::SynchronizeUserGroups do
|
|
11
|
+
let(:gdc_gd_client) { double(:gdc_gd_client) }
|
|
12
|
+
let(:development_client) { double(:development_client) }
|
|
13
|
+
let(:logger) { double(:logger) }
|
|
14
|
+
|
|
15
|
+
let(:from_project) { double(:from_project) }
|
|
16
|
+
let(:to_project) { double(:to_project) }
|
|
17
|
+
|
|
18
|
+
let(:params) do
|
|
19
|
+
params = {
|
|
20
|
+
gdc_gd_client: gdc_gd_client,
|
|
21
|
+
development_client: development_client,
|
|
22
|
+
synchronize: [{
|
|
23
|
+
segment_id: 'some_segment_ids',
|
|
24
|
+
from: 'from_project_id',
|
|
25
|
+
to: [{ pid: 'to_project_id' }]
|
|
26
|
+
}],
|
|
27
|
+
gdc_logger: logger
|
|
28
|
+
}
|
|
29
|
+
GoodData::LCM2.convert_to_smart_hash(params)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
before do
|
|
33
|
+
allow(logger).to receive(:info)
|
|
34
|
+
|
|
35
|
+
allow(development_client).to receive(:projects) { from_project }
|
|
36
|
+
allow(from_project).to receive(:title)
|
|
37
|
+
allow(from_project).to receive(:pid)
|
|
38
|
+
|
|
39
|
+
allow(gdc_gd_client).to receive(:projects) { to_project }
|
|
40
|
+
allow(to_project).to receive(:title)
|
|
41
|
+
allow(to_project).to receive(:pid)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'should transfer user groups' do
|
|
45
|
+
result = [{ from: 'from_project_id', to: 'to_project_id', user_group: 'user_group_name', status: 'created' }]
|
|
46
|
+
expect(GoodData::Project).to receive(:transfer_user_groups).with(from_project, to_project).and_return(result)
|
|
47
|
+
subject.class.call(params)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require 'active_support/core_ext/hash'
|
|
2
|
+
require 'gooddata/lcm/lcm2'
|
|
3
|
+
require_relative 'shared_examples_for_user_actions'
|
|
4
|
+
|
|
5
|
+
describe GoodData::LCM2::SynchronizeUsers do
|
|
6
|
+
let(:client) { double('client') }
|
|
7
|
+
let(:user) { double('user') }
|
|
8
|
+
let(:data_source) { double('user') }
|
|
9
|
+
let(:domain) { double('domain') }
|
|
10
|
+
let(:project) { double('project') }
|
|
11
|
+
let(:organization) { double('organization') }
|
|
12
|
+
let(:logger) { double('logger') }
|
|
13
|
+
|
|
14
|
+
before do
|
|
15
|
+
allow(client).to receive(:projects).and_return(project)
|
|
16
|
+
allow(client).to receive(:user).and_return(user)
|
|
17
|
+
allow(client).to receive(:domain).and_return(domain)
|
|
18
|
+
allow(domain).to receive(:clients).and_return(organization)
|
|
19
|
+
allow(organization).to receive(:project_uri)
|
|
20
|
+
allow(project).to receive(:import_users).and_return([{}])
|
|
21
|
+
allow(project).to receive(:metadata).and_return({})
|
|
22
|
+
allow(project).to receive(:uri)
|
|
23
|
+
allow(project).to receive(:pid).and_return('123456789')
|
|
24
|
+
allow(data_source).to receive(:realize)
|
|
25
|
+
allow(user).to receive(:login).and_return('my_login')
|
|
26
|
+
allow(GoodData::Helpers::DataSource).to receive(:new)
|
|
27
|
+
.and_return(data_source)
|
|
28
|
+
allow(logger).to receive(:debug)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context 'when multiple_projects_column not specified' do
|
|
32
|
+
context 'when mode requires client_id' do
|
|
33
|
+
let(:params) do
|
|
34
|
+
params = {
|
|
35
|
+
GDC_GD_CLIENT: client,
|
|
36
|
+
input_source: 'foo',
|
|
37
|
+
domain: 'bar',
|
|
38
|
+
gdc_logger: logger,
|
|
39
|
+
sync_mode: 'sync_one_project_based_on_custom_id'
|
|
40
|
+
}
|
|
41
|
+
GoodData::LCM2.convert_to_smart_hash(params)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it_behaves_like 'a user action' do
|
|
45
|
+
let(:client_id) { '123456789' }
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context 'when mode requires client_id' do
|
|
50
|
+
let(:params) do
|
|
51
|
+
params = {
|
|
52
|
+
GDC_GD_CLIENT: client,
|
|
53
|
+
input_source: 'foo',
|
|
54
|
+
domain: 'bar',
|
|
55
|
+
gdc_logger: logger,
|
|
56
|
+
sync_mode: 'sync_one_project_based_on_pid'
|
|
57
|
+
}
|
|
58
|
+
GoodData::LCM2.convert_to_smart_hash(params)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
before do
|
|
62
|
+
allow(File).to receive(:open).and_return("project_id\n123456789")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'uses project_id column' do
|
|
66
|
+
expect(project).to receive(:import_users) do |filtered_users|
|
|
67
|
+
filtered_users.each do |u|
|
|
68
|
+
expect(u[:pid]).to eq '123456789'
|
|
69
|
+
end
|
|
70
|
+
[]
|
|
71
|
+
end
|
|
72
|
+
subject.class.call(params)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
require 'gooddata/helpers/data_helper'
|
|
8
8
|
|
|
9
9
|
describe GoodData::Helpers::DataSource do
|
|
10
|
+
let(:file_size) { 666 }
|
|
11
|
+
|
|
10
12
|
before :each do
|
|
11
13
|
@s3_client = double('s3_client')
|
|
12
14
|
@bucket = double('bucket')
|
|
@@ -15,6 +17,8 @@ describe GoodData::Helpers::DataSource do
|
|
|
15
17
|
allow(@s3_client).to receive(:bucket) { @bucket }
|
|
16
18
|
allow(@bucket).to receive(:object) { @objects }
|
|
17
19
|
allow(@objects).to receive(:get) { StringIO.new('aaa') }
|
|
20
|
+
allow(@objects).to receive(:size) { file_size }
|
|
21
|
+
allow(File).to receive(:size) { file_size }
|
|
18
22
|
|
|
19
23
|
@ds = GoodData::Helpers::DataSource.new(type: :s3, bucket: 'some_bucket', key: 'some_key')
|
|
20
24
|
end
|
|
@@ -47,4 +51,17 @@ describe GoodData::Helpers::DataSource do
|
|
|
47
51
|
ds.realize(params)
|
|
48
52
|
end.to raise_exception 'Key "key" is missing in S3 datasource'
|
|
49
53
|
end
|
|
54
|
+
|
|
55
|
+
context 'when size of the downloaded file is not right' do
|
|
56
|
+
before do
|
|
57
|
+
allow(File).to receive(:size) { 0 }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'raises an error' do
|
|
61
|
+
params = { 'aws_client' => { 's3_client' => @s3_client } }
|
|
62
|
+
expect do
|
|
63
|
+
@ds.realize(params)
|
|
64
|
+
end.to raise_exception(/Expected size 666, got 0/)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
50
67
|
end
|
|
@@ -123,6 +123,22 @@ describe GoodData::Helpers do
|
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
+
it 'should not throw error if missing reference parameter placeholder' do
|
|
127
|
+
params = {
|
|
128
|
+
'x' => 'y',
|
|
129
|
+
'ads_password' => 'ads_123',
|
|
130
|
+
'gd_encoded_params' => '{"login_username": "login_user", "login_password": "${my_password}"}'
|
|
131
|
+
}
|
|
132
|
+
expected_result = {
|
|
133
|
+
'x' => 'y',
|
|
134
|
+
'ads_password' => 'ads_123',
|
|
135
|
+
'login_username' => 'login_user',
|
|
136
|
+
'login_password' => '${my_password}'
|
|
137
|
+
}
|
|
138
|
+
result = GoodData::Helpers.decode_params(params, :resolve_reference_params => true)
|
|
139
|
+
expect(result).to eq(expected_result)
|
|
140
|
+
end
|
|
141
|
+
|
|
126
142
|
it 'should encode reference parameters in gd_encoded_params' do
|
|
127
143
|
params = {
|
|
128
144
|
'x' => 'y',
|
data/spec/unit/helpers_spec.rb
CHANGED
|
@@ -38,12 +38,6 @@ describe GoodData::Helpers do
|
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
describe '#find_goodfile' do
|
|
42
|
-
it 'works' do
|
|
43
|
-
GoodData::Helpers.find_goodfile.should_not be_nil
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
41
|
describe "#decode_params" do
|
|
48
42
|
it 'decodes the data params from json' do
|
|
49
43
|
params = {
|
|
@@ -99,12 +99,29 @@ describe GoodData::Model::ProjectBlueprint do
|
|
|
99
99
|
|
|
100
100
|
it 'invalid blueprint should give you list of violating references' do
|
|
101
101
|
errors = @invalid_blueprint.validate
|
|
102
|
-
expect(errors.size).to eq
|
|
103
|
-
expect(errors).to
|
|
102
|
+
expect(errors.size).to eq 5
|
|
103
|
+
expect(errors).to match_array([
|
|
104
104
|
{
|
|
105
105
|
:type => :wrong_label_reference,
|
|
106
106
|
:label => "some_label_id",
|
|
107
107
|
:wrong_reference => "attr.repos.repo_id ERROR"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
type: :invalid_identifier,
|
|
111
|
+
id: 'some_attr_id(hello)'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: :duplicated_identifier,
|
|
115
|
+
id: 'some_label_id'
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: :wrong_label_reference,
|
|
119
|
+
label: "some_label_id",
|
|
120
|
+
wrong_reference: "some_attr_id"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: :attribute_without_label,
|
|
124
|
+
attribute: "some_attr_id(hello)"
|
|
108
125
|
}
|
|
109
126
|
])
|
|
110
127
|
end
|
|
@@ -417,7 +434,7 @@ describe GoodData::Model::ProjectBlueprint do
|
|
|
417
434
|
d.add_date('opportunity_comitted', dataset: 'committed_on')
|
|
418
435
|
end
|
|
419
436
|
end
|
|
420
|
-
expect(bp.datasets.flat_map { |d| d.find_columns_by_type(:date) }.map
|
|
437
|
+
expect(bp.datasets.flat_map { |d| d.find_columns_by_type(:date) }.map { |d| d.data[:format] }).to eq [GoodData::Model::DEFAULT_DATE_FORMAT]
|
|
421
438
|
end
|
|
422
439
|
|
|
423
440
|
it 'blueprint can be set with explicit date' do
|
|
@@ -435,7 +452,7 @@ describe GoodData::Model::ProjectBlueprint do
|
|
|
435
452
|
end
|
|
436
453
|
end
|
|
437
454
|
expect(bp.valid?).to be_truthy
|
|
438
|
-
expect(bp.datasets.flat_map { |d| d.find_columns_by_type(:date) }.map
|
|
455
|
+
expect(bp.datasets.flat_map { |d| d.find_columns_by_type(:date) }.map { |d| d.data[:format] }).to eq ['yyyy/MM/dd']
|
|
439
456
|
end
|
|
440
457
|
|
|
441
458
|
describe '#remove' do
|
|
@@ -71,4 +71,20 @@ describe GoodData::Model::ProjectCreator do
|
|
|
71
71
|
GoodData::Model::ProjectCreator.pick_correct_chunks(@data, update_preference: { cascade_drops: true, preserve_data: false, unmeetable_condition: true })
|
|
72
72
|
end.to raise_error
|
|
73
73
|
end
|
|
74
|
+
|
|
75
|
+
it 'should pick correct update chunks based on new parameter "allow_cascade_drops" in your preference' do
|
|
76
|
+
chunk = GoodData::Model::ProjectCreator.pick_correct_chunks(@data, update_preference: { allow_cascade_drops: false })
|
|
77
|
+
expect(chunk).to eq [@chunk_a]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'should pick correct update chunks based on new parameter "keep_data" in your preference' do
|
|
81
|
+
chunk = GoodData::Model::ProjectCreator.pick_correct_chunks(@data, update_preference: { keep_data: false })
|
|
82
|
+
expect(chunk).to eq [@chunk_a, @chunk_b]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it 'should raise error when mixing new parameters with the old ones in your preference' do
|
|
86
|
+
expect do
|
|
87
|
+
GoodData::Model::ProjectCreator.pick_correct_chunks(@data, update_preference: { allow_cascade_drops: true, cascade_drops: false })
|
|
88
|
+
end.to raise_error('Please do not mix old parameters (:cascade_drops, :preserve_data) with the new ones (:allow_cascade_drops, :keep_data).')
|
|
89
|
+
end
|
|
74
90
|
end
|
|
@@ -4,221 +4,90 @@
|
|
|
4
4
|
# This source code is licensed under the BSD-style license found in the
|
|
5
5
|
# LICENSE file in the root directory of this source tree.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
shared_examples 'a blueprint provider' do
|
|
8
|
+
it 'requests model view with includeCA=true' do
|
|
9
|
+
expect(client).to receive(:get).with(
|
|
10
|
+
'/gdc/projects/foo/model/view',
|
|
11
|
+
hash_including(params: hash_including(includeCA: true))
|
|
12
|
+
)
|
|
13
|
+
subject.blueprint(include_ca: true)
|
|
14
14
|
end
|
|
15
|
+
end
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
describe GoodData::Project do
|
|
18
|
+
subject { GoodData::Project }
|
|
19
|
+
let(:from_project) { double('from_project') }
|
|
20
|
+
let(:to_project) { double('to_project') }
|
|
21
|
+
let(:process) { double('process') }
|
|
22
|
+
let(:add) { double('add') }
|
|
23
|
+
let(:output_stage) { double('output_stage') }
|
|
24
|
+
let(:client) { double('client') }
|
|
25
|
+
let(:connection) { double('connection') }
|
|
26
|
+
let(:server) { double('server') }
|
|
27
|
+
|
|
28
|
+
before do
|
|
29
|
+
allow(from_project).to receive(:processes).and_return([process])
|
|
30
|
+
allow(to_project).to receive(:processes).and_return([])
|
|
31
|
+
allow(process).to receive(:type).and_return(:dataload)
|
|
32
|
+
allow(to_project).to receive(:add).and_return(add)
|
|
33
|
+
allow(to_project).to receive(:client).and_return(client)
|
|
34
|
+
allow(client).to receive(:connection).and_return(connection)
|
|
35
|
+
allow(connection).to receive(:server).and_return(server)
|
|
36
|
+
allow(from_project).to receive(:add).and_return(add)
|
|
37
|
+
allow(from_project).to receive(:client).and_return(client)
|
|
38
|
+
allow(add).to receive(:output_stage).and_return(output_stage)
|
|
18
39
|
end
|
|
19
40
|
|
|
20
|
-
describe '
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
expect(projects).to be_a_kind_of(Array)
|
|
25
|
-
projects.pmap do |project|
|
|
26
|
-
expect(project).to be_an_instance_of(GoodData::Project)
|
|
41
|
+
describe '.transfer_output_stage' do
|
|
42
|
+
context 'when source and target domains are different' do
|
|
43
|
+
before do
|
|
44
|
+
allow(server).to receive(:url).and_return('foo', 'bar')
|
|
27
45
|
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'Returns project if ID passed' do
|
|
31
|
-
expect(@project).to_not be_nil
|
|
32
|
-
expect(@project).to be_a_kind_of(GoodData::Project)
|
|
33
|
-
expect(@project.pid).to eq @project.pid
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'Returns project if URL passed' do
|
|
37
|
-
expect(@project).to_not be_nil
|
|
38
|
-
expect(@project).to be_a_kind_of(GoodData::Project)
|
|
39
|
-
expect(@project.pid).to eq @project.pid
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'Throws an exception when invalid format of URL passed' do
|
|
43
|
-
invalid_url = '/gdc/invalid_url'
|
|
44
|
-
expect { GoodData::Project[invalid_url] }.to raise_error
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
describe '#all' do
|
|
49
|
-
it 'Returns all projects' do
|
|
50
|
-
projects = GoodData::Project.all(:client => @client)
|
|
51
|
-
expect(projects).to_not be_nil
|
|
52
|
-
expect(projects).to be_a_kind_of(Array)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
describe '#get_role_by_identifier' do
|
|
57
|
-
it 'Looks up for role by identifier' do
|
|
58
|
-
role = @project.get_role_by_identifier('readOnlyUserRole')
|
|
59
|
-
expect(role).to_not be_nil
|
|
60
|
-
expect(role).to be_a_kind_of(GoodData::ProjectRole)
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
46
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
expect(role).to_not be_nil
|
|
68
|
-
expect(role).to be_a_kind_of(GoodData::ProjectRole)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
describe '#get_role_by_title' do
|
|
73
|
-
it 'Looks up for role by title' do
|
|
74
|
-
role = @project.get_role_by_title('Viewer')
|
|
75
|
-
expect(role).to_not be_nil
|
|
76
|
-
expect(role).to be_a_kind_of(GoodData::ProjectRole)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
describe "#member" do
|
|
81
|
-
it 'Returns GoodData::Membership when looking for existing user using login' do
|
|
82
|
-
res = @project.get_user(ConnectionHelper::DEFAULT_USERNAME)
|
|
83
|
-
expect(res).to be_instance_of(GoodData::Membership)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it 'Returns GoodData::Membership when looking for existing user using URL' do
|
|
87
|
-
res = @project.get_user(ConnectionHelper::DEFAULT_USER_URL)
|
|
88
|
-
expect(res).to be_instance_of(GoodData::Membership)
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it 'Returns GoodData::Membership when looking for existing user using GoodData::Profile' do
|
|
92
|
-
user = @project.members.first
|
|
93
|
-
res = @project.get_user(user)
|
|
94
|
-
expect(res).to be_instance_of(GoodData::Membership)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it 'Returns null for non-existing user' do
|
|
98
|
-
res = @project.get_user(ConnectionHelper::TEST_USERNAME)
|
|
99
|
-
expect(res).to be_nil
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
describe "#member?" do
|
|
104
|
-
it 'Returns true when looking for existing user using login' do
|
|
105
|
-
res = @project.member?(ConnectionHelper::DEFAULT_USERNAME)
|
|
106
|
-
expect(res).to be_truthy
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
it 'Returns true when looking for existing user using URL' do
|
|
110
|
-
res = @project.member?(ConnectionHelper::DEFAULT_USER_URL)
|
|
111
|
-
expect(res).to be_truthy
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
it 'Returns true when looking for existing user using GoodData::Profile' do
|
|
115
|
-
user = @project.members.first
|
|
116
|
-
res = @project.member?(user)
|
|
117
|
-
expect(res).to be_truthy
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it 'Returns false for non-existing user' do
|
|
121
|
-
res = @project.member?(ConnectionHelper::TEST_USERNAME)
|
|
122
|
-
expect(res).to be_falsey
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it 'Returns true for existing user when using optional list' do
|
|
126
|
-
list = @project.members
|
|
127
|
-
res = @project.member?(ConnectionHelper::DEFAULT_USERNAME, list)
|
|
128
|
-
expect(res).to be_truthy
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it 'Returns false for non-existing user when using optional list' do
|
|
132
|
-
list = []
|
|
133
|
-
res = @project.member?(ConnectionHelper::DEFAULT_USERNAME, list)
|
|
134
|
-
expect(res).to be_falsey
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
describe '#members?' do
|
|
139
|
-
it 'Returns array of bools when looking for existing users using GoodData::Profile' do
|
|
140
|
-
users = @project.members.take(10)
|
|
141
|
-
res = @project.members?(users)
|
|
142
|
-
expect(res.all?).to be_truthy
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
it 'Support variety of inputs' do
|
|
146
|
-
users = @project.members.take(1)
|
|
147
|
-
res = @project.members?(users + [ConnectionHelper::TEST_USERNAME])
|
|
148
|
-
expect(res).to eq [true, false]
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
describe '#roles' do
|
|
153
|
-
it 'Returns array of GoodData::ProjectRole' do
|
|
154
|
-
roles = @project.roles
|
|
155
|
-
expect(roles).to be_instance_of(Array)
|
|
156
|
-
|
|
157
|
-
roles.each do |role|
|
|
158
|
-
expect(role).to be_instance_of(GoodData::ProjectRole)
|
|
47
|
+
it 'raises an error' do
|
|
48
|
+
expect { subject.transfer_output_stage(from_project, to_project, {}) }
|
|
49
|
+
.to raise_error(/Cannot transfer output stage from foo to bar/)
|
|
159
50
|
end
|
|
160
51
|
end
|
|
161
52
|
end
|
|
162
53
|
|
|
163
|
-
describe '#
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
it 'excludes scheduled emails' do
|
|
173
|
-
@project.schedule_mail.save
|
|
174
|
-
export_token = @project.export_clone(options)
|
|
175
|
-
clone.import_clone(export_token)
|
|
176
|
-
expect(@project.scheduled_mails.to_a).not_to be_empty
|
|
177
|
-
expect(clone.scheduled_mails.to_a).to be_empty
|
|
178
|
-
end
|
|
54
|
+
describe '#blueprint' do
|
|
55
|
+
let(:project_data) do
|
|
56
|
+
{
|
|
57
|
+
'project' => {
|
|
58
|
+
'links' => { 'self' => '/gdc/foo' },
|
|
59
|
+
'meta' => { 'title' => 'My Project' }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
179
62
|
end
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
it 'is ok' do
|
|
183
|
-
# there are no staging environments on other datacenters
|
|
184
|
-
# so just checking if the parameter gets accepted
|
|
185
|
-
@project.export_clone(cross_data_center_export: true)
|
|
186
|
-
end
|
|
63
|
+
let(:diff_result) do
|
|
64
|
+
{ 'asyncTask' => { 'link' => { 'poll' => 'poll_me' } } }
|
|
187
65
|
end
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
allow(@client)
|
|
197
|
-
.to receive(:poll_on_response).and_return(fail_response)
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
it 'raises ExportCloneError' do
|
|
201
|
-
expect { @project.export_clone }.to raise_error(GoodData::ExportCloneError)
|
|
202
|
-
end
|
|
66
|
+
let(:blueprint) { double(GoodData::Model::ProjectBlueprint) }
|
|
67
|
+
subject { GoodData::Project.new(project_data) }
|
|
68
|
+
before do
|
|
69
|
+
allow(client).to receive(:get).and_return(diff_result)
|
|
70
|
+
allow(client).to receive(:poll_on_code)
|
|
71
|
+
allow(GoodData::Model::FromWire).to receive(:from_wire) .and_return(blueprint)
|
|
72
|
+
allow(blueprint).to receive(:title=)
|
|
73
|
+
subject.client = client
|
|
203
74
|
end
|
|
204
|
-
end
|
|
205
75
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
let(:fail_response) do
|
|
209
|
-
response = { taskState: { status: 'ERROR' } }
|
|
210
|
-
GoodData::Helpers.stringify_keys(response)
|
|
76
|
+
context 'when include_ca option is true' do
|
|
77
|
+
it_behaves_like 'a blueprint provider'
|
|
211
78
|
end
|
|
212
79
|
|
|
213
|
-
|
|
214
|
-
|
|
80
|
+
context 'when include_ca option is not specified' do
|
|
81
|
+
it_behaves_like 'a blueprint provider'
|
|
215
82
|
end
|
|
216
83
|
|
|
217
|
-
context 'when
|
|
218
|
-
it '
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
84
|
+
context 'when include_ca option is false' do
|
|
85
|
+
it 'requests model view with includeCA=false' do
|
|
86
|
+
expect(client).to receive(:get).with(
|
|
87
|
+
'/gdc/projects/foo/model/view',
|
|
88
|
+
hash_including(params: hash_including(includeCA: false))
|
|
89
|
+
)
|
|
90
|
+
subject.blueprint(include_ca: false)
|
|
222
91
|
end
|
|
223
92
|
end
|
|
224
93
|
end
|