gooddata 1.0.2-java → 1.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/CONTRIBUTING.md +12 -0
  4. data/README.md +5 -2
  5. data/Rakefile +0 -1
  6. data/dev-gooddata-sso.pub.encrypted +40 -0
  7. data/gooddata.gemspec +3 -3
  8. data/lib/gooddata/connection.rb +23 -13
  9. data/lib/gooddata/helpers/data_helper.rb +0 -1
  10. data/lib/gooddata/lcm/actions/apply_custom_maql.rb +8 -1
  11. data/lib/gooddata/lcm/actions/associate_clients.rb +8 -1
  12. data/lib/gooddata/lcm/actions/base_action.rb +10 -0
  13. data/lib/gooddata/lcm/actions/collect_ca_metrics.rb +7 -1
  14. data/lib/gooddata/lcm/actions/collect_client_projects.rb +3 -0
  15. data/lib/gooddata/lcm/actions/collect_clients.rb +3 -1
  16. data/lib/gooddata/lcm/actions/collect_data_product.rb +10 -2
  17. data/lib/gooddata/lcm/actions/collect_dynamic_schedule_params.rb +12 -1
  18. data/lib/gooddata/lcm/actions/collect_ldm_objects.rb +6 -2
  19. data/lib/gooddata/lcm/actions/collect_meta.rb +1 -1
  20. data/lib/gooddata/lcm/actions/collect_segment_clients.rb +8 -1
  21. data/lib/gooddata/lcm/actions/collect_segments.rb +6 -5
  22. data/lib/gooddata/lcm/actions/collect_tagged_objects.rb +1 -1
  23. data/lib/gooddata/lcm/actions/collect_users_brick_users.rb +10 -4
  24. data/lib/gooddata/lcm/actions/create_segment_masters.rb +12 -2
  25. data/lib/gooddata/lcm/actions/ensure_data_product.rb +10 -0
  26. data/lib/gooddata/lcm/actions/ensure_technical_users_domain.rb +5 -1
  27. data/lib/gooddata/lcm/actions/ensure_technical_users_project.rb +3 -0
  28. data/lib/gooddata/lcm/actions/execute_schedules.rb +10 -0
  29. data/lib/gooddata/lcm/actions/import_object_collections.rb +1 -1
  30. data/lib/gooddata/lcm/actions/provision_clients.rb +12 -2
  31. data/lib/gooddata/lcm/actions/purge_clients.rb +2 -0
  32. data/lib/gooddata/lcm/actions/rename_existing_client_projects.rb +3 -0
  33. data/lib/gooddata/lcm/actions/synchronize_attribute_drillpaths.rb +4 -1
  34. data/lib/gooddata/lcm/actions/synchronize_cas.rb +7 -1
  35. data/lib/gooddata/lcm/actions/synchronize_clients.rb +11 -1
  36. data/lib/gooddata/lcm/actions/synchronize_color_palette.rb +7 -1
  37. data/lib/gooddata/lcm/actions/synchronize_etls_in_segment.rb +12 -7
  38. data/lib/gooddata/lcm/actions/synchronize_label_types.rb +4 -1
  39. data/lib/gooddata/lcm/actions/synchronize_ldm.rb +18 -7
  40. data/lib/gooddata/lcm/actions/synchronize_meta.rb +9 -0
  41. data/lib/gooddata/lcm/actions/synchronize_new_segments.rb +11 -1
  42. data/lib/gooddata/lcm/actions/synchronize_processes.rb +7 -1
  43. data/lib/gooddata/lcm/actions/synchronize_schedules.rb +4 -1
  44. data/lib/gooddata/lcm/actions/synchronize_tag_objects.rb +6 -0
  45. data/lib/gooddata/lcm/actions/synchronize_user_filters.rb +60 -15
  46. data/lib/gooddata/lcm/actions/synchronize_user_groups.rb +7 -1
  47. data/lib/gooddata/lcm/actions/synchronize_users.rb +106 -3
  48. data/lib/gooddata/lcm/actions/update_release_table.rb +19 -0
  49. data/lib/gooddata/lcm/helpers/check_helper.rb +21 -6
  50. data/lib/gooddata/lcm/lcm2.rb +35 -22
  51. data/lib/gooddata/lcm/types/class/gd_logger.rb +23 -0
  52. data/lib/gooddata/lcm/types/class/gd_product.rb +23 -0
  53. data/lib/gooddata/lcm/types/class/gd_project.rb +23 -0
  54. data/lib/gooddata/lcm/types/class/smart_hash.rb +23 -0
  55. data/lib/gooddata/lcm/types/complex/segment.rb +1 -1
  56. data/lib/gooddata/lcm/types/scalar/integer.rb +2 -2
  57. data/lib/gooddata/lcm/types/special/any.rb +18 -0
  58. data/lib/gooddata/models/blueprint/dataset_blueprint.rb +1 -1
  59. data/lib/gooddata/models/blueprint/to_manifest.rb +1 -3
  60. data/lib/gooddata/models/blueprint/to_wire.rb +2 -1
  61. data/lib/gooddata/models/from_wire.rb +13 -1
  62. data/lib/gooddata/models/metadata/folder.rb +22 -0
  63. data/lib/gooddata/models/metadata/metric.rb +5 -8
  64. data/lib/gooddata/models/model.rb +1 -1
  65. data/lib/gooddata/models/process.rb +42 -32
  66. data/lib/gooddata/models/project.rb +19 -36
  67. data/lib/gooddata/models/project_creator.rb +3 -1
  68. data/lib/gooddata/models/project_role.rb +3 -4
  69. data/lib/gooddata/models/schedule.rb +0 -2
  70. data/lib/gooddata/models/user_filters/mandatory_user_filter.rb +9 -1
  71. data/lib/gooddata/models/user_filters/user_filter.rb +1 -2
  72. data/lib/gooddata/models/user_filters/user_filter_builder.rb +18 -6
  73. data/lib/gooddata/rest/client.rb +1 -2
  74. data/lib/gooddata/rest/connection.rb +12 -46
  75. data/lib/gooddata/rest/phmap.rb +101 -56
  76. data/lib/gooddata/version.rb +1 -1
  77. data/rubydev_public.gpg.encrypted +51 -0
  78. data/rubydev_secret_keys.gpg.encrypted +109 -0
  79. data/spec/data/user_filters.csv +2 -0
  80. data/spec/environment/default.rb +2 -2
  81. data/spec/environment/development.rb +1 -1
  82. data/spec/environment/staging.rb +2 -3
  83. data/spec/environment/testing.rb +4 -4
  84. data/spec/integration/connection_spec.rb +37 -0
  85. data/spec/integration/core/connection_spec.rb +1 -1
  86. data/spec/integration/core/logging_spec.rb +8 -6
  87. data/spec/integration/core/project_spec.rb +1 -1
  88. data/spec/integration/mandatory_user_filter_spec.rb +53 -0
  89. data/spec/integration/mixins/id_to_uri_spec.rb +17 -5
  90. data/spec/integration/models/label_spec.rb +9 -0
  91. data/spec/integration/models/metric_spec.rb +24 -0
  92. data/spec/integration/models/process_spec.rb +35 -0
  93. data/spec/integration/models/project_role_spec.rb +1 -1
  94. data/spec/integration/models/schedule_spec.rb +0 -8
  95. data/spec/integration/schedule_spec.rb +4 -6
  96. data/spec/integration/user_filters_spec.rb +20 -16
  97. data/spec/integration/user_group_spec.rb +1 -1
  98. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/can_assign_a_custom_logger.yml +2287 -0
  99. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/client_logs_when_given_custom_message.yml +2287 -0
  100. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/has_the_request_id_logged_when_I_passed_it.yml +2287 -0
  101. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logging_off/Disables_logging.yml +2287 -0
  102. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logging_on/Enables_logging.yml +2287 -0
  103. data/spec/integration/vcr_cassettes/GoodData_-_project/_project/Returns_project_assigned.yml +354 -0
  104. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_nil.yml +299 -0
  105. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_directly.yml +354 -0
  106. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_using_project_ID.yml +354 -0
  107. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_using_project_URL.yml +354 -0
  108. data/spec/integration/vcr_cassettes/GoodData_-_project/_with_project/Uses_project_specified.yml +354 -0
  109. data/spec/integration/vcr_cassettes/GoodData_Metric/all.yml +2065 -0
  110. data/spec/integration/vcr_cassettes/GoodData_Metric/should_be_able_to_update_folders.yml +119 -0
  111. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/all.yml +9812 -0
  112. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_get_json_containing_correct_id.yml +174 -0
  113. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_return_nil_for_unknown_id.yml +58 -0
  114. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_throw_BadRequest_for_-1.yml +63 -0
  115. data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_connect/Connects_using_username_and_password.yml +299 -0
  116. data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_disconnect/Connects_using_username_and_password.yml +299 -0
  117. data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_generate_request_id/Generates_a_non-empty_string.yml +2287 -0
  118. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_/Should_list_user_groups_as_Array.yml +56 -0
  119. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_add_members/Should_add_member.yml +315 -0
  120. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_members/Should_return_members_as_array.yml +54 -0
  121. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_remove_members/Should_remove_existing_members.yml +258 -0
  122. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_save/updates_existing_group.yml +159 -0
  123. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_set_members/Should_set_new_members.yml +158 -0
  124. data/spec/integration/vcr_cassettes/GoodData_UserGroup/all.yml +809 -0
  125. data/spec/spec_helper.rb +46 -2
  126. data/spec/unit/actions/associate_clients_spec.rb +2 -1
  127. data/spec/unit/actions/collect_data_product_spec.rb +3 -1
  128. data/spec/unit/actions/collect_segment_clients_spec.rb +1 -0
  129. data/spec/unit/actions/create_segment_masters_spec.rb +1 -0
  130. data/spec/unit/actions/ensure_data_product_spec.rb +1 -0
  131. data/spec/unit/actions/ensure_technical_users_domain_spec.rb +2 -0
  132. data/spec/unit/actions/ensure_technical_users_project_spec.rb +4 -0
  133. data/spec/unit/actions/provision_clients_spec.rb +2 -1
  134. data/spec/unit/actions/synchronize_etls_in_segment_spec.rb +0 -6
  135. data/spec/unit/actions/synchronize_ldm_spec.rb +20 -7
  136. data/spec/unit/actions/synchronize_user_filters_spec.rb +21 -0
  137. data/spec/unit/helpers/check_helper_production_spec.rb +34 -0
  138. data/spec/unit/helpers/check_helper_spec.rb +97 -9
  139. data/spec/unit/lcm/lcm2_spec.rb +67 -3
  140. data/spec/unit/models/blueprint/to_wire_spec.rb +1 -0
  141. data/spec/unit/models/dataset_blueprint.rb +14 -0
  142. data/spec/unit/models/from_wire_spec.rb +20 -0
  143. data/spec/unit/models/model_spec.rb +10 -0
  144. data/spec/unit/models/to_manifest_spec.rb +29 -0
  145. data/spec/unit/models/user_filters/user_filter_builder_spec.rb +44 -6
  146. data/spec/unit/rest/phmap_spec.rb +117 -0
  147. data/spec/vcr_configurer.rb +63 -0
  148. metadata +283 -24
  149. data/lib/gooddata/lcm/actions/ensure_segments.rb +0 -32
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  # Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
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
+ #
7
+ ENV['RSPEC_ENV'] = 'test'
6
8
 
7
9
  require 'simplecov'
8
10
  # for simplecov to work correctly, it has to be started before any other code
@@ -26,12 +28,13 @@ require 'pathname'
26
28
  require 'webmock/rspec'
27
29
  require 'gooddata'
28
30
 
31
+ vcr_enabled = !ENV['VCR_ON'] || ENV['VCR_ON'] == 'true' # VCR is enabled by default - set VCR_ON=false to disable
32
+ require 'vcr_configurer' if vcr_enabled
33
+
29
34
  logger = Logger.new(STDOUT)
30
35
  logger.level = Logger::WARN
31
36
  GoodData.logger = logger
32
37
 
33
- WebMock.disable!
34
-
35
38
  # Automagically include all helpers/*_helper.rb
36
39
 
37
40
  require_relative 'environment/environment'
@@ -63,4 +66,45 @@ RSpec.configure do |config|
63
66
  config.filter_run_excluding :broken => true
64
67
 
65
68
  config.fail_fast = false
69
+
70
+ if vcr_enabled
71
+ config.before(:all) do
72
+ # in case the test uses VCR
73
+ if self.class.metadata[:vcr]
74
+ # replace parallel iterations with the serial one, since VCR can't handle parallel request matching correctly
75
+ module Enumerable
76
+ def peach_with_index(*)
77
+ each_with_index
78
+ end
79
+ end
80
+
81
+ # insert the cassete recording everything what happens outside the tests cases
82
+ VCR.insert_cassette("#{self.class.metadata[:description]}/all")
83
+
84
+ # avoid polling idle time by overriding sleep
85
+ module Kernel
86
+ alias :old_sleep :sleep
87
+ def sleep(n)
88
+ n
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ config.after(:all) do
95
+ # in case the test uses VCR
96
+ if self.class.metadata[:vcr]
97
+ # eject the cassete recording everything what happens outside the tests cases
98
+ VCR.eject_cassette
99
+
100
+ # reload the original parallel iterations
101
+ load('pmap.rb') if self.class.metadata[:vcr]
102
+
103
+ # reload sleep method
104
+ module Kernel
105
+ alias :sleep :old_sleep
106
+ end
107
+ end
108
+ end
109
+ end
66
110
  end
@@ -34,7 +34,8 @@ describe GoodData::LCM2::AssociateClients do
34
34
  gdc_gd_client: gdc_gd_client,
35
35
  clients: [
36
36
  { segment: segment }
37
- ]
37
+ ],
38
+ domain: domain
38
39
  }
39
40
  GoodData::LCM2.convert_to_smart_hash(params)
40
41
  end
@@ -24,6 +24,7 @@ describe GoodData::LCM2::CollectDataProduct do
24
24
  let(:data_product_id) { 'data-product' }
25
25
  let(:params) do
26
26
  params = {
27
+ domain: domain,
27
28
  gdc_gd_client: client,
28
29
  gdc_logger: gdc_logger,
29
30
  data_product: data_product_id
@@ -42,7 +43,8 @@ describe GoodData::LCM2::CollectDataProduct do
42
43
  let(:params) do
43
44
  params = {
44
45
  gdc_gd_client: client,
45
- gdc_logger: gdc_logger
46
+ gdc_logger: gdc_logger,
47
+ domain: domain
46
48
  }
47
49
  GoodData::LCM2.convert_to_smart_hash(params)
48
50
  end
@@ -57,6 +57,7 @@ describe GoodData::LCM2::CollectSegmentClients do
57
57
  gdc_gd_client: gdc_gd_client,
58
58
  synchronize: [{}],
59
59
  segments: [segment],
60
+ domain: domain,
60
61
  ads_client: ads_client
61
62
  }
62
63
  GoodData::LCM2.convert_to_smart_hash(params)
@@ -26,6 +26,7 @@ describe GoodData::LCM2::CreateSegmentMasters do
26
26
  segments: [{ segment_id: 'segment_foo', driver: 'Pg', master_name: 'name' }],
27
27
  tokens: { pg: 'pgtoken' },
28
28
  ads_client: ads_client,
29
+ domain: domain,
29
30
  development_client: development_client,
30
31
  gdc_logger: gdc_logger,
31
32
  project_environment: 'DEVELOPMENT',
@@ -18,6 +18,7 @@ describe GoodData::LCM2::EnsureDataProduct do
18
18
  params = {
19
19
  data_product: "data-product-#{SecureRandom.uuid}",
20
20
  gdc_gd_client: client,
21
+ domain: domain,
21
22
  gdc_logger: gdc_logger
22
23
  }
23
24
  GoodData::LCM2.convert_to_smart_hash(params)
@@ -31,6 +31,7 @@ describe GoodData::LCM2::EnsureTechnicalUsersDomain do
31
31
  let(:params) do
32
32
  params = {
33
33
  gdc_gd_client: gdc_gd_client,
34
+ domain: domain,
34
35
  technical_user: ['foo@bar.com']
35
36
  }
36
37
  GoodData::LCM2.convert_to_smart_hash(params)
@@ -42,6 +43,7 @@ describe GoodData::LCM2::EnsureTechnicalUsersDomain do
42
43
  let(:params) do
43
44
  params = {
44
45
  gdc_gd_client: gdc_gd_client,
46
+ domain: domain,
45
47
  technical_users: ['foo@bar.com']
46
48
  }
47
49
  GoodData::LCM2.convert_to_smart_hash(params)
@@ -25,6 +25,7 @@ end
25
25
  describe GoodData::LCM2::EnsureTechnicalUsersProject do
26
26
  let(:gdc_gd_client) { double(:gdc_gd_client) }
27
27
  let(:project) { double(:project) }
28
+ let(:domain) { double(:domain) }
28
29
  before do
29
30
  allow(project).to receive(:title) { 'foo project' }
30
31
  allow(project).to receive(:pid) { 'abcdefg' }
@@ -38,6 +39,7 @@ describe GoodData::LCM2::EnsureTechnicalUsersProject do
38
39
  gdc_gd_client: gdc_gd_client,
39
40
  technical_users: ['foo@bar.com'],
40
41
  synchronize: [],
42
+ domain: domain,
41
43
  clients: [{ project: 'abcdefg' }]
42
44
  }
43
45
  GoodData::LCM2.convert_to_smart_hash(params)
@@ -51,6 +53,7 @@ describe GoodData::LCM2::EnsureTechnicalUsersProject do
51
53
  params = {
52
54
  gdc_gd_client: gdc_gd_client,
53
55
  technical_user: ['foo@bar.com'],
56
+ domain: domain,
54
57
  synchronize: [{ to: [{ pid: 'qux' }] }]
55
58
  }
56
59
  GoodData::LCM2.convert_to_smart_hash(params)
@@ -62,6 +65,7 @@ describe GoodData::LCM2::EnsureTechnicalUsersProject do
62
65
  let(:params) do
63
66
  params = {
64
67
  gdc_gd_client: gdc_gd_client,
68
+ domain: domain,
65
69
  technical_users: ['foo@bar.com'],
66
70
  synchronize: [{ to: [{ pid: 'qux' }] }]
67
71
  }
@@ -32,12 +32,13 @@ describe GoodData::LCM2::ProvisionClients do
32
32
  segments: [
33
33
  segment
34
34
  ],
35
+ domain: domain,
35
36
  data_product: data_product
36
37
  }
37
38
  GoodData::LCM2.convert_to_smart_hash(params)
38
39
  end
39
40
 
40
- it 'clean all zombie clients ' do
41
+ it 'clean all zombie clients' do
41
42
  expect(GoodData::LCM2::PurgeClients).to receive(:call).and_return(results: [], params: { client_projects: [] })
42
43
  expect { subject.class.call(params) }.to raise_error('limit reached')
43
44
  end
@@ -125,9 +125,7 @@ describe GoodData::LCM2::SynchronizeETLsInSegment do
125
125
  end
126
126
 
127
127
  it 'each schedules must have different parameters' do
128
- schedule1.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
129
128
  schedule1.should_receive(:update_params).once.ordered.with('HELLO' => 'hi')
130
- schedule2.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
131
129
  schedule2.should_receive(:update_params).once.ordered.with('BYE' => 'bye')
132
130
  subject.class.call(params)
133
131
  end
@@ -161,9 +159,7 @@ describe GoodData::LCM2::SynchronizeETLsInSegment do
161
159
  end
162
160
 
163
161
  it 'all schedules must have the parameter' do
164
- schedule1.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
165
162
  schedule1.should_receive(:update_params).once.ordered.with('HELLO' => 'hi')
166
- schedule2.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
167
163
  schedule2.should_receive(:update_params).once.ordered.with('HELLO' => 'hi')
168
164
  subject.class.call(params)
169
165
  end
@@ -202,9 +198,7 @@ describe GoodData::LCM2::SynchronizeETLsInSegment do
202
198
  end
203
199
 
204
200
  it 'parameters should be passed to the correct client project and schedule' do
205
- schedule1.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
206
201
  schedule1.should_receive(:update_params).once.ordered.with('HELLO' => 'hi')
207
- schedule2.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
208
202
  subject.class.call(params)
209
203
  end
210
204
  end
@@ -15,8 +15,9 @@ describe GoodData::LCM2::SynchronizeLdm do
15
15
  let(:gdc_gd_client) { double(GoodData::Rest::Client) }
16
16
  let(:logger) { double(Logger) }
17
17
  let(:project) { double(GoodData::Project) }
18
+ let(:target_project) { double(GoodData::Project) }
18
19
  let(:synchronize) do
19
- [{ from: 'foo', to: [] }]
20
+ [{ from: 'from_pid', to: [{ pid: 'to_pid' }] }]
20
21
  end
21
22
  let(:basic_params) do
22
23
  {
@@ -31,15 +32,18 @@ describe GoodData::LCM2::SynchronizeLdm do
31
32
  end
32
33
 
33
34
  before do
34
- allow(gdc_gd_client).to receive(:projects).and_return(project)
35
+ allow(gdc_gd_client).to receive(:projects)
36
+ .with('from_pid')
37
+ .and_return(project)
38
+ allow(gdc_gd_client).to receive(:projects)
39
+ .with('to_pid')
40
+ .and_return(target_project)
35
41
  allow(project).to receive(:title)
36
42
  allow(project).to receive(:pid)
43
+ allow(project).to receive(:blueprint)
37
44
  allow(logger).to receive(:info)
38
- end
39
-
40
- context 'when include_computed_attributes is not specified' do
41
- let(:params) { basic_params }
42
- it_behaves_like 'a computed attributes synchronizer'
45
+ allow(target_project).to receive(:title)
46
+ allow(target_project).to receive(:update_from_blueprint)
43
47
  end
44
48
 
45
49
  context 'when include_computed_attributes is true' do
@@ -54,4 +58,13 @@ describe GoodData::LCM2::SynchronizeLdm do
54
58
  subject.class.call(converted_params)
55
59
  end
56
60
  end
61
+
62
+ context 'when exclude_fact_rule is true' do
63
+ let(:params) { basic_params.merge(exclude_fact_rule: 'true') }
64
+ it 'calls update_from_blueprint with exclude_fact_rule option' do
65
+ expect(target_project).to receive(:update_from_blueprint)
66
+ .with(any_args, hash_including(exclude_fact_rule: true))
67
+ subject.class.call(converted_params)
68
+ end
69
+ end
57
70
  end
@@ -85,6 +85,27 @@ describe GoodData::LCM2::SynchronizeUserFilters do
85
85
  it_behaves_like 'a user action filtering segments' do
86
86
  let(:message_for_project) { :add_data_permissions }
87
87
  end
88
+
89
+ context 'when dry_run param is true' do
90
+ let(:params) do
91
+ params = {
92
+ GDC_GD_CLIENT: client,
93
+ input_source: 'foo',
94
+ domain: 'bar',
95
+ filters_config: { labels: [] },
96
+ sync_mode: mode,
97
+ gdc_logger: logger,
98
+ dry_run: true
99
+ }
100
+ GoodData::LCM2.convert_to_smart_hash(params)
101
+ end
102
+
103
+ it 'sets the dry_run option' do
104
+ expect(project).to receive(:add_data_permissions)
105
+ .with(instance_of(Array), hash_including(dry_run: true))
106
+ subject.class.call(params)
107
+ end
108
+ end
88
109
  end
89
110
  end
90
111
  end
@@ -0,0 +1,34 @@
1
+ require 'gooddata/lcm/actions/base_action'
2
+ require 'gooddata/lcm/helpers/check_helper'
3
+ require 'gooddata/lcm/types/types'
4
+
5
+ describe 'GoodData::LCM2::Helpers::Check' do
6
+ let(:params) do
7
+ params = { test_param_three: 'Testing param three' }
8
+ GoodData::LCM2.convert_to_smart_hash(params)
9
+ end
10
+ let(:spec) do
11
+ GoodData::LCM2::BaseAction.define_params(self) do
12
+ description 'Testing param two'
13
+ param :test_param_two, instance_of(GoodData::LCM2::Type::StringType), required: true
14
+
15
+ description 'Testing param four'
16
+ param :test_param_three, instance_of(GoodData::LCM2::Type::IntegerType), required: false
17
+ end
18
+ end
19
+ context 'when running outside the tests' do
20
+ let(:mocked_logger) { double(Logger) }
21
+ before do
22
+ expect(GoodData).to receive(:logger).and_return(mocked_logger)
23
+ expect(ENV).to receive(:[]).with('RSPEC_ENV').and_return('production')
24
+ expect(mocked_logger).to receive(:error)
25
+ end
26
+ it 'writes out error message but do not fail when virifying required params' do
27
+ expect { GoodData::LCM2::Helpers.check_params(spec, params) }.not_to raise_error(/Mandatory/)
28
+ end
29
+
30
+ it 'writes out error message but do not fail when checking types' do
31
+ expect { GoodData::LCM2::Helpers.check_params(spec, params) }.not_to raise_error(/has invalid type/)
32
+ end
33
+ end
34
+ end
@@ -7,21 +7,27 @@ require 'gooddata/lcm/actions/base_action'
7
7
  require 'gooddata/lcm/helpers/check_helper'
8
8
  require 'gooddata/lcm/types/types'
9
9
 
10
- describe 'GoodData::LCM2::Helpers::Checkout' do
10
+ describe 'GoodData::LCM2::Helpers::Check' do
11
11
  let(:params) do
12
12
  params = {
13
13
  test_param_two: 'Testing param two',
14
14
  test_param_three: 'Testing param three',
15
- test_param_four: 4
15
+ test_param_four: 4,
16
+ UPPER_case_param: 'qux'
16
17
  }
17
18
  GoodData::LCM2.convert_to_smart_hash(params)
18
19
  end
19
- it 'verifies required' do
20
- PARAMS = GoodData::LCM2::BaseAction.define_params(self) do
20
+ let(:spec) do
21
+ GoodData::LCM2::BaseAction.define_params(self) do
21
22
  description 'Testing param one'
22
23
  param :test_param_one, instance_of(GoodData::LCM2::Type::StringType), required: true
24
+
25
+ description 'Param four'
26
+ param :test_param_four, instance_of(GoodData::LCM2::Type::StringType), required: false
23
27
  end
24
- expect { GoodData::LCM2::Helpers.check_params(PARAMS, params) }.to raise_error(/Mandatory/)
28
+ end
29
+ it 'verifies required' do
30
+ expect { GoodData::LCM2::Helpers.check_params(spec, params) }.to raise_error(/Mandatory/)
25
31
  end
26
32
 
27
33
  it 'fills default' do
@@ -37,10 +43,92 @@ describe 'GoodData::LCM2::Helpers::Checkout' do
37
43
  end
38
44
 
39
45
  it 'checks types' do
40
- PARAMS_3 = GoodData::LCM2::BaseAction.define_params(self) do
41
- description 'Testing param four'
42
- param :test_param_four, instance_of(GoodData::LCM2::Type::StringType), required: false
46
+ params['test_param_one'] = 'test_param_one'
47
+ expect { GoodData::LCM2::Helpers.check_params(spec, params) }.to raise_error(/has invalid type/)
48
+ end
49
+
50
+ it 'fails when unspecified variable is acessed' do
51
+ params.setup_filters(spec)
52
+ expect { params[:test_param_three] }.to raise_error(/not defined in the specification/)
53
+ end
54
+
55
+ context 'when created from stringified hash' do
56
+ subject { GoodData::LCM2::Helpers.check_params(spec, params) }
57
+ let(:params) do
58
+ raw_params = { 'update_preference' => { 'keep_data' => false,
59
+ 'allow_cascade_drops' => true } }
60
+ GoodData::LCM2.convert_to_smart_hash(raw_params)
61
+ end
62
+
63
+ let(:spec) do
64
+ GoodData::LCM2::BaseAction.define_params(self) do
65
+ description 'Some param'
66
+ param :update_preference, instance_of(GoodData::LCM2::Type::UpdatePreferenceType), required: false
67
+
68
+ description 'Replacement param'
69
+ param :replacement_param, instance_of(GoodData::LCM2::Type::GdClientType), required: false
70
+
71
+ description 'Deprecated param'
72
+ param :deprecated_param, instance_of(GoodData::LCM2::Type::StringType), required: false, deprecated: true, replacement: :replacement_param
73
+
74
+ description 'List of production tag Names'
75
+ param :production_tags, array_of(instance_of(GoodData::LCM2::Type::StringType)), required: false
76
+
77
+ description 'Production Tag Names'
78
+ param :production_tag, instance_of(GoodData::LCM2::Type::StringType), required: false, deprecated: true, replacement: :production_tags
79
+
80
+ description 'Default testing param'
81
+ param :default_test, array_of(instance_of(GoodData::LCM2::Type::StringType)), required: false, default: 'default value'
82
+
83
+ description 'Deprecated testing param'
84
+ param :deprecated_test, instance_of(GoodData::LCM2::Type::StringType), required: false, deprecated: true, replacement: :default_test
85
+ end
86
+ end
87
+
88
+ it 'works with default values' do
89
+ subject
90
+ expect(params[:update_preference][:keep_data]).to be(false)
91
+ end
92
+
93
+ context 'when deprecated params together with default values are supplied' do
94
+ let(:params) do
95
+ raw_params = {
96
+ 'deprecated_param' => 'franta',
97
+ 'production_tag' => 'pepa',
98
+ 'update_preference' => {
99
+ 'cascade_drops' => true,
100
+ 'keep_data' => false
101
+ },
102
+ 'deprecated_test' => 'jednicka'
103
+ }
104
+ GoodData::LCM2.convert_to_smart_hash(raw_params)
105
+ end
106
+ it 'works with default values on deprecated params' do
107
+ subject
108
+ expect(params[:update_preference][:keep_data]).to be(false)
109
+ expect(params[:update_preference][:cascade_drops]).to be(true)
110
+ end
111
+
112
+ it 'does not fill default values on replacement params if deprecated one has value' do
113
+ subject
114
+ expect(params[:default_test]).to be(nil)
115
+ expect(params[:deprecated_test]).to eq('jednicka')
116
+ end
117
+ end
118
+ end
119
+
120
+ context 'when key contains upper-case letters' do
121
+ let(:spec) do
122
+ GoodData::LCM2::BaseAction.define_params(self) do
123
+ description 'Testing param'
124
+ param :upper_case_param, instance_of(GoodData::LCM2::Type::StringType)
125
+ end
126
+ end
127
+
128
+ before { params.setup_filters(spec) }
129
+
130
+ it 'fetching works with both lower case and original case' do
131
+ ['upper_case_param', :upper_case_param, 'UPPER_case_param', :UPPER_case_param].map { |e| expect(params[e]).to eq('qux') }
43
132
  end
44
- expect { GoodData::LCM2::Helpers.check_params(PARAMS_3, params) }.to raise_error(/has invalid type/)
45
133
  end
46
134
  end