switchman 1.0.0 → 1.2.0

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.
Files changed (288) hide show
  1. checksums.yaml +8 -8
  2. data/app/models/switchman/shard.rb +10 -3
  3. data/db/switchman_test.sqlite3 +0 -0
  4. data/lib/switchman/active_record/association.rb +36 -10
  5. data/lib/switchman/active_record/base.rb +9 -5
  6. data/lib/switchman/active_record/calculations.rb +12 -11
  7. data/lib/switchman/active_record/connection_handler.rb +102 -47
  8. data/lib/switchman/active_record/connection_pool.rb +3 -64
  9. data/lib/switchman/active_record/finder_methods.rb +1 -1
  10. data/lib/switchman/active_record/query_methods.rb +50 -25
  11. data/lib/switchman/active_record/relation.rb +5 -5
  12. data/lib/switchman/active_record/spawn_methods.rb +76 -29
  13. data/lib/switchman/connection_pool_proxy.rb +3 -1
  14. data/lib/switchman/database_server.rb +4 -2
  15. data/lib/switchman/engine.rb +8 -5
  16. data/lib/switchman/r_spec_helper.rb +14 -6
  17. data/lib/switchman/rails.rb +7 -9
  18. data/lib/switchman/test_helper.rb +4 -3
  19. data/lib/switchman/version.rb +1 -1
  20. data/spec/dummy/app/models/appendage.rb +2 -4
  21. data/spec/dummy/app/models/digit.rb +2 -4
  22. data/spec/dummy/app/models/feature.rb +0 -2
  23. data/spec/dummy/app/models/user.rb +0 -2
  24. data/spec/dummy/config/application.rb +0 -6
  25. data/spec/dummy/config/database.yml +10 -0
  26. data/spec/dummy/config/environments/development.rb +2 -9
  27. data/spec/dummy/config/environments/production.rb +2 -3
  28. data/spec/dummy/config/environments/test.rb +2 -11
  29. data/spec/dummy/config/routes.rb +2 -2
  30. data/spec/dummy/db/schema.rb +32 -29
  31. data/spec/dummy/db/switchman_test.sqlite3 +0 -0
  32. data/spec/dummy/log/development.log +23 -0
  33. data/spec/dummy/log/test.log +36056 -86392
  34. data/spec/dummy/tmp/cache/2E3/840/shard%2F3 +0 -0
  35. data/spec/dummy/tmp/cache/2E4/850/shard%2F4 +0 -0
  36. data/spec/dummy/tmp/cache/2E6/870/shard%2F6 +0 -0
  37. data/spec/dummy/tmp/cache/2E7/880/shard%2F7 +0 -0
  38. data/spec/dummy/tmp/cache/{346/D90/shard%2F105 → 313/970/shard%2F30} +1 -1
  39. data/spec/dummy/tmp/cache/314/990/shard%2F40 +0 -0
  40. data/spec/dummy/tmp/cache/{31C/A40/shard%2F75 → 315/970/shard%2F14} +1 -1
  41. data/spec/dummy/tmp/cache/315/9A0/shard%2F41 +0 -0
  42. data/spec/dummy/tmp/cache/315/9B0/shard%2F50 +0 -0
  43. data/spec/dummy/tmp/cache/317/9C0/shard%2F43 +0 -0
  44. data/spec/dummy/tmp/cache/318/9B0/shard%2F26 +0 -0
  45. data/spec/dummy/tmp/cache/318/9D0/shard%2F44 +0 -0
  46. data/spec/dummy/tmp/cache/319/9C0/shard%2F27 +0 -0
  47. data/spec/dummy/tmp/cache/31A/9F0/shard%2F46 +0 -0
  48. data/spec/dummy/tmp/cache/31C/A20/shard%2F57 +0 -0
  49. data/spec/dummy/tmp/cache/31D/A20/shard%2F49 +0 -0
  50. data/spec/dummy/tmp/cache/349/E10/shard%2F153 +0 -0
  51. data/spec/dummy/tmp/cache/34A/E20/shard%2F154 +0 -0
  52. data/spec/dummy/tmp/cache/{345/DC0/shard%2F140 → 34A/E50/shard%2F181} +1 -1
  53. data/spec/dummy/tmp/cache/{318/A00/shard%2F71 → 34E/E70/shard%2F167} +1 -1
  54. data/spec/dummy/tmp/cache/375/530/shard%2F3200 +1 -0
  55. data/spec/dummy/tmp/cache/376/510/shard%2F2202 +1 -0
  56. data/spec/dummy/tmp/cache/376/520/shard%2F2211 +1 -0
  57. data/spec/dummy/tmp/cache/376/530/shard%2F2220 +1 -0
  58. data/spec/dummy/tmp/cache/377/4F0/shard%2F2014 +0 -0
  59. data/spec/dummy/tmp/cache/377/520/shard%2F2203 +1 -0
  60. data/spec/dummy/tmp/cache/377/530/shard%2F2212 +1 -0
  61. data/spec/dummy/tmp/cache/377/550/shard%2F2230 +1 -0
  62. data/spec/dummy/tmp/cache/377/550/shard%2F3040 +1 -0
  63. data/spec/dummy/tmp/cache/378/500/shard%2F2015 +0 -0
  64. data/spec/dummy/tmp/cache/378/520/shard%2F3005 +1 -0
  65. data/spec/dummy/tmp/cache/378/550/shard%2F2222 +1 -0
  66. data/spec/dummy/tmp/cache/378/560/shard%2F3122 +1 -0
  67. data/spec/dummy/tmp/cache/378/5A0/shard%2F2510 +1 -0
  68. data/spec/dummy/tmp/cache/378/5B0/shard%2F2600 +2 -0
  69. data/spec/dummy/tmp/cache/379/530/shard%2F3006 +1 -0
  70. data/spec/dummy/tmp/cache/379/540/shard%2F2205 +1 -0
  71. data/spec/dummy/tmp/cache/379/550/shard%2F2214 +1 -0
  72. data/spec/dummy/tmp/cache/379/560/shard%2F2223 +1 -0
  73. data/spec/dummy/tmp/cache/379/560/shard%2F3033 +1 -0
  74. data/spec/dummy/tmp/cache/379/560/shard%2F3114 +1 -0
  75. data/spec/dummy/tmp/cache/379/570/shard%2F3042 +1 -0
  76. data/spec/dummy/tmp/cache/379/580/shard%2F3051 +1 -0
  77. data/spec/dummy/tmp/cache/379/590/shard%2F3060 +1 -0
  78. data/spec/dummy/tmp/cache/379/5C0/shard%2F2601 +2 -0
  79. data/spec/dummy/tmp/cache/379/5D0/shard%2F2610 +2 -0
  80. data/spec/dummy/tmp/cache/37A/540/shard%2F3007 +1 -0
  81. data/spec/dummy/tmp/cache/37A/570/shard%2F2224 +1 -0
  82. data/spec/dummy/tmp/cache/37A/570/shard%2F3034 +1 -0
  83. data/spec/dummy/tmp/cache/37A/580/shard%2F3043 +1 -0
  84. data/spec/dummy/tmp/cache/37A/590/shard%2F3052 +1 -0
  85. data/spec/dummy/tmp/cache/37A/590/shard%2F3214 +1 -0
  86. data/spec/dummy/tmp/cache/37A/5A0/shard%2F3061 +1 -0
  87. data/spec/dummy/tmp/cache/37A/5B0/shard%2F3070 +1 -0
  88. data/spec/dummy/tmp/cache/37A/5E0/shard%2F2530 +0 -0
  89. data/spec/dummy/tmp/cache/37A/5F0/shard%2F2701 +0 -0
  90. data/spec/dummy/tmp/cache/37B/540/shard%2F2027 +1 -0
  91. data/spec/dummy/tmp/cache/37B/570/shard%2F3026 +1 -0
  92. data/spec/dummy/tmp/cache/37B/5C0/shard%2F2261 +1 -0
  93. data/spec/dummy/tmp/cache/37B/5C0/shard%2F2504 +1 -0
  94. data/spec/dummy/tmp/cache/37B/5C0/shard%2F3152 +1 -0
  95. data/spec/dummy/tmp/cache/37B/5D0/shard%2F2513 +1 -0
  96. data/spec/dummy/tmp/cache/37B/5E0/shard%2F2603 +2 -0
  97. data/spec/dummy/tmp/cache/37B/5F0/shard%2F2531 +0 -0
  98. data/spec/dummy/tmp/cache/37B/5F0/shard%2F2612 +2 -0
  99. data/spec/dummy/tmp/cache/37B/610/shard%2F2630 +2 -0
  100. data/spec/dummy/tmp/cache/37B/630/shard%2F2810 +2 -0
  101. data/spec/dummy/tmp/cache/37C/580/shard%2F2217 +1 -0
  102. data/spec/dummy/tmp/cache/37C/580/shard%2F3108 +1 -0
  103. data/spec/dummy/tmp/cache/37C/590/shard%2F3036 +1 -0
  104. data/spec/dummy/tmp/cache/37C/5A0/shard%2F3045 +1 -0
  105. data/spec/dummy/tmp/cache/37C/5B0/shard%2F3054 +1 -0
  106. data/spec/dummy/tmp/cache/37C/5C0/shard%2F3063 +1 -0
  107. data/spec/dummy/tmp/cache/37C/5D0/shard%2F2262 +1 -0
  108. data/spec/dummy/tmp/cache/37C/5D0/shard%2F3072 +0 -0
  109. data/spec/dummy/tmp/cache/37C/5E0/shard%2F2190 +1 -0
  110. data/spec/dummy/tmp/cache/37C/5F0/shard%2F2604 +2 -0
  111. data/spec/dummy/tmp/cache/37C/600/shard%2F2370 +1 -0
  112. data/spec/dummy/tmp/cache/37C/600/shard%2F2613 +2 -0
  113. data/spec/dummy/tmp/cache/37C/620/shard%2F2631 +2 -0
  114. data/spec/dummy/tmp/cache/37D/5A0/shard%2F3037 +1 -0
  115. data/spec/dummy/tmp/cache/37D/5B0/shard%2F3046 +1 -0
  116. data/spec/dummy/tmp/cache/37D/5C0/shard%2F3055 +1 -0
  117. data/spec/dummy/tmp/cache/37D/5D0/shard%2F2254 +1 -0
  118. data/spec/dummy/tmp/cache/37D/5D0/shard%2F3064 +1 -0
  119. data/spec/dummy/tmp/cache/37D/5E0/shard%2F3073 +1 -0
  120. data/spec/dummy/tmp/cache/37D/5F0/shard%2F2191 +1 -0
  121. data/spec/dummy/tmp/cache/37D/600/shard%2F2524 +1 -0
  122. data/spec/dummy/tmp/cache/37D/610/shard%2F2371 +1 -0
  123. data/spec/dummy/tmp/cache/37D/620/shard%2F2380 +1 -0
  124. data/spec/dummy/tmp/cache/37D/620/shard%2F2461 +1 -0
  125. data/spec/dummy/tmp/cache/37D/630/shard%2F2470 +1 -0
  126. data/spec/dummy/tmp/cache/37D/650/shard%2F2650 +0 -0
  127. data/spec/dummy/tmp/cache/37E/5B0/shard%2F2228 +1 -0
  128. data/spec/dummy/tmp/cache/37E/5D0/shard%2F3137 +1 -0
  129. data/spec/dummy/tmp/cache/37E/5F0/shard%2F2264 +1 -0
  130. data/spec/dummy/tmp/cache/37E/610/shard%2F2525 +1 -0
  131. data/spec/dummy/tmp/cache/37E/610/shard%2F2606 +2 -0
  132. data/spec/dummy/tmp/cache/37E/620/shard%2F2615 +2 -0
  133. data/spec/dummy/tmp/cache/37E/620/shard%2F3182 +0 -0
  134. data/spec/dummy/tmp/cache/37E/630/shard%2F2624 +2 -0
  135. data/spec/dummy/tmp/cache/37E/630/shard%2F2705 +1 -0
  136. data/spec/dummy/tmp/cache/37E/640/shard%2F2633 +0 -0
  137. data/spec/dummy/tmp/cache/37E/650/shard%2F2723 +1 -0
  138. data/spec/dummy/tmp/cache/37F/5C0/shard%2F2229 +1 -0
  139. data/spec/dummy/tmp/cache/37F/5C0/shard%2F3039 +1 -0
  140. data/spec/dummy/tmp/cache/37F/5E0/shard%2F3057 +1 -0
  141. data/spec/dummy/tmp/cache/37F/5F0/shard%2F3066 +1 -0
  142. data/spec/dummy/tmp/cache/37F/600/shard%2F3075 +1 -0
  143. data/spec/dummy/tmp/cache/37F/610/shard%2F2193 +1 -0
  144. data/spec/dummy/tmp/cache/37F/620/shard%2F2607 +2 -0
  145. data/spec/dummy/tmp/cache/37F/620/shard%2F3093 +1 -0
  146. data/spec/dummy/tmp/cache/37F/630/shard%2F2373 +1 -0
  147. data/spec/dummy/tmp/cache/37F/630/shard%2F2535 +0 -0
  148. data/spec/dummy/tmp/cache/37F/630/shard%2F2616 +2 -0
  149. data/spec/dummy/tmp/cache/37F/640/shard%2F2382 +1 -0
  150. data/spec/dummy/tmp/cache/37F/640/shard%2F2625 +2 -0
  151. data/spec/dummy/tmp/cache/37F/650/shard%2F2634 +0 -0
  152. data/spec/dummy/tmp/cache/380/5F0/shard%2F3058 +1 -0
  153. data/spec/dummy/tmp/cache/380/600/shard%2F3067 +1 -0
  154. data/spec/dummy/tmp/cache/380/600/shard%2F3148 +0 -0
  155. data/spec/dummy/tmp/cache/380/610/shard%2F2509 +1 -0
  156. data/spec/dummy/tmp/cache/380/610/shard%2F3076 +1 -0
  157. data/spec/dummy/tmp/cache/380/630/shard%2F2527 +1 -0
  158. data/spec/dummy/tmp/cache/380/640/shard%2F2374 +1 -0
  159. data/spec/dummy/tmp/cache/380/640/shard%2F2536 +0 -0
  160. data/spec/dummy/tmp/cache/380/660/shard%2F2473 +1 -0
  161. data/spec/dummy/tmp/cache/380/670/shard%2F2482 +1 -0
  162. data/spec/dummy/tmp/cache/380/670/shard%2F2806 +2 -0
  163. data/spec/dummy/tmp/cache/{2E9/8A0/shard%2F9 → 380/680/shard%2F2653} +1 -1
  164. data/spec/dummy/tmp/cache/380/6A0/shard%2F2671 +1 -0
  165. data/spec/dummy/tmp/cache/380/6A0/shard%2F2752 +2 -0
  166. data/spec/dummy/tmp/cache/380/6B0/shard%2F2761 +2 -0
  167. data/spec/dummy/tmp/cache/381/600/shard%2F2249 +1 -0
  168. data/spec/dummy/tmp/cache/381/610/shard%2F3149 +0 -0
  169. data/spec/dummy/tmp/cache/381/640/shard%2F2609 +2 -0
  170. data/spec/dummy/tmp/cache/381/640/shard%2F3095 +0 -0
  171. data/spec/dummy/tmp/cache/381/650/shard%2F3185 +1 -0
  172. data/spec/dummy/tmp/cache/381/660/shard%2F2627 +2 -0
  173. data/spec/dummy/tmp/cache/381/670/shard%2F2636 +1 -0
  174. data/spec/dummy/tmp/cache/381/680/shard%2F2807 +2 -0
  175. data/spec/dummy/tmp/cache/381/690/shard%2F2573 +1 -0
  176. data/spec/dummy/tmp/cache/381/6B0/shard%2F2591 +2 -0
  177. data/spec/dummy/tmp/cache/381/6B0/shard%2F2753 +2 -0
  178. data/spec/dummy/tmp/cache/381/6F0/shard%2F2870 +1 -0
  179. data/spec/dummy/tmp/cache/382/620/shard%2F3069 +1 -0
  180. data/spec/dummy/tmp/cache/382/640/shard%2F2196 +1 -0
  181. data/spec/dummy/tmp/cache/382/650/shard%2F3096 +0 -0
  182. data/spec/dummy/tmp/cache/382/650/shard%2F3177 +1 -0
  183. data/spec/dummy/tmp/cache/382/660/shard%2F2376 +1 -0
  184. data/spec/dummy/tmp/cache/382/670/shard%2F2628 +2 -0
  185. data/spec/dummy/tmp/cache/382/6A0/shard%2F2493 +1 -0
  186. data/spec/dummy/tmp/cache/382/6C0/shard%2F2592 +2 -0
  187. data/spec/dummy/tmp/cache/382/6C0/shard%2F2835 +1 -0
  188. data/spec/dummy/tmp/cache/383/650/shard%2F2197 +1 -0
  189. data/spec/dummy/tmp/cache/383/670/shard%2F2377 +1 -0
  190. data/spec/dummy/tmp/cache/383/670/shard%2F2458 +1 -0
  191. data/spec/dummy/tmp/cache/383/680/shard%2F2548 +1 -0
  192. data/spec/dummy/tmp/cache/383/690/shard%2F2476 +1 -0
  193. data/spec/dummy/tmp/cache/383/6A0/shard%2F2809 +2 -0
  194. data/spec/dummy/tmp/cache/383/6C0/shard%2F2746 +1 -0
  195. data/spec/dummy/tmp/cache/383/6D0/shard%2F2755 +2 -0
  196. data/spec/dummy/tmp/cache/383/6E0/shard%2F2764 +2 -0
  197. data/spec/dummy/tmp/cache/383/700/shard%2F2782 +2 -0
  198. data/spec/dummy/tmp/cache/383/700/shard%2F2863 +1 -0
  199. data/spec/dummy/tmp/cache/384/6A0/shard%2F2477 +1 -0
  200. data/spec/dummy/tmp/cache/384/6E0/shard%2F2594 +2 -0
  201. data/spec/dummy/tmp/cache/384/6E0/shard%2F2756 +2 -0
  202. data/spec/dummy/tmp/cache/384/6F0/shard%2F2684 +0 -0
  203. data/spec/dummy/tmp/cache/384/6F0/shard%2F2765 +2 -0
  204. data/spec/dummy/tmp/cache/384/710/shard%2F2864 +1 -0
  205. data/spec/dummy/tmp/cache/384/720/shard%2F2873 +1 -0
  206. data/spec/dummy/tmp/cache/385/670/shard%2F2199 +1 -0
  207. data/spec/dummy/tmp/cache/385/690/shard%2F2379 +1 -0
  208. data/spec/dummy/tmp/cache/385/6F0/shard%2F2595 +2 -0
  209. data/spec/dummy/tmp/cache/385/710/shard%2F2694 +1 -0
  210. data/spec/dummy/tmp/cache/386/6B0/shard%2F3199 +1 -0
  211. data/spec/dummy/tmp/cache/386/6C0/shard%2F2479 +1 -0
  212. data/spec/dummy/tmp/cache/386/700/shard%2F2758 +2 -0
  213. data/spec/dummy/tmp/cache/386/720/shard%2F2776 +2 -0
  214. data/spec/dummy/tmp/cache/386/730/shard%2F2866 +1 -0
  215. data/spec/dummy/tmp/cache/387/710/shard%2F2597 +2 -0
  216. data/spec/dummy/tmp/cache/388/720/shard%2F2598 +2 -0
  217. data/spec/dummy/tmp/cache/389/750/shard%2F2779 +2 -0
  218. data/spec/dummy/tmp/cache/389/760/shard%2F2869 +1 -0
  219. data/spec/dummy/tmp/cache/3A2/E80/shard%2F10010 +1 -0
  220. data/spec/dummy/tmp/cache/3A6/F80/shard%2F13200 +1 -0
  221. data/spec/dummy/tmp/cache/3A8/F70/shard%2F12203 +1 -0
  222. data/spec/dummy/tmp/cache/3A8/F80/shard%2F12212 +1 -0
  223. data/spec/dummy/tmp/cache/3A9/F50/shard%2F12015 +1 -0
  224. data/spec/dummy/tmp/cache/3A9/FC0/shard%2F12240 +1 -0
  225. data/spec/dummy/tmp/cache/3A9/FF0/shard%2F12510 +1 -0
  226. data/spec/dummy/tmp/cache/3AA/F10/shard%2F10027 +1 -0
  227. data/spec/dummy/tmp/cache/3AA/F80/shard%2F13006 +1 -0
  228. data/spec/dummy/tmp/cache/3AA/FB0/shard%2F12223 +1 -0
  229. data/spec/dummy/tmp/cache/3AA/FD0/shard%2F13132 +1 -0
  230. data/spec/dummy/tmp/cache/3AB/F70/shard%2F10073 +1 -0
  231. data/spec/dummy/tmp/cache/3AB/F70/shard%2F10154 +1 -0
  232. data/spec/dummy/tmp/cache/3AB/FC0/shard%2F13115 +1 -0
  233. data/spec/dummy/tmp/cache/3AC/050/shard%2F12702 +1 -0
  234. data/spec/dummy/tmp/cache/3AC/FB0/shard%2F13017 +1 -0
  235. data/spec/dummy/tmp/cache/3AD/010/shard%2F12253 +1 -0
  236. data/spec/dummy/tmp/cache/3AD/020/shard%2F12262 +1 -0
  237. data/spec/dummy/tmp/cache/3AE/040/shard%2F12191 +1 -0
  238. data/spec/dummy/tmp/cache/3AF/060/shard%2F12525 +1 -0
  239. data/spec/dummy/tmp/cache/3AF/0B0/shard%2F12651 +1 -0
  240. data/spec/dummy/tmp/cache/3B0/010/shard%2F12229 +1 -0
  241. data/spec/dummy/tmp/cache/3B0/080/shard%2F13183 +1 -0
  242. data/spec/dummy/tmp/cache/3B0/0A0/shard%2F12634 +1 -0
  243. data/spec/dummy/tmp/cache/3B1/070/shard%2F13166 +1 -0
  244. data/spec/dummy/tmp/cache/3B1/090/shard%2F12536 +1 -0
  245. data/spec/dummy/tmp/cache/3B1/0C0/shard%2F12563 +1 -0
  246. data/spec/dummy/tmp/cache/3B1/0D0/shard%2F12491 +1 -0
  247. data/spec/dummy/tmp/cache/3B1/0F0/shard%2F12833 +1 -0
  248. data/spec/dummy/tmp/cache/3B2/000/shard%2F10179 +1 -0
  249. data/spec/dummy/tmp/cache/3B2/060/shard%2F13149 +1 -0
  250. data/spec/dummy/tmp/cache/3B2/140/shard%2F12870 +1 -0
  251. data/spec/dummy/tmp/cache/3B3/0A0/shard%2F13096 +1 -0
  252. data/spec/dummy/tmp/cache/3B3/0F0/shard%2F12736 +1 -0
  253. data/spec/dummy/tmp/cache/3B4/090/shard%2F13079 +1 -0
  254. data/spec/dummy/tmp/cache/3B4/0A0/shard%2F12197 +1 -0
  255. data/spec/dummy/tmp/cache/3B4/0E0/shard%2F12719 +1 -0
  256. data/spec/dummy/tmp/cache/3B5/160/shard%2F12864 +1 -0
  257. data/spec/dummy/tmp/cache/3B6/150/shard%2F12685 +1 -0
  258. data/spec/dummy/tmp/cache/3B7/140/shard%2F12668 +1 -0
  259. data/spec/dummy/tmp/cache/3B9/150/shard%2F12499 +1 -0
  260. data/spec/lib/active_record/association_spec.rb +21 -11
  261. data/spec/lib/active_record/finder_methods_spec.rb +1 -1
  262. data/spec/lib/active_record/query_cache_spec.rb +63 -43
  263. data/spec/lib/active_record/query_methods_spec.rb +6 -5
  264. data/spec/lib/active_record/relation_spec.rb +1 -1
  265. data/spec/lib/active_record/spawn_methods_spec.rb +5 -4
  266. data/spec/lib/connection_pool_proxy_spec.rb +2 -0
  267. data/spec/lib/database_server_spec.rb +18 -6
  268. data/spec/lib/shackles_spec.rb +8 -6
  269. metadata +512 -59
  270. data/spec/dummy/tmp/cache/317/9E0/shard%2F61 +0 -0
  271. data/spec/dummy/tmp/cache/318/9F0/shard%2F62 +0 -0
  272. data/spec/dummy/tmp/cache/31A/A10/shard%2F64 +0 -0
  273. data/spec/dummy/tmp/cache/31A/A20/shard%2F73 +0 -0
  274. data/spec/dummy/tmp/cache/31B/A20/shard%2F65 +0 -0
  275. data/spec/dummy/tmp/cache/31B/A30/shard%2F74 +0 -0
  276. data/spec/dummy/tmp/cache/31D/A30/shard%2F58 +0 -0
  277. data/spec/dummy/tmp/cache/31D/A40/shard%2F67 +0 -0
  278. data/spec/dummy/tmp/cache/31E/A40/shard%2F59 +0 -0
  279. data/spec/dummy/tmp/cache/31E/A50/shard%2F68 +0 -0
  280. data/spec/dummy/tmp/cache/320/A80/shard%2F79 +0 -0
  281. data/spec/dummy/tmp/cache/344/D70/shard%2F103 +0 -0
  282. data/spec/dummy/tmp/cache/345/D80/shard%2F104 +0 -0
  283. data/spec/dummy/tmp/cache/349/DE0/shard%2F126 +0 -0
  284. data/spec/dummy/tmp/cache/34A/DF0/shard%2F127 +0 -0
  285. data/spec/dummy/tmp/cache/34B/E00/shard%2F128 +0 -1
  286. data/spec/dummy/tmp/cache/34B/E10/shard%2F137 +0 -0
  287. data/spec/dummy/tmp/cache/34C/E20/shard%2F138 +0 -0
  288. data/spec/dummy/tmp/cache/34C/E80/shard%2F192 +0 -0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�
2
+ I" name;TI"switchman_test_shard_2809;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395351017.159604:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395348920.634311: @value" :nil
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�
2
+ I" name;TI"switchman_test_shard_2755;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395348973.031633:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�
2
+ I" name;TI"switchman_test_shard_2764;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395349371.95282:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�
2
+ I" name;TI"switchman_test_shard_2782;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395350401.1010911:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi/ I" name;TI"switchman_test_shard_2863;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395351418.1376588:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi� I" name;TI"switchman_test_shard_2477;TI"database_server_id;TI"1;TI" default;TF:@created_atf1395264726.5928588:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi"
2
+ I" name;TI"switchman_test_shard_2594;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395345225.275854:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�
2
+ I" name;TI"switchman_test_shard_2756;TI"database_server_id;TI"1;TI" default;TF:@created_atf1395348973.1136022:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�
2
+ I" name;TI"switchman_test_shard_2765;TI"database_server_id;TI"1;TI" default;TF:@created_atf1395349372.035467:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi0 I" name;TI"switchman_test_shard_2864;TI"database_server_id;TI"1;TI" default;TF:@created_atf1395351418.1517792:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395351428.7750468:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395258204.944012:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETiK I" name;TI"switchman_test_shard_2379;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395261397.955012:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi#
2
+ I" name;TI"switchman_test_shard_2595;TI"database_server_id;TI"1;TI" default;TF:@created_atf1395345225.515469:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395348853.244767: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi I" name;TI"switchman_test_shard_3199;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395766435.693439:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi� I" name;TI"switchman_test_shard_2479;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395264761.2054908:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�
2
+ I" name;TI"switchman_test_shard_2758;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395349017.004371:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�
2
+ I" name;TI"switchman_test_shard_2776;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395350269.0577972:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395351418.236246:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi%
2
+ I" name;TI"switchman_test_shard_2597;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395345294.7767859:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi&
2
+ I" name;TI"switchman_test_shard_2598;TI"database_server_id;TI"1;TI" default;TF:@created_atf1395345294.810807:@expires_in0
@@ -0,0 +1,2 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�
2
+ I" name;TI"switchman_test_shard_2779;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395350364.3173969:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi5 I" name;TI"switchman_test_shard_2869;TI"database_server_id;TI" test;TI" default;TF:@created_atf1395351428.434088:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395249172.588981: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395766435.380675:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395258225.299445:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395258895.314236:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395253362.161854: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395259536.8502998:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395265351.107174:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395249202.276902: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395353374.976767:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395259330.9373682:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395356925.251668:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395247876.422563: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395250828.909863: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395356903.01191:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395348876.576017: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395353401.3710551:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395259554.234432:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395259597.792585:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395258112.406572:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395265484.546037:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395348798.0567172: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395259361.571546:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395766408.394197: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395347922.839416: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395678017.240988: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395344339.6799722: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395344990.876418:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395264885.3503292:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395351233.769553: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395251074.866422: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395356959.37007: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395351428.641105:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395356588.327811: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395348920.596425: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395356468.371645:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395258204.732102:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395348900.906124: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395351418.146604:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395348853.369654: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1395348831.209704: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1395265096.122713:@expires_in0
@@ -25,7 +25,8 @@ module Switchman
25
25
  end
26
26
 
27
27
  it "should set shard value to parent for association scope" do
28
- scope = @user1.appendages.scoped
28
+ scope = @user1.appendages
29
+ scope = ::Rails.version < '4' ? scope.scoped : scope.scope
29
30
  scope.shard_value.should == @user1
30
31
  scope.shard_source_value.should == :association
31
32
  end
@@ -39,9 +40,10 @@ module Switchman
39
40
 
40
41
  describe "transaction" do
41
42
  it "should activate the owner's shard and start the transaction on that shard" do
43
+ base_value = @user1.shard.activate { User.connection.open_transactions }
42
44
  @user1.appendages.transaction(:requires_new => true) do
43
45
  Shard.current.should == @shard1
44
- User.connection.open_transactions.should == 2
46
+ User.connection.open_transactions.should == base_value + 1
45
47
  end
46
48
  end
47
49
  end
@@ -66,7 +68,11 @@ module Switchman
66
68
  d1 = a1.digits.create!
67
69
  d1.shard.should == @shard1
68
70
 
69
- @user1.digits.scoped.shard_value.should == @user1
71
+ if ::Rails.version < '4'
72
+ @user1.digits.scoped.shard_value.should == @user1
73
+ else
74
+ @user1.digits.scope.shard_value.should == @user1
75
+ end
70
76
  @user1.digits.find(d1.id).should == d1
71
77
  end
72
78
 
@@ -99,9 +105,15 @@ module Switchman
99
105
  it "should properly set up a cross-shard-category query" do
100
106
  @shard1.activate(:mirror_universe) do
101
107
  mirror_user = MirrorUser.create!
102
- relation = mirror_user.association(:user).scoped
108
+ relation = mirror_user.association(:user)
109
+ relation = ::Rails.version < '4' ? relation.scoped : relation.scope
103
110
  relation.shard_value.should == Shard.default
104
- relation.where_values.first.right.should == mirror_user.global_id
111
+ if ::Rails.version < '4'
112
+ relation.where_values.first.right.should == mirror_user.global_id
113
+ else
114
+ relation.where_values.first.right.should be_a(Arel::Nodes::BindParam)
115
+ relation.bind_values.map(&:last).should == [mirror_user.global_id]
116
+ end
105
117
  end
106
118
  end
107
119
 
@@ -229,12 +241,10 @@ module Switchman
229
241
  user3 = User.create!
230
242
  user3.appendages.create!
231
243
 
232
- appendages = Appendage.all(:include => :user)
233
- appendages2 = Appendage.includes(:user).all
244
+ appendages = Appendage.includes(:user).to_a
234
245
  @user1.delete
235
246
 
236
247
  appendages.map(&:user).sort.should == [@user1, @user2, user3].sort
237
- appendages2.map(&:user).sort.should == [@user1, @user2, user3].sort
238
248
  end
239
249
 
240
250
  it "should preload belongs_to :through associations across shards" do
@@ -244,7 +254,7 @@ module Switchman
244
254
  a2 = @shard1.activate {Appendage.create!(:user => @user2) }
245
255
  d2 = Digit.create!(:appendage => a2)
246
256
 
247
- digits = Digit.includes(:user).all
257
+ digits = Digit.includes(:user).to_a
248
258
  @user1.delete
249
259
 
250
260
  digits.map(&:user).sort.should == [@user1, @user2].sort
@@ -258,7 +268,7 @@ module Switchman
258
268
  User.associated_shards_map = { @user1.global_id => [@shard1, @shard2] }
259
269
 
260
270
  begin
261
- users = User.where(:id => [@user1, @user2]).includes(:appendages).all
271
+ users = User.where(:id => [@user1, @user2]).includes(:appendages).to_a
262
272
  users.each {|u| u.appendages.loaded?.should be_true}
263
273
 
264
274
  u1 = users.detect {|u| u.id == @user1.id}
@@ -294,7 +304,7 @@ module Switchman
294
304
  Appendage.associated_shards_map = { a2.global_id => [@shard1, @shard2], a6.global_id => [@shard1] }
295
305
 
296
306
  begin
297
- users = User.where(:id => [@user1, @user2]).includes(:digits).all
307
+ users = User.where(:id => [@user1, @user2]).includes(:digits).to_a
298
308
  users.each {|u| u.digits.loaded?.should be_true}
299
309
 
300
310
  u1 = users.detect {|u| u.id == @user1.id}
@@ -43,7 +43,7 @@ module Switchman
43
43
 
44
44
  it "should work for a multi-shard scope" do
45
45
  user2 = @shard2.activate { User.create!(name: "multi-shard exists") }
46
- User.where(name: "multi-shard exists").shard(Shard.scoped).exists?.should be_true
46
+ User.where(name: "multi-shard exists").shard(::Rails.version < '4' ? Shard.scoped : Shard.all).exists?.should be_true
47
47
  end
48
48
  end
49
49
  end
@@ -52,7 +52,7 @@ module Switchman
52
52
  @shard3.activate do
53
53
  User.create!
54
54
  end
55
- @shard1.activate { User.all }.should_not == @shard3.activate { User.all }
55
+ @shard1.activate { User.all.to_a }.should_not == @shard3.activate { User.all.to_a }
56
56
  end
57
57
 
58
58
  describe "query_cache_enabled" do
@@ -167,13 +167,13 @@ module Switchman
167
167
  describe "select_all" do
168
168
  it "should cache when query cache enabled" do
169
169
  User.connection.enable_query_cache!
170
- User.all
170
+ User.all.to_a
171
171
  User.connection.query_cache.should_not be_empty
172
172
  end
173
173
 
174
174
  it "should not cache when query cache disabled" do
175
175
  User.connection.disable_query_cache!
176
- User.all
176
+ User.all.to_a
177
177
  User.connection.query_cache.should be_empty
178
178
  end
179
179
 
@@ -181,12 +181,12 @@ module Switchman
181
181
  User.connection.disable_query_cache!
182
182
  threaded(
183
183
  lambda{ |cc| User.connection.cache{ cc.call } },
184
- lambda{ User.all; User.connection.query_cache.should be_empty })
184
+ lambda{ User.all.to_a; User.connection.query_cache.should be_empty })
185
185
  end
186
186
 
187
187
  it "should not cache when query is locked" do
188
188
  User.connection.enable_query_cache!
189
- User.lock.all
189
+ User.lock.to_a
190
190
  User.connection.query_cache.should be_empty
191
191
  end
192
192
  end
@@ -194,14 +194,14 @@ module Switchman
194
194
  describe "insert" do
195
195
  it "should clear thread's query cache if enabled" do
196
196
  User.connection.enable_query_cache!
197
- User.all
197
+ User.all.to_a
198
198
  User.create!
199
199
  User.connection.query_cache.should be_empty
200
200
  end
201
201
 
202
202
  it "should not clear thread's query cache if disabled" do
203
203
  User.connection.enable_query_cache!
204
- User.all
204
+ User.all.to_a
205
205
  User.connection.disable_query_cache!
206
206
  User.create!
207
207
  User.connection.query_cache.should_not be_empty
@@ -209,7 +209,7 @@ module Switchman
209
209
 
210
210
  it "should not clear thread's query cache if disabled but other thread's enabled" do
211
211
  User.connection.enable_query_cache!
212
- User.all
212
+ User.all.to_a
213
213
  User.connection.disable_query_cache!
214
214
  threaded(
215
215
  lambda{ |cc| User.create!; cc.call },
@@ -218,7 +218,7 @@ module Switchman
218
218
 
219
219
  it "should not clear other thread's query cache" do
220
220
  User.connection.enable_query_cache!
221
- User.all
221
+ User.all.to_a
222
222
  User.connection.disable_query_cache!
223
223
  threaded(
224
224
  lambda{ |cc| User.create!; cc.call },
@@ -233,35 +233,45 @@ module Switchman
233
233
 
234
234
  it "should clear thread's query cache if enabled" do
235
235
  User.connection.enable_query_cache!
236
- User.all
236
+ User.all.to_a
237
237
  User.update_all(updated_at: Time.now)
238
238
  User.connection.query_cache.should be_empty
239
239
  end
240
240
 
241
241
  it "should not clear thread's query cache if disabled" do
242
242
  User.connection.enable_query_cache!
243
- User.all
243
+ User.all.to_a
244
244
  User.connection.disable_query_cache!
245
245
  User.update_all(updated_at: Time.now)
246
246
  User.connection.query_cache.should_not be_empty
247
247
  end
248
248
 
249
- it "should not clear thread's query cache if disabled but other thread's enabled" do
250
- User.connection.enable_query_cache!
251
- User.all
252
- User.connection.disable_query_cache!
253
- threaded(
254
- lambda{ |cc| User.update_all(updated_at: Time.now); cc.call },
255
- lambda{ User.connection.query_cache.should_not be_empty })
256
- end
249
+ context "non-transactional" do
250
+ unless ::ActiveRecord::Base.connection_pool.spec.config[:adapter_name] == 'PostgreSQL'
251
+ self.use_transactional_fixtures = false
257
252
 
258
- it "should not clear other thread's query cache" do
259
- User.connection.enable_query_cache!
260
- User.all
261
- User.connection.disable_query_cache!
262
- threaded(
263
- lambda{ |cc| User.update_all(updated_at: Time.now); cc.call },
264
- lambda{ User.connection.query_cache.should_not be_empty })
253
+ after do
254
+ User.delete_all
255
+ end
256
+ end
257
+
258
+ it "should not clear thread's query cache if disabled but other thread's enabled" do
259
+ User.connection.enable_query_cache!
260
+ User.all.to_a
261
+ User.connection.disable_query_cache!
262
+ threaded(
263
+ lambda{ |cc| User.update_all(updated_at: Time.now); cc.call },
264
+ lambda{ User.connection.query_cache.should_not be_empty })
265
+ end
266
+
267
+ it "should not clear other thread's query cache" do
268
+ User.connection.enable_query_cache!
269
+ User.all.to_a
270
+ User.connection.disable_query_cache!
271
+ threaded(
272
+ lambda{ |cc| User.update_all(updated_at: Time.now); cc.call },
273
+ lambda{ User.connection.query_cache.should_not be_empty })
274
+ end
265
275
  end
266
276
  end
267
277
 
@@ -272,35 +282,45 @@ module Switchman
272
282
 
273
283
  it "should clear thread's query cache if enabled" do
274
284
  User.connection.enable_query_cache!
275
- User.all
285
+ User.all.to_a
276
286
  User.delete_all
277
287
  User.connection.query_cache.should be_empty
278
288
  end
279
289
 
280
290
  it "should not clear thread's query cache if disabled" do
281
291
  User.connection.enable_query_cache!
282
- User.all
292
+ User.all.to_a
283
293
  User.connection.disable_query_cache!
284
294
  User.delete_all
285
295
  User.connection.query_cache.should_not be_empty
286
296
  end
287
297
 
288
- it "should not clear thread's query cache if disabled but other thread's enabled" do
289
- User.connection.enable_query_cache!
290
- User.all
291
- User.connection.disable_query_cache!
292
- threaded(
293
- lambda{ |cc| User.delete_all; cc.call },
294
- lambda{ User.connection.query_cache.should_not be_empty })
295
- end
298
+ context "non-transactional" do
299
+ unless ::ActiveRecord::Base.connection_pool.spec.config[:adapter_name] == 'PostgreSQL'
300
+ self.use_transactional_fixtures = false
296
301
 
297
- it "should not clear other thread's query cache" do
298
- User.connection.enable_query_cache!
299
- User.all
300
- User.connection.disable_query_cache!
301
- threaded(
302
- lambda{ |cc| User.delete_all; cc.call },
303
- lambda{ User.connection.query_cache.should_not be_empty })
302
+ after do
303
+ User.delete_all
304
+ end
305
+ end
306
+
307
+ it "should not clear thread's query cache if disabled but other thread's enabled" do
308
+ User.connection.enable_query_cache!
309
+ User.all.to_a
310
+ User.connection.disable_query_cache!
311
+ threaded(
312
+ lambda{ |cc| User.delete_all; cc.call },
313
+ lambda{ User.connection.query_cache.should_not be_empty })
314
+ end
315
+
316
+ it "should not clear other thread's query cache" do
317
+ User.connection.enable_query_cache!
318
+ User.all.to_a
319
+ User.connection.disable_query_cache!
320
+ threaded(
321
+ lambda{ |cc| User.delete_all; cc.call },
322
+ lambda{ User.connection.query_cache.should_not be_empty })
323
+ end
304
324
  end
305
325
  end
306
326
  end
@@ -31,22 +31,22 @@ module Switchman
31
31
  end
32
32
 
33
33
  it "should be the default shard if it's a scope of Shard" do
34
- User.shard(Shard.scoped).primary_shard.should == Shard.default
34
+ User.shard(::Rails.version < '4' ? Shard.scoped : Shard.all).primary_shard.should == Shard.default
35
35
  @shard1.activate do
36
- User.shard(Shard.scoped).primary_shard.should == Shard.default
36
+ User.shard(::Rails.version < '4' ? Shard.scoped : Shard.all).primary_shard.should == Shard.default
37
37
  end
38
38
  end
39
39
  end
40
40
 
41
41
  it "should default to the current shard" do
42
- relation = User.scoped
42
+ relation = ::Rails.version < '4' ? User.scoped : User.all
43
43
  relation.shard_value.should == Shard.default
44
44
  relation.shard_source_value.should == :implicit
45
45
 
46
46
  @shard1.activate do
47
47
  relation.shard_value.should == Shard.default
48
48
 
49
- relation = User.scoped
49
+ relation = ::Rails.version < '4' ? User.scoped : User.all
50
50
  relation.shard_value.should == @shard1
51
51
  relation.shard_source_value.should == :implicit
52
52
  end
@@ -145,7 +145,8 @@ module Switchman
145
145
  grandchild = child.children.create!
146
146
  child.reload.parent.should == @user1
147
147
 
148
- relation = @user1.association(:grandchildren).scoped
148
+ relation = @user1.association(:grandchildren)
149
+ relation = ::Rails.version < '4' ? relation.scoped : relation.scope
149
150
 
150
151
  attribute = relation.where_values.first.left
151
152
  attribute.name.to_s.should == 'parent_id'
@@ -16,7 +16,7 @@ module Switchman
16
16
  end
17
17
 
18
18
  it "should activate multiple shards if necessary" do
19
- User.where(:id => [@user1.id, @user2.id]).all.sort_by(&:id).should == [@user1, @user2].sort_by(&:id)
19
+ User.where(:id => [@user1.id, @user2.id]).sort_by(&:id).should == [@user1, @user2].sort_by(&:id)
20
20
  end
21
21
  end
22
22
 
@@ -20,20 +20,21 @@ module Switchman
20
20
  end
21
21
 
22
22
  it "should ignore implicit shard value lhs" do
23
- result = User.scoped.merge(User.shard(@shard1))
23
+ scope = ::Rails.version < '4' ? User.scoped : User.all
24
+ result = scope.merge(User.shard(@shard1))
24
25
  result.shard_value.should == @shard1
25
26
  result.shard_source_value.should == :explicit
26
27
  end
27
28
 
28
29
  it "should ignore implicit shard value rhs" do
29
- result = User.shard(@shard1).merge(User.scoped)
30
+ result = User.shard(@shard1).merge(::Rails.version < '4' ? User.scoped : User.all)
30
31
  result.shard_value.should == @shard1
31
32
  result.shard_source_value.should == :explicit
32
33
  end
33
34
 
34
35
  it "should take lhs shard_value for double implicit" do
35
- scope1 = @shard2.activate { User.scoped }
36
- result = scope1.merge(User.scoped)
36
+ scope1 = @shard2.activate { ::Rails.version < '4' ? User.scoped : User.all }
37
+ result = scope1.merge(::Rails.version < '4' ? User.scoped : User.all)
37
38
  result.shard_value.should == @shard2
38
39
  result.shard_source_value.should == :implicit
39
40
  end