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.
Files changed (139) hide show
  1. checksums.yaml +5 -5
  2. data/.flayignore +6 -0
  3. data/.gitignore +1 -0
  4. data/.pronto.yml +3 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +4 -1
  7. data/CHANGELOG.md +18 -0
  8. data/CONTRIBUTING.md +14 -1
  9. data/DEPENDENCIES.md +324 -253
  10. data/Dockerfile.jruby +5 -7
  11. data/Dockerfile.ruby +8 -8
  12. data/Rakefile +24 -0
  13. data/ci.rake +47 -0
  14. data/docker-compose.yml +34 -0
  15. data/gooddata.gemspec +8 -2
  16. data/lib/gooddata/bricks/middleware/restforce_middleware.rb +0 -3
  17. data/lib/gooddata/helpers/data_helper.rb +10 -7
  18. data/lib/gooddata/helpers/global_helpers_params.rb +8 -3
  19. data/lib/gooddata/lcm/actions/apply_custom_maql.rb +2 -1
  20. data/lib/gooddata/lcm/actions/associate_clients.rb +10 -1
  21. data/lib/gooddata/lcm/actions/collect_client_projects.rb +78 -0
  22. data/lib/gooddata/lcm/actions/collect_clients.rb +20 -6
  23. data/lib/gooddata/lcm/actions/collect_data_product.rb +62 -0
  24. data/lib/gooddata/lcm/actions/collect_dynamic_schedule_params.rb +62 -0
  25. data/lib/gooddata/lcm/actions/{collect_attrs.rb → collect_ldm_objects.rb} +3 -3
  26. data/lib/gooddata/lcm/actions/collect_meta.rb +6 -3
  27. data/lib/gooddata/lcm/actions/collect_segment_clients.rb +2 -1
  28. data/lib/gooddata/lcm/actions/collect_segments.rb +6 -7
  29. data/lib/gooddata/lcm/actions/collect_tagged_objects.rb +7 -4
  30. data/lib/gooddata/lcm/actions/create_segment_masters.rb +7 -3
  31. data/lib/gooddata/lcm/actions/ensure_data_product.rb +53 -0
  32. data/lib/gooddata/lcm/actions/ensure_technical_users_domain.rb +6 -2
  33. data/lib/gooddata/lcm/actions/ensure_technical_users_project.rb +30 -18
  34. data/lib/gooddata/lcm/actions/execute_schedules.rb +128 -0
  35. data/lib/gooddata/lcm/actions/provision_clients.rb +32 -21
  36. data/lib/gooddata/lcm/actions/purge_clients.rb +25 -39
  37. data/lib/gooddata/lcm/actions/rename_existing_client_projects.rb +70 -0
  38. data/lib/gooddata/lcm/actions/segments_filter.rb +6 -0
  39. data/lib/gooddata/lcm/actions/synchronize_cas.rb +11 -0
  40. data/lib/gooddata/lcm/actions/synchronize_clients.rb +2 -1
  41. data/lib/gooddata/lcm/actions/synchronize_etls_in_segment.rb +34 -15
  42. data/lib/gooddata/lcm/actions/synchronize_ldm.rb +10 -1
  43. data/lib/gooddata/lcm/actions/synchronize_new_segments.rb +2 -1
  44. data/lib/gooddata/lcm/actions/synchronize_processes.rb +4 -7
  45. data/lib/gooddata/lcm/actions/synchronize_tag_objects.rb +8 -5
  46. data/lib/gooddata/lcm/actions/synchronize_user_filters.rb +224 -0
  47. data/lib/gooddata/lcm/actions/synchronize_user_groups.rb +53 -0
  48. data/lib/gooddata/lcm/actions/synchronize_users.rb +324 -0
  49. data/lib/gooddata/lcm/dsl/type_dsl.rb +1 -0
  50. data/lib/gooddata/lcm/helpers/check_helper.rb +4 -0
  51. data/lib/gooddata/lcm/helpers/tags_helper.rb +4 -3
  52. data/lib/gooddata/lcm/lcm2.rb +33 -1
  53. data/lib/gooddata/lcm/types/complex/segment.rb +3 -0
  54. data/lib/gooddata/lcm/types/complex/update_preference.rb +8 -2
  55. data/lib/gooddata/lcm/types/special/array.rb +1 -3
  56. data/lib/gooddata/lcm/types/special/enum.rb +1 -3
  57. data/lib/gooddata/mixins/md_id_to_uri.rb +0 -1
  58. data/lib/gooddata/mixins/md_json.rb +2 -2
  59. data/lib/gooddata/models/blueprint/project_blueprint.rb +15 -0
  60. data/lib/gooddata/models/blueprint/to_wire.rb +1 -0
  61. data/lib/gooddata/models/client.rb +21 -9
  62. data/lib/gooddata/models/data_product.rb +149 -0
  63. data/lib/gooddata/models/domain.rb +26 -72
  64. data/lib/gooddata/models/from_wire.rb +2 -0
  65. data/lib/gooddata/models/metadata/report.rb +9 -3
  66. data/lib/gooddata/models/metadata/report_definition.rb +2 -2
  67. data/lib/gooddata/models/model.rb +1 -1
  68. data/lib/gooddata/models/process.rb +4 -0
  69. data/lib/gooddata/models/project.rb +58 -35
  70. data/lib/gooddata/models/project_creator.rb +13 -0
  71. data/lib/gooddata/models/segment.rb +63 -16
  72. data/lib/gooddata/models/style_setting.rb +2 -15
  73. data/lib/gooddata/models/user_group.rb +2 -0
  74. data/lib/gooddata/rest/connection.rb +32 -9
  75. data/lib/gooddata/rest/object_factory.rb +0 -25
  76. data/lib/gooddata/version.rb +1 -1
  77. data/spec/data/blueprints/invalid_blueprint.json +2 -2
  78. data/spec/data/blueprints/test_project_model_spec.json +1 -1
  79. data/spec/data/dynamic_schedule_params_table.csv +7 -0
  80. data/spec/data/workspace_table.csv +3 -3
  81. data/spec/environment/staging.rb +3 -3
  82. data/spec/integration/ads_output_stage_spec.rb +0 -10
  83. data/spec/integration/clients_spec.rb +1 -1
  84. data/spec/{unit → integration}/commands/command_projects_spec.rb +0 -0
  85. data/spec/{unit → integration}/core/connection_spec.rb +0 -0
  86. data/spec/{unit → integration}/core/logging_spec.rb +0 -0
  87. data/spec/{unit → integration}/core/project_spec.rb +0 -0
  88. data/spec/integration/date_dim_switch_spec.rb +13 -0
  89. data/spec/integration/full_process_schedule_spec.rb +2 -2
  90. data/spec/integration/helpers_spec.rb +16 -0
  91. data/spec/integration/lcm_spec.rb +12 -2
  92. data/spec/integration/mixins/id_to_uri_spec.rb +44 -0
  93. data/spec/integration/models/data_product_spec.rb +71 -0
  94. data/spec/{unit → integration}/models/domain_spec.rb +2 -2
  95. data/spec/{unit → integration}/models/invitation_spec.rb +0 -0
  96. data/spec/{unit → integration}/models/membership_spec.rb +0 -0
  97. data/spec/{unit → integration}/models/params_spec.rb +0 -0
  98. data/spec/{unit → integration}/models/profile_spec.rb +0 -0
  99. data/spec/{unit → integration}/models/project_role_spec.rb +0 -0
  100. data/spec/integration/models/project_spec.rb +225 -0
  101. data/spec/{unit → integration}/models/schedule_spec.rb +0 -0
  102. data/spec/{unit → integration}/models/unit_project_spec.rb +0 -0
  103. data/spec/integration/project_spec.rb +40 -5
  104. data/spec/integration/segments_spec.rb +27 -26
  105. data/spec/integration/user_filters_spec.rb +1 -1
  106. data/spec/spec_helper.rb +15 -19
  107. data/spec/unit/actions/associate_clients_spec.rb +47 -0
  108. data/spec/unit/actions/collect_client_projects_spec.rb +47 -0
  109. data/spec/unit/actions/collect_clients_spec.rb +27 -0
  110. data/spec/unit/actions/collect_data_product_spec.rb +64 -0
  111. data/spec/unit/actions/collect_dynamic_schedule_params_spec.rb +56 -0
  112. data/spec/unit/actions/collect_meta_spec.rb +4 -4
  113. data/spec/unit/actions/collect_segment_clients_spec.rb +44 -3
  114. data/spec/unit/actions/collect_tagged_objects_spec.rb +20 -4
  115. data/spec/unit/actions/create_segment_masters_spec.rb +64 -0
  116. data/spec/unit/actions/ensure_data_product_spec.rb +38 -0
  117. data/spec/unit/actions/ensure_technical_users_domain_spec.rb +51 -0
  118. data/spec/unit/actions/ensure_technical_users_project_spec.rb +72 -0
  119. data/spec/unit/actions/execute_schedules_spec.rb +94 -0
  120. data/spec/unit/actions/provision_clients_spec.rb +45 -0
  121. data/spec/unit/actions/purge_clients_spec.rb +47 -0
  122. data/spec/unit/actions/rename_existing_client_projects_spec.rb +54 -0
  123. data/spec/unit/actions/segments_filter_spec.rb +46 -0
  124. data/spec/unit/actions/shared_examples_for_user_actions.rb +10 -0
  125. data/spec/unit/actions/synchronize_cas_spec.rb +58 -0
  126. data/spec/unit/actions/synchronize_etls_in_segment_spec.rb +174 -13
  127. data/spec/unit/actions/synchronize_ldm_spec.rb +57 -0
  128. data/spec/unit/actions/synchronize_user_filters_spec.rb +142 -0
  129. data/spec/unit/actions/synchronize_user_groups_spec.rb +49 -0
  130. data/spec/unit/actions/synchronize_users_spec.rb +76 -0
  131. data/spec/unit/helpers/data_helper_spec.rb +17 -0
  132. data/spec/unit/helpers/global_helpers_spec.rb +16 -0
  133. data/spec/unit/helpers_spec.rb +0 -6
  134. data/spec/unit/models/blueprint/project_blueprint_spec.rb +21 -4
  135. data/spec/unit/models/project_creator_spec.rb +16 -0
  136. data/spec/unit/models/project_spec.rb +66 -197
  137. metadata +202 -100
  138. data/PULL_REQUEST_TEMPLATE.md +0 -5
  139. data/lib/gooddata/bricks/middleware/params_inspect_middleware.rb +0 -21
@@ -0,0 +1,38 @@
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/actions/ensure_data_product'
8
+ require 'gooddata/lcm/lcm2'
9
+
10
+ describe GoodData::LCM2::EnsureDataProduct do
11
+ context 'when data_product parameter is passed' do
12
+ let(:client) { double(:client) }
13
+ let(:domain) { double(:domain) }
14
+ let(:data_product) { GoodData::DataProduct.new({}) }
15
+ let(:gdc_logger) { double(:gdc_logger) }
16
+
17
+ let(:params) do
18
+ params = {
19
+ data_product: "data-product-#{SecureRandom.uuid}",
20
+ gdc_gd_client: client,
21
+ gdc_logger: gdc_logger
22
+ }
23
+ GoodData::LCM2.convert_to_smart_hash(params)
24
+ end
25
+
26
+ before do
27
+ allow(domain).to receive(:data_products) { raise RestClient::BadRequest }
28
+ allow(domain).to receive(:create_data_product) { data_product }
29
+ allow(client).to receive(:domain) { domain }
30
+ allow(gdc_logger).to receive(:info) {}
31
+ end
32
+
33
+ it 'creates the data_product' do
34
+ expect(domain).to receive(:create_data_product)
35
+ subject.class.call(params)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,51 @@
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/actions/ensure_technical_users_project'
8
+ require 'gooddata/lcm/lcm2'
9
+
10
+ shared_examples 'a technical users domain action' do
11
+ it 'adds technical user to the domain' do
12
+ expect(domain).to receive(:add_user)
13
+ .with(login: 'foo@bar.com', email: 'foo@bar.com')
14
+ subject.class.call(params)
15
+ end
16
+ end
17
+
18
+ describe GoodData::LCM2::EnsureTechnicalUsersDomain do
19
+ let(:gdc_gd_client) { double(:gdc_gd_client) }
20
+ let(:domain) { double(:domain) }
21
+ let(:user) { double(:user) }
22
+ before do
23
+ allow(gdc_gd_client).to receive(:domain) { domain }
24
+ allow(domain).to receive(:users) { [] }
25
+ allow(user).to receive(:login)
26
+ allow(user).to receive(:email)
27
+ allow(domain).to receive(:add_user) { user }
28
+ end
29
+
30
+ context 'when deprecated param technical_user specified' do
31
+ let(:params) do
32
+ params = {
33
+ gdc_gd_client: gdc_gd_client,
34
+ technical_user: ['foo@bar.com']
35
+ }
36
+ GoodData::LCM2.convert_to_smart_hash(params)
37
+ end
38
+ it_behaves_like 'a technical users domain action'
39
+ end
40
+
41
+ context 'when param technical_users specified' do
42
+ let(:params) do
43
+ params = {
44
+ gdc_gd_client: gdc_gd_client,
45
+ technical_users: ['foo@bar.com']
46
+ }
47
+ GoodData::LCM2.convert_to_smart_hash(params)
48
+ end
49
+ it_behaves_like 'a technical users domain action'
50
+ end
51
+ end
@@ -0,0 +1,72 @@
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/actions/ensure_technical_users_project'
8
+ require 'gooddata/lcm/lcm2'
9
+
10
+ shared_examples 'a technical users project action' do
11
+ it 'adds technical user to the project' do
12
+ expect(project).to receive(:create_users).with([{ login: 'foo@bar.com', role: 'admin' }])
13
+ result = subject.class.call(params)
14
+ expected = [{ project: 'foo project',
15
+ pid: 'abcdefg',
16
+ login: 'foo@bar.com',
17
+ role: 'admin',
18
+ result: 'successful',
19
+ message: 'yahoo!',
20
+ url: '/gdc/account/foo' }]
21
+ expect(result).to eq(expected)
22
+ end
23
+ end
24
+
25
+ describe GoodData::LCM2::EnsureTechnicalUsersProject do
26
+ let(:gdc_gd_client) { double(:gdc_gd_client) }
27
+ let(:project) { double(:project) }
28
+ before do
29
+ allow(project).to receive(:title) { 'foo project' }
30
+ allow(project).to receive(:pid) { 'abcdefg' }
31
+ allow(project).to receive(:create_users) { [{ type: 'successful', message: 'yahoo!', user: '/gdc/account/foo' }] }
32
+ allow(gdc_gd_client).to receive(:projects) { project }
33
+ end
34
+
35
+ context 'when user wants to assign an existing project to new client' do
36
+ let(:params) do
37
+ params = {
38
+ gdc_gd_client: gdc_gd_client,
39
+ technical_users: ['foo@bar.com'],
40
+ synchronize: [],
41
+ clients: [{ project: 'abcdefg' }]
42
+ }
43
+ GoodData::LCM2.convert_to_smart_hash(params)
44
+ end
45
+
46
+ it_behaves_like 'a technical users project action'
47
+ end
48
+
49
+ context 'when deprecated param technical_user specified' do
50
+ let(:params) do
51
+ params = {
52
+ gdc_gd_client: gdc_gd_client,
53
+ technical_user: ['foo@bar.com'],
54
+ synchronize: [{ to: [{ pid: 'qux' }] }]
55
+ }
56
+ GoodData::LCM2.convert_to_smart_hash(params)
57
+ end
58
+ it_behaves_like 'a technical users project action'
59
+ end
60
+
61
+ context 'when param technical_users specified' do
62
+ let(:params) do
63
+ params = {
64
+ gdc_gd_client: gdc_gd_client,
65
+ technical_users: ['foo@bar.com'],
66
+ synchronize: [{ to: [{ pid: 'qux' }] }]
67
+ }
68
+ GoodData::LCM2.convert_to_smart_hash(params)
69
+ end
70
+ it_behaves_like 'a technical users project action'
71
+ end
72
+ end
@@ -0,0 +1,94 @@
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/execute_schedules'
9
+
10
+ describe GoodData::LCM2::ExecuteSchedules do
11
+ let(:client) { double(:client) }
12
+ let(:logger) { double(:logger) }
13
+ let(:project) { double(:project) }
14
+ let(:schedule) { double(:schedule) }
15
+
16
+ before do
17
+ allow(logger).to receive(:info)
18
+ allow(logger).to receive(:warn)
19
+ allow(client).to receive(:projects).and_return([project])
20
+ allow(schedule).to receive(:params).and_return('MODE' => 'foo')
21
+ allow(schedule).to receive(:project).and_return(project)
22
+ allow(schedule).to receive(:obj_id).and_return('id')
23
+ allow(project).to receive(:schedules).and_return([schedule])
24
+ allow(project).to receive(:pid)
25
+ allow(project).to receive(:title)
26
+ end
27
+
28
+ context 'In simplest case' do
29
+ let(:params) do
30
+ params = {
31
+ GDC_GD_CLIENT: client,
32
+ list_of_modes: 'foo|bar',
33
+ work_done_identificator: 'IGNORE',
34
+ gdc_logger: logger
35
+ }
36
+ GoodData::LCM2.convert_to_smart_hash(params)
37
+ end
38
+
39
+ it 'execute schedules' do
40
+ expect(schedule).to receive(:execute)
41
+ subject.class.call(params)
42
+ end
43
+ end
44
+
45
+ context 'when SEGMENT_LIST is specified' do
46
+ let(:params) do
47
+ params = {
48
+ GDC_GD_CLIENT: client,
49
+ list_of_modes: 'foo|bar',
50
+ work_done_identificator: 'IGNORE',
51
+ gdc_logger: logger,
52
+ segment_list: 'A|B'
53
+ }
54
+ GoodData::LCM2.convert_to_smart_hash(params)
55
+ end
56
+
57
+ it 'throw error if DOMAIN is not filled' do
58
+ expect do
59
+ subject.class.call(params)
60
+ end.to raise_error(/In case that you are using SEGMENT_LIST parameter, you need to fill out DOMAIN parameter/)
61
+ end
62
+ end
63
+
64
+ context 'when SEGMENT_LIST and DOMAIN are specified' do
65
+ let(:params) do
66
+ params = {
67
+ GDC_GD_CLIENT: client,
68
+ list_of_modes: 'foo|bar',
69
+ work_done_identificator: 'IGNORE',
70
+ gdc_logger: logger,
71
+ segment_list: 'A',
72
+ domain: 'domain'
73
+ }
74
+ GoodData::LCM2.convert_to_smart_hash(params)
75
+ end
76
+
77
+ let(:domain) { double(:domain) }
78
+ let(:segment) { double(:segment) }
79
+ let(:segment_client) { double(:segment_client) }
80
+
81
+ before do
82
+ allow(client).to receive(:domain).and_return(domain)
83
+ allow(domain).to receive(:segments).and_return(segment)
84
+ allow(segment).to receive(:clients).and_return([segment_client])
85
+ allow(project).to receive(:obj_id).and_return('id')
86
+ allow(segment_client).to receive(:project).and_return(project)
87
+ end
88
+
89
+ it 'should work' do
90
+ expect(schedule).to receive(:execute)
91
+ subject.class.call(params)
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,45 @@
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/actions/provision_clients'
8
+ require 'gooddata/lcm/actions/purge_clients'
9
+ require 'gooddata/lcm/lcm2'
10
+
11
+ describe GoodData::LCM2::ProvisionClients do
12
+ let(:gdc_gd_client) { double('gdc_gd_client') }
13
+ let(:domain) { double('domain') }
14
+ let(:logger) { double('logger') }
15
+ let(:segment) { double('segment') }
16
+ let(:data_product) { double('data_product') }
17
+
18
+ before do
19
+ allow(gdc_gd_client).to receive(:domain).and_return(domain)
20
+ allow(logger).to receive(:debug)
21
+ allow(logger).to receive(:error).and_return({})
22
+ allow(segment).to receive(:segment_id).and_return({})
23
+ allow(segment).to receive(:provision_client_projects).and_raise('limit reached')
24
+ allow(domain).to receive(:segments) { segment }
25
+ end
26
+
27
+ context 'when provisioning get errors' do
28
+ let(:params) do
29
+ params = {
30
+ gdc_gd_client: gdc_gd_client,
31
+ gdc_logger: logger,
32
+ segments: [
33
+ segment
34
+ ],
35
+ data_product: data_product
36
+ }
37
+ GoodData::LCM2.convert_to_smart_hash(params)
38
+ end
39
+
40
+ it 'clean all zombie clients ' do
41
+ expect(GoodData::LCM2::PurgeClients).to receive(:call).and_return(results: [], params: { client_projects: [] })
42
+ expect { subject.class.call(params) }.to raise_error('limit reached')
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,47 @@
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/purge_clients'
9
+
10
+ describe GoodData::LCM2::PurgeClients do
11
+ let(:client1) { double('client1') }
12
+ let(:client2) { double('client2') }
13
+ let(:project) { double('project') }
14
+
15
+ context "some clients which don't have project or project is deleted are existing in segment" do
16
+ let(:params) do
17
+ params = {
18
+ client_projects: {
19
+ 'client_id' => {
20
+ segment_client: client1,
21
+ project: project
22
+ },
23
+ 'delete' => {
24
+ segment_client: client2
25
+ }
26
+ }
27
+ }
28
+ GoodData::LCM2.convert_to_smart_hash(params)
29
+ end
30
+
31
+ before do
32
+ allow(client1).to receive(:project) { project }
33
+ allow(client1).to receive(:client_id) { 'client_id' }
34
+ allow(client2).to receive(:client_id) { 'delete' }
35
+ allow(client1).to receive(:delete)
36
+ allow(client2).to receive(:delete)
37
+ allow(project).to receive(:pid) { '123456789' }
38
+ allow(project).to receive(:deleted?) { false }
39
+ end
40
+
41
+ it 'purge them' do
42
+ expect(client2).to receive(:delete)
43
+ result = subject.class.call(params)[:results]
44
+ expect(result).to eq [{ client_id: 'client_id', project: '123456789', status: 'ok - not purged' }, { client_id: 'delete', project: nil, status: 'purged' }]
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,54 @@
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_etls_in_segment'
9
+
10
+ describe GoodData::LCM2::RenameExistingClientProjects do
11
+ let(:gdc_gd_client) { double('gdc_gd_client') }
12
+ let(:domain) { double('domain') }
13
+ let(:client) { double('client') }
14
+ let(:project) { double('project') }
15
+
16
+ context 'client project is existing in input source' do
17
+ let(:params) do
18
+ params = {
19
+ gdc_gd_client: gdc_gd_client,
20
+ organization: domain,
21
+ clients: [
22
+ {
23
+ id: 'Id',
24
+ settings: [
25
+ {
26
+ name: 'lcm.title',
27
+ value: 'renamed project'
28
+ }
29
+ ]
30
+ }
31
+ ],
32
+ client_projects: {
33
+ 'Id' => { segment_client: client, project: project }
34
+ }
35
+ }
36
+ GoodData::LCM2.convert_to_smart_hash(params)
37
+ end
38
+
39
+ before do
40
+ allow(gdc_gd_client).to receive(:domain) { domain }
41
+ allow(client).to receive(:project) { project }
42
+ allow(project).to receive(:pid) { '123456789' }
43
+ allow(project).to receive(:title) { "old project" }
44
+ allow(project).to receive(:title=)
45
+ allow(project).to receive(:save)
46
+ end
47
+
48
+ it 'rename client project title' do
49
+ expect(project).to receive(:title=).with('renamed project')
50
+ result = subject.class.call(params)
51
+ expect(result).to eq [{ id: 'Id', pid: '123456789', old_title: 'old project', new_title: 'renamed project' }]
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,46 @@
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/actions/segments_filter'
8
+ require 'gooddata/lcm/lcm2'
9
+
10
+ describe GoodData::LCM2::SegmentsFilter do
11
+ context 'when segments contains duplicate segment ids' do
12
+ let(:params) do
13
+ params = {
14
+ segments: [
15
+ { segment_id: 'segment_foo' },
16
+ { segment_id: 'Segment_foo' }
17
+ ]
18
+ }
19
+ GoodData::LCM2.convert_to_smart_hash(params)
20
+ end
21
+
22
+ it 'raise error' do
23
+ expect { subject.class.call(params) }.to raise_error(/segment_foo/, /Segment_foo/)
24
+ end
25
+ end
26
+
27
+ context 'when passed segments' do
28
+ let(:params) do
29
+ params = {
30
+ segments: [
31
+ { segment_id: 'correct-segment' },
32
+ { segment_id: 'wrong-segment' }
33
+ ],
34
+ segments_filter: [
35
+ 'correct-segment'
36
+ ]
37
+ }
38
+ GoodData::LCM2.convert_to_smart_hash(params)
39
+ end
40
+
41
+ it 'filters the segments according to segments_filter' do
42
+ results = subject.class.call(params)
43
+ expect(results[:results].first.segment_id).to eq 'correct-segment'
44
+ end
45
+ end
46
+ end