Skip to content

Commit 2d7d41d

Browse files
authored
Merge pull request #566 from splitio/FME-4370-imp-prop-integrations
Updated integration tests
2 parents 9997c3d + 35fd494 commit 2d7d41d

File tree

4 files changed

+63
-7
lines changed

4 files changed

+63
-7
lines changed

lib/splitclient-rb/clients/split_client.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def treatments(key, feature_flag_names, attributes = {}, options = nil, calling_
273273
bucketing_key, matching_key = keys_from_key(key)
274274
bucketing_key = bucketing_key ? bucketing_key.to_s : nil
275275
matching_key = matching_key ? matching_key.to_s : nil
276+
attributes = parsed_attributes(attributes)
276277

277278
if !@config.split_validator.valid_get_treatments_parameters(calling_method, key, sanitized_feature_flag_names, matching_key, bucketing_key, attributes)
278279
to_return = Hash.new
@@ -379,7 +380,7 @@ def evaluate_treatment(feature_flag, feature_flag_name, bucketing_key, matching_
379380
impressions_disabled = false
380381
end
381382

382-
options, size = validate_options(options)
383+
options, size = validate_options(options) unless options.nil?
383384
options[:properties] = nil unless options.nil? or check_properties_size((EVENT_AVERAGE_SIZE + size), "Properties are ignored")
384385

385386
record_latency(calling_method, start)

spec/cache/senders/impressions_formatter_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
it 'formats multiple impressions for one key' do
7676
params = { attributes: {}, time: 1_478_113_518_900 }
7777
impressions = []
78-
impressions << { :impression => impressions_manager.build_impression('matching_key3', nil, 'foo2', treatment3, false, params, {"prop": "val"}), :disabled => false }
78+
impressions << { :impression => impressions_manager.build_impression('matching_key3', nil, 'foo2', treatment3, false, params, {:properties => {:prop => "val"}}), :disabled => false }
7979
impressions_manager.track(impressions)
8080

8181
expect(formatted_impressions.find { |i| i[:f] == :foo1 }[:i]).to match_array(

spec/cache/senders/impressions_sender_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
params2 = { attributes: {}, time: 1_478_113_518_285 }
4747
impressions = []
4848
impressions << { :impression => impressions_manager.build_impression('matching_key', 'foo1', 'foo1', treatment1, false, params), :disabled => false }
49-
impressions << { :impression => impressions_manager.build_impression('matching_key2', 'foo2', 'foo2', treatment2, false, params2, {:prop=>"val"}), :disabled => false }
49+
impressions << { :impression => impressions_manager.build_impression('matching_key2', 'foo2', 'foo2', treatment2, false, params2, {:properties => {:prop => "val"}}), :disabled => false }
5050
impressions_manager.track(impressions)
5151
end
5252

spec/engine_spec.rb

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,33 @@
7777
treatment: 'off',
7878
config: nil
7979
)
80+
expect(subject.get_treatment_with_config('nicolas', 'mauro_test', {}, nil)).to eq(
81+
treatment: 'off',
82+
config: nil
83+
)
84+
expect(subject.get_treatment_with_config('nicolas', 'mauro_test', {}, {})).to eq(
85+
treatment: 'off',
86+
config: nil
87+
)
88+
expect(subject.get_treatment_with_config('nicolas', 'mauro_test', {}, "prop")).to eq(
89+
treatment: 'off',
90+
config: nil
91+
)
92+
expect(subject.get_treatment_with_config('nicolas', 'mauro_test', {}, 123)).to eq(
93+
treatment: 'off',
94+
config: nil
95+
)
8096
close_redis
8197
end
8298

8399
it 'get_treatment returns off' do
84100
expect(subject.get_treatment('nicolas', 'mauro_test', nil)).to eq 'off'
85101
expect(subject.get_treatment('nicolas', 'mauro_test')).to eq 'off'
86102
expect(subject.get_treatment('nicolas', 'mauro_test', {})).to eq 'off'
103+
expect(subject.get_treatment('nicolas', 'mauro_test', {}, nil)).to eq 'off'
104+
expect(subject.get_treatment('nicolas', 'mauro_test', {}, {})).to eq 'off'
105+
expect(subject.get_treatment('nicolas', 'mauro_test', {}, "prop")).to eq 'off'
106+
expect(subject.get_treatment('nicolas', 'mauro_test', {}, 123)).to eq 'off'
87107
end
88108

89109
it 'get_treatments returns off' do
@@ -96,6 +116,18 @@
96116
expect(subject.get_treatments('nicolas', ['mauro_test'], {})).to eq(
97117
mauro_test: 'off'
98118
)
119+
expect(subject.get_treatments('nicolas', ['mauro_test'], {}, nil)).to eq(
120+
mauro_test: 'off'
121+
)
122+
expect(subject.get_treatments('nicolas', ['mauro_test'], {}, {})).to eq(
123+
mauro_test: 'off'
124+
)
125+
expect(subject.get_treatments('nicolas', ['mauro_test'], {}, "prop")).to eq(
126+
mauro_test: 'off'
127+
)
128+
expect(subject.get_treatments('nicolas', ['mauro_test'], {}, 123)).to eq(
129+
mauro_test: 'off'
130+
)
99131
close_redis
100132
end
101133

@@ -109,6 +141,18 @@
109141
expect(subject.get_treatments_by_flag_set('nicolas', 'set_2', {})).to eq(
110142
mauro_test: 'off'
111143
)
144+
expect(subject.get_treatments_by_flag_set('nicolas', 'set_2', {}, {})).to eq(
145+
mauro_test: 'off'
146+
)
147+
expect(subject.get_treatments_by_flag_set('nicolas', 'set_2', {}, nil)).to eq(
148+
mauro_test: 'off'
149+
)
150+
expect(subject.get_treatments_by_flag_set('nicolas', 'set_2', {}, "prop")).to eq(
151+
mauro_test: 'off'
152+
)
153+
expect(subject.get_treatments_by_flag_set('nicolas', 'set_2', {}, 123)).to eq(
154+
mauro_test: 'off'
155+
)
112156
close_redis
113157
end
114158

@@ -122,6 +166,18 @@
122166
expect(subject.get_treatments_by_flag_sets('nicolas', ['set_2'], {})).to eq(
123167
mauro_test: 'off'
124168
)
169+
expect(subject.get_treatments_by_flag_sets('nicolas', ['set_2'], {}, {})).to eq(
170+
mauro_test: 'off'
171+
)
172+
expect(subject.get_treatments_by_flag_sets('nicolas', ['set_2'], {}, nil)).to eq(
173+
mauro_test: 'off'
174+
)
175+
expect(subject.get_treatments_by_flag_sets('nicolas', ['set_2'], {}, "prop")).to eq(
176+
mauro_test: 'off'
177+
)
178+
expect(subject.get_treatments_by_flag_sets('nicolas', ['set_2'], {}, 123)).to eq(
179+
mauro_test: 'off'
180+
)
125181
close_redis
126182
end
127183
end
@@ -141,8 +197,7 @@
141197
end
142198

143199
it 'returns CONTROL and label for incorrect feature name' do
144-
treatment = subject.get_treatment('random_user_id', 'test_featur', nil, nil, false, true)
145-
puts treatment
200+
treatment = subject.get_treatment('random_user_id', 'test_featur', nil, nil, nil, false, true)
146201
expect(treatment).to eq(
147202
treatment: SplitIoClient::Engine::Models::Treatment::CONTROL,
148203
label: SplitIoClient::Engine::Models::Label::NOT_FOUND,
@@ -229,7 +284,7 @@
229284

230285
#TODO We will remove multiple param in the future.
231286
it 'returns CONTROL and label on nil key' do
232-
expect(subject.get_treatment(nil, 'test_feature', nil, nil, false, true)).to eq(
287+
expect(subject.get_treatment(nil, 'test_feature', nil, nil, nil, false, true)).to eq(
233288
treatment: SplitIoClient::Engine::Models::Treatment::CONTROL,
234289
label: nil,
235290
change_number: nil
@@ -289,7 +344,7 @@
289344

290345
#TODO We will remove multiple param in the future.
291346
it 'returns CONTROL and label on nil split_name' do
292-
expect(subject.get_treatment('random_user_id', nil, nil, nil, false, true)).to eq(
347+
expect(subject.get_treatment('random_user_id', nil, nil, nil, nil, false, true)).to eq(
293348
treatment: SplitIoClient::Engine::Models::Treatment::CONTROL,
294349
label: nil,
295350
change_number: nil

0 commit comments

Comments
 (0)