gooddata 0.6.53 → 0.6.54

Sign up to get free protection for your applications and to get access to all the features.
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,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/actions/associate_clients'
8
+ require 'gooddata/lcm/lcm2'
9
+
10
+ describe GoodData::LCM2::AssociateClients do
11
+ DATA_PRODUCT_ID = 'data-product-id'
12
+
13
+ let(:gdc_gd_client) { double(:gdc_gd_client) }
14
+ let(:segment) { double(:segment) }
15
+ let(:domain) { double(:domain) }
16
+ let(:client) { double(:client) }
17
+ let(:data_product) { double(:data_product) }
18
+
19
+ before do
20
+ allow(gdc_gd_client).to receive(:domain) { domain }
21
+ allow(domain).to receive(:update_clients_settings)
22
+ allow(domain).to receive(:segments) { segment }
23
+ allow(domain).to receive(:update_clients) {}
24
+ allow(segment).to receive(:clients) { [client] }
25
+ allow(client).to receive(:id) { 'an-id' }
26
+ allow(segment).to receive(:create_client) { client }
27
+ allow(segment).to receive(:data_product) { data_product }
28
+ allow(data_product).to receive(:data_product_id) { DATA_PRODUCT_ID }
29
+ end
30
+
31
+ context 'when clients parameter is passed' do
32
+ let(:params) do
33
+ params = {
34
+ gdc_gd_client: gdc_gd_client,
35
+ clients: [
36
+ { segment: segment }
37
+ ]
38
+ }
39
+ GoodData::LCM2.convert_to_smart_hash(params)
40
+ end
41
+
42
+ it 'enriches the clients with data_product_id' do
43
+ subject.class.call(params)
44
+ expect(params.clients.first.data_product_id).to eq(DATA_PRODUCT_ID)
45
+ end
46
+ end
47
+ 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/collect_client_projects'
9
+
10
+ describe GoodData::LCM2::CollectClientProjects do
11
+ let(:gdc_gd_client) { double('gdc_gd_client') }
12
+ let(:domain) { double('domain') }
13
+ let(:segment) { double('segment') }
14
+ let(:client) { double('client') }
15
+ let(:project) { double('project') }
16
+
17
+ context 'some clients are existing in segment' do
18
+ let(:params) do
19
+ params = {
20
+ gdc_gd_client: gdc_gd_client,
21
+ organization: domain,
22
+ segments: [
23
+ {
24
+ segment_id: 'id'
25
+ }
26
+ ]
27
+ }
28
+ GoodData::LCM2.convert_to_smart_hash(params)
29
+ end
30
+
31
+ before do
32
+ allow(gdc_gd_client).to receive(:domain) { domain }
33
+ allow(domain).to receive(:segments) { [segment] }
34
+ allow(segment).to receive(:segment_id) { 'id' }
35
+ allow(segment).to receive(:clients) { [client] }
36
+ allow(client).to receive(:project) { project }
37
+ allow(client).to receive(:client_id) { 'client_id' }
38
+ allow(project).to receive(:pid) { '123456789' }
39
+ end
40
+
41
+ it 'collect their projects' do
42
+ result = subject.class.call(params)
43
+ expect(result[:params][:client_projects]).to eq('client_id' => { segment_client: client, project: project })
44
+ expect(result[:results]).to eq [{ client_id: 'client_id', project: '123456789' }]
45
+ end
46
+ end
47
+ end
@@ -10,8 +10,13 @@ require 'gooddata/lcm/lcm2'
10
10
  describe GoodData::LCM2::CollectClients do
11
11
  let(:data_source) { double(:data_source) }
12
12
  let(:input_data) { double(:input_data) }
13
+ let(:gdc_gd_client) { double(:gdc_gd_client) }
14
+ let(:datasource) { double(:datasource) }
15
+ let(:project) { double(:project) }
13
16
 
14
17
  before do
18
+ allow(project).to receive(:deleted?).and_return(false)
19
+ allow(gdc_gd_client).to receive(:projects).and_return(project)
15
20
  allow(GoodData::Helpers::DataSource).to receive(:new)
16
21
  .and_return(data_source)
17
22
  allow(data_source).to receive(:realize)
@@ -21,6 +26,7 @@ describe GoodData::LCM2::CollectClients do
21
26
  context 'when segments is specified' do
22
27
  let(:params) do
23
28
  params = {
29
+ gdc_gd_client: gdc_gd_client,
24
30
  segments: [{ segment_id: 'segment_foo' }],
25
31
  input_source: {}
26
32
  }
@@ -35,4 +41,25 @@ describe GoodData::LCM2::CollectClients do
35
41
  expect(result[:results]).to eq(expected)
36
42
  end
37
43
  end
44
+
45
+ context 'when input source contains deleted project' do
46
+ let(:params) do
47
+ params = {
48
+ gdc_gd_client: gdc_gd_client,
49
+ segments: [{ segment_id: 'segment_foo' }],
50
+ input_source: {}
51
+ }
52
+ GoodData::LCM2.convert_to_smart_hash(params)
53
+ end
54
+
55
+ before do
56
+ allow(project).to receive(:deleted?).and_return(true)
57
+ end
58
+
59
+ it 'raise error' do
60
+ expect do
61
+ subject.class.call(params)
62
+ end.to raise_error(/Project 123456 of client client_foo is deleted./)
63
+ end
64
+ end
38
65
  end
@@ -0,0 +1,64 @@
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
+ describe GoodData::LCM2::CollectDataProduct do
8
+ it 'Has GoodData::Bricks::DefaultDataProductMiddleware class' do
9
+ GoodData::LCM2::CollectDataProduct.should_not be(nil)
10
+ end
11
+
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
+ before do
18
+ allow(client).to receive(:domain) { domain }
19
+ allow(gdc_logger).to receive(:info) {}
20
+ end
21
+
22
+ context 'when data_product parameter is passed' do
23
+ let(:params) do
24
+ params = {
25
+ gdc_gd_client: client,
26
+ gdc_logger: gdc_logger,
27
+ data_product: "data-product-#{SecureRandom.uuid}"
28
+ }
29
+ GoodData::LCM2.convert_to_smart_hash(params)
30
+ end
31
+
32
+ before do
33
+ allow(domain).to receive(:data_products) { data_product }
34
+ end
35
+
36
+ it 'hydrates the data_product object into params and runs the app' do
37
+ result = subject.class.call(params)
38
+ expect(result[:params][:data_product]).to be_a GoodData::DataProduct
39
+ end
40
+ end
41
+
42
+ context 'when no data_product parameter is passed' do
43
+ let(:params) do
44
+ params = {
45
+ gdc_gd_client: client,
46
+ gdc_logger: gdc_logger
47
+ }
48
+ GoodData::LCM2.convert_to_smart_hash(params)
49
+ end
50
+
51
+ it 'fallbacks to the only data_product if only one exists in the domain' do
52
+ allow(domain).to receive(:data_products) { [data_product] }
53
+
54
+ result = subject.class.call(params)
55
+ expect(result[:params][:data_product]).to be_a GoodData::DataProduct
56
+ end
57
+
58
+ it 'fails when multiple data_products are available to fallback on' do
59
+ allow(domain).to receive(:data_products) { [data_product, GoodData::DataProduct.new({})] }
60
+
61
+ expect { subject.class.call(params) }.to raise_error
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,56 @@
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/collect_dynamic_schedule_params'
8
+ require 'gooddata/lcm/lcm2'
9
+
10
+ describe GoodData::LCM2::CollectDymanicScheduleParams do
11
+ let(:data_source) { double(:data_source) }
12
+
13
+ before do
14
+ allow(GoodData::Helpers::DataSource).to receive(:new).and_return(data_source)
15
+ allow(data_source).to receive(:realize).and_return('spec/data/dynamic_schedule_params_table.csv')
16
+ end
17
+
18
+ context 'when dynamic schedule params are passed' do
19
+ let(:params) do
20
+ params = {
21
+ dynamic_params: {
22
+ input_source: {}
23
+ }
24
+ }
25
+ GoodData::LCM2.convert_to_smart_hash(params)
26
+ end
27
+
28
+ it 'collects them' do
29
+ result = subject.class.call(params)
30
+ expected = {
31
+ 'client_1' => {
32
+ 'rollout' => {
33
+ 'MODE' => 'mode_a'
34
+ },
35
+ all_schedules: {
36
+ 'MODE' => 'mode_x'
37
+ },
38
+ 'release' => {
39
+ 'MODE' => 'mode_c'
40
+ }
41
+ },
42
+ 'client_2' => {
43
+ 'provisioning' => {
44
+ 'MODE' => 'mode_b'
45
+ }
46
+ },
47
+ all_clients: {
48
+ all_schedules: {
49
+ 'MODE' => 'mode_all'
50
+ }
51
+ }
52
+ }
53
+ expect(result[:params][:schedule_params]).to eq(expected)
54
+ end
55
+ end
56
+ end
@@ -36,7 +36,7 @@ describe GoodData::LCM2::CollectMeta do
36
36
  params = {
37
37
  development_client: development_client,
38
38
  synchronize: [{ from: 'project_id' }],
39
- production_tag: 'production_tag'
39
+ production_tags: 'production_tag'
40
40
  }
41
41
  GoodData::LCM2.convert_to_smart_hash(params)
42
42
  end
@@ -54,7 +54,7 @@ describe GoodData::LCM2::CollectMeta do
54
54
  params = {
55
55
  development_client: development_client,
56
56
  synchronize: [{ from: 'project_id' }],
57
- segments: [{ production_tag: 'segment_production_tag' }, {}]
57
+ segments: [{ production_tags: 'segment_production_tag' }, {}]
58
58
  }
59
59
  GoodData::LCM2.convert_to_smart_hash(params)
60
60
  end
@@ -72,8 +72,8 @@ describe GoodData::LCM2::CollectMeta do
72
72
  params = {
73
73
  development_client: development_client,
74
74
  synchronize: [{ from: 'project_id' }],
75
- segments: [{ production_tag: 'segment_production_tag' }, {}],
76
- production_tag: 'production_tag'
75
+ segments: [{ production_tags: 'segment_production_tag' }, {}],
76
+ production_tags: 'production_tag'
77
77
  }
78
78
  GoodData::LCM2.convert_to_smart_hash(params)
79
79
  end
@@ -15,6 +15,12 @@ describe GoodData::LCM2::CollectSegmentClients do
15
15
  let(:client) { double('client') }
16
16
  let(:clients) { [client] }
17
17
 
18
+ before do
19
+ allow(gdc_gd_client).to receive(:domain).and_return(domain)
20
+ allow(domain).to receive(:segments).and_return(segments)
21
+ allow(segment).to receive(:clients).and_return(clients)
22
+ end
23
+
18
24
  context 'when client has no project in segments' do
19
25
  let(:params) do
20
26
  params = {
@@ -26,9 +32,6 @@ describe GoodData::LCM2::CollectSegmentClients do
26
32
  end
27
33
 
28
34
  before do
29
- allow(gdc_gd_client).to receive(:domain).and_return(domain)
30
- allow(domain).to receive(:segments).and_return(segments)
31
- allow(segment).to receive(:clients).and_return(clients)
32
35
  allow(client).to receive(:project?).and_return(false)
33
36
  allow(client).to receive(:client_id).and_return('my_client_id')
34
37
  end
@@ -37,4 +40,42 @@ describe GoodData::LCM2::CollectSegmentClients do
37
40
  expect { subject.class.call(params) }.to raise_error
38
41
  end
39
42
  end
43
+
44
+ context 'when client has project in segments' do
45
+ let(:segment) { double('segment') }
46
+ let(:project) { double('project') }
47
+ let(:ads_client) { double('ads_client') }
48
+ let(:ads_response) do
49
+ [
50
+ {
51
+ master_project_id: 'master_project_id'
52
+ }
53
+ ]
54
+ end
55
+ let(:params) do
56
+ params = {
57
+ gdc_gd_client: gdc_gd_client,
58
+ synchronize: [{}],
59
+ segments: [segment],
60
+ ads_client: ads_client
61
+ }
62
+ GoodData::LCM2.convert_to_smart_hash(params)
63
+ end
64
+
65
+ before do
66
+ allow(client).to receive(:project).and_return(project)
67
+ allow(client).to receive(:project?).and_return(true)
68
+ allow(gdc_gd_client).to receive(:projects).with('master_project_id').and_return(project)
69
+ allow(client).to receive(:client_id).and_return('client_id')
70
+ allow(segment).to receive(:segment_id).and_return('segment-id')
71
+ allow(ads_client).to receive(:execute_select).and_return(ads_response)
72
+ allow(project).to receive(:pid)
73
+ allow(project).to receive(:title)
74
+ end
75
+
76
+ it 'uses the project from client in segments' do
77
+ expect(client).to receive(:project)
78
+ subject.class.call(params)
79
+ end
80
+ end
40
81
  end
@@ -71,7 +71,7 @@ describe GoodData::LCM2::CollectTaggedObjects do
71
71
  params = {
72
72
  development_client: development_client,
73
73
  synchronize: [{ from: 'some_development_project_id' }],
74
- segments: [{ production_tag: 'production_tag' }, {}]
74
+ segments: [{ production_tags: 'production_tag' }, {}]
75
75
  }
76
76
  GoodData::LCM2.convert_to_smart_hash(params)
77
77
  end
@@ -85,7 +85,7 @@ describe GoodData::LCM2::CollectTaggedObjects do
85
85
  development_client: development_client,
86
86
  synchronize: [{ from: 'some_development_project_id' }],
87
87
  segments: [{}],
88
- production_tag: 'production_tag'
88
+ production_tags: 'production_tag'
89
89
  }
90
90
  GoodData::LCM2.convert_to_smart_hash(params)
91
91
  end
@@ -98,13 +98,29 @@ describe GoodData::LCM2::CollectTaggedObjects do
98
98
  params = {
99
99
  development_client: development_client,
100
100
  synchronize: [{ from: 'some_development_project_id' }],
101
- segments: [{ production_tag: 'production_tag' }, {}],
102
- production_tag: 'global_production_tag'
101
+ segments: [{ production_tags: 'production_tag' }, {}],
102
+ production_tags: 'global_production_tag'
103
103
  }
104
104
  GoodData::LCM2.convert_to_smart_hash(params)
105
105
  end
106
106
 
107
107
  it_behaves_like 'a tagged object collector'
108
108
  end
109
+
110
+ context 'when using multi tags' do
111
+ let(:params) do
112
+ params = {
113
+ development_client: development_client,
114
+ synchronize: [{ from: 'some_development_project_id' }],
115
+ segments: [{ production_tags: %w(production_tag prod_tag2) }, {}]
116
+ }
117
+ GoodData::LCM2.convert_to_smart_hash(params)
118
+ end
119
+
120
+ it 'finds projects by the specified tags' do
121
+ expect(development_project).to receive(:find_by_tag).with(%w(production_tag prod_tag2))
122
+ subject.class.call(params)
123
+ end
124
+ end
109
125
  end
110
126
  end
@@ -0,0 +1,64 @@
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/collect_segment_clients'
8
+ require 'gooddata/lcm/lcm2'
9
+
10
+ describe GoodData::LCM2::CreateSegmentMasters do
11
+ let(:gdc_gd_client) { double('gdc_gd_client') }
12
+ let(:ads_client) { double('ads_client') }
13
+ let(:development_client) { double('development_client') }
14
+ let(:gdc_logger) { double('gdc_logger') }
15
+ let(:project) { double('project') }
16
+ let(:domain) { double('domain') }
17
+ let(:segment) { double('segment') }
18
+ let(:segments) { [segment] }
19
+ let(:data_product) { double('data_product') }
20
+
21
+ context 'when parametrizing project environment' do
22
+ let(:params) do
23
+ params = {
24
+ gdc_gd_client: gdc_gd_client,
25
+ synchronize: [{}],
26
+ segments: [{ segment_id: 'segment_foo', driver: 'Pg', master_name: 'name' }],
27
+ tokens: { pg: 'pgtoken' },
28
+ ads_client: ads_client,
29
+ development_client: development_client,
30
+ gdc_logger: gdc_logger,
31
+ project_environment: 'DEVELOPMENT',
32
+ data_product: data_product
33
+ }
34
+ GoodData::LCM2.convert_to_smart_hash(params)
35
+ end
36
+
37
+ before do
38
+ allow(ads_client).to receive(:execute_select) { [{ version: '1.2' }] }
39
+ allow(development_client).to receive(:projects) { true }
40
+ allow(gdc_logger).to receive(:info) {}
41
+ allow(gdc_gd_client).to receive(:create_project) { project }
42
+ allow(gdc_gd_client).to receive(:domain) { domain }
43
+ allow(project).to receive(:pid) { '123' }
44
+ allow(project).to receive(:json) { {} }
45
+ allow(domain).to receive(:segments) { [] }
46
+ allow(domain).to receive(:create_segment) {}
47
+ allow(segment).to receive(:master_project) {}
48
+ allow(segment).to receive(:master_project=) {}
49
+ allow(segment).to receive(:save) {}
50
+ allow(segment).to receive(:synchronize_clients) {}
51
+ allow(data_product).to receive(:create_segment) { segment }
52
+ end
53
+
54
+ it 'passes the argument to create_project' do
55
+ expect(gdc_gd_client).to receive(:create_project).with(
56
+ title: 'name',
57
+ auth_token: 'pgtoken',
58
+ driver: 'Pg',
59
+ environment: 'DEVELOPMENT'
60
+ )
61
+ subject.class.call(params)
62
+ end
63
+ end
64
+ end