lazy_global_record 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd68a16a608b4a57f85b97d807fd188c555b309f
4
- data.tar.gz: e506abed0676e857ae55c46ff91ca123c805bd4d
3
+ metadata.gz: 80f068e29c8dba787bf3ee262e954db73b1f65d4
4
+ data.tar.gz: ade0cf9586c796625a5e4b274f6e88b2f68fe1d2
5
5
  SHA512:
6
- metadata.gz: 9ee14c3989110816b6f75d10f08e54540bb3d2951de3a0742ceb1f7ba5e0f145f3865c029de5a4c9227f9c1c7de6f2d01eac998988c6ba809cdef29147aa4090
7
- data.tar.gz: 5db7a76e65762cebd962e9771474d07f75ef22052932dad64a8f6ca9dcaa40efacff0698b6c40eb12adf27066350c13bc08a0c428a72ea30ebdb3096560b65ce
6
+ metadata.gz: 98a7ae2b0ee15141ef5e40e63be863c953f56e47dd303ef71ebc8d430eb90ea1a924dcec479463f2c47b2f6b887e4ee4db00b98246af9fb692f0f75715e38a62
7
+ data.tar.gz: 800d262e97fc32cb9c7cd91b7b2db0394deb1e997c734a3b0f246211c404bc814bd77726709a2439a88697a9cbd8ef698043d32eed15e157b61c812fa8c64afb
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # LazyGlobalRecord
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/lazy_global_record.svg)](https://badge.fury.io/rb/lazy_global_record)
4
+
3
5
  Lazy loading of 'interesting' ActiveRecord model id's, thread-safely and with
4
6
  easy cache reset and lazy creation in testing. Uses ruby-concurrent
5
7
  as a dependency.
@@ -33,13 +35,8 @@ it out and the cached value is wrong. And it's none of it thread-safe,
33
35
  and this is 2016, get with the concurrency program already.
34
36
 
35
37
  So this gem provides an answer, with a pattern to fetch and cache
36
- an ActiveRecord model `id` (or other values), such that:
37
-
38
- * thread-safe lazy loading
39
- * Raise if it's not there in production
40
- * Create it lazily if it's not there in dev/test
41
- * Allow reset of memoization in dev/test, after every test
42
- * Supply various custom logic with a concise api
38
+ an ActiveRecord model `id` (or other values), lazily, thread-safely,
39
+ with auto-creation and easy cache reset in test env.
43
40
 
44
41
  ~~~ruby
45
42
  class Department < ActiveRecord::Base
@@ -1,3 +1,3 @@
1
1
  class LazyGlobalRecord
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -35,9 +35,11 @@ class LazyGlobalRecord
35
35
  def value
36
36
  # double-deref, our atomic slot, and the delay itself.
37
37
  # needed so we can #reset in a thread-safe way too.
38
- value = @slot.value.value
39
- if @slot.value.reason
40
- raise @slot.value.reason
38
+ delay = @slot.value
39
+
40
+ value = delay.value
41
+ if delay.reason
42
+ raise delay.reason
41
43
  end
42
44
  value
43
45
  end
@@ -51,7 +53,7 @@ class LazyGlobalRecord
51
53
  end
52
54
 
53
55
  def reset
54
- raise TypeError.new("This ClassState object is not resettable") unless resettable?
56
+ raise TypeError.new("This LazyGlobalRecord object is not resettable") unless resettable?
55
57
  @slot.set( create_delay )
56
58
  end
57
59
 
@@ -1155,3 +1155,498 @@ LazyGlobalRecordTest: test_it_does_allow_reset_when_allowed
1155
1155
   (0.0ms) RELEASE SAVEPOINT active_record_1
1156
1156
  Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 2]]
1157
1157
   (0.5ms) rollback transaction
1158
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
1159
+  (0.1ms) begin transaction
1160
+ --------------------------------------------------------------------
1161
+ LazyGlobalRecordTest: test_it_creates_a_record_when_creation_allowed
1162
+ --------------------------------------------------------------------
1163
+  (0.1ms) SAVEPOINT active_record_1
1164
+ Value Load (0.4ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "three"]]
1165
+ SQL (0.6ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "three"], ["created_at", "2016-03-01 18:00:20.552514"], ["updated_at", "2016-03-01 18:00:20.552514"]]
1166
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1167
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 1]]
1168
+  (0.4ms) rollback transaction
1169
+  (0.1ms) begin transaction
1170
+ -------------------------------------------------------------------
1171
+ LazyGlobalRecordTest: test_it_does_not_allow_reset_when_not_allowed
1172
+ -------------------------------------------------------------------
1173
+  (0.0ms) SAVEPOINT active_record_1
1174
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "four"]]
1175
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "four"], ["created_at", "2016-03-01 18:00:20.557594"], ["updated_at", "2016-03-01 18:00:20.557594"]]
1176
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1177
+  (0.3ms) rollback transaction
1178
+  (0.0ms) begin transaction
1179
+ ---------------------------------------------------------
1180
+ LazyGlobalRecordTest: test_raises_on_exceptions_in_filter
1181
+ ---------------------------------------------------------
1182
+  (0.0ms) SAVEPOINT active_record_1
1183
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1184
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "one"], ["created_at", "2016-03-01 18:00:20.560124"], ["updated_at", "2016-03-01 18:00:20.560124"]]
1185
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
1186
+  (0.3ms) rollback transaction
1187
+  (0.1ms) begin transaction
1188
+ -----------------------------------------------------------
1189
+ LazyGlobalRecordTest: test_it_does_allow_reset_when_allowed
1190
+ -----------------------------------------------------------
1191
+  (0.1ms) SAVEPOINT active_record_1
1192
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "five"], ["other_value", "first"], ["created_at", "2016-03-01 18:00:20.562271"], ["updated_at", "2016-03-01 18:00:20.562271"]]
1193
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1194
+  (0.0ms) SAVEPOINT active_record_1
1195
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "five"]]
1196
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1197
+ SQL (0.0ms) DELETE FROM "values"
1198
+  (0.0ms) SAVEPOINT active_record_1
1199
+ SQL (0.5ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "five"], ["other_value", "second"], ["created_at", "2016-03-01 18:00:20.564327"], ["updated_at", "2016-03-01 18:00:20.564327"]]
1200
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1201
+  (0.0ms) SAVEPOINT active_record_1
1202
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "five"]]
1203
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1204
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 2]]
1205
+  (0.5ms) rollback transaction
1206
+  (0.1ms) begin transaction
1207
+ ----------------------------------------
1208
+ LazyGlobalRecordTest: test_custom_filter
1209
+ ----------------------------------------
1210
+  (0.0ms) SAVEPOINT active_record_1
1211
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "seven"], ["other_value", "treasure"], ["created_at", "2016-03-01 18:00:20.567862"], ["updated_at", "2016-03-01 18:00:20.567862"]]
1212
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1213
+  (0.0ms) SAVEPOINT active_record_1
1214
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "seven"]]
1215
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1216
+  (0.3ms) rollback transaction
1217
+  (0.0ms) begin transaction
1218
+ -------------------------------------------------------
1219
+ LazyGlobalRecordTest: test_it_uses_custom_creation_proc
1220
+ -------------------------------------------------------
1221
+  (0.0ms) SAVEPOINT active_record_1
1222
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "six"]]
1223
+ SQL (0.2ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "six"], ["other_value", "manual"], ["created_at", "2016-03-01 18:00:20.571096"], ["updated_at", "2016-03-01 18:00:20.571096"]]
1224
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1225
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 1]]
1226
+  (0.4ms) rollback transaction
1227
+  (0.1ms) begin transaction
1228
+ ---------------------------------------------------------------------------
1229
+ LazyGlobalRecordTest: test_it_raises_on_no_record_when_creation_not_allowed
1230
+ ---------------------------------------------------------------------------
1231
+  (0.0ms) SAVEPOINT active_record_1
1232
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "two"]]
1233
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1234
+  (0.0ms) rollback transaction
1235
+  (0.0ms) begin transaction
1236
+ ---------------------------------------------------
1237
+ LazyGlobalRecordTest: test_it_returns_id_by_default
1238
+ ---------------------------------------------------
1239
+  (0.0ms) SAVEPOINT active_record_1
1240
+ SQL (0.4ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "one"], ["created_at", "2016-03-01 18:00:20.574683"], ["updated_at", "2016-03-01 18:00:20.574683"]]
1241
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1242
+  (0.1ms) SAVEPOINT active_record_1
1243
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1244
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1245
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1246
+  (0.4ms) rollback transaction
1247
+  (0.1ms) begin transaction
1248
+ -----------------------------------------------------------------------
1249
+ LazyGlobalRecordTest: test_raises_an_exception_if_exceptions_are_raised
1250
+ -----------------------------------------------------------------------
1251
+  (0.0ms) SAVEPOINT active_record_1
1252
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1253
+  (0.0ms) SAVEPOINT active_record_1
1254
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "nonesuch"]]
1255
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1256
+  (0.0ms) rollback transaction
1257
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1258
+  (0.1ms) begin transaction
1259
+ --------------------------------------------------------------------
1260
+ LazyGlobalRecordTest: test_it_creates_a_record_when_creation_allowed
1261
+ --------------------------------------------------------------------
1262
+  (0.0ms) SAVEPOINT active_record_1
1263
+ Value Load (0.2ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "three"]]
1264
+ SQL (0.3ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "three"], ["created_at", "2016-03-01 18:00:40.630182"], ["updated_at", "2016-03-01 18:00:40.630182"]]
1265
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1266
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 1]]
1267
+  (1.3ms) rollback transaction
1268
+  (0.1ms) begin transaction
1269
+ -------------------------------------------------------------------
1270
+ LazyGlobalRecordTest: test_it_does_not_allow_reset_when_not_allowed
1271
+ -------------------------------------------------------------------
1272
+  (0.0ms) SAVEPOINT active_record_1
1273
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "four"]]
1274
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "four"], ["created_at", "2016-03-01 18:00:40.635501"], ["updated_at", "2016-03-01 18:00:40.635501"]]
1275
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1276
+  (0.3ms) rollback transaction
1277
+  (0.1ms) begin transaction
1278
+ ---------------------------------------------------------
1279
+ LazyGlobalRecordTest: test_raises_on_exceptions_in_filter
1280
+ ---------------------------------------------------------
1281
+  (0.0ms) SAVEPOINT active_record_1
1282
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1283
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "one"], ["created_at", "2016-03-01 18:00:40.638030"], ["updated_at", "2016-03-01 18:00:40.638030"]]
1284
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
1285
+  (0.3ms) rollback transaction
1286
+  (0.1ms) begin transaction
1287
+ -----------------------------------------------------------------------
1288
+ LazyGlobalRecordTest: test_raises_an_exception_if_exceptions_are_raised
1289
+ -----------------------------------------------------------------------
1290
+  (0.0ms) SAVEPOINT active_record_1
1291
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1292
+  (0.1ms) SAVEPOINT active_record_1
1293
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "nonesuch"]]
1294
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1295
+  (0.0ms) rollback transaction
1296
+  (0.0ms) begin transaction
1297
+ ---------------------------------------------------
1298
+ LazyGlobalRecordTest: test_it_returns_id_by_default
1299
+ ---------------------------------------------------
1300
+  (0.0ms) SAVEPOINT active_record_1
1301
+ SQL (0.4ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "one"], ["created_at", "2016-03-01 18:00:40.641708"], ["updated_at", "2016-03-01 18:00:40.641708"]]
1302
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1303
+  (0.0ms) SAVEPOINT active_record_1
1304
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1305
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1306
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1307
+  (0.4ms) rollback transaction
1308
+  (0.1ms) begin transaction
1309
+ ---------------------------------------------------------------------------
1310
+ LazyGlobalRecordTest: test_it_raises_on_no_record_when_creation_not_allowed
1311
+ ---------------------------------------------------------------------------
1312
+  (0.0ms) SAVEPOINT active_record_1
1313
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "two"]]
1314
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1315
+  (0.0ms) rollback transaction
1316
+  (0.1ms) begin transaction
1317
+ -----------------------------------------------------------
1318
+ LazyGlobalRecordTest: test_it_does_allow_reset_when_allowed
1319
+ -----------------------------------------------------------
1320
+  (0.0ms) SAVEPOINT active_record_1
1321
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "five"], ["other_value", "first"], ["created_at", "2016-03-01 18:00:40.646657"], ["updated_at", "2016-03-01 18:00:40.646657"]]
1322
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1323
+  (0.0ms) SAVEPOINT active_record_1
1324
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "five"]]
1325
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1326
+ SQL (0.0ms) DELETE FROM "values"
1327
+  (0.0ms) SAVEPOINT active_record_1
1328
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "five"], ["other_value", "second"], ["created_at", "2016-03-01 18:00:40.648809"], ["updated_at", "2016-03-01 18:00:40.648809"]]
1329
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1330
+  (0.0ms) SAVEPOINT active_record_1
1331
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "five"]]
1332
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1333
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 2]]
1334
+  (0.7ms) rollback transaction
1335
+  (0.0ms) begin transaction
1336
+ -------------------------------------------------------
1337
+ LazyGlobalRecordTest: test_it_uses_custom_creation_proc
1338
+ -------------------------------------------------------
1339
+  (0.1ms) SAVEPOINT active_record_1
1340
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "six"]]
1341
+ SQL (0.2ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "six"], ["other_value", "manual"], ["created_at", "2016-03-01 18:00:40.652769"], ["updated_at", "2016-03-01 18:00:40.652769"]]
1342
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1343
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 1]]
1344
+  (0.4ms) rollback transaction
1345
+  (0.1ms) begin transaction
1346
+ ----------------------------------------
1347
+ LazyGlobalRecordTest: test_custom_filter
1348
+ ----------------------------------------
1349
+  (0.0ms) SAVEPOINT active_record_1
1350
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "seven"], ["other_value", "treasure"], ["created_at", "2016-03-01 18:00:40.655919"], ["updated_at", "2016-03-01 18:00:40.655919"]]
1351
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1352
+  (0.1ms) SAVEPOINT active_record_1
1353
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "seven"]]
1354
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1355
+  (0.4ms) rollback transaction
1356
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
1357
+  (0.1ms) begin transaction
1358
+ ---------------------------------------------------
1359
+ LazyGlobalRecordTest: test_it_returns_id_by_default
1360
+ ---------------------------------------------------
1361
+  (0.1ms) SAVEPOINT active_record_1
1362
+ SQL (0.9ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "one"], ["created_at", "2016-03-02 17:38:49.834874"], ["updated_at", "2016-03-02 17:38:49.834874"]]
1363
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1364
+  (0.0ms) SAVEPOINT active_record_1
1365
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1366
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1367
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1368
+  (0.4ms) rollback transaction
1369
+  (0.1ms) begin transaction
1370
+ --------------------------------------------------------------------
1371
+ LazyGlobalRecordTest: test_it_creates_a_record_when_creation_allowed
1372
+ --------------------------------------------------------------------
1373
+  (0.0ms) SAVEPOINT active_record_1
1374
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "three"]]
1375
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "three"], ["created_at", "2016-03-02 17:38:49.847644"], ["updated_at", "2016-03-02 17:38:49.847644"]]
1376
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1377
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 1]]
1378
+  (0.4ms) rollback transaction
1379
+  (0.1ms) begin transaction
1380
+ -------------------------------------------------------------------
1381
+ LazyGlobalRecordTest: test_it_does_not_allow_reset_when_not_allowed
1382
+ -------------------------------------------------------------------
1383
+  (0.0ms) SAVEPOINT active_record_1
1384
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "four"]]
1385
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "four"], ["created_at", "2016-03-02 17:38:49.852844"], ["updated_at", "2016-03-02 17:38:49.852844"]]
1386
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1387
+  (0.4ms) rollback transaction
1388
+  (0.1ms) begin transaction
1389
+ ---------------------------------------------------------
1390
+ LazyGlobalRecordTest: test_raises_on_exceptions_in_filter
1391
+ ---------------------------------------------------------
1392
+  (0.0ms) SAVEPOINT active_record_1
1393
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1394
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "one"], ["created_at", "2016-03-02 17:38:49.855708"], ["updated_at", "2016-03-02 17:38:49.855708"]]
1395
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1396
+  (0.4ms) rollback transaction
1397
+  (0.0ms) begin transaction
1398
+ ----------------------------------------
1399
+ LazyGlobalRecordTest: test_custom_filter
1400
+ ----------------------------------------
1401
+  (0.0ms) SAVEPOINT active_record_1
1402
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "seven"], ["other_value", "treasure"], ["created_at", "2016-03-02 17:38:49.857922"], ["updated_at", "2016-03-02 17:38:49.857922"]]
1403
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1404
+  (0.0ms) SAVEPOINT active_record_1
1405
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "seven"]]
1406
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1407
+  (0.4ms) rollback transaction
1408
+  (0.1ms) begin transaction
1409
+ -----------------------------------------------------------------------
1410
+ LazyGlobalRecordTest: test_raises_an_exception_if_exceptions_are_raised
1411
+ -----------------------------------------------------------------------
1412
+  (0.0ms) SAVEPOINT active_record_1
1413
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1414
+  (0.1ms) SAVEPOINT active_record_1
1415
+ Value Load (0.2ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "nonesuch"]]
1416
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
1417
+  (0.1ms) rollback transaction
1418
+  (0.1ms) begin transaction
1419
+ -------------------------------------------------------
1420
+ LazyGlobalRecordTest: test_it_uses_custom_creation_proc
1421
+ -------------------------------------------------------
1422
+  (0.0ms) SAVEPOINT active_record_1
1423
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "six"]]
1424
+ SQL (0.2ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "six"], ["other_value", "manual"], ["created_at", "2016-03-02 17:38:49.864812"], ["updated_at", "2016-03-02 17:38:49.864812"]]
1425
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1426
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 1]]
1427
+  (0.4ms) rollback transaction
1428
+  (0.0ms) begin transaction
1429
+ ---------------------------------------------------------------------------
1430
+ LazyGlobalRecordTest: test_it_raises_on_no_record_when_creation_not_allowed
1431
+ ---------------------------------------------------------------------------
1432
+  (0.0ms) SAVEPOINT active_record_1
1433
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "two"]]
1434
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1435
+  (0.0ms) rollback transaction
1436
+  (0.2ms) begin transaction
1437
+ -----------------------------------------------------------
1438
+ LazyGlobalRecordTest: test_it_does_allow_reset_when_allowed
1439
+ -----------------------------------------------------------
1440
+  (0.1ms) SAVEPOINT active_record_1
1441
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "five"], ["other_value", "first"], ["created_at", "2016-03-02 17:38:49.869017"], ["updated_at", "2016-03-02 17:38:49.869017"]]
1442
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1443
+  (0.0ms) SAVEPOINT active_record_1
1444
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "five"]]
1445
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1446
+ SQL (0.0ms) DELETE FROM "values"
1447
+  (0.0ms) SAVEPOINT active_record_1
1448
+ SQL (0.4ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "five"], ["other_value", "second"], ["created_at", "2016-03-02 17:38:49.871797"], ["updated_at", "2016-03-02 17:38:49.871797"]]
1449
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1450
+  (0.1ms) SAVEPOINT active_record_1
1451
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "five"]]
1452
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1453
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 2]]
1454
+  (0.6ms) rollback transaction
1455
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1456
+  (0.1ms) begin transaction
1457
+ ---------------------------------------------------
1458
+ LazyGlobalRecordTest: test_it_returns_id_by_default
1459
+ ---------------------------------------------------
1460
+  (0.0ms) SAVEPOINT active_record_1
1461
+ SQL (0.3ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "one"], ["created_at", "2016-03-02 17:41:10.695871"], ["updated_at", "2016-03-02 17:41:10.695871"]]
1462
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1463
+  (0.0ms) SAVEPOINT active_record_1
1464
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1465
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1466
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1467
+  (1.2ms) rollback transaction
1468
+  (0.1ms) begin transaction
1469
+ --------------------------------------------------------------------
1470
+ LazyGlobalRecordTest: test_it_creates_a_record_when_creation_allowed
1471
+ --------------------------------------------------------------------
1472
+  (0.0ms) SAVEPOINT active_record_1
1473
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "three"]]
1474
+ SQL (0.3ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "three"], ["created_at", "2016-03-02 17:41:10.705471"], ["updated_at", "2016-03-02 17:41:10.705471"]]
1475
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1476
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 1]]
1477
+  (0.3ms) rollback transaction
1478
+  (0.1ms) begin transaction
1479
+ ---------------------------------------------------------
1480
+ LazyGlobalRecordTest: test_raises_on_exceptions_in_filter
1481
+ ---------------------------------------------------------
1482
+  (0.1ms) SAVEPOINT active_record_1
1483
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1484
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "one"], ["created_at", "2016-03-02 17:41:10.710122"], ["updated_at", "2016-03-02 17:41:10.710122"]]
1485
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
1486
+  (0.3ms) rollback transaction
1487
+  (0.1ms) begin transaction
1488
+ -------------------------------------------------------------------
1489
+ LazyGlobalRecordTest: test_it_does_not_allow_reset_when_not_allowed
1490
+ -------------------------------------------------------------------
1491
+  (0.0ms) SAVEPOINT active_record_1
1492
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "four"]]
1493
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "four"], ["created_at", "2016-03-02 17:41:10.712892"], ["updated_at", "2016-03-02 17:41:10.712892"]]
1494
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1495
+  (0.3ms) rollback transaction
1496
+  (0.1ms) begin transaction
1497
+ ----------------------------------------
1498
+ LazyGlobalRecordTest: test_custom_filter
1499
+ ----------------------------------------
1500
+  (0.0ms) SAVEPOINT active_record_1
1501
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "seven"], ["other_value", "treasure"], ["created_at", "2016-03-02 17:41:10.714983"], ["updated_at", "2016-03-02 17:41:10.714983"]]
1502
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1503
+  (0.0ms) SAVEPOINT active_record_1
1504
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "seven"]]
1505
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1506
+  (0.4ms) rollback transaction
1507
+  (0.0ms) begin transaction
1508
+ ---------------------------------------------------------------------------
1509
+ LazyGlobalRecordTest: test_it_raises_on_no_record_when_creation_not_allowed
1510
+ ---------------------------------------------------------------------------
1511
+  (0.0ms) SAVEPOINT active_record_1
1512
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "two"]]
1513
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1514
+  (0.0ms) rollback transaction
1515
+  (0.0ms) begin transaction
1516
+ -------------------------------------------------------
1517
+ LazyGlobalRecordTest: test_it_uses_custom_creation_proc
1518
+ -------------------------------------------------------
1519
+  (0.0ms) SAVEPOINT active_record_1
1520
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "six"]]
1521
+ SQL (0.2ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "six"], ["other_value", "manual"], ["created_at", "2016-03-02 17:41:10.719480"], ["updated_at", "2016-03-02 17:41:10.719480"]]
1522
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1523
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 1]]
1524
+  (0.4ms) rollback transaction
1525
+  (0.1ms) begin transaction
1526
+ -----------------------------------------------------------------------
1527
+ LazyGlobalRecordTest: test_raises_an_exception_if_exceptions_are_raised
1528
+ -----------------------------------------------------------------------
1529
+  (0.0ms) SAVEPOINT active_record_1
1530
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1531
+  (0.0ms) SAVEPOINT active_record_1
1532
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "nonesuch"]]
1533
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1534
+  (0.0ms) rollback transaction
1535
+  (0.1ms) begin transaction
1536
+ -----------------------------------------------------------
1537
+ LazyGlobalRecordTest: test_it_does_allow_reset_when_allowed
1538
+ -----------------------------------------------------------
1539
+  (0.1ms) SAVEPOINT active_record_1
1540
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "five"], ["other_value", "first"], ["created_at", "2016-03-02 17:41:10.723668"], ["updated_at", "2016-03-02 17:41:10.723668"]]
1541
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1542
+  (0.0ms) SAVEPOINT active_record_1
1543
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "five"]]
1544
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1545
+ SQL (0.0ms) DELETE FROM "values"
1546
+  (0.0ms) SAVEPOINT active_record_1
1547
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "five"], ["other_value", "second"], ["created_at", "2016-03-02 17:41:10.726118"], ["updated_at", "2016-03-02 17:41:10.726118"]]
1548
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1549
+  (0.0ms) SAVEPOINT active_record_1
1550
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "five"]]
1551
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1552
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 2]]
1553
+  (0.5ms) rollback transaction
1554
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1555
+  (0.1ms) begin transaction
1556
+ -------------------------------------------------------
1557
+ LazyGlobalRecordTest: test_it_uses_custom_creation_proc
1558
+ -------------------------------------------------------
1559
+  (0.0ms) SAVEPOINT active_record_1
1560
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "six"]]
1561
+ SQL (0.4ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "six"], ["other_value", "manual"], ["created_at", "2016-03-02 17:43:21.216628"], ["updated_at", "2016-03-02 17:43:21.216628"]]
1562
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1563
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 1]]
1564
+  (1.3ms) rollback transaction
1565
+  (0.1ms) begin transaction
1566
+ ---------------------------------------------------------
1567
+ LazyGlobalRecordTest: test_raises_on_exceptions_in_filter
1568
+ ---------------------------------------------------------
1569
+  (0.0ms) SAVEPOINT active_record_1
1570
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1571
+ SQL (0.3ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "one"], ["created_at", "2016-03-02 17:43:21.222139"], ["updated_at", "2016-03-02 17:43:21.222139"]]
1572
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
1573
+  (0.3ms) rollback transaction
1574
+  (0.0ms) begin transaction
1575
+ ---------------------------------------------------
1576
+ LazyGlobalRecordTest: test_it_returns_id_by_default
1577
+ ---------------------------------------------------
1578
+  (0.0ms) SAVEPOINT active_record_1
1579
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "one"], ["created_at", "2016-03-02 17:43:21.224342"], ["updated_at", "2016-03-02 17:43:21.224342"]]
1580
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1581
+  (0.0ms) SAVEPOINT active_record_1
1582
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1583
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1584
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "one"]]
1585
+  (0.3ms) rollback transaction
1586
+  (0.1ms) begin transaction
1587
+ -------------------------------------------------------------------
1588
+ LazyGlobalRecordTest: test_it_does_not_allow_reset_when_not_allowed
1589
+ -------------------------------------------------------------------
1590
+  (0.0ms) SAVEPOINT active_record_1
1591
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "four"]]
1592
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "four"], ["created_at", "2016-03-02 17:43:21.227808"], ["updated_at", "2016-03-02 17:43:21.227808"]]
1593
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1594
+  (0.4ms) rollback transaction
1595
+  (0.1ms) begin transaction
1596
+ ---------------------------------------------------------------------------
1597
+ LazyGlobalRecordTest: test_it_raises_on_no_record_when_creation_not_allowed
1598
+ ---------------------------------------------------------------------------
1599
+  (0.0ms) SAVEPOINT active_record_1
1600
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "two"]]
1601
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1602
+  (0.1ms) rollback transaction
1603
+  (0.0ms) begin transaction
1604
+ --------------------------------------------------------------------
1605
+ LazyGlobalRecordTest: test_it_creates_a_record_when_creation_allowed
1606
+ --------------------------------------------------------------------
1607
+  (0.0ms) SAVEPOINT active_record_1
1608
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "three"]]
1609
+ SQL (0.2ms) INSERT INTO "values" ("value", "created_at", "updated_at") VALUES (?, ?, ?) [["value", "three"], ["created_at", "2016-03-02 17:43:21.231774"], ["updated_at", "2016-03-02 17:43:21.231774"]]
1610
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1611
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 1]]
1612
+  (0.4ms) rollback transaction
1613
+  (0.1ms) begin transaction
1614
+ -----------------------------------------------------------------------
1615
+ LazyGlobalRecordTest: test_raises_an_exception_if_exceptions_are_raised
1616
+ -----------------------------------------------------------------------
1617
+  (0.0ms) SAVEPOINT active_record_1
1618
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1619
+  (0.0ms) SAVEPOINT active_record_1
1620
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "nonesuch"]]
1621
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
1622
+  (0.0ms) rollback transaction
1623
+  (0.0ms) begin transaction
1624
+ -----------------------------------------------------------
1625
+ LazyGlobalRecordTest: test_it_does_allow_reset_when_allowed
1626
+ -----------------------------------------------------------
1627
+  (0.0ms) SAVEPOINT active_record_1
1628
+ SQL (0.2ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "five"], ["other_value", "first"], ["created_at", "2016-03-02 17:43:21.235495"], ["updated_at", "2016-03-02 17:43:21.235495"]]
1629
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1630
+  (0.0ms) SAVEPOINT active_record_1
1631
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "five"]]
1632
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1633
+ SQL (0.0ms) DELETE FROM "values"
1634
+  (0.0ms) SAVEPOINT active_record_1
1635
+ SQL (0.3ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "five"], ["other_value", "second"], ["created_at", "2016-03-02 17:43:21.237476"], ["updated_at", "2016-03-02 17:43:21.237476"]]
1636
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1637
+  (0.0ms) SAVEPOINT active_record_1
1638
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "five"]]
1639
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1640
+ Value Load (0.0ms) SELECT "values".* FROM "values" WHERE "values"."id" = ? LIMIT 1 [["id", 2]]
1641
+  (0.8ms) rollback transaction
1642
+  (0.1ms) begin transaction
1643
+ ----------------------------------------
1644
+ LazyGlobalRecordTest: test_custom_filter
1645
+ ----------------------------------------
1646
+  (0.1ms) SAVEPOINT active_record_1
1647
+ SQL (0.4ms) INSERT INTO "values" ("value", "other_value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["value", "seven"], ["other_value", "treasure"], ["created_at", "2016-03-02 17:43:21.241562"], ["updated_at", "2016-03-02 17:43:21.241562"]]
1648
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1649
+  (0.0ms) SAVEPOINT active_record_1
1650
+ Value Load (0.1ms) SELECT "values".* FROM "values" WHERE "values"."value" = ? ORDER BY "values"."id" ASC LIMIT 1 [["value", "seven"]]
1651
+  (0.0ms) RELEASE SAVEPOINT active_record_1
1652
+  (0.4ms) rollback transaction
@@ -85,8 +85,12 @@ class LazyGlobalRecordTest < ActiveSupport::TestCase
85
85
  create_with: -> { raise ArgumentError.new("expected") }
86
86
  )
87
87
  assert_raise(ArgumentError) { lazy.value }
88
+
89
+ # and a second time please
90
+ assert_raise(ArgumentError) { lazy.value }
88
91
  end
89
92
 
93
+
90
94
  test "custom filter" do
91
95
  Value.create(:value => "seven", :other_value => "treasure")
92
96
  lazy = LazyGlobalRecord.new(
@@ -102,6 +106,16 @@ class LazyGlobalRecordTest < ActiveSupport::TestCase
102
106
  assert struct.id.present?
103
107
  assert_equal "treasure", struct.other_value
104
108
  assert_equal "more", struct.more
109
+ end
110
+
111
+ test "raises on exceptions in filter" do
112
+ lazy = LazyGlobalRecord.new(
113
+ relation: -> { Value.where(value: "one") },
114
+ filter: lambda { |original| raise ArgumentError, "intentional" }
115
+ )
105
116
 
117
+ assert_raise(ArgumentError) { value = lazy.value }
118
+ # and ensure a second time please
119
+ assert_raise(ArgumentError) { value = lazy.value }
106
120
  end
107
121
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_global_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friends of the Web
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.4.5.1
129
+ rubygems_version: 2.5.1
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: Lazy loading of 'interesting' ActiveRecord model id's, thread-safely and