|
1250 | 1250 | end |
1251 | 1251 |
|
1252 | 1252 | it 'should return global holdouts that do not exclude the flag' do |
1253 | | - holdouts = config_with_holdouts.get_holdouts_for_flag('multi_variate_feature') |
| 1253 | + multi_variate_feature_id = '155559' |
| 1254 | + holdouts = config_with_holdouts.get_holdouts_for_flag(multi_variate_feature_id) |
1254 | 1255 | expect(holdouts.length).to eq(3) |
1255 | 1256 |
|
1256 | 1257 | global_holdout = holdouts.find { |h| h['key'] == 'global_holdout' } |
|
1263 | 1264 | end |
1264 | 1265 |
|
1265 | 1266 | it 'should not return global holdouts that exclude the flag' do |
1266 | | - holdouts = config_with_holdouts.get_holdouts_for_flag('boolean_single_variable_feature') |
| 1267 | + boolean_feature_id = '155554' |
| 1268 | + holdouts = config_with_holdouts.get_holdouts_for_flag(boolean_feature_id) |
1267 | 1269 | expect(holdouts.length).to eq(1) |
1268 | 1270 |
|
1269 | 1271 | global_holdout = holdouts.find { |h| h['key'] == 'global_holdout' } |
1270 | 1272 | expect(global_holdout).to be_nil |
1271 | 1273 | end |
1272 | 1274 |
|
1273 | 1275 | it 'should cache results for subsequent calls' do |
1274 | | - holdouts1 = config_with_holdouts.get_holdouts_for_flag('multi_variate_feature') |
1275 | | - holdouts2 = config_with_holdouts.get_holdouts_for_flag('multi_variate_feature') |
| 1276 | + multi_variate_feature_id = '155559' |
| 1277 | + holdouts1 = config_with_holdouts.get_holdouts_for_flag(multi_variate_feature_id) |
| 1278 | + holdouts2 = config_with_holdouts.get_holdouts_for_flag(multi_variate_feature_id) |
1276 | 1279 | expect(holdouts1).to equal(holdouts2) |
1277 | 1280 | expect(holdouts1.length).to eq(3) |
1278 | 1281 | end |
1279 | 1282 |
|
1280 | 1283 | it 'should return only global holdouts for flags not specifically targeted' do |
1281 | | - holdouts = config_with_holdouts.get_holdouts_for_flag('string_single_variable_feature') |
| 1284 | + string_feature_id = '594060' |
| 1285 | + holdouts = config_with_holdouts.get_holdouts_for_flag(string_feature_id) |
1282 | 1286 |
|
1283 | 1287 | # Should only include global holdout (not excluded and no specific targeting) |
1284 | 1288 | expect(holdouts.length).to eq(2) |
|
1394 | 1398 |
|
1395 | 1399 | it 'should properly categorize holdouts during initialization' do |
1396 | 1400 | expect(config_with_complex_holdouts.holdout_id_map.keys).to contain_exactly('global_holdout', 'specific_holdout') |
1397 | | - expect(config_with_complex_holdouts.global_holdouts.keys).to contain_exactly('global_holdout') |
| 1401 | + expect(config_with_complex_holdouts.global_holdouts.map { |h| h['id'] }).to contain_exactly('global_holdout') |
1398 | 1402 |
|
1399 | 1403 | # Use the correct feature flag IDs |
1400 | 1404 | boolean_feature_id = '155554' |
|
1416 | 1420 |
|
1417 | 1421 | it 'should only process running holdouts during initialization' do |
1418 | 1422 | expect(config_with_complex_holdouts.holdout_id_map['inactive_holdout']).to be_nil |
1419 | | - expect(config_with_complex_holdouts.global_holdouts['inactive_holdout']).to be_nil |
| 1423 | + expect(config_with_complex_holdouts.global_holdouts.find { |h| h['id'] == 'inactive_holdout' }).to be_nil |
1420 | 1424 |
|
1421 | 1425 | boolean_feature_id = '155554' |
1422 | 1426 | included_for_boolean = config_with_complex_holdouts.included_holdouts[boolean_feature_id] |
|
1594 | 1598 |
|
1595 | 1599 | it 'should handle mixed holdout configurations' do |
1596 | 1600 | # Verify the config has properly categorized holdouts |
1597 | | - expect(config_with_holdouts.global_holdouts).to be_a(Hash) |
| 1601 | + expect(config_with_holdouts.global_holdouts).to be_a(Array) |
1598 | 1602 | expect(config_with_holdouts.included_holdouts).to be_a(Hash) |
1599 | 1603 | expect(config_with_holdouts.excluded_holdouts).to be_a(Hash) |
1600 | 1604 | end |
|
1774 | 1778 | config = Optimizely::DatafileProjectConfig.new(config_json, logger, error_handler) |
1775 | 1779 |
|
1776 | 1780 | # Should treat as global holdout |
1777 | | - expect(config.global_holdouts['holdout_nil']).not_to be_nil |
| 1781 | + expect(config.global_holdouts.find { |h| h['id'] == 'holdout_nil' }).not_to be_nil |
1778 | 1782 | end |
1779 | 1783 |
|
1780 | 1784 | it 'should only include running holdouts in maps' do |
|
0 commit comments