slender_data 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/slender_data.coffee +14 -0
  3. data/app/assets/javascripts/slender_data/brest_loader.coffee +139 -0
  4. data/app/assets/javascripts/slender_data/cache.coffee +9 -24
  5. data/app/assets/javascripts/slender_data/entry_store.coffee +107 -0
  6. data/app/assets/javascripts/slender_data/loading_indicator.coffee +28 -0
  7. data/app/assets/javascripts/slender_data/loading_tracker.coffee +74 -0
  8. data/app/assets/javascripts/slender_data/parameterizable.coffee +50 -0
  9. data/app/assets/javascripts/slender_data/persistence_manager.coffee +114 -233
  10. data/app/assets/javascripts/slender_data/queries/base_query.coffee +32 -0
  11. data/app/assets/javascripts/slender_data/queries/multi_query.coffee +91 -0
  12. data/app/assets/javascripts/slender_data/queries/single_query.coffee +81 -0
  13. data/app/assets/javascripts/slender_data/query_cache.coffee +87 -0
  14. data/lib/slender_data/version.rb +1 -1
  15. data/spec/dummy/Rakefile +6 -0
  16. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  17. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  18. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  19. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  20. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  21. data/spec/dummy/bin/bundle +3 -0
  22. data/spec/dummy/bin/rails +4 -0
  23. data/spec/dummy/bin/rake +4 -0
  24. data/spec/dummy/config.ru +4 -0
  25. data/spec/dummy/config/application.rb +23 -0
  26. data/spec/dummy/config/boot.rb +5 -0
  27. data/spec/dummy/config/database.yml +25 -0
  28. data/spec/dummy/config/environment.rb +5 -0
  29. data/spec/dummy/config/environments/development.rb +31 -0
  30. data/spec/dummy/config/environments/production.rb +80 -0
  31. data/spec/dummy/config/environments/test.rb +36 -0
  32. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  33. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  34. data/spec/dummy/config/initializers/inflections.rb +16 -0
  35. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  36. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  37. data/spec/dummy/config/initializers/session_store.rb +3 -0
  38. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  39. data/spec/dummy/config/locales/en.yml +23 -0
  40. data/spec/dummy/config/routes.rb +4 -0
  41. data/spec/dummy/db/test.sqlite3 +0 -0
  42. data/spec/dummy/lib/tasks/tasks.rake +13 -0
  43. data/spec/dummy/log/development.log +349013 -0
  44. data/spec/dummy/log/test.log +883 -0
  45. data/spec/dummy/public/404.html +58 -0
  46. data/spec/dummy/public/422.html +58 -0
  47. data/spec/dummy/public/500.html +57 -0
  48. data/spec/dummy/public/favicon.ico +0 -0
  49. data/spec/dummy/spec/javascripts/brest_loader_spec.coffee +314 -0
  50. data/spec/dummy/spec/javascripts/cache_spec.coffee +93 -0
  51. data/spec/dummy/spec/javascripts/entry_store_spec.coffee +315 -0
  52. data/spec/dummy/spec/javascripts/jquery.js +6 -0
  53. data/spec/dummy/spec/javascripts/loading_tracker_spec.coffee +95 -0
  54. data/spec/dummy/spec/javascripts/parameterizable_spec.coffee +138 -0
  55. data/spec/dummy/spec/javascripts/persistence_manager_spec.coffee +659 -0
  56. data/spec/dummy/spec/javascripts/queries/base_query_spec.coffee +41 -0
  57. data/spec/dummy/spec/javascripts/queries/multi_query_spec.coffee +143 -0
  58. data/spec/dummy/spec/javascripts/queries/single_query_spec.coffee +112 -0
  59. data/spec/dummy/spec/javascripts/query_cache_spec.coffee +347 -0
  60. data/spec/dummy/spec/javascripts/sinon-chai.js +109 -0
  61. data/spec/dummy/spec/javascripts/sinon.js +4290 -0
  62. data/spec/dummy/spec/javascripts/spec_helper.coffee +23 -0
  63. data/spec/dummy/tmp/cache/assets/development/sprockets/02dabf70b4ae4a034f349ce89b4831d8 +0 -0
  64. data/spec/dummy/tmp/cache/assets/development/sprockets/031a6c2e3a4e952151301446bd3fc16d +0 -0
  65. data/spec/dummy/tmp/cache/assets/development/sprockets/0373c4e5507b3195c4ad15224d991609 +0 -0
  66. data/spec/dummy/tmp/cache/assets/development/sprockets/05175bd457a57c3ad73ab9a2c8696c9b +0 -0
  67. data/spec/dummy/tmp/cache/assets/development/sprockets/086e89c7529d5063e771b41793bfe311 +0 -0
  68. data/spec/dummy/tmp/cache/assets/development/sprockets/08b36042c3a4a79ebd9cee8ee1b88e6a +0 -0
  69. data/spec/dummy/tmp/cache/assets/development/sprockets/10513fd445754b59bd6001ea6ee727d9 +0 -0
  70. data/spec/dummy/tmp/cache/assets/development/sprockets/124f6816f926ae28ad20cc56425f3c91 +0 -0
  71. data/spec/dummy/tmp/cache/assets/development/sprockets/12ce2414098e368903aeb9923e275ef7 +0 -0
  72. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  73. data/spec/dummy/tmp/cache/assets/development/sprockets/14eca89f8dccac139fd132de35d22628 +0 -0
  74. data/spec/dummy/tmp/cache/assets/development/sprockets/16c8b12ef6dcb486a7b771e43bbcc117 +0 -0
  75. data/spec/dummy/tmp/cache/assets/development/sprockets/19cdfaa89f900500a03507b86afe1231 +0 -0
  76. data/spec/dummy/tmp/cache/assets/development/sprockets/1b3a4d533a743ca2ccfbca0986613995 +0 -0
  77. data/spec/dummy/tmp/cache/assets/development/sprockets/1ca8c5b832302c6c94692d0875a59605 +0 -0
  78. data/spec/dummy/tmp/cache/assets/development/sprockets/2e2576241d2a4969c9277fe85851c92b +0 -0
  79. data/spec/dummy/tmp/cache/assets/development/sprockets/2ec1baba6d6dc634d091b3acf8127cf7 +0 -0
  80. data/spec/dummy/tmp/cache/assets/development/sprockets/2ff315acad8ceec317fd566d792df64f +0 -0
  81. data/spec/dummy/tmp/cache/assets/development/sprockets/311f68c1b9e342ebab4c92c8cb2b5e54 +0 -0
  82. data/spec/dummy/tmp/cache/assets/development/sprockets/324a5040c964d5e8d293564383c49b91 +0 -0
  83. data/spec/dummy/tmp/cache/assets/development/sprockets/3310b5a70d0b220782ab3e87642834e9 +0 -0
  84. data/spec/dummy/tmp/cache/assets/development/sprockets/33ea745e7aa9669831758b7d36db1cb4 +0 -0
  85. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  86. data/spec/dummy/tmp/cache/assets/development/sprockets/3999afdceee7ca8dcf53757221c62d71 +0 -0
  87. data/spec/dummy/tmp/cache/assets/development/sprockets/3ba03b9f1aab60e78424f36e0e6cce6c +0 -0
  88. data/spec/dummy/tmp/cache/assets/development/sprockets/3e9a6ed890157d94f18b480f0079d8e1 +0 -0
  89. data/spec/dummy/tmp/cache/assets/development/sprockets/3ef50ccfe459d5c89ecc79a448586b49 +0 -0
  90. data/spec/dummy/tmp/cache/assets/development/sprockets/46c298dc2ff12ec748c70c017684fc28 +0 -0
  91. data/spec/dummy/tmp/cache/assets/development/sprockets/476318dd8109fbf173335456cabb4128 +0 -0
  92. data/spec/dummy/tmp/cache/assets/development/sprockets/5602ee157ea76a2f44a43739a83b1a6c +0 -0
  93. data/spec/dummy/tmp/cache/assets/development/sprockets/5b390f4782d6b77f5aec7ec56f3ad934 +0 -0
  94. data/spec/dummy/tmp/cache/assets/development/sprockets/5b5a66f4eefc591d284af6535ae474ea +0 -0
  95. data/spec/dummy/tmp/cache/assets/development/sprockets/5c41eeb2e98dc0833647e8547880435e +0 -0
  96. data/spec/dummy/tmp/cache/assets/development/sprockets/5cd2936d626662390288ab4c07ff3957 +0 -0
  97. data/spec/dummy/tmp/cache/assets/development/sprockets/5fd362891a204d492d9fa57ffee6e114 +0 -0
  98. data/spec/dummy/tmp/cache/assets/development/sprockets/643d60abdbcc813c95214920f12f09c3 +0 -0
  99. data/spec/dummy/tmp/cache/assets/development/sprockets/6591bc7545da5a2f5f7dee20b1f110a5 +0 -0
  100. data/spec/dummy/tmp/cache/assets/development/sprockets/6597f36181468ff92ba4284afe001181 +0 -0
  101. data/spec/dummy/tmp/cache/assets/development/sprockets/69b7946c418b75e7ba78f9fc73d3e9b9 +0 -0
  102. data/spec/dummy/tmp/cache/assets/development/sprockets/6c75b81de9afea82a6cbb56749157e3f +0 -0
  103. data/spec/dummy/tmp/cache/assets/development/sprockets/6e4bc63f9308eb5929a77f7607101af1 +0 -0
  104. data/spec/dummy/tmp/cache/assets/development/sprockets/6ee2243cf1cf415b6267b84dd7b8ba77 +0 -0
  105. data/spec/dummy/tmp/cache/assets/development/sprockets/6f8457b4ba418f572891745381a1e0f5 +0 -0
  106. data/spec/dummy/tmp/cache/assets/development/sprockets/6fd5544e52538b06ac40e5b387b020a5 +0 -0
  107. data/spec/dummy/tmp/cache/assets/development/sprockets/6fed8361766f5ae3cbf781986d6945b2 +0 -0
  108. data/spec/dummy/tmp/cache/assets/development/sprockets/70ffa648dbbe0f2431e7f9307b569354 +0 -0
  109. data/spec/dummy/tmp/cache/assets/development/sprockets/731f0bc492f775825f046d500938fc5a +0 -0
  110. data/spec/dummy/tmp/cache/assets/development/sprockets/76153dd2cc3d0c6e584080efb16e872a +0 -0
  111. data/spec/dummy/tmp/cache/assets/development/sprockets/76cd4393e7976d030f4623b8b6b372a0 +0 -0
  112. data/spec/dummy/tmp/cache/assets/development/sprockets/78d5dac5e2f907dd68813ed23a0fd4ac +0 -0
  113. data/spec/dummy/tmp/cache/assets/development/sprockets/7a400f93bfb71a1a11c59b9804adda6d +0 -0
  114. data/spec/dummy/tmp/cache/assets/development/sprockets/7abf5e8d9666225cb1d7881798dbd87a +0 -0
  115. data/spec/dummy/tmp/cache/assets/development/sprockets/7d6f1f3e48f6cc97a9bb4606f8c5a020 +0 -0
  116. data/spec/dummy/tmp/cache/assets/development/sprockets/814ca144649e7dec9e9158b3ec3460f1 +0 -0
  117. data/spec/dummy/tmp/cache/assets/development/sprockets/83de5b2d2c5d49f7737ae1f0316435ec +0 -0
  118. data/spec/dummy/tmp/cache/assets/development/sprockets/84c67faa73fdd082d4bd7f7712cb0499 +0 -0
  119. data/spec/dummy/tmp/cache/assets/development/sprockets/87a6ddc523ccbf2673750499bede3fc9 +0 -0
  120. data/spec/dummy/tmp/cache/assets/development/sprockets/8a90082fa76a7f37dd92a9b9a9b9f593 +0 -0
  121. data/spec/dummy/tmp/cache/assets/development/sprockets/8c5b622a33c6c034ecb4e78f131c5f73 +0 -0
  122. data/spec/dummy/tmp/cache/assets/development/sprockets/8c9851849e82bb9670e56f046df437f9 +0 -0
  123. data/spec/dummy/tmp/cache/assets/development/sprockets/8fc1455d3af69de5da04bf2a2a3f0b74 +0 -0
  124. data/spec/dummy/tmp/cache/assets/development/sprockets/96af98519e5badf206b77c3ecaf86d20 +0 -0
  125. data/spec/dummy/tmp/cache/assets/development/sprockets/98610661915880264fdb51c8f1a14141 +0 -0
  126. data/spec/dummy/tmp/cache/assets/development/sprockets/9a00753cdfb01f357dc39eeada77d0bc +0 -0
  127. data/spec/dummy/tmp/cache/assets/development/sprockets/9ad3db355e00d28ed3faed6dea5b1bff +0 -0
  128. data/spec/dummy/tmp/cache/assets/development/sprockets/9cbb3109d489692fd270c77ffa9d9559 +0 -0
  129. data/spec/dummy/tmp/cache/assets/development/sprockets/a22afac508f5adc12bf48d2f8333b8f7 +0 -0
  130. data/spec/dummy/tmp/cache/assets/development/sprockets/a49d020ee42c78bf7d22a21e8ee3b80f +0 -0
  131. data/spec/dummy/tmp/cache/assets/development/sprockets/a4f4f6c56c368263c0fbcf3f1542aa73 +0 -0
  132. data/spec/dummy/tmp/cache/assets/development/sprockets/a56b8266298c4171918ee403aa1c9e0f +0 -0
  133. data/spec/dummy/tmp/cache/assets/development/sprockets/a73a44bfca198fdf779532b644ec8af5 +0 -0
  134. data/spec/dummy/tmp/cache/assets/development/sprockets/aa4a22da44bd1b7dbdbb18f983d6c09b +0 -0
  135. data/spec/dummy/tmp/cache/assets/development/sprockets/ab0236bf3eac5cd30348c18efce8246b +0 -0
  136. data/spec/dummy/tmp/cache/assets/development/sprockets/abf215c8dc45135a91f4f993514c653f +0 -0
  137. data/spec/dummy/tmp/cache/assets/development/sprockets/ac1b8c30ad00cc489b7ec78bd6e2fc6c +0 -0
  138. data/spec/dummy/tmp/cache/assets/development/sprockets/ae8bd07980ad64ef8e9ac3fe38413c6d +0 -0
  139. data/spec/dummy/tmp/cache/assets/development/sprockets/b1950420978c68074fc6fd81d4320bc0 +0 -0
  140. data/spec/dummy/tmp/cache/assets/development/sprockets/b2d6aa1cb303474ebf3bfc571904ad23 +0 -0
  141. data/spec/dummy/tmp/cache/assets/development/sprockets/b59a10f85562b39fc7dd651965df9cab +0 -0
  142. data/spec/dummy/tmp/cache/assets/development/sprockets/b8d24bca037cf4b0a9e2979c11c8aea8 +0 -0
  143. data/spec/dummy/tmp/cache/assets/development/sprockets/bc2f15f88df08b4265c83133d6107680 +0 -0
  144. data/spec/dummy/tmp/cache/assets/development/sprockets/bd7ddfa86995ff5d259ea37e4a90c51c +0 -0
  145. data/spec/dummy/tmp/cache/assets/development/sprockets/c0515d57887926d6e28a0f87da31ee8e +0 -0
  146. data/spec/dummy/tmp/cache/assets/development/sprockets/c4820232e07d4e298e834c1011a72faa +0 -0
  147. data/spec/dummy/tmp/cache/assets/development/sprockets/c6babc078901541de3f4cb5cc2703bea +0 -0
  148. data/spec/dummy/tmp/cache/assets/development/sprockets/c9635dd5cbd79bdd9c58a89f6ea01595 +0 -0
  149. data/spec/dummy/tmp/cache/assets/development/sprockets/c9962abce37f5a56d5f05afe1edfe1b8 +0 -0
  150. data/spec/dummy/tmp/cache/assets/development/sprockets/cce1f28f0d1f5c2817e6eaf392bac615 +0 -0
  151. data/spec/dummy/tmp/cache/assets/development/sprockets/d37cae0bfdf135e6e71bcd0572bef329 +0 -0
  152. data/spec/dummy/tmp/cache/assets/development/sprockets/d4956056f6f35287a04295df6e52575d +0 -0
  153. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  154. data/spec/dummy/tmp/cache/assets/development/sprockets/dc54acb6b8cd4b84b13f440d57db37b1 +0 -0
  155. data/spec/dummy/tmp/cache/assets/development/sprockets/dd51c50b2d8231175e8da83e8b057120 +0 -0
  156. data/spec/dummy/tmp/cache/assets/development/sprockets/dec2df59b57b3639f89847e50416c924 +0 -0
  157. data/spec/dummy/tmp/cache/assets/development/sprockets/df45b0abc2c323093874639ceb72c012 +0 -0
  158. data/spec/dummy/tmp/cache/assets/development/sprockets/e0393ec0ca968f0d4182c82802da79d5 +0 -0
  159. data/spec/dummy/tmp/cache/assets/development/sprockets/e43bfee690613c316a59f122315314e5 +0 -0
  160. data/spec/dummy/tmp/cache/assets/development/sprockets/ed1d892145be7053348b0ba28c27b427 +0 -0
  161. data/spec/dummy/tmp/cache/assets/development/sprockets/ef2b922f05692ba49eb1f68801786b8e +0 -0
  162. data/spec/dummy/tmp/cache/assets/development/sprockets/efec5fde178e0875317a0d380222545d +0 -0
  163. data/spec/dummy/tmp/cache/assets/development/sprockets/f01906d52258e56e92a230dc3e55805d +0 -0
  164. data/spec/dummy/tmp/cache/assets/development/sprockets/f1b4ffa23205a95782c5c5050359429f +0 -0
  165. data/spec/dummy/tmp/cache/assets/development/sprockets/f2080a87aa027245a444b1486dce7792 +0 -0
  166. data/spec/dummy/tmp/cache/assets/development/sprockets/f37842723e3572ba18f02519dab4ee77 +0 -0
  167. data/spec/dummy/tmp/cache/assets/development/sprockets/f72501aca20f34d765720253853e6105 +0 -0
  168. data/spec/dummy/tmp/cache/assets/development/sprockets/f74306735334107c5d17684f524b65cf +0 -0
  169. data/spec/dummy/tmp/cache/assets/development/sprockets/f89dc49f90e98b448540556861f0173e +0 -0
  170. data/spec/dummy/tmp/cache/assets/development/sprockets/feadb1611975b23f2647e1ac656ad90b +0 -0
  171. data/spec/dummy/tmp/cache/assets/development/sprockets/ff445b9646db9910af486791b285b112 +0 -0
  172. data/spec/dummy/tmp/cache/assets/development/sprockets/ffa1eaa25729d9d4cd7e2fd666868936 +0 -0
  173. data/spec/dummy/tmp/cache/assets/test/sprockets/02dabf70b4ae4a034f349ce89b4831d8 +0 -0
  174. data/spec/dummy/tmp/cache/assets/test/sprockets/031a6c2e3a4e952151301446bd3fc16d +0 -0
  175. data/spec/dummy/tmp/cache/assets/test/sprockets/0373c4e5507b3195c4ad15224d991609 +0 -0
  176. data/spec/dummy/tmp/cache/assets/test/sprockets/05175bd457a57c3ad73ab9a2c8696c9b +0 -0
  177. data/spec/dummy/tmp/cache/assets/test/sprockets/086e89c7529d5063e771b41793bfe311 +0 -0
  178. data/spec/dummy/tmp/cache/assets/test/sprockets/08b36042c3a4a79ebd9cee8ee1b88e6a +0 -0
  179. data/spec/dummy/tmp/cache/assets/test/sprockets/10513fd445754b59bd6001ea6ee727d9 +0 -0
  180. data/spec/dummy/tmp/cache/assets/test/sprockets/124f6816f926ae28ad20cc56425f3c91 +0 -0
  181. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  182. data/spec/dummy/tmp/cache/assets/test/sprockets/14eca89f8dccac139fd132de35d22628 +0 -0
  183. data/spec/dummy/tmp/cache/assets/test/sprockets/16c8b12ef6dcb486a7b771e43bbcc117 +0 -0
  184. data/spec/dummy/tmp/cache/assets/test/sprockets/2b22662f42e9f485aafa6a333faaa256 +0 -0
  185. data/spec/dummy/tmp/cache/assets/test/sprockets/2e2576241d2a4969c9277fe85851c92b +0 -0
  186. data/spec/dummy/tmp/cache/assets/test/sprockets/2ec1baba6d6dc634d091b3acf8127cf7 +0 -0
  187. data/spec/dummy/tmp/cache/assets/test/sprockets/2ff315acad8ceec317fd566d792df64f +0 -0
  188. data/spec/dummy/tmp/cache/assets/test/sprockets/311f68c1b9e342ebab4c92c8cb2b5e54 +0 -0
  189. data/spec/dummy/tmp/cache/assets/test/sprockets/324a5040c964d5e8d293564383c49b91 +0 -0
  190. data/spec/dummy/tmp/cache/assets/test/sprockets/3310b5a70d0b220782ab3e87642834e9 +0 -0
  191. data/spec/dummy/tmp/cache/assets/test/sprockets/33ea745e7aa9669831758b7d36db1cb4 +0 -0
  192. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  193. data/spec/dummy/tmp/cache/assets/test/sprockets/3999afdceee7ca8dcf53757221c62d71 +0 -0
  194. data/spec/dummy/tmp/cache/assets/test/sprockets/3e9a6ed890157d94f18b480f0079d8e1 +0 -0
  195. data/spec/dummy/tmp/cache/assets/test/sprockets/3ef50ccfe459d5c89ecc79a448586b49 +0 -0
  196. data/spec/dummy/tmp/cache/assets/test/sprockets/46c298dc2ff12ec748c70c017684fc28 +0 -0
  197. data/spec/dummy/tmp/cache/assets/test/sprockets/476318dd8109fbf173335456cabb4128 +0 -0
  198. data/spec/dummy/tmp/cache/assets/test/sprockets/5602ee157ea76a2f44a43739a83b1a6c +0 -0
  199. data/spec/dummy/tmp/cache/assets/test/sprockets/5b390f4782d6b77f5aec7ec56f3ad934 +0 -0
  200. data/spec/dummy/tmp/cache/assets/test/sprockets/5b5a66f4eefc591d284af6535ae474ea +0 -0
  201. data/spec/dummy/tmp/cache/assets/test/sprockets/5cd2936d626662390288ab4c07ff3957 +0 -0
  202. data/spec/dummy/tmp/cache/assets/test/sprockets/643d60abdbcc813c95214920f12f09c3 +0 -0
  203. data/spec/dummy/tmp/cache/assets/test/sprockets/6597f36181468ff92ba4284afe001181 +0 -0
  204. data/spec/dummy/tmp/cache/assets/test/sprockets/6c75b81de9afea82a6cbb56749157e3f +0 -0
  205. data/spec/dummy/tmp/cache/assets/test/sprockets/6e4bc63f9308eb5929a77f7607101af1 +0 -0
  206. data/spec/dummy/tmp/cache/assets/test/sprockets/6ee2243cf1cf415b6267b84dd7b8ba77 +0 -0
  207. data/spec/dummy/tmp/cache/assets/test/sprockets/6f8457b4ba418f572891745381a1e0f5 +0 -0
  208. data/spec/dummy/tmp/cache/assets/test/sprockets/6fd5544e52538b06ac40e5b387b020a5 +0 -0
  209. data/spec/dummy/tmp/cache/assets/test/sprockets/6fed8361766f5ae3cbf781986d6945b2 +0 -0
  210. data/spec/dummy/tmp/cache/assets/test/sprockets/70ffa648dbbe0f2431e7f9307b569354 +0 -0
  211. data/spec/dummy/tmp/cache/assets/test/sprockets/76cd4393e7976d030f4623b8b6b372a0 +0 -0
  212. data/spec/dummy/tmp/cache/assets/test/sprockets/7a400f93bfb71a1a11c59b9804adda6d +0 -0
  213. data/spec/dummy/tmp/cache/assets/test/sprockets/7abf5e8d9666225cb1d7881798dbd87a +0 -0
  214. data/spec/dummy/tmp/cache/assets/test/sprockets/7d6f1f3e48f6cc97a9bb4606f8c5a020 +0 -0
  215. data/spec/dummy/tmp/cache/assets/test/sprockets/814ca144649e7dec9e9158b3ec3460f1 +0 -0
  216. data/spec/dummy/tmp/cache/assets/test/sprockets/83de5b2d2c5d49f7737ae1f0316435ec +0 -0
  217. data/spec/dummy/tmp/cache/assets/test/sprockets/873c5252aa4eab7409b712c5e276bad2 +0 -0
  218. data/spec/dummy/tmp/cache/assets/test/sprockets/87a6ddc523ccbf2673750499bede3fc9 +0 -0
  219. data/spec/dummy/tmp/cache/assets/test/sprockets/8a90082fa76a7f37dd92a9b9a9b9f593 +0 -0
  220. data/spec/dummy/tmp/cache/assets/test/sprockets/8c5b622a33c6c034ecb4e78f131c5f73 +0 -0
  221. data/spec/dummy/tmp/cache/assets/test/sprockets/8c9851849e82bb9670e56f046df437f9 +0 -0
  222. data/spec/dummy/tmp/cache/assets/test/sprockets/8fc1455d3af69de5da04bf2a2a3f0b74 +0 -0
  223. data/spec/dummy/tmp/cache/assets/test/sprockets/98610661915880264fdb51c8f1a14141 +0 -0
  224. data/spec/dummy/tmp/cache/assets/test/sprockets/9a00753cdfb01f357dc39eeada77d0bc +0 -0
  225. data/spec/dummy/tmp/cache/assets/test/sprockets/9ad3db355e00d28ed3faed6dea5b1bff +0 -0
  226. data/spec/dummy/tmp/cache/assets/test/sprockets/a22afac508f5adc12bf48d2f8333b8f7 +0 -0
  227. data/spec/dummy/tmp/cache/assets/test/sprockets/a4f4f6c56c368263c0fbcf3f1542aa73 +0 -0
  228. data/spec/dummy/tmp/cache/assets/test/sprockets/a56b8266298c4171918ee403aa1c9e0f +0 -0
  229. data/spec/dummy/tmp/cache/assets/test/sprockets/a73a44bfca198fdf779532b644ec8af5 +0 -0
  230. data/spec/dummy/tmp/cache/assets/test/sprockets/aa4a22da44bd1b7dbdbb18f983d6c09b +0 -0
  231. data/spec/dummy/tmp/cache/assets/test/sprockets/ab0236bf3eac5cd30348c18efce8246b +0 -0
  232. data/spec/dummy/tmp/cache/assets/test/sprockets/ac1b8c30ad00cc489b7ec78bd6e2fc6c +0 -0
  233. data/spec/dummy/tmp/cache/assets/test/sprockets/ae8bd07980ad64ef8e9ac3fe38413c6d +0 -0
  234. data/spec/dummy/tmp/cache/assets/test/sprockets/b1950420978c68074fc6fd81d4320bc0 +0 -0
  235. data/spec/dummy/tmp/cache/assets/test/sprockets/b2d6aa1cb303474ebf3bfc571904ad23 +0 -0
  236. data/spec/dummy/tmp/cache/assets/test/sprockets/b8d24bca037cf4b0a9e2979c11c8aea8 +0 -0
  237. data/spec/dummy/tmp/cache/assets/test/sprockets/bc2f15f88df08b4265c83133d6107680 +0 -0
  238. data/spec/dummy/tmp/cache/assets/test/sprockets/c9962abce37f5a56d5f05afe1edfe1b8 +0 -0
  239. data/spec/dummy/tmp/cache/assets/test/sprockets/cce1f28f0d1f5c2817e6eaf392bac615 +0 -0
  240. data/spec/dummy/tmp/cache/assets/test/sprockets/d37cae0bfdf135e6e71bcd0572bef329 +0 -0
  241. data/spec/dummy/tmp/cache/assets/test/sprockets/d4956056f6f35287a04295df6e52575d +0 -0
  242. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  243. data/spec/dummy/tmp/cache/assets/test/sprockets/dc54acb6b8cd4b84b13f440d57db37b1 +0 -0
  244. data/spec/dummy/tmp/cache/assets/test/sprockets/dd51c50b2d8231175e8da83e8b057120 +0 -0
  245. data/spec/dummy/tmp/cache/assets/test/sprockets/df13b2e8a88a9dcdc4a830fdd8f8d7b8 +0 -0
  246. data/spec/dummy/tmp/cache/assets/test/sprockets/df45b0abc2c323093874639ceb72c012 +0 -0
  247. data/spec/dummy/tmp/cache/assets/test/sprockets/e0393ec0ca968f0d4182c82802da79d5 +0 -0
  248. data/spec/dummy/tmp/cache/assets/test/sprockets/e43bfee690613c316a59f122315314e5 +0 -0
  249. data/spec/dummy/tmp/cache/assets/test/sprockets/ed1d892145be7053348b0ba28c27b427 +0 -0
  250. data/spec/dummy/tmp/cache/assets/test/sprockets/ef2b922f05692ba49eb1f68801786b8e +0 -0
  251. data/spec/dummy/tmp/cache/assets/test/sprockets/f01906d52258e56e92a230dc3e55805d +0 -0
  252. data/spec/dummy/tmp/cache/assets/test/sprockets/f1b4ffa23205a95782c5c5050359429f +0 -0
  253. data/spec/dummy/tmp/cache/assets/test/sprockets/f2080a87aa027245a444b1486dce7792 +0 -0
  254. data/spec/dummy/tmp/cache/assets/test/sprockets/f37842723e3572ba18f02519dab4ee77 +0 -0
  255. data/spec/dummy/tmp/cache/assets/test/sprockets/f72501aca20f34d765720253853e6105 +0 -0
  256. data/spec/dummy/tmp/cache/assets/test/sprockets/feadb1611975b23f2647e1ac656ad90b +0 -0
  257. data/spec/dummy/tmp/cache/assets/test/sprockets/ff445b9646db9910af486791b285b112 +0 -0
  258. metadata +499 -6
  259. data/app/assets/javascripts/slender_data.js +0 -8
  260. data/app/assets/javascripts/slender_data/ajax_loader.coffee +0 -76
  261. data/app/assets/javascripts/slender_data/indexed_cache.coffee +0 -33
@@ -0,0 +1,41 @@
1
+ #= require spec_helper
2
+ #= require slender_data/queries/base_query
3
+
4
+ describe 'slender_data.BaseQuery', ->
5
+
6
+ beforeEach ->
7
+ define_test_data this
8
+
9
+
10
+ describe 'selector_name', ->
11
+
12
+ it 'returns "id" for id queries', ->
13
+ query = new slender_data.BaseQuery id: 1, @test_params
14
+ expect(query.selector_name()).to.equal 'id'
15
+
16
+ it 'returns "ids" for ids queries', ->
17
+ query = new slender_data.BaseQuery ids: [1, 2], @test_params
18
+ expect(query.selector_name()).to.equal 'ids'
19
+
20
+ it 'returns "entry" for entry queries', ->
21
+ query = new slender_data.BaseQuery entry: {id: 1}, @test_params
22
+ expect(query.selector_name()).to.equal 'entry'
23
+
24
+
25
+ describe 'selector_value', ->
26
+
27
+ it 'returns the given id for id queries', ->
28
+ query = new slender_data.BaseQuery id: 1, @test_params
29
+ expect(query.selector_value()).to.eql 1
30
+
31
+ it 'returns the given entry for entry queries', ->
32
+ query = new slender_data.BaseQuery entry: {id: 1}, @test_params
33
+ expect(query.selector_value()).to.eql {id: 1}
34
+
35
+
36
+ describe 'to_hash', ->
37
+
38
+ it 'returns the hash representation of this query', ->
39
+ query = new slender_data.BaseQuery id: 3, @test_params
40
+ expect(query.to_hash()).to.eql {id: 3}
41
+
@@ -0,0 +1,143 @@
1
+ #= require spec_helper
2
+ #= require slender_data/queries/multi_query
3
+
4
+
5
+ describe 'slender_data.MultiQuery', ->
6
+
7
+ beforeEach ->
8
+ define_test_data this
9
+
10
+
11
+ describe 'constructor', ->
12
+
13
+ it 'allows to provide ids using their generic name "ids"', ->
14
+ multi_query = new slender_data.MultiQuery ids: [1, 2], @test_params
15
+ expect(multi_query.ids()).to.eql [1, 2]
16
+
17
+ it 'allows to provide ids using their domain specific name (i.e. "usernames")', ->
18
+ multi_query = new slender_data.MultiQuery usernames: [1, 2], @test_params
19
+ expect(multi_query.ids()).to.eql [1, 2]
20
+
21
+ it 'allows to provide entries using their generic name "entries"', ->
22
+ multi_query = new slender_data.MultiQuery entries: [ {username: 'one'},
23
+ {username: 'two'} ],
24
+ @test_params
25
+ expect(multi_query.entries()).to.eql [ {username: 'one'},
26
+ {username: 'two'} ]
27
+
28
+ it 'allows to provide entries using their domain specific name (i.e. "users")', ->
29
+ multi_query = new slender_data.MultiQuery users: [ {username: 'one'},
30
+ {username: 'two'} ],
31
+ @test_params
32
+ expect(multi_query.entries()).to.eql [ {username: 'one'},
33
+ {username: 'two'} ]
34
+
35
+ it 'throws an exception for unknown query selectors', ->
36
+ expect(-> new slender_data.MultiQuery [1,2]).to.throw()
37
+ expect(-> new slender_data.MultiQuery zonk: [1,2]).to.throw()
38
+
39
+
40
+
41
+ describe 'empty', ->
42
+
43
+ it 'returns true if the multi-query describes no entries', ->
44
+ multi_query = new slender_data.MultiQuery ids: [], @test_params
45
+ expect(multi_query.empty()).to.be.true
46
+
47
+ it 'returns false if the multi-query describes at least one snippet', ->
48
+ multi_query = new slender_data.MultiQuery ids: [1], @test_params
49
+ expect(multi_query.empty()).to.be.false
50
+
51
+
52
+
53
+ describe 'entries', ->
54
+
55
+ it 'throws an exception for an ids query', ->
56
+ query = new slender_data.MultiQuery usernames: ['one'], @test_params
57
+ expect(-> query.entries()).to.throw()
58
+
59
+ it 'returns the entries for the given entries query', ->
60
+ users = [{username: 'one'}]
61
+ query = new slender_data.MultiQuery users: users, @test_params
62
+ result = query.users()
63
+ expect(result).to.eql users
64
+
65
+
66
+
67
+ describe 'ids', ->
68
+
69
+ it 'returns the ids of the given ids query', ->
70
+ query = new slender_data.MultiQuery usernames: ['one', 'two'], @test_params
71
+ expect(query.usernames()).to.eql ['one', 'two']
72
+
73
+ it 'returns the id of the given entry query', ->
74
+ query = new slender_data.MultiQuery users: [ {username: 'one'}
75
+ {username: 'two'} ],
76
+ @test_params
77
+ expect(query.ids()).to.eql ['one', 'two']
78
+
79
+
80
+
81
+ describe 'replicate', ->
82
+
83
+ beforeEach ->
84
+ @test_params.versioning = yes
85
+ @test_params.partial_entries = yes
86
+ multi_query = new slender_data.MultiQuery users: [@user_1], full: yes,
87
+ @test_params
88
+ @result = multi_query.replicate [@user_2]
89
+
90
+ it 'creates a new MultiQuery', ->
91
+ expect(@result).to.be.an.instanceof slender_data.MultiQuery
92
+
93
+ it 'makes the new MultiQuery have the same selector name', ->
94
+ expect(@result.selector_name()).to.eql 'users'
95
+
96
+ it 'makes the new MultiQuery have the given selector values', ->
97
+ expect(@result.selector_value()).to.eql [@user_2]
98
+
99
+ it 'copies the "partial_entries" configuration setting to the new MultiQuery', ->
100
+ expect(@result.partial_entries).to.be.true
101
+
102
+ it 'copies the "versioning" configuration setting to the new MultiQuery', ->
103
+ expect(@result.versioning).to.be.true
104
+
105
+ it 'copies the "full" query parameter to the new MultiQuery', ->
106
+ expect(@result.full).to.be.true
107
+
108
+
109
+
110
+ describe 'single_selector_name', ->
111
+
112
+ it 'returns the custom entry name if the custom entries name is given', ->
113
+ @test_params.entry_name = 'entry'
114
+ @test_params.entries_name = 'entries'
115
+ multi_query = new slender_data.MultiQuery entries: [{id: 1}], @test_params
116
+ expect(multi_query.single_selector_name()).to.equal 'entry'
117
+
118
+ it 'it truncates the last character for any other selector name', ->
119
+ multi_query = new slender_data.MultiQuery ids: [1], @test_params
120
+ expect(multi_query.single_selector_name()).to.equal 'id'
121
+
122
+
123
+
124
+ describe 'transpose', ->
125
+
126
+ it 'converts the given ids MultiQuery into an array of id Queries', ->
127
+ multi_query = new slender_data.MultiQuery usernames: ['one', 'two', 'three'],
128
+ @test_params
129
+ result = multi_query.transpose()
130
+ expect(result[0].to_hash()).to.eql username: 'one'
131
+ expect(result[1].to_hash()).to.eql username: 'two'
132
+ expect(result[2].to_hash()).to.eql username: 'three'
133
+
134
+ it 'converts the given entries MultiQuery into an array of entry Queries', ->
135
+ multi_query = new slender_data.MultiQuery
136
+ users: [{username: 'one'}, {username: 'two'}, {username: 'three'}],
137
+ @test_params
138
+ result = multi_query.transpose()
139
+ expect(result.length).to.eql 3
140
+ expect(result[0].to_hash()).to.eql user: {username: 'one'}
141
+ expect(result[1].to_hash()).to.eql user: {username: 'two'}
142
+ expect(result[2].to_hash()).to.eql user: {username: 'three'}
143
+
@@ -0,0 +1,112 @@
1
+ #= require spec_helper
2
+ #= require slender_data/queries/single_query
3
+
4
+
5
+ describe 'slender_data.SingleQuery', ->
6
+
7
+ beforeEach ->
8
+ define_test_data this
9
+ @entry_query = new slender_data.SingleQuery user: @user_1, @test_params
10
+ @id_query = new slender_data.SingleQuery username: 'one', @test_params
11
+
12
+
13
+ describe 'constructor', ->
14
+
15
+ it 'allows to provide an id using its generic name "id"', ->
16
+ query = new slender_data.SingleQuery id: 'one', @test_params
17
+ expect(query.id()).to.eql 'one'
18
+
19
+ it 'allows to provide an id using its domain specific name (i.e. "username")', ->
20
+ query = new slender_data.SingleQuery username: 'one', @test_params
21
+ expect(query.id()).to.eql 'one'
22
+
23
+ it 'allows to provide an entry using its generic name "entry"', ->
24
+ query = new slender_data.SingleQuery entry: {username: 'one'}, @test_params
25
+ expect(query.entry()).to.eql username: 'one'
26
+
27
+ it 'allows to provide an entry using its domain specific name (i.e. "user")', ->
28
+ query = new slender_data.SingleQuery user: {username: 'one'}, @test_params
29
+ expect(query.entry()).to.eql username: 'one'
30
+
31
+ it 'allows to provide the version using its generic name "version"', ->
32
+ query = new slender_data.SingleQuery entry: {username: 'foo', version: 2}, @test_params
33
+ expect(query.version()).to.eql 2
34
+
35
+ it 'allows to provide an entry using its domain specific name (i.e. "timestamp")', ->
36
+ query = new slender_data.SingleQuery user: {username: 'foo', timestamp: 2}, @test_params
37
+ expect(query.version()).to.eql 2
38
+
39
+ it 'throws an exception for missing query selectors', ->
40
+ expect(=> new slender_data.SingleQuery 'one', @test_params).to.throw()
41
+
42
+ it 'throws an exception for unknown query selectors', ->
43
+ expect(=> new slender_data.SingleQuery zonk: 'one', @test_params).to.throw()
44
+
45
+
46
+
47
+ describe 'entry getter', ->
48
+
49
+ context 'entry query', ->
50
+
51
+ it 'allows access through the entry() function', ->
52
+ expect(@entry_query.entry()).to.eql @user_1
53
+
54
+ it 'allows access through the domain-specific name', ->
55
+ expect(@entry_query.user()).to.eql @user_1
56
+
57
+
58
+ context 'id query', ->
59
+
60
+ it 'throws an exception', ->
61
+ expect(-> @id_query.user()).to.throw()
62
+
63
+
64
+
65
+ describe 'id getter', ->
66
+
67
+ context 'entry query', ->
68
+
69
+ it 'returns the id through the id() function', ->
70
+ expect(@entry_query.id()).to.equal 'one'
71
+
72
+ it 'returns the id through its domain-specific name', ->
73
+ expect(@entry_query.username()).to.equal 'one'
74
+
75
+
76
+ context 'id query', ->
77
+
78
+ it 'returns the id through the id() function', ->
79
+ expect(@id_query.id()).to.equal 'one'
80
+
81
+ it 'returns the id through its domain-specific name', ->
82
+ expect(@id_query.username()).to.equal 'one'
83
+
84
+
85
+
86
+ describe 'version getter', ->
87
+
88
+ context 'entry query', ->
89
+
90
+ it 'returns the version through the version() function', ->
91
+ expect(@entry_query.version()).to.equal 2
92
+
93
+ it 'returns the version through its domain-specific name', ->
94
+ expect(@entry_query.timestamp()).to.equal 2
95
+
96
+
97
+ context 'id query', ->
98
+
99
+ it 'throws an exception because id queries can not contain versions', ->
100
+ expect(-> @id_query.version).to.throw()
101
+ expect(-> @id_query.timestamp).to.throw()
102
+
103
+
104
+
105
+ describe 'to_hash', ->
106
+
107
+ it 'returns the hash versions of id queries', ->
108
+ expect(@id_query.to_hash()).to.eql username: 'one'
109
+
110
+ it 'returns the hash versions of entry queries', ->
111
+ expect(@entry_query.to_hash()).to.eql user: @user_1
112
+
@@ -0,0 +1,347 @@
1
+ #= require spec_helper
2
+
3
+
4
+ describe 'QueryCache', ->
5
+
6
+ beforeEach ->
7
+ define_test_data this
8
+ @query_cache = new slender_data.QueryCache @test_params
9
+
10
+
11
+ describe 'add', ->
12
+
13
+ describe 'normal behavior', ->
14
+
15
+ beforeEach ->
16
+ @result = @query_cache.add @user_1
17
+
18
+ it 'adds the given entry', ->
19
+ expect(@query_cache.cache.length()).to.equal 1
20
+ expect(@query_cache.get username: 'one').to.equal @user_1
21
+
22
+ it 'returns nothing', ->
23
+ expect(@result).to.be.undefined
24
+
25
+
26
+ describe 'partial/full behavior', ->
27
+
28
+ beforeEach ->
29
+ @test_params.partial_entries = yes
30
+ @query_cache = new slender_data.QueryCache @test_params
31
+
32
+ it 'replaces an existing partial entry with the given full entry', ->
33
+ @query_cache.add @partial_user_1
34
+ @query_cache.add @full_user_1
35
+ expect(@query_cache.get username: 'one').to.eql @full_user_1
36
+
37
+ it 'does not replace an existing full entry with the given partial entry', ->
38
+ @query_cache.add @full_user_1
39
+ @query_cache.add @partial_user_1
40
+ expect(@query_cache.get username: 'one').to.eql @full_user_1
41
+
42
+
43
+
44
+ describe 'add_clone', ->
45
+
46
+ describe 'normal behavior', ->
47
+
48
+ beforeEach ->
49
+ @result = @query_cache.add_clone @user_1
50
+
51
+ it 'adds a copy of the given entry', ->
52
+ expect(@query_cache.length()).to.equal 1
53
+ expect(@query_cache.get user: @user_1).to.eql @user_1
54
+ expect(@query_cache.get user: @user_1).to.not.equal @user_1
55
+
56
+ it 'returns a copy of the added entry', ->
57
+ expect(@result).to.eql @user_1
58
+ expect(@result).to.not.equal @user_1
59
+
60
+
61
+ describe 'partial/full behavior', ->
62
+
63
+ beforeEach ->
64
+ @test_params.partial_entries = yes
65
+ @query_cache = new slender_data.QueryCache @test_params
66
+
67
+ it 'replaces an existing partial entry with the given full entry', ->
68
+ @query_cache.add @partial_user_1
69
+ @query_cache.add_clone @full_user_1
70
+ expect(@query_cache.get username: 'one').to.eql @full_user_1
71
+
72
+ it 'does not replace an existing full entry with the given partial entry', ->
73
+ @query_cache.add @full_user_1
74
+ @query_cache.add_clone @partial_user_1
75
+ expect(@query_cache.get username: 'one').to.eql @full_user_1
76
+
77
+
78
+
79
+ describe 'add_clones', ->
80
+
81
+ beforeEach ->
82
+ @result = @query_cache.add_clones [@user_1, @user_2]
83
+
84
+ it 'adds copies of the given entries to the chache', ->
85
+ expect(@query_cache.length()).to.equal 2
86
+ cache_content = @query_cache.get_many users: [@user_1, @user_2]
87
+ expect(cache_content.found[0]).to.eql @user_1
88
+ expect(cache_content.found[0]).to.not.equal @user_1
89
+ expect(cache_content.found[1]).to.eql @user_2
90
+ expect(cache_content.found[1]).to.not.equal @user_2
91
+
92
+ it 'returns copies of the added entries', ->
93
+ expect(@result).to.eql [@user_1, @user_2]
94
+
95
+
96
+
97
+ describe 'add_many', ->
98
+
99
+ describe 'normal behavior', ->
100
+
101
+ beforeEach ->
102
+ @result = @query_cache.add_many [@user_1, @user_2]
103
+
104
+ it 'adds the given entries', ->
105
+ expect(@query_cache.length()).to.equal 2
106
+ expect(@query_cache.get user: @user_1).to.equal @user_1
107
+ expect(@query_cache.get user: @user_2).to.equal @user_2
108
+
109
+ it 'returns undefined', ->
110
+ expect(@result).to.be.undefined
111
+
112
+
113
+ describe 'partial/full behavior', ->
114
+
115
+ beforeEach ->
116
+ @test_params.partial_entries = yes
117
+ @query_cache = new slender_data.QueryCache @test_params
118
+ @query_cache.add_many [@partial_user_1, @full_user_2]
119
+ @query_cache.add_many [@full_user_1, @partial_user_2]
120
+
121
+ it 'replaces an existing partial entry with the given full entry', ->
122
+ expect(@query_cache.get username: 'one').to.eql @full_user_1
123
+
124
+ it 'does not replace an existing full entry with the given partial entry', ->
125
+ expect(@query_cache.get username: 'two').to.eql @full_user_2
126
+
127
+
128
+
129
+ describe 'add_many_as_clones', ->
130
+
131
+ describe 'normal behavior', ->
132
+
133
+ beforeEach ->
134
+ @result = @query_cache.add_many_as_clones [@user_1, @user_2]
135
+
136
+ it 'adds clones of the given entries', ->
137
+ expect(@query_cache.length()).to.equal 2
138
+ expect(@query_cache.get user: @user_1).to.eql @user_1
139
+ expect(@query_cache.get user: @user_1).to.not.equal @user_1
140
+ expect(@query_cache.get user: @user_2).to.eql @user_2
141
+ expect(@query_cache.get user: @user_2).to.not.equal @user_2
142
+
143
+ it 'returns the added entries', ->
144
+ expect(@result.length).to.equal 2
145
+ expect(@result[0]).to.eql @user_1
146
+ expect(@result[0]).to.not.equal @user_1
147
+ expect(@result[1]).to.eql @user_2
148
+ expect(@result[1]).to.not.equal @user_2
149
+
150
+
151
+ describe 'partial/full behavior', ->
152
+
153
+ beforeEach ->
154
+ @test_params.partial_entries = yes
155
+ @query_cache = new slender_data.QueryCache @test_params
156
+ @query_cache.add_many [@partial_user_1, @full_user_2]
157
+ @query_cache.add_many_as_clones [@full_user_1, @partial_user_2]
158
+
159
+ it 'replaces an existing partial entry with the given full entry', ->
160
+ expect(@query_cache.get username: 'one').to.eql @full_user_1
161
+
162
+ it 'does not replace an existing full entry with the given partial entry', ->
163
+ expect(@query_cache.get username: 'two').to.eql @full_user_2
164
+
165
+
166
+
167
+ describe 'get', ->
168
+
169
+ describe 'normal behavior', ->
170
+
171
+ beforeEach ->
172
+ @query_cache.add @user_1
173
+
174
+ it 'returns the entry described by the given entry', ->
175
+ expect(@query_cache.get user: @user_1).to.equal @user_1
176
+
177
+ it 'returns the entry described by the given id', ->
178
+ expect(@query_cache.get username: @user_1.username).to.equal @user_1
179
+
180
+ it 'returns undefined if the entry does not exist', ->
181
+ expect(@query_cache.get id: 99).to.be.undefined
182
+
183
+
184
+ describe 'partial entries enabled', ->
185
+
186
+ beforeEach ->
187
+ @test_params.partial_entries = yes
188
+ @query_cache = new slender_data.QueryCache @test_params
189
+
190
+ context 'partial entry cached', ->
191
+
192
+ beforeEach ->
193
+ @query_cache.add @partial_user_1
194
+
195
+ it 'returns the partial entry if a partial entry is requested', ->
196
+ @result = @query_cache.get username: 'one'
197
+ expect(@result).to.eql @partial_user_1
198
+
199
+ it 'returns nothing if a full entry is requested', ->
200
+ @result = @query_cache.get username: 'one', full: yes
201
+ expect(@result).to.be.undefined
202
+
203
+ context 'full entry cached', ->
204
+
205
+ beforeEach ->
206
+ @query_cache.add @full_user_1
207
+
208
+ it 'returns the full entry if a partial entry is requested', ->
209
+ @result = @query_cache.get username: 'one'
210
+ expect(@result).to.eql @full_user_1
211
+
212
+ it 'returns the full entry if a full entry is requested', ->
213
+ @result = @query_cache.get username: 'one', full: yes
214
+ expect(@result).to.eql @full_user_1
215
+
216
+
217
+ describe 'versioning', ->
218
+
219
+ beforeEach ->
220
+ @test_params.versioning = yes
221
+ @query_cache = new slender_data.QueryCache @test_params
222
+
223
+ it 'returns the cached entry if it is fresh', ->
224
+ @query_cache.add @user_1
225
+ @result = @query_cache.get user: @user_1
226
+ expect(@result).to.eql @user_1
227
+
228
+ it 'returns nothing if the cached entry is stale', ->
229
+ @result = @query_cache.add @user_1_outdated
230
+ expect(@result).to.be.undefined
231
+
232
+
233
+ describe 'get_many', ->
234
+
235
+ describe 'normal behavior', ->
236
+
237
+ beforeEach ->
238
+ @query_cache.add_many [@user_1, @user_2]
239
+
240
+ it 'returns the entries described by the given entry multi-query', ->
241
+ result = @query_cache.get_many users: [@user_1, @user_2]
242
+ expect(result.found).to.eql [@user_1, @user_2]
243
+ expect(result.missing.empty()).to.be.true
244
+
245
+ it 'returns the entries described by the given id multi-query', ->
246
+ result = @query_cache.get_many usernames: ['one', 'two']
247
+ expect(result.found).to.eql [@user_1, @user_2]
248
+ expect(result.missing.empty()).to.be.true
249
+
250
+ it "reports non-existing entries as a MultiQuery in the 'missing' result portion", ->
251
+ result = @query_cache.get_many usernames: ['one', 99]
252
+ expect(result.missing).to.be.an.instanceof slender_data.MultiQuery
253
+ expect(result.missing.to_hash()).to.eql usernames: [99]
254
+
255
+
256
+ describe 'with partial entries enabled', ->
257
+
258
+ beforeEach ->
259
+ @test_params.partial_entries = yes
260
+ @query_cache = new slender_data.QueryCache @test_params
261
+ @query_cache.add_many [@partial_user_1, @full_user_2]
262
+
263
+ context 'partial entries are allowed', ->
264
+
265
+ beforeEach ->
266
+ @result = @query_cache.get_many usernames: ['one', 'two', 'three']
267
+
268
+ it 'returns partial and full entries', ->
269
+ expect(@result.found).to.eql [@partial_user_1, @full_user_2]
270
+
271
+ it 'reports missing entries', ->
272
+ expect(@result.missing.to_hash()).to.eql usernames: ['three']
273
+
274
+ it 'configures the missing entries multi_query to allow partial entries as well', ->
275
+ expect(@result.missing.full).to.be.falsy
276
+
277
+
278
+ context 'full entries requested', ->
279
+
280
+ beforeEach ->
281
+ @result = @query_cache.get_many usernames: ['one', 'two'], full: yes
282
+
283
+ it 'returns only full entries', ->
284
+ expect(@result.found).to.eql [@full_user_2]
285
+
286
+ it 'reports missing entries', ->
287
+ expect(@result.missing.to_hash().usernames).to.eql ['one']
288
+
289
+ it 'configures the missing entries multi-query to also request only full entries', ->
290
+ expect(@result.missing.full).to.be.true
291
+
292
+
293
+ describe 'versioning', ->
294
+
295
+ beforeEach ->
296
+ @test_params.versioning = yes
297
+ @query_cache = new slender_data.QueryCache @test_params
298
+ @query_cache.add_many [@user_1_outdated, @user_2]
299
+ @result = @query_cache.get_many users: [@user_1, @user_2]
300
+
301
+ it 'returns only cached entries with the right version from the cache', ->
302
+ expect(@result.found).to.eql [@user_2]
303
+
304
+ it 'reports outdated cached entries as missing', ->
305
+ expect(@result.missing.to_hash()).to.eql users: [@user_1]
306
+
307
+
308
+
309
+ describe 'length', ->
310
+
311
+ it 'returns the number of stored entries', ->
312
+ expect(@query_cache.length()).to.equal 0
313
+ @query_cache.add @user_1
314
+ expect(@query_cache.length()).to.equal 1
315
+ @query_cache.add @user_2
316
+ expect(@query_cache.length()).to.equal 2
317
+ @query_cache.remove user: @user_1
318
+ expect(@query_cache.length()).to.equal 1
319
+
320
+
321
+ describe 'remove', ->
322
+
323
+ beforeEach ->
324
+ @query_cache.add @user_1
325
+
326
+ it 'removes the given entry from the cache', ->
327
+ @query_cache.remove user: @user_1
328
+ expect(@query_cache.length()).to.equal 0
329
+
330
+ it 'removes the entry with the given id from the cache', ->
331
+ @query_cache.remove username: 'one'
332
+ expect(@query_cache.length()).to.equal 0
333
+
334
+
335
+ describe 'remove_many', ->
336
+
337
+ beforeEach ->
338
+ @query_cache.add_many [@user_1, @user_2]
339
+
340
+ it 'removes the given entries from the server', ->
341
+ @query_cache.remove_many users: [@user_1, @user_2]
342
+ expect(@query_cache.length()).to.equal 0
343
+
344
+ it 'removes the entries with the given ids from the server', ->
345
+ @query_cache.remove_many usernames: ['one', 'two']
346
+ expect(@query_cache.length()).to.equal 0
347
+