switchman 1.2.13 → 1.2.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/switchman/active_record/persistence.rb +10 -0
- data/lib/switchman/engine.rb +24 -11
- data/lib/switchman/version.rb +1 -1
- data/spec/dummy/db/shard_895.sqlite3 +0 -0
- data/spec/dummy/db/shard_930.sqlite3 +0 -0
- data/spec/dummy/db/shard_953.sqlite3 +0 -0
- data/spec/dummy/db/shard_982.sqlite3 +0 -0
- data/spec/dummy/db/shard_988.sqlite3 +0 -0
- data/spec/dummy/log/development.log +7 -0
- data/spec/dummy/log/test.log +18064 -0
- data/spec/dummy/tmp/cache/350/F40/shard%2F916 +0 -0
- data/spec/dummy/tmp/cache/351/F50/shard%2F917 +0 -0
- data/spec/dummy/tmp/cache/351/F70/shard%2F935 +1 -0
- data/spec/dummy/tmp/cache/354/FD0/shard%2F965 +1 -0
- data/spec/dummy/tmp/cache/355/FD0/shard%2F957 +1 -0
- data/spec/dummy/tmp/cache/356/010/shard%2F985 +0 -0
- data/spec/dummy/tmp/cache/358/040/shard%2F996 +1 -0
- data/spec/dummy/tmp/cache/3AE/090/shard%2F10940 +1 -0
- data/spec/dummy/tmp/cache/3B2/0A0/shard%2F10917 +1 -0
- data/spec/dummy/tmp/cache/3B3/100/shard%2F10963 +1 -0
- data/spec/dummy/tmp/cache/3B8/170/shard%2F10986 +1 -0
- data/spec/lib/active_record/persistence_spec.rb +41 -0
- data/spec/lib/engine_spec.rb +14 -0
- metadata +39 -2
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1409002763.6297522:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1409003720.083852:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1409002871.117686:@value":nil
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1409005241.415301:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1409002870.992409:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1409002763.468243:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1409003719.886336:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1409005241.376394:@value":nil
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Switchman
|
4
|
+
module ActiveRecord
|
5
|
+
describe FinderMethods do
|
6
|
+
include RSpecHelper
|
7
|
+
|
8
|
+
class SqlMatches < Mocha::ParameterMatchers::Base
|
9
|
+
def initialize(parent)
|
10
|
+
@parent = parent
|
11
|
+
end
|
12
|
+
|
13
|
+
def matches?(available_parameters)
|
14
|
+
param = available_parameters.shift
|
15
|
+
return false unless param.respond_to?(:to_sql)
|
16
|
+
@parent.matches?([param.to_sql])
|
17
|
+
end
|
18
|
+
|
19
|
+
def mocha_inspect
|
20
|
+
"sql_matches(#{@parent.mocha_inspect})"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#touch" do
|
25
|
+
it "should touch on the correct shard" do
|
26
|
+
user = @shard1.activate { User.create! }
|
27
|
+
|
28
|
+
User.connection.expects(:update).never
|
29
|
+
# does not match the global id
|
30
|
+
argument = Not(SqlMatches.new(regexp_matches(/#{user.global_id.to_s}/)))
|
31
|
+
# but does match UPDATE <stuff> local_id
|
32
|
+
argument &= SqlMatches.new(regexp_matches(/UPDATE.*#{user.local_id}/))
|
33
|
+
# expects an update
|
34
|
+
@shard1.activate { User.connection.expects(:update).with(argument, anything, anything).once }
|
35
|
+
|
36
|
+
user.touch
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Switchman
|
4
|
+
describe Engine do
|
5
|
+
describe ".lookup_stores" do
|
6
|
+
it "should link strings to other entries" do
|
7
|
+
stores = Engine.lookup_stores('db1' => :memory_store, 'db2' => :memory_store, 'db3' => 'db1')
|
8
|
+
expect(stores['db1']).to be_a(::ActiveSupport::Cache::MemoryStore)
|
9
|
+
expect(stores['db1']).to equal stores['db3']
|
10
|
+
expect(stores['db1']).to_not equal stores['db2']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-08-
|
13
|
+
date: 2014-08-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/switchman/active_record/connection_pool.rb
|
145
145
|
- lib/switchman/active_record/finder_methods.rb
|
146
146
|
- lib/switchman/active_record/log_subscriber.rb
|
147
|
+
- lib/switchman/active_record/persistence.rb
|
147
148
|
- lib/switchman/active_record/postgresql_adapter.rb
|
148
149
|
- lib/switchman/active_record/query_cache.rb
|
149
150
|
- lib/switchman/active_record/query_methods.rb
|
@@ -222,6 +223,11 @@ files:
|
|
222
223
|
- spec/dummy/db/shard_753.sqlite3
|
223
224
|
- spec/dummy/db/shard_76.sqlite3
|
224
225
|
- spec/dummy/db/shard_802.sqlite3
|
226
|
+
- spec/dummy/db/shard_895.sqlite3
|
227
|
+
- spec/dummy/db/shard_930.sqlite3
|
228
|
+
- spec/dummy/db/shard_953.sqlite3
|
229
|
+
- spec/dummy/db/shard_982.sqlite3
|
230
|
+
- spec/dummy/db/shard_988.sqlite3
|
225
231
|
- spec/dummy/db/test.sqlite3
|
226
232
|
- spec/dummy/log/development.log
|
227
233
|
- spec/dummy/log/test.log
|
@@ -262,9 +268,12 @@ files:
|
|
262
268
|
- spec/dummy/tmp/cache/350/EB0/shard%2F349
|
263
269
|
- spec/dummy/tmp/cache/350/F00/shard%2F718
|
264
270
|
- spec/dummy/tmp/cache/350/F40/shard%2F592
|
271
|
+
- spec/dummy/tmp/cache/350/F40/shard%2F916
|
265
272
|
- spec/dummy/tmp/cache/351/F00/shard%2F386
|
266
273
|
- spec/dummy/tmp/cache/351/F10/shard%2F638
|
267
274
|
- spec/dummy/tmp/cache/351/F10/shard%2F719
|
275
|
+
- spec/dummy/tmp/cache/351/F50/shard%2F917
|
276
|
+
- spec/dummy/tmp/cache/351/F70/shard%2F935
|
268
277
|
- spec/dummy/tmp/cache/352/F10/shard%2F387
|
269
278
|
- spec/dummy/tmp/cache/352/F10/shard%2F468
|
270
279
|
- spec/dummy/tmp/cache/352/F30/shard%2F729
|
@@ -273,6 +282,10 @@ files:
|
|
273
282
|
- spec/dummy/tmp/cache/354/F50/shard%2F569
|
274
283
|
- spec/dummy/tmp/cache/354/F80/shard%2F677
|
275
284
|
- spec/dummy/tmp/cache/354/F90/shard%2F767
|
285
|
+
- spec/dummy/tmp/cache/354/FD0/shard%2F965
|
286
|
+
- spec/dummy/tmp/cache/355/FD0/shard%2F957
|
287
|
+
- spec/dummy/tmp/cache/356/010/shard%2F985
|
288
|
+
- spec/dummy/tmp/cache/358/040/shard%2F996
|
276
289
|
- spec/dummy/tmp/cache/358/FE0/shard%2F699
|
277
290
|
- spec/dummy/tmp/cache/3A5/EA0/shard%2F10004
|
278
291
|
- spec/dummy/tmp/cache/3A6/F40/shard%2F10410
|
@@ -293,6 +306,7 @@ files:
|
|
293
306
|
- spec/dummy/tmp/cache/3AD/F90/shard%2F10318
|
294
307
|
- spec/dummy/tmp/cache/3AD/FA0/shard%2F10246
|
295
308
|
- spec/dummy/tmp/cache/3AE/060/shard%2F10751
|
309
|
+
- spec/dummy/tmp/cache/3AE/090/shard%2F10940
|
296
310
|
- spec/dummy/tmp/cache/3AE/FF0/shard%2F10364
|
297
311
|
- spec/dummy/tmp/cache/3AF/030/shard%2F10635
|
298
312
|
- spec/dummy/tmp/cache/3B0/FE0/shard%2F10177
|
@@ -300,10 +314,13 @@ files:
|
|
300
314
|
- spec/dummy/tmp/cache/3B1/040/shard%2F10466
|
301
315
|
- spec/dummy/tmp/cache/3B1/090/shard%2F10673
|
302
316
|
- spec/dummy/tmp/cache/3B2/070/shard%2F10566
|
317
|
+
- spec/dummy/tmp/cache/3B2/0A0/shard%2F10917
|
303
318
|
- spec/dummy/tmp/cache/3B3/060/shard%2F10387
|
319
|
+
- spec/dummy/tmp/cache/3B3/100/shard%2F10963
|
304
320
|
- spec/dummy/tmp/cache/3B5/0B0/shard%2F10497
|
305
321
|
- spec/dummy/tmp/cache/3B6/100/shard%2F10696
|
306
322
|
- spec/dummy/tmp/cache/3B7/0E0/shard%2F10589
|
323
|
+
- spec/dummy/tmp/cache/3B8/170/shard%2F10986
|
307
324
|
- spec/dummy/tmp/cache/3BA/160/shard%2F10799
|
308
325
|
- spec/lib/action_controller/caching_spec.rb
|
309
326
|
- spec/lib/active_record/abstract_adapter_spec.rb
|
@@ -314,6 +331,7 @@ files:
|
|
314
331
|
- spec/lib/active_record/connection_handler_spec.rb
|
315
332
|
- spec/lib/active_record/connection_pool_spec.rb
|
316
333
|
- spec/lib/active_record/finder_methods_spec.rb
|
334
|
+
- spec/lib/active_record/persistence_spec.rb
|
317
335
|
- spec/lib/active_record/query_cache_spec.rb
|
318
336
|
- spec/lib/active_record/query_methods_spec.rb
|
319
337
|
- spec/lib/active_record/relation_spec.rb
|
@@ -321,6 +339,7 @@ files:
|
|
321
339
|
- spec/lib/connection_pool_proxy_spec.rb
|
322
340
|
- spec/lib/database_server_spec.rb
|
323
341
|
- spec/lib/default_shard_spec.rb
|
342
|
+
- spec/lib/engine_spec.rb
|
324
343
|
- spec/lib/r_spec_helper_spec.rb
|
325
344
|
- spec/lib/rails_spec.rb
|
326
345
|
- spec/lib/shackles_spec.rb
|
@@ -411,6 +430,11 @@ test_files:
|
|
411
430
|
- spec/dummy/db/shard_753.sqlite3
|
412
431
|
- spec/dummy/db/shard_76.sqlite3
|
413
432
|
- spec/dummy/db/shard_802.sqlite3
|
433
|
+
- spec/dummy/db/shard_895.sqlite3
|
434
|
+
- spec/dummy/db/shard_930.sqlite3
|
435
|
+
- spec/dummy/db/shard_953.sqlite3
|
436
|
+
- spec/dummy/db/shard_982.sqlite3
|
437
|
+
- spec/dummy/db/shard_988.sqlite3
|
414
438
|
- spec/dummy/db/test.sqlite3
|
415
439
|
- spec/dummy/log/development.log
|
416
440
|
- spec/dummy/log/test.log
|
@@ -452,9 +476,12 @@ test_files:
|
|
452
476
|
- spec/dummy/tmp/cache/350/EB0/shard%2F349
|
453
477
|
- spec/dummy/tmp/cache/350/F00/shard%2F718
|
454
478
|
- spec/dummy/tmp/cache/350/F40/shard%2F592
|
479
|
+
- spec/dummy/tmp/cache/350/F40/shard%2F916
|
455
480
|
- spec/dummy/tmp/cache/351/F00/shard%2F386
|
456
481
|
- spec/dummy/tmp/cache/351/F10/shard%2F638
|
457
482
|
- spec/dummy/tmp/cache/351/F10/shard%2F719
|
483
|
+
- spec/dummy/tmp/cache/351/F50/shard%2F917
|
484
|
+
- spec/dummy/tmp/cache/351/F70/shard%2F935
|
458
485
|
- spec/dummy/tmp/cache/352/F10/shard%2F387
|
459
486
|
- spec/dummy/tmp/cache/352/F10/shard%2F468
|
460
487
|
- spec/dummy/tmp/cache/352/F30/shard%2F729
|
@@ -463,6 +490,10 @@ test_files:
|
|
463
490
|
- spec/dummy/tmp/cache/354/F50/shard%2F569
|
464
491
|
- spec/dummy/tmp/cache/354/F80/shard%2F677
|
465
492
|
- spec/dummy/tmp/cache/354/F90/shard%2F767
|
493
|
+
- spec/dummy/tmp/cache/354/FD0/shard%2F965
|
494
|
+
- spec/dummy/tmp/cache/355/FD0/shard%2F957
|
495
|
+
- spec/dummy/tmp/cache/356/010/shard%2F985
|
496
|
+
- spec/dummy/tmp/cache/358/040/shard%2F996
|
466
497
|
- spec/dummy/tmp/cache/358/FE0/shard%2F699
|
467
498
|
- spec/dummy/tmp/cache/3A5/EA0/shard%2F10004
|
468
499
|
- spec/dummy/tmp/cache/3A6/F40/shard%2F10410
|
@@ -483,6 +514,7 @@ test_files:
|
|
483
514
|
- spec/dummy/tmp/cache/3AD/F90/shard%2F10318
|
484
515
|
- spec/dummy/tmp/cache/3AD/FA0/shard%2F10246
|
485
516
|
- spec/dummy/tmp/cache/3AE/060/shard%2F10751
|
517
|
+
- spec/dummy/tmp/cache/3AE/090/shard%2F10940
|
486
518
|
- spec/dummy/tmp/cache/3AE/FF0/shard%2F10364
|
487
519
|
- spec/dummy/tmp/cache/3AF/030/shard%2F10635
|
488
520
|
- spec/dummy/tmp/cache/3B0/FE0/shard%2F10177
|
@@ -490,10 +522,13 @@ test_files:
|
|
490
522
|
- spec/dummy/tmp/cache/3B1/040/shard%2F10466
|
491
523
|
- spec/dummy/tmp/cache/3B1/090/shard%2F10673
|
492
524
|
- spec/dummy/tmp/cache/3B2/070/shard%2F10566
|
525
|
+
- spec/dummy/tmp/cache/3B2/0A0/shard%2F10917
|
493
526
|
- spec/dummy/tmp/cache/3B3/060/shard%2F10387
|
527
|
+
- spec/dummy/tmp/cache/3B3/100/shard%2F10963
|
494
528
|
- spec/dummy/tmp/cache/3B5/0B0/shard%2F10497
|
495
529
|
- spec/dummy/tmp/cache/3B6/100/shard%2F10696
|
496
530
|
- spec/dummy/tmp/cache/3B7/0E0/shard%2F10589
|
531
|
+
- spec/dummy/tmp/cache/3B8/170/shard%2F10986
|
497
532
|
- spec/dummy/tmp/cache/3BA/160/shard%2F10799
|
498
533
|
- spec/lib/action_controller/caching_spec.rb
|
499
534
|
- spec/lib/active_record/abstract_adapter_spec.rb
|
@@ -504,6 +539,7 @@ test_files:
|
|
504
539
|
- spec/lib/active_record/connection_handler_spec.rb
|
505
540
|
- spec/lib/active_record/connection_pool_spec.rb
|
506
541
|
- spec/lib/active_record/finder_methods_spec.rb
|
542
|
+
- spec/lib/active_record/persistence_spec.rb
|
507
543
|
- spec/lib/active_record/query_cache_spec.rb
|
508
544
|
- spec/lib/active_record/query_methods_spec.rb
|
509
545
|
- spec/lib/active_record/relation_spec.rb
|
@@ -511,6 +547,7 @@ test_files:
|
|
511
547
|
- spec/lib/connection_pool_proxy_spec.rb
|
512
548
|
- spec/lib/database_server_spec.rb
|
513
549
|
- spec/lib/default_shard_spec.rb
|
550
|
+
- spec/lib/engine_spec.rb
|
514
551
|
- spec/lib/r_spec_helper_spec.rb
|
515
552
|
- spec/lib/rails_spec.rb
|
516
553
|
- spec/lib/shackles_spec.rb
|