@@ -234,7 +234,7 @@ class PostHog
234
234
expect ( c . get_feature_flag ( "complex-flag" , "some-distinct-id_outside_rollout?" , person_properties :
{ "region" => "USA" , "email" => "[email protected] " } ) ) . to eq ( "decide-fallback-value" )
235
235
assert_requested :post , decide_endpoint , times : 1
236
236
expect ( WebMock ) . to have_requested ( :post , decide_endpoint ) . with (
237
- body :
{ "distinct_id" :
"some-distinct-id_outside_rollout?" , "groups" :
{ } , "group_properties" :
{ } , "person_properties" :
{ "$current_distinct_id " :
"some-distinct-id_outside_rollout?" , "region" => "USA" , "email" => "[email protected] " } , "token" :
"testsecret" } )
237
+ body :
{ "distinct_id" :
"some-distinct-id_outside_rollout?" , "groups" :
{ } , "group_properties" :
{ } , "person_properties" :
{ "distinct_id " :
"some-distinct-id_outside_rollout?" , "region" => "USA" , "email" => "[email protected] " } , "token" :
"testsecret" } )
238
238
239
239
WebMock . reset_executed_requests!
240
240
@@ -243,7 +243,7 @@ class PostHog
243
243
assert_requested :post , decide_endpoint , times : 1
244
244
245
245
expect ( WebMock ) . to have_requested ( :post , decide_endpoint ) . with (
246
- body : { "distinct_id" : "some-distinct-id" , "groups" : { } , "group_properties" : { } , "person_properties" : { "$current_distinct_id " : "some-distinct-id" , "doesnt_matter" => "1" } , "token" : "testsecret" } )
246
+ body : { "distinct_id" : "some-distinct-id" , "groups" : { } , "group_properties" : { } , "person_properties" : { "distinct_id " : "some-distinct-id" , "doesnt_matter" => "1" } , "token" : "testsecret" } )
247
247
248
248
WebMock . reset_executed_requests!
249
249
@@ -1235,9 +1235,9 @@ class PostHog
1235
1235
1236
1236
end
1237
1237
1238
- it 'with relative date operators - is_relative_date_before ' do
1238
+ it 'with relative date operators - is_date_before ' do
1239
1239
Timecop . freeze ( Time . gm ( 2022 , 5 , 1 ) ) do
1240
- property_a = { 'key' => 'key' , 'value' => '6h' , 'operator' => 'is_relative_date_before ' }
1240
+ property_a = { 'key' => 'key' , 'value' => '- 6h' , 'operator' => 'is_date_before ' }
1241
1241
expect ( FeatureFlagsPoller . match_property ( property_a , { 'key' => '2022-03-01' } ) ) . to be true
1242
1242
expect ( FeatureFlagsPoller . match_property ( property_a , { 'key' => '2022-04-30' } ) ) . to be true
1243
1243
expect ( FeatureFlagsPoller . match_property ( property_a , { 'key' => DateTime . new ( 2022 , 4 , 30 , 1 , 2 , 3 ) } ) ) . to be true
@@ -1259,9 +1259,9 @@ class PostHog
1259
1259
end
1260
1260
end
1261
1261
1262
- it 'with relative date operators - is_relative_date_after ' do
1262
+ it 'with relative date operators - is_date_after ' do
1263
1263
Timecop . freeze ( Time . gm ( 2022 , 5 , 1 ) ) do
1264
- property_b = { 'key' => 'key' , 'value' => '1h' , 'operator' => 'is_relative_date_after ' }
1264
+ property_b = { 'key' => 'key' , 'value' => '1h' , 'operator' => 'is_date_after ' }
1265
1265
expect ( FeatureFlagsPoller . match_property ( property_b , { 'key' => '2022-05-02' } ) ) . to be true
1266
1266
expect ( FeatureFlagsPoller . match_property ( property_b , { 'key' => '2022-05-30' } ) ) . to be true
1267
1267
expect ( FeatureFlagsPoller . match_property ( property_b , { 'key' => DateTime . new ( 2022 , 5 , 30 ) } ) ) . to be true
@@ -1271,15 +1271,15 @@ class PostHog
1271
1271
# can't be invalid string
1272
1272
expect { FeatureFlagsPoller . match_property ( property_b , { 'key' => 'abcdef' } ) } . to raise_error ( InconclusiveMatchError )
1273
1273
# invalid flag property
1274
- property_c = { 'key' => 'key' , 'value' => 1234 , 'operator' => 'is_relative_date_after ' }
1274
+ property_c = { 'key' => 'key' , 'value' => 1234 , 'operator' => 'is_date_after ' }
1275
1275
expect { FeatureFlagsPoller . match_property ( property_c , { 'key' => 1 } ) } . to raise_error ( InconclusiveMatchError )
1276
1276
expect { FeatureFlagsPoller . match_property ( property_c , { 'key' => '2022-05-30' } ) } . to raise_error ( InconclusiveMatchError )
1277
1277
end
1278
1278
end
1279
1279
1280
1280
it 'with relative date operators - all possible relative dates' do
1281
1281
Timecop . freeze ( Time . gm ( 2022 , 5 , 1 ) ) do
1282
- property_d = { 'key' => 'key' , 'value' => '12d' , 'operator' => 'is_relative_date_before ' }
1282
+ property_d = { 'key' => 'key' , 'value' => '- 12d' , 'operator' => 'is_date_before ' }
1283
1283
expect ( FeatureFlagsPoller . match_property ( property_d , { 'key' => '2022-05-30' } ) ) . to be false
1284
1284
1285
1285
expect ( FeatureFlagsPoller . match_property ( property_d , { 'key' => '2022-03-30' } ) ) . to be true
@@ -1288,45 +1288,45 @@ class PostHog
1288
1288
expect ( FeatureFlagsPoller . match_property ( property_d , { 'key' => '2022-04-19 02:00:01+02:00' } ) ) . to be false
1289
1289
1290
1290
# Try all possible relative dates
1291
- property_e = { 'key' => 'key' , 'value' => '1h' , 'operator' => 'is_relative_date_before ' }
1291
+ property_e = { 'key' => 'key' , 'value' => '1h' , 'operator' => 'is_date_before ' }
1292
1292
expect ( FeatureFlagsPoller . match_property ( property_e , { 'key' => '2022-05-01 00:00:00' } ) ) . to be false
1293
1293
expect ( FeatureFlagsPoller . match_property ( property_e , { 'key' => '2022-04-30 22:00:00' } ) ) . to be true
1294
1294
1295
- property_f = { 'key' => 'key' , 'value' => '1d' , 'operator' => 'is_relative_date_before ' }
1295
+ property_f = { 'key' => 'key' , 'value' => '1d' , 'operator' => 'is_date_before ' }
1296
1296
expect ( FeatureFlagsPoller . match_property ( property_f , { 'key' => '2022-04-29 23:59:00' } ) ) . to be true
1297
1297
expect ( FeatureFlagsPoller . match_property ( property_f , { 'key' => '2022-04-30 00:00:01' } ) ) . to be false
1298
1298
1299
- property_g = { 'key' => 'key' , 'value' => '1w' , 'operator' => 'is_relative_date_before ' }
1299
+ property_g = { 'key' => 'key' , 'value' => '1w' , 'operator' => 'is_date_before ' }
1300
1300
expect ( FeatureFlagsPoller . match_property ( property_g , { 'key' => '2022-04-23 00:00:00' } ) ) . to be true
1301
1301
expect ( FeatureFlagsPoller . match_property ( property_g , { 'key' => '2022-04-24 00:00:00' } ) ) . to be false
1302
1302
expect ( FeatureFlagsPoller . match_property ( property_g , { 'key' => '2022-04-24 00:00:01' } ) ) . to be false
1303
1303
1304
- property_h = { 'key' => 'key' , 'value' => '1m' , 'operator' => 'is_relative_date_before ' }
1304
+ property_h = { 'key' => 'key' , 'value' => '1m' , 'operator' => 'is_date_before ' }
1305
1305
expect ( FeatureFlagsPoller . match_property ( property_h , { 'key' => '2022-03-01 00:00:00' } ) ) . to be true
1306
1306
expect ( FeatureFlagsPoller . match_property ( property_h , { 'key' => '2022-04-05 00:00:00' } ) ) . to be false
1307
1307
1308
- property_i = { 'key' => 'key' , 'value' => '1y' , 'operator' => 'is_relative_date_before ' }
1308
+ property_i = { 'key' => 'key' , 'value' => '1y' , 'operator' => 'is_date_before ' }
1309
1309
expect ( FeatureFlagsPoller . match_property ( property_i , { 'key' => '2021-04-28 00:00:00' } ) ) . to be true
1310
1310
expect ( FeatureFlagsPoller . match_property ( property_i , { 'key' => '2021-05-01 00:00:01' } ) ) . to be false
1311
1311
1312
- property_j = { 'key' => 'key' , 'value' => '122h' , 'operator' => 'is_relative_date_after ' }
1312
+ property_j = { 'key' => 'key' , 'value' => '122h' , 'operator' => 'is_date_after ' }
1313
1313
expect ( FeatureFlagsPoller . match_property ( property_j , { 'key' => '2022-05-01 00:00:00' } ) ) . to be true
1314
1314
expect ( FeatureFlagsPoller . match_property ( property_j , { 'key' => '2022-04-23 01:00:00' } ) ) . to be false
1315
1315
1316
- property_k = { 'key' => 'key' , 'value' => '2d' , 'operator' => 'is_relative_date_after ' }
1316
+ property_k = { 'key' => 'key' , 'value' => '- 2d' , 'operator' => 'is_date_after ' }
1317
1317
expect ( FeatureFlagsPoller . match_property ( property_k , { 'key' => '2022-05-01 00:00:00' } ) ) . to be true
1318
1318
expect ( FeatureFlagsPoller . match_property ( property_k , { 'key' => '2022-04-29 00:00:01' } ) ) . to be true
1319
1319
expect ( FeatureFlagsPoller . match_property ( property_k , { 'key' => '2022-04-29 00:00:00' } ) ) . to be false
1320
1320
1321
- property_l = { 'key' => 'key' , 'value' => '02w' , 'operator' => 'is_relative_date_after ' }
1321
+ property_l = { 'key' => 'key' , 'value' => '02w' , 'operator' => 'is_date_after ' }
1322
1322
expect ( FeatureFlagsPoller . match_property ( property_l , { 'key' => '2022-05-01 00:00:00' } ) ) . to be true
1323
1323
expect ( FeatureFlagsPoller . match_property ( property_l , { 'key' => '2022-04-16 00:00:00' } ) ) . to be false
1324
1324
1325
- property_m = { 'key' => 'key' , 'value' => '1m' , 'operator' => 'is_relative_date_after ' }
1325
+ property_m = { 'key' => 'key' , 'value' => '1m' , 'operator' => 'is_date_after ' }
1326
1326
expect ( FeatureFlagsPoller . match_property ( property_m , { 'key' => '2022-04-01 00:00:01' } ) ) . to be true
1327
1327
expect ( FeatureFlagsPoller . match_property ( property_m , { 'key' => '2022-04-01 00:00:00' } ) ) . to be false
1328
1328
1329
- property_n = { 'key' => 'key' , 'value' => '1y' , 'operator' => 'is_relative_date_after ' }
1329
+ property_n = { 'key' => 'key' , 'value' => '1y' , 'operator' => 'is_date_after ' }
1330
1330
expect ( FeatureFlagsPoller . match_property ( property_n , { 'key' => '2022-05-01 00:00:00' } ) ) . to be true
1331
1331
expect ( FeatureFlagsPoller . match_property ( property_n , { 'key' => '2021-05-01 00:00:01' } ) ) . to be true
1332
1332
expect ( FeatureFlagsPoller . match_property ( property_n , { 'key' => '2021-05-01 00:00:00' } ) ) . to be false
0 commit comments