raffle_v1 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +6 -14
  2. data/README.md +11 -2
  3. data/app/assets/images/raffle_v1/game.png +0 -0
  4. data/app/assets/images/raffle_v1/gift.png +0 -0
  5. data/app/assets/images/raffle_v1/lifesaver.png +0 -0
  6. data/app/assets/images/raffle_v1/person01.jpg +0 -0
  7. data/app/assets/javascripts/raffle_v1/application.js +2 -1
  8. data/app/assets/javascripts/raffle_v1/home.js.coffee +3 -0
  9. data/app/assets/javascripts/raffle_v1/locales.js.coffee +3 -0
  10. data/app/assets/javascripts/raffle_v1/page_layouts.js.coffee +3 -0
  11. data/app/assets/javascripts/raffle_v1/pages.js.coffee +3 -0
  12. data/app/assets/javascripts/raffle_v1/programs.js.coffee +3 -0
  13. data/app/assets/javascripts/raffle_v1/roles.js.coffee +3 -0
  14. data/app/assets/javascripts/raffle_v1/stylesheets.js.coffee +3 -0
  15. data/app/assets/javascripts/raffle_v1/terms_and_conditions.js.coffee +3 -0
  16. data/app/assets/javascripts/raffle_v1/terms_of_conditions.js.coffee +3 -0
  17. data/app/assets/javascripts/raffle_v1/translation_keys.js.coffee +3 -0
  18. data/app/assets/javascripts/raffle_v1/translation_objects.js.coffee +3 -0
  19. data/app/assets/javascripts/raffle_v1/user.js.coffee +3 -0
  20. data/app/assets/javascripts/raffle_v1/versions.js.coffee +3 -0
  21. data/app/assets/stylesheets/raffle_v1/TableTools.css +264 -0
  22. data/app/assets/stylesheets/raffle_v1/TableTools.css.scss +264 -0
  23. data/app/assets/stylesheets/raffle_v1/TableTools_JUI.css +182 -0
  24. data/app/assets/stylesheets/raffle_v1/TableTools_JUI.css.scss +183 -0
  25. data/app/assets/stylesheets/raffle_v1/_custom.css.scss +3310 -0
  26. data/app/assets/stylesheets/raffle_v1/_variable.scss +122 -0
  27. data/app/assets/stylesheets/raffle_v1/_variable_defaults.scss +83 -0
  28. data/app/assets/stylesheets/raffle_v1/application.css.scss +34 -0
  29. data/app/assets/stylesheets/raffle_v1/application.css.scss.erb +32 -0
  30. data/app/assets/stylesheets/raffle_v1/bootstrap-responsive.css +570 -0
  31. data/app/assets/stylesheets/raffle_v1/bootstrap-responsive.css.scss +570 -0
  32. data/app/assets/stylesheets/raffle_v1/bootstrap.css +4226 -0
  33. data/app/assets/stylesheets/raffle_v1/bootstrap.css.scss +4226 -0
  34. data/app/assets/stylesheets/raffle_v1/colorbox.css +88 -0
  35. data/app/assets/stylesheets/raffle_v1/colorbox.css.scss +88 -0
  36. data/app/assets/stylesheets/raffle_v1/grid.css.scss +258 -0
  37. data/app/assets/stylesheets/raffle_v1/hierarchy.css.scss +16 -0
  38. data/app/assets/stylesheets/raffle_v1/home.css.scss +18 -0
  39. data/app/assets/stylesheets/raffle_v1/jquery.dataTables.css +83 -0
  40. data/app/assets/stylesheets/raffle_v1/jquery.dataTables.css.scss +83 -0
  41. data/app/assets/stylesheets/raffle_v1/jquery.jcarousel.css +206 -0
  42. data/app/assets/stylesheets/raffle_v1/jquery.wysiwyg.css +57 -0
  43. data/app/assets/stylesheets/raffle_v1/jquery.wysiwyg.css.scss +57 -0
  44. data/app/assets/stylesheets/raffle_v1/jqueryui/jquery.ui.core.css +38 -0
  45. data/app/assets/stylesheets/raffle_v1/jqueryui/jquery.ui.core.css.scss +38 -0
  46. data/app/assets/stylesheets/raffle_v1/jqueryui/jquery.ui.dialog.css +21 -0
  47. data/app/assets/stylesheets/raffle_v1/jqueryui/jquery.ui.dialog.css.scss +21 -0
  48. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  49. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  50. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  51. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  52. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  53. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  54. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  55. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  56. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  57. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  58. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  59. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  60. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  61. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  62. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/jquery-ui-1.8.18.custom.css +563 -0
  63. data/app/assets/stylesheets/raffle_v1/jqueryui/ui-lightness/jquery-ui-1.8.18.custom.css.scss +563 -0
  64. data/app/assets/stylesheets/raffle_v1/locales.css.scss +3 -0
  65. data/app/assets/stylesheets/raffle_v1/page_layouts.css.scss +3 -0
  66. data/app/assets/stylesheets/raffle_v1/pages.css.scss +3 -0
  67. data/app/assets/stylesheets/raffle_v1/programs.css.scss +3 -0
  68. data/app/assets/stylesheets/raffle_v1/reset.css.scss +96 -0
  69. data/app/assets/stylesheets/raffle_v1/roles.css.scss +3 -0
  70. data/app/assets/stylesheets/raffle_v1/scaffolds.css.scss +42 -0
  71. data/app/assets/stylesheets/raffle_v1/stylesheets.css.scss +3 -0
  72. data/app/assets/stylesheets/raffle_v1/terms_and_conditions.css.scss +3 -0
  73. data/app/assets/stylesheets/raffle_v1/terms_of_conditions.css.scss +4 -0
  74. data/app/assets/stylesheets/raffle_v1/translation_keys.css.scss +3 -0
  75. data/app/assets/stylesheets/raffle_v1/translation_objects.css.scss +3 -0
  76. data/app/assets/stylesheets/raffle_v1/ui.multiselect.css +33 -0
  77. data/app/assets/stylesheets/raffle_v1/ui.multiselect.css.scss +33 -0
  78. data/app/assets/stylesheets/raffle_v1/user.css.scss +3 -0
  79. data/app/assets/stylesheets/raffle_v1/versions.css.scss +3 -0
  80. data/app/controllers/raffle_v1/application_controller.rb +80 -0
  81. data/app/controllers/raffle_v1/home_controller.rb +15 -0
  82. data/app/controllers/raffle_v1/locales_controller.rb +87 -0
  83. data/app/controllers/raffle_v1/page_layouts_controller.rb +87 -0
  84. data/app/controllers/raffle_v1/pages_controller.rb +180 -0
  85. data/app/controllers/raffle_v1/programs_controller.rb +140 -0
  86. data/app/controllers/raffle_v1/roles_controller.rb +87 -0
  87. data/app/controllers/raffle_v1/stylesheets_controller.rb +19 -0
  88. data/app/controllers/raffle_v1/terms_and_conditions_controller.rb +118 -0
  89. data/app/controllers/raffle_v1/translation_keys_controller.rb +119 -0
  90. data/app/controllers/raffle_v1/translation_objects_controller.rb +87 -0
  91. data/app/controllers/raffle_v1/user_controller.rb +138 -0
  92. data/app/controllers/raffle_v1/versions_controller.rb +15 -0
  93. data/app/models/raffle_v1/ability.rb +30 -0
  94. data/app/models/raffle_v1/admin.rb +35 -0
  95. data/app/models/raffle_v1/admin_ability.rb +28 -0
  96. data/app/models/raffle_v1/locale.rb +29 -0
  97. data/app/models/raffle_v1/page.rb +26 -0
  98. data/app/models/raffle_v1/page_layout.rb +6 -0
  99. data/app/models/raffle_v1/program.rb +84 -0
  100. data/app/models/raffle_v1/program_locale.rb +11 -0
  101. data/app/models/raffle_v1/program_setting.rb +5 -0
  102. data/app/models/raffle_v1/role.rb +5 -0
  103. data/app/models/raffle_v1/roles_users.rb +5 -0
  104. data/app/models/raffle_v1/stylesheet.rb +9 -0
  105. data/app/models/raffle_v1/terms_and_condition.rb +17 -0
  106. data/app/models/raffle_v1/translation.rb +29 -0
  107. data/app/models/raffle_v1/translation_key.rb +35 -0
  108. data/app/models/raffle_v1/translation_object.rb +11 -0
  109. data/app/models/raffle_v1/user.rb +108 -0
  110. data/config/rafflev1.rb +6 -0
  111. data/db/migrate/20130123214645_devise_create_users.rb +49 -0
  112. data/db/migrate/20130124004626_devise_create_admins.rb +49 -0
  113. data/db/migrate/20130124231541_create_versions.rb +18 -0
  114. data/db/migrate/20130127235347_create_programs.rb +9 -0
  115. data/db/migrate/20130129155515_add_domain_fields_to_programs.rb +6 -0
  116. data/db/migrate/20130129160949_create_terms_and_conditions.rb +18 -0
  117. data/db/migrate/20130129183112_add_program_to_users.rb +5 -0
  118. data/db/migrate/20130129204204_add_username_to_users.rb +6 -0
  119. data/db/migrate/20130129211205_create_roles.rb +9 -0
  120. data/db/migrate/20130129212302_create_roles_users.rb +12 -0
  121. data/db/migrate/20130130013315_create_locales.rb +11 -0
  122. data/db/migrate/20130130154500_create_program_locales.rb +8 -0
  123. data/db/migrate/20130130223342_add_settings_to_users.rb +5 -0
  124. data/db/migrate/20130130223609_add_locale_available_to_program.rb +5 -0
  125. data/db/migrate/20130130223810_add_locales_to_versions.rb +5 -0
  126. data/db/migrate/20130130224141_add_locale_name_to_program.rb +5 -0
  127. data/db/migrate/20130130224327_add_admin_type_to_admins.rb +5 -0
  128. data/db/migrate/20130130225223_add_deleted_at_to_models.rb +9 -0
  129. data/db/migrate/20130130230516_create_translations.rb +13 -0
  130. data/db/migrate/20130131005653_add_timeout_field_to_program.rb +7 -0
  131. data/db/migrate/20130131144951_create_stylesheets.rb +14 -0
  132. data/db/migrate/20130202132442_add_tos_to_program.rb +5 -0
  133. data/db/migrate/20130202133149_add_programid_to_terms.rb +23 -0
  134. data/db/migrate/20130202193646_add_akm_to_terms_and_conditions.rb +5 -0
  135. data/db/migrate/20130203035054_create_translation_keys.rb +10 -0
  136. data/db/migrate/20130203214314_create_program_settings.rb +9 -0
  137. data/db/migrate/20130204025824_add_translationkey_to_translation.rb +5 -0
  138. data/db/migrate/20130204030555_create_translation_objects.rb +39 -0
  139. data/db/migrate/20130205203152_create_pages.rb +25 -0
  140. data/db/migrate/20130208042652_add_fields_to_page.rb +6 -0
  141. data/db/migrate/20130208043123_create_page_layouts.rb +12 -0
  142. data/db/migrate/20130208051925_add_statusitem_to_page.rb +5 -0
  143. data/db/migrate/20130306012135_add_fields_to_user.rb +40 -0
  144. data/db/migrate/20130306162357_change_bad_fields_on_user.rb +11 -0
  145. data/db/migrate/20130306163554_add_password_created_at_to_user.rb +6 -0
  146. data/db/migrate/20130306165455_add_confirmable_to_user.rb +14 -0
  147. data/db/migrate/20130306211253_add_username_index_to_user.rb +41 -0
  148. data/db/migrate/20130313011833_add_field_to_user.rb +5 -0
  149. data/lib/database_cleaner-0.7.2/Gemfile.lock +163 -0
  150. data/lib/database_cleaner-0.7.2/History.txt +209 -0
  151. data/lib/database_cleaner-0.7.2/LICENSE +20 -0
  152. data/lib/database_cleaner-0.7.2/README.textile +223 -0
  153. data/lib/database_cleaner-0.7.2/Rakefile +65 -0
  154. data/lib/database_cleaner-0.7.2/TODO +3 -0
  155. data/lib/database_cleaner-0.7.2/VERSION.yml +5 -0
  156. data/lib/database_cleaner-0.7.2/cucumber.yml +1 -0
  157. data/lib/database_cleaner-0.7.2/examples/Gemfile +49 -0
  158. data/lib/database_cleaner-0.7.2/examples/Gemfile.lock +163 -0
  159. data/lib/database_cleaner-0.7.2/examples/config/database.yml.example +8 -0
  160. data/{test/dummy/db/test.sqlite3 → lib/database_cleaner-0.7.2/examples/db/sqlite_databases_go_here} +0 -0
  161. data/lib/database_cleaner-0.7.2/examples/features/example.feature +11 -0
  162. data/lib/database_cleaner-0.7.2/examples/features/example_multiple_db.feature +23 -0
  163. data/lib/database_cleaner-0.7.2/examples/features/example_multiple_orm.feature +22 -0
  164. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/activerecord_steps.rb +31 -0
  165. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/couchpotato_steps.rb +31 -0
  166. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/datamapper_steps.rb +37 -0
  167. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/mongoid_steps.rb +23 -0
  168. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/mongomapper_steps.rb +31 -0
  169. data/lib/database_cleaner-0.7.2/examples/features/step_definitions/translation_steps.rb +55 -0
  170. data/lib/database_cleaner-0.7.2/examples/features/support/env.rb +62 -0
  171. data/lib/database_cleaner-0.7.2/examples/lib/activerecord_models.rb +41 -0
  172. data/lib/database_cleaner-0.7.2/examples/lib/couchpotato_models.rb +61 -0
  173. data/lib/database_cleaner-0.7.2/examples/lib/datamapper_models.rb +50 -0
  174. data/lib/database_cleaner-0.7.2/examples/lib/mongoid_models.rb +49 -0
  175. data/lib/database_cleaner-0.7.2/examples/lib/mongomapper_models.rb +51 -0
  176. data/lib/database_cleaner-0.7.2/features/cleaning.feature +22 -0
  177. data/lib/database_cleaner-0.7.2/features/cleaning_default_strategy.feature +19 -0
  178. data/lib/database_cleaner-0.7.2/features/cleaning_multiple_dbs.feature +21 -0
  179. data/lib/database_cleaner-0.7.2/features/cleaning_multiple_orms.feature +29 -0
  180. data/lib/database_cleaner-0.7.2/features/step_definitions/database_cleaner_steps.rb +32 -0
  181. data/lib/database_cleaner-0.7.2/features/support/env.rb +7 -0
  182. data/lib/database_cleaner-0.7.2/features/support/feature_runner.rb +39 -0
  183. data/lib/database_cleaner-0.7.2/lib/database_cleaner.rb +3 -0
  184. data/lib/database_cleaner-0.7.2/lib/database_cleaner/active_record/base.rb +53 -0
  185. data/lib/database_cleaner-0.7.2/lib/database_cleaner/active_record/deletion.rb +69 -0
  186. data/lib/database_cleaner-0.7.2/lib/database_cleaner/active_record/transaction.rb +28 -0
  187. data/lib/database_cleaner-0.7.2/lib/database_cleaner/active_record/truncation.rb +151 -0
  188. data/lib/database_cleaner-0.7.2/lib/database_cleaner/base.rb +138 -0
  189. data/lib/database_cleaner-0.7.2/lib/database_cleaner/configuration.rb +94 -0
  190. data/lib/database_cleaner-0.7.2/lib/database_cleaner/couch_potato/base.rb +7 -0
  191. data/lib/database_cleaner-0.7.2/lib/database_cleaner/couch_potato/truncation.rb +28 -0
  192. data/lib/database_cleaner-0.7.2/lib/database_cleaner/cucumber.rb +11 -0
  193. data/lib/database_cleaner-0.7.2/lib/database_cleaner/data_mapper/base.rb +21 -0
  194. data/lib/database_cleaner-0.7.2/lib/database_cleaner/data_mapper/transaction.rb +26 -0
  195. data/lib/database_cleaner-0.7.2/lib/database_cleaner/data_mapper/truncation.rb +175 -0
  196. data/lib/database_cleaner-0.7.2/lib/database_cleaner/generic/base.rb +20 -0
  197. data/lib/database_cleaner-0.7.2/lib/database_cleaner/generic/truncation.rb +37 -0
  198. data/lib/database_cleaner-0.7.2/lib/database_cleaner/mongo/truncation.rb +22 -0
  199. data/lib/database_cleaner-0.7.2/lib/database_cleaner/mongo_mapper/base.rb +20 -0
  200. data/lib/database_cleaner-0.7.2/lib/database_cleaner/mongo_mapper/truncation.rb +19 -0
  201. data/lib/database_cleaner-0.7.2/lib/database_cleaner/mongoid/base.rb +20 -0
  202. data/lib/database_cleaner-0.7.2/lib/database_cleaner/mongoid/truncation.rb +20 -0
  203. data/lib/database_cleaner-0.7.2/lib/database_cleaner/null_strategy.rb +15 -0
  204. data/lib/database_cleaner-0.7.2/lib/database_cleaner/sequel/base.rb +22 -0
  205. data/lib/database_cleaner-0.7.2/lib/database_cleaner/sequel/transaction.rb +25 -0
  206. data/lib/database_cleaner-0.7.2/lib/database_cleaner/sequel/truncation.rb +50 -0
  207. data/lib/database_cleaner-0.7.2/spec/database_cleaner/active_record/base_spec.rb +144 -0
  208. data/lib/database_cleaner-0.7.2/spec/database_cleaner/active_record/transaction_spec.rb +77 -0
  209. data/lib/database_cleaner-0.7.2/spec/database_cleaner/active_record/truncation_spec.rb +76 -0
  210. data/lib/database_cleaner-0.7.2/spec/database_cleaner/base_spec.rb +493 -0
  211. data/lib/database_cleaner-0.7.2/spec/database_cleaner/configuration_spec.rb +294 -0
  212. data/lib/database_cleaner-0.7.2/spec/database_cleaner/couch_potato/truncation_spec.rb +41 -0
  213. data/lib/database_cleaner-0.7.2/spec/database_cleaner/data_mapper/base_spec.rb +30 -0
  214. data/lib/database_cleaner-0.7.2/spec/database_cleaner/data_mapper/transaction_spec.rb +23 -0
  215. data/lib/database_cleaner-0.7.2/spec/database_cleaner/data_mapper/truncation_spec.rb +11 -0
  216. data/lib/database_cleaner-0.7.2/spec/database_cleaner/generic/base_spec.rb +22 -0
  217. data/lib/database_cleaner-0.7.2/spec/database_cleaner/generic/truncation_spec.rb +78 -0
  218. data/lib/database_cleaner-0.7.2/spec/database_cleaner/mongo_mapper/base_spec.rb +33 -0
  219. data/lib/database_cleaner-0.7.2/spec/database_cleaner/mongo_mapper/mongo_examples.rb +8 -0
  220. data/lib/database_cleaner-0.7.2/spec/database_cleaner/mongo_mapper/truncation_spec.rb +74 -0
  221. data/lib/database_cleaner-0.7.2/spec/database_cleaner/sequel/base_spec.rb +32 -0
  222. data/lib/database_cleaner-0.7.2/spec/database_cleaner/sequel/transaction_spec.rb +21 -0
  223. data/lib/database_cleaner-0.7.2/spec/database_cleaner/sequel/truncation_spec.rb +13 -0
  224. data/lib/database_cleaner-0.7.2/spec/database_cleaner/shared_strategy_spec.rb +13 -0
  225. data/lib/database_cleaner-0.7.2/spec/rcov.opts +1 -0
  226. data/lib/database_cleaner-0.7.2/spec/spec.opts +7 -0
  227. data/lib/database_cleaner-0.7.2/spec/spec_helper.rb +19 -0
  228. data/lib/generators/raffle_v1/install/USAGE +8 -0
  229. data/lib/generators/raffle_v1/install/install_generator.rb +2 -2
  230. data/lib/raffle_v1/version.rb +1 -1
  231. metadata +266 -80
  232. data/test/dummy/db/development.sqlite3 +0 -0
  233. data/test/dummy/log/development.log +0 -1304
  234. data/test/dummy/tmp/cache/assets/CA9/000/sprockets%2F4a08cdc7528358910b09a742236ce1d5 +0 -0
  235. data/test/dummy/tmp/cache/assets/CB2/BD0/sprockets%2F85aac33f66112e73231ea0779f646d48 +0 -0
  236. data/test/dummy/tmp/cache/assets/CC8/930/sprockets%2Ff75c059e31f23788564cdeb37454997a +0 -0
  237. data/test/dummy/tmp/cache/assets/CEF/E80/sprockets%2Fd1d95274bb399cd78c4372bc6330679f +0 -0
  238. data/test/dummy/tmp/cache/assets/D00/C30/sprockets%2F7d453e5233c35cc0664189bd1c060dca +0 -0
  239. data/test/dummy/tmp/cache/assets/D06/390/sprockets%2F2db5f5807daaf42647f3f1614b2061c7 +0 -0
  240. data/test/dummy/tmp/cache/assets/D06/5C0/sprockets%2F10f71b69148321ca26d0bb94df09ed46 +0 -0
  241. data/test/dummy/tmp/cache/assets/D1E/8D0/sprockets%2Fd0f3965813d75eefebe5353981159cb3 +0 -0
  242. data/test/dummy/tmp/cache/assets/D35/FB0/sprockets%2Ff706372b7e19b270321cbce180d7edd3 +0 -0
  243. data/test/dummy/tmp/cache/assets/D49/1E0/sprockets%2F1c8eb9a82d46a60faa9b194282db8976 +0 -0
  244. data/test/dummy/tmp/cache/assets/D67/FA0/sprockets%2F3072f540a4a5f4af3636dc9cee4bd821 +0 -0
  245. data/test/dummy/tmp/cache/assets/D76/180/sprockets%2Fe06d9366092cba68641ddefa60cb5e97 +0 -0
  246. data/test/dummy/tmp/cache/assets/D9B/470/sprockets%2Fb7bb6ac37b3929f36a390e4f5b70aec3 +0 -0
  247. data/test/dummy/tmp/cache/assets/D9F/080/sprockets%2F67fdbee8438ea0fdd3406c4f3b277a14 +0 -0
  248. data/test/dummy/tmp/cache/assets/DCD/970/sprockets%2Fb3d4eb65c6d389bff1cb035a7c4e74d2 +0 -0
  249. data/test/dummy/tmp/cache/assets/DD2/7D0/sprockets%2F6d8fc01a6bd28f831fdbe625ea56f2c7 +0 -0
  250. data/test/dummy/tmp/cache/assets/DF1/CA0/sprockets%2Faa2be5b854dacdce2a30a0fff7412887 +0 -0
  251. data/test/dummy/tmp/cache/assets/E0B/E40/sprockets%2F96b1b0fa8f4feee3299fc9dcd2078d0d +0 -0
@@ -0,0 +1,25 @@
1
+ require 'database_cleaner/sequel/base'
2
+ module DatabaseCleaner
3
+ module Sequel
4
+ class Transaction
5
+ include ::DatabaseCleaner::Sequel::Base
6
+
7
+ def start
8
+ @fibers||= []
9
+ db= self.db
10
+ f= Fiber.new do
11
+ db.transaction(:rollback => :always, :savepoint => true) do
12
+ Fiber.yield
13
+ end
14
+ end
15
+ f.resume
16
+ @fibers<< f
17
+ end
18
+
19
+ def clean
20
+ f= @fibers.pop
21
+ f.resume
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,50 @@
1
+ require "database_cleaner/generic/truncation"
2
+ require 'database_cleaner/sequel/base'
3
+
4
+ module DatabaseCleaner
5
+ module Sequel
6
+ class Truncation
7
+ include ::DatabaseCleaner::Sequel::Base
8
+ include ::DatabaseCleaner::Generic::Truncation
9
+
10
+ def clean
11
+ case db_type= db.url.sub(/:.+/,'').to_sym
12
+ when :postgres
13
+ # PostgreSQL requires all tables with FKs to be truncates in the same command, or have the CASCADE keyword
14
+ # appended. Bulk truncation without CASCADE is:
15
+ # * Safer. Tables outside of tables_to_truncate won't be affected.
16
+ # * Faster. Less roundtrips to the db.
17
+ unless (tables= tables_to_truncate(db)).empty?
18
+ all_tables= tables.map{|t| %["#{t}"]}.join ','
19
+ db.run "TRUNCATE TABLE #{all_tables};"
20
+ end
21
+ else
22
+ # Truncate each table normally
23
+ each_table do |db, table|
24
+ db[table].truncate
25
+ end
26
+ end
27
+ end
28
+
29
+ def each_table
30
+ tables_to_truncate(db).each do |table|
31
+ yield db, table
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def tables_to_truncate(db)
38
+ (@only || db.tables) - @tables_to_exclude
39
+ end
40
+
41
+ # overwritten
42
+ def migration_storage_name
43
+ :schema_info
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+
50
+
@@ -0,0 +1,144 @@
1
+ require 'spec_helper'
2
+ require 'active_record'
3
+ require 'database_cleaner/active_record/base'
4
+ require 'database_cleaner/shared_strategy_spec'
5
+
6
+ module DatabaseCleaner
7
+ describe ActiveRecord do
8
+ it { should respond_to(:available_strategies) }
9
+
10
+ describe "config_file_location" do
11
+ subject { ActiveRecord.config_file_location }
12
+
13
+ it "should default to DatabaseCleaner.root / config / database.yml" do
14
+ ActiveRecord.config_file_location=nil
15
+ DatabaseCleaner.should_receive(:app_root).and_return("/path/to")
16
+ subject.should == '/path/to/config/database.yml'
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ module ActiveRecord
23
+ class ExampleStrategy
24
+ include ::DatabaseCleaner::ActiveRecord::Base
25
+ end
26
+
27
+ describe ExampleStrategy do
28
+ let :config_location do
29
+ '/path/to/config/database.yml'
30
+ end
31
+
32
+ before { ::DatabaseCleaner::ActiveRecord.stub(:config_file_location).and_return(config_location) }
33
+
34
+ it_should_behave_like "a generic strategy"
35
+
36
+ describe "db" do
37
+
38
+ it "should store my desired db" do
39
+ subject.stub(:load_config)
40
+
41
+ subject.db = :my_db
42
+ subject.db.should == :my_db
43
+ end
44
+
45
+ it "should default to :default" do
46
+ subject.db.should == :default
47
+ end
48
+
49
+ it "should load_config when I set db" do
50
+ subject.should_receive(:load_config)
51
+ subject.db = :my_db
52
+ end
53
+ end
54
+
55
+ describe "load_config" do
56
+
57
+ before do
58
+ subject.db = :my_db
59
+ yaml = <<-Y
60
+ my_db:
61
+ database: <%= "ONE".downcase %>
62
+ Y
63
+ File.stub(:file?).with(config_location).and_return(true)
64
+ IO.stub(:read).with(config_location).and_return(yaml)
65
+ end
66
+
67
+ it "should parse the config" do
68
+ YAML.should_receive(:load).and_return( {:nil => nil} )
69
+ subject.load_config
70
+ end
71
+
72
+ it "should process erb in the config" do
73
+ transformed = <<-Y
74
+ my_db:
75
+ database: one
76
+ Y
77
+ YAML.should_receive(:load).with(transformed).and_return({ "my_db" => {"database" => "one"} })
78
+ subject.load_config
79
+ end
80
+
81
+ it "should store the relevant config in connection_hash" do
82
+ subject.load_config
83
+ subject.connection_hash.should == {"database" => "one"}
84
+ end
85
+
86
+ it "should skip config if config file is not available" do
87
+ File.should_receive(:file?).with(config_location).and_return(false)
88
+ subject.load_config
89
+ subject.connection_hash.should be_blank
90
+ end
91
+
92
+ it "skips the file when the db is set to :default" do
93
+ # to avoid https://github.com/bmabey/database_cleaner/issues/72
94
+ subject.db = :default
95
+ YAML.should_not_receive(:load)
96
+ subject.load_config
97
+ end
98
+
99
+ end
100
+
101
+ describe "connection_hash" do
102
+ it "should store connection_hash" do
103
+ subject.connection_hash = { :key => "value" }
104
+ subject.connection_hash.should == { :key => "value" }
105
+ end
106
+ end
107
+
108
+ describe "create_connection_klass" do
109
+ it "should return a class" do
110
+ subject.create_connection_klass.should be_a(Class)
111
+ end
112
+
113
+ it "should return a class extending ::ActiveRecord::Base" do
114
+ subject.create_connection_klass.ancestors.should include(::ActiveRecord::Base)
115
+ end
116
+ end
117
+
118
+ describe "connection_klass" do
119
+ it { expect{ subject.connection_klass }.to_not raise_error }
120
+ it "should default to ActiveRecord::Base" do
121
+ subject.connection_klass.should == ::ActiveRecord::Base
122
+ end
123
+
124
+ context "when connection_hash is set" do
125
+ let(:hash) { mock("hash") }
126
+ before { subject.stub(:connection_hash).and_return(hash) }
127
+
128
+ it "should create connection_klass if it doesnt exist if connection_hash is set" do
129
+ subject.should_receive(:create_connection_klass).and_return(mock('class').as_null_object)
130
+ subject.connection_klass
131
+ end
132
+
133
+ it "should configure the class from create_connection_klass if connection_hash is set" do
134
+ klass = mock('klass')
135
+ klass.should_receive(:establish_connection).with(hash)
136
+
137
+ subject.should_receive(:create_connection_klass).and_return(klass)
138
+ subject.connection_klass
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,77 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'database_cleaner/active_record/transaction'
3
+ require 'active_record'
4
+
5
+ module DatabaseCleaner
6
+ module ActiveRecord
7
+
8
+ describe Transaction do
9
+ let (:connection) { mock("connection") }
10
+ before(:each) do
11
+ ::ActiveRecord::Base.stub!(:connection).and_return(connection)
12
+ end
13
+
14
+ describe "#start" do
15
+ it "should increment open transactions if possible" do
16
+ connection.stub!(:respond_to?).with(:increment_open_transactions).and_return(true)
17
+ connection.stub!(:begin_db_transaction)
18
+
19
+ connection.should_receive(:increment_open_transactions)
20
+ Transaction.new.start
21
+ end
22
+
23
+ it "should tell ActiveRecord to increment connection if its not possible to increment current connection" do
24
+ connection.stub!(:respond_to?).with(:increment_open_transactions).and_return(false)
25
+ connection.stub!(:begin_db_transaction)
26
+
27
+ ::ActiveRecord::Base.should_receive(:increment_open_transactions)
28
+ Transaction.new.start
29
+ end
30
+
31
+ it "should start a transaction" do
32
+ connection.stub!(:increment_open_transactions)
33
+
34
+ connection.should_receive(:begin_db_transaction)
35
+ Transaction.new.start
36
+ end
37
+ end
38
+
39
+ describe "#clean" do
40
+ it "should start a transaction" do
41
+ connection.should_receive(:open_transactions).and_return(1)
42
+
43
+ connection.stub!(:decrement_open_transactions)
44
+
45
+ connection.should_receive(:rollback_db_transaction)
46
+ Transaction.new.clean
47
+ end
48
+
49
+ it "should decrement open transactions if possible" do
50
+ connection.should_receive(:open_transactions).and_return(1)
51
+
52
+ connection.stub!(:respond_to?).with(:decrement_open_transactions).and_return(true)
53
+ connection.stub!(:rollback_db_transaction)
54
+
55
+ connection.should_receive(:decrement_open_transactions)
56
+ Transaction.new.clean
57
+ end
58
+
59
+ it "should not try to decrement or rollback if open_transactions is 0 for whatever reason" do
60
+ connection.should_receive(:open_transactions).and_return(0)
61
+
62
+ Transaction.new.clean
63
+ end
64
+
65
+ it "should decrement connection via ActiveRecord::Base if connection won't" do
66
+ connection.should_receive(:open_transactions).and_return(1)
67
+ connection.stub!(:respond_to?).with(:decrement_open_transactions).and_return(false)
68
+ connection.stub!(:rollback_db_transaction)
69
+
70
+ ::ActiveRecord::Base.should_receive(:decrement_open_transactions)
71
+ Transaction.new.clean
72
+ end
73
+ end
74
+ end
75
+
76
+ end
77
+ end
@@ -0,0 +1,76 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'active_record'
3
+ require 'database_cleaner/active_record/truncation'
4
+
5
+
6
+ module ActiveRecord
7
+ module ConnectionAdapters
8
+ [MysqlAdapter, Mysql2Adapter, SQLite3Adapter, JdbcAdapter, PostgreSQLAdapter, IBM_DBAdapter].each do |adapter|
9
+ describe adapter, "#truncate_table" do
10
+ it "responds" do
11
+ adapter.new("foo").should respond_to(:truncate_table)
12
+ end
13
+ it "should truncate the table"
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ module DatabaseCleaner
20
+ module ActiveRecord
21
+
22
+ describe Truncation do
23
+ let(:connection) { mock('connection') }
24
+
25
+
26
+ before(:each) do
27
+ connection.stub!(:disable_referential_integrity).and_yield
28
+ connection.stub!(:views).and_return([])
29
+ ::ActiveRecord::Base.stub!(:connection).and_return(connection)
30
+ end
31
+
32
+ it "should truncate all tables except for schema_migrations" do
33
+ connection.stub!(:tables).and_return(%w[schema_migrations widgets dogs])
34
+
35
+ connection.should_receive(:truncate_tables).with(['widgets', 'dogs'])
36
+ Truncation.new.clean
37
+ end
38
+
39
+ it "should only truncate the tables specified in the :only option when provided" do
40
+ connection.stub!(:tables).and_return(%w[schema_migrations widgets dogs])
41
+
42
+ connection.should_receive(:truncate_tables).with(['widgets'])
43
+
44
+ Truncation.new(:only => ['widgets']).clean
45
+ end
46
+
47
+ it "should not truncate the tables specified in the :except option" do
48
+ connection.stub!(:tables).and_return(%w[schema_migrations widgets dogs])
49
+
50
+ connection.should_receive(:truncate_tables).with(['dogs'])
51
+
52
+ Truncation.new(:except => ['widgets']).clean
53
+ end
54
+
55
+ it "should raise an error when :only and :except options are used" do
56
+ running {
57
+ Truncation.new(:except => ['widgets'], :only => ['widgets'])
58
+ }.should raise_error(ArgumentError)
59
+ end
60
+
61
+ it "should raise an error when invalid options are provided" do
62
+ running { Truncation.new(:foo => 'bar') }.should raise_error(ArgumentError)
63
+ end
64
+
65
+ it "should not truncate views" do
66
+ connection.stub!(:tables).and_return(%w[widgets dogs])
67
+ connection.stub!(:views).and_return(["widgets"])
68
+
69
+ connection.should_receive(:truncate_tables).with(['dogs'])
70
+
71
+ Truncation.new.clean
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,493 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'database_cleaner/active_record/transaction'
3
+ require 'database_cleaner/data_mapper/transaction'
4
+ require 'database_cleaner/mongo_mapper/truncation'
5
+ require 'database_cleaner/mongoid/truncation'
6
+ require 'database_cleaner/couch_potato/truncation'
7
+
8
+ module DatabaseCleaner
9
+ describe Base do
10
+
11
+ describe "autodetect" do
12
+
13
+ #Cache all ORMs, we'll need them later but not now.
14
+ before(:all) do
15
+ Temp_AR = ::ActiveRecord if defined?(::ActiveRecord) and not defined?(Temp_AR)
16
+ Temp_DM = ::DataMapper if defined?(::DataMapper) and not defined?(Temp_DM)
17
+ Temp_MM = ::MongoMapper if defined?(::MongoMapper) and not defined?(Temp_MM)
18
+ Temp_MO = ::Mongoid if defined?(::Mongoid) and not defined?(Temp_MO)
19
+ Temp_CP = ::CouchPotato if defined?(::CouchPotato) and not defined?(Temp_CP)
20
+ Temp_SQ = ::Sequel if defined?(::Sequel) and not defined?(Temp_SQ)
21
+ end
22
+
23
+ #Remove all ORM mocks and restore from cache
24
+ after(:all) do
25
+ Object.send(:remove_const, 'ActiveRecord') if defined?(::ActiveRecord)
26
+ Object.send(:remove_const, 'DataMapper') if defined?(::DataMapper)
27
+ Object.send(:remove_const, 'MongoMapper') if defined?(::MongoMapper)
28
+ Object.send(:remove_const, 'Mongoid') if defined?(::Mongoid)
29
+ Object.send(:remove_const, 'CouchPotato') if defined?(::CouchPotato)
30
+ Object.send(:remove_const, 'Sequel') if defined?(::Sequel)
31
+
32
+
33
+ # Restore ORMs
34
+ ::ActiveRecord = Temp_AR if defined? Temp_AR
35
+ ::DataMapper = Temp_DM if defined? Temp_DM
36
+ ::MongoMapper = Temp_MM if defined? Temp_MM
37
+ ::Mongoid = Temp_MO if defined? Temp_MO
38
+ ::CouchPotato = Temp_CP if defined? Temp_CP
39
+ end
40
+
41
+ #reset the orm mocks
42
+ before(:each) do
43
+ Object.send(:remove_const, 'ActiveRecord') if defined?(::ActiveRecord)
44
+ Object.send(:remove_const, 'DataMapper') if defined?(::DataMapper)
45
+ Object.send(:remove_const, 'MongoMapper') if defined?(::MongoMapper)
46
+ Object.send(:remove_const, 'Mongoid') if defined?(::Mongoid)
47
+ Object.send(:remove_const, 'CouchPotato') if defined?(::CouchPotato)
48
+ Object.send(:remove_const, 'Sequel') if defined?(::Sequel)
49
+ end
50
+
51
+ let(:cleaner) { DatabaseCleaner::Base.new :autodetect }
52
+
53
+ it "should raise an error when no ORM is detected" do
54
+ running { cleaner }.should raise_error(DatabaseCleaner::NoORMDetected)
55
+ end
56
+
57
+ it "should detect ActiveRecord first" do
58
+ Object.const_set('ActiveRecord','Actively mocking records.')
59
+ Object.const_set('DataMapper', 'Mapping data mocks')
60
+ Object.const_set('MongoMapper', 'Mapping mock mongos')
61
+ Object.const_set('Mongoid', 'Mongoid mock')
62
+ Object.const_set('CouchPotato', 'Couching mock potatos')
63
+ Object.const_set('Sequel', 'Sequel mock')
64
+
65
+ cleaner.orm.should == :active_record
66
+ cleaner.should be_auto_detected
67
+ end
68
+
69
+ it "should detect DataMapper second" do
70
+ Object.const_set('DataMapper', 'Mapping data mocks')
71
+ Object.const_set('MongoMapper', 'Mapping mock mongos')
72
+ Object.const_set('Mongoid', 'Mongoid mock')
73
+ Object.const_set('CouchPotato', 'Couching mock potatos')
74
+ Object.const_set('Sequel', 'Sequel mock')
75
+
76
+ cleaner.orm.should == :data_mapper
77
+ cleaner.should be_auto_detected
78
+ end
79
+
80
+ it "should detect MongoMapper third" do
81
+ Object.const_set('MongoMapper', 'Mapping mock mongos')
82
+ Object.const_set('Mongoid', 'Mongoid mock')
83
+ Object.const_set('CouchPotato', 'Couching mock potatos')
84
+ Object.const_set('Sequel', 'Sequel mock')
85
+
86
+ cleaner.orm.should == :mongo_mapper
87
+ cleaner.should be_auto_detected
88
+ end
89
+
90
+ it "should detect Mongoid fourth" do
91
+ Object.const_set('Mongoid', 'Mongoid mock')
92
+ Object.const_set('CouchPotato', 'Couching mock potatos')
93
+ Object.const_set('Sequel', 'Sequel mock')
94
+
95
+ cleaner.orm.should == :mongoid
96
+ cleaner.should be_auto_detected
97
+ end
98
+
99
+ it "should detect CouchPotato fifth" do
100
+ Object.const_set('CouchPotato', 'Couching mock potatos')
101
+ Object.const_set('Sequel', 'Sequel mock')
102
+
103
+ cleaner.orm.should == :couch_potato
104
+ cleaner.should be_auto_detected
105
+ end
106
+
107
+ it "should detect Sequel last" do
108
+ Object.const_set('Sequel', 'Sequel mock')
109
+
110
+ cleaner.orm.should == :sequel
111
+ cleaner.should be_auto_detected
112
+ end
113
+ end
114
+
115
+ describe "orm_module" do
116
+ it "should ask ::DatabaseCleaner what the module is for its orm" do
117
+ orm = mock("orm")
118
+ mockule = mock("module")
119
+
120
+ cleaner = ::DatabaseCleaner::Base.new
121
+ cleaner.should_receive(:orm).and_return(orm)
122
+
123
+ ::DatabaseCleaner.should_receive(:orm_module).with(orm).and_return(mockule)
124
+
125
+ cleaner.send(:orm_module).should == mockule
126
+ end
127
+ end
128
+
129
+ describe "comparison" do
130
+ it "should be equal if orm, connection and strategy are the same" do
131
+ strategy = mock("strategy")
132
+
133
+ one = DatabaseCleaner::Base.new(:active_record,:connection => :default)
134
+ one.strategy = strategy
135
+
136
+ two = DatabaseCleaner::Base.new(:active_record,:connection => :default)
137
+ two.strategy = strategy
138
+
139
+ one.should == two
140
+ two.should == one
141
+ end
142
+ end
143
+
144
+ describe "initialization" do
145
+ context "db specified" do
146
+ subject { ::DatabaseCleaner::Base.new(:active_record,:connection => :my_db) }
147
+
148
+ it "should store db from :connection in params hash" do
149
+ subject.db.should == :my_db
150
+ end
151
+ end
152
+
153
+ describe "orm" do
154
+ it "should store orm" do
155
+ cleaner = ::DatabaseCleaner::Base.new :a_orm
156
+ cleaner.orm.should == :a_orm
157
+ end
158
+
159
+ it "converts string to symbols" do
160
+ cleaner = ::DatabaseCleaner::Base.new "mongoid"
161
+ cleaner.orm.should == :mongoid
162
+ end
163
+
164
+ it "is autodetected if orm is not provided" do
165
+ cleaner = ::DatabaseCleaner::Base.new
166
+ cleaner.should be_auto_detected
167
+ end
168
+
169
+ it "is autodetected if you specify :autodetect" do
170
+ cleaner = ::DatabaseCleaner::Base.new "autodetect"
171
+ cleaner.should be_auto_detected
172
+ end
173
+
174
+ it "should default to autodetect upon initalisation" do
175
+ subject.should be_auto_detected
176
+ end
177
+ end
178
+ end
179
+
180
+ describe "db" do
181
+ it "should default to :default" do
182
+ subject.db.should == :default
183
+ end
184
+
185
+ it "should return any stored db value" do
186
+ subject.stub(:strategy_db=)
187
+ subject.db = :test_db
188
+ subject.db.should == :test_db
189
+ end
190
+
191
+ it "should pass db to any specified strategy" do
192
+ subject.should_receive(:strategy_db=).with(:a_new_db)
193
+ subject.db = :a_new_db
194
+ end
195
+ end
196
+
197
+ describe "strategy_db=" do
198
+ let(:strategy) { mock("strategy") }
199
+
200
+ before(:each) do
201
+ subject.strategy = strategy
202
+ end
203
+
204
+ it "should check that strategy supports db specification" do
205
+ strategy.should_receive(:respond_to?).with(:db=).and_return(true)
206
+ strategy.stub(:db=)
207
+ subject.strategy_db = :a_db
208
+ end
209
+
210
+ context "when strategy supports db specification" do
211
+ before(:each) { strategy.stub(:respond_to?).with(:db=).and_return true }
212
+
213
+ it "should pass db to the strategy" do
214
+ strategy.should_receive(:db=).with(:a_db)
215
+ subject.strategy_db = :a_db
216
+ end
217
+ end
218
+
219
+ context "when strategy doesn't supports db specification" do
220
+ before(:each) { strategy.stub(:respond_to?).with(:db=).and_return false }
221
+
222
+ it "should check to see if db is :default" do
223
+ db = mock("default")
224
+ db.should_receive(:==).with(:default).and_return(true)
225
+
226
+ subject.strategy_db = db
227
+ end
228
+
229
+ it "should raise an argument error when db isn't default" do
230
+ db = mock("a db")
231
+ expect{ subject.strategy_db = db }.to raise_error ArgumentError
232
+ end
233
+ end
234
+ end
235
+
236
+ describe "clean_with" do
237
+ let (:strategy) { mock("strategy",:clean => true) }
238
+
239
+ before(:each) { subject.stub(:create_strategy).with(anything).and_return(strategy) }
240
+
241
+ it "should pass all arguments to create_strategy" do
242
+ subject.should_receive(:create_strategy).with(:lorum, :dollar, :amet, :ipsum => "random").and_return(strategy)
243
+ subject.clean_with :lorum, :dollar, :amet, { :ipsum => "random" }
244
+ end
245
+
246
+ it "should invoke clean on the created strategy" do
247
+ strategy.should_receive(:clean)
248
+ subject.clean_with :strategy
249
+ end
250
+
251
+ it "should return the strategy" do
252
+ subject.clean_with( :strategy ).should == strategy
253
+ end
254
+ end
255
+
256
+ describe "clean_with!" do
257
+ let (:strategy) { mock("strategy",:clean => true) }
258
+
259
+ before(:each) { subject.stub(:create_strategy).with(anything).and_return(strategy) }
260
+
261
+ it "should pass all arguments to create_strategy" do
262
+ subject.should_receive(:create_strategy).with(:lorum, :dollar, :amet, :ipsum => "random").and_return(strategy)
263
+ subject.clean_with! :lorum, :dollar, :amet, { :ipsum => "random" }
264
+ end
265
+
266
+ it "should invoke clean on the created strategy" do
267
+ strategy.should_receive(:clean)
268
+ subject.clean_with! :strategy
269
+ end
270
+
271
+ it "should return the strategy" do
272
+ subject.clean_with!( :strategy ).should == strategy
273
+ end
274
+ end
275
+
276
+ describe "create_strategy" do
277
+ let(:klass) { mock("klass",:new => mock("instance")) }
278
+
279
+ before :each do
280
+ subject.stub(:orm_strategy).and_return(klass)
281
+ end
282
+
283
+ it "should pass the first argument to orm_strategy" do
284
+ subject.should_receive(:orm_strategy).with(:strategy).and_return(Object)
285
+ subject.create_strategy :strategy
286
+ end
287
+ it "should pass the remainding argument to orm_strategy.new" do
288
+ klass.should_receive(:new).with(:params => {:lorum => "ipsum"})
289
+
290
+ subject.create_strategy :strategy, {:params => {:lorum => "ipsum"}}
291
+ end
292
+ it "should return the resulting strategy" do
293
+ subject.create_strategy( :strategy ).should == klass.new
294
+ end
295
+ end
296
+
297
+ describe "strategy=" do
298
+ let(:mock_strategy) { mock("strategy") }
299
+
300
+ it "should proxy symbolised strategies to create_strategy" do
301
+ subject.should_receive(:create_strategy).with(:symbol)
302
+ subject.strategy = :symbol
303
+ end
304
+
305
+ it "should proxy params with symbolised strategies" do
306
+ subject.should_receive(:create_strategy).with(:symbol,:param => "one")
307
+ subject.strategy= :symbol, {:param => "one"}
308
+ end
309
+
310
+ it "should accept strategy objects" do
311
+ expect{ subject.strategy = mock_strategy }.to_not raise_error
312
+ end
313
+
314
+ it "should raise argument error when params given with strategy Object" do
315
+ expect{ subject.strategy = mock("object"), {:param => "one"} }.to raise_error ArgumentError
316
+ end
317
+
318
+ it "should attempt to set strategy db" do
319
+ subject.stub(:db).and_return(:my_db)
320
+ subject.should_receive(:strategy_db=).with(:my_db)
321
+ subject.strategy = mock_strategy
322
+ end
323
+
324
+ it "should return the stored strategy" do
325
+ result = subject.strategy = mock_strategy
326
+ result.should == mock_strategy
327
+ end
328
+ end
329
+
330
+ describe "strategy" do
331
+ subject { ::DatabaseCleaner::Base.new :a_orm }
332
+
333
+ it "returns a null strategy when strategy no set and undetectable" do
334
+ subject.instance_values["@strategy"] = nil
335
+ subject.strategy.should == DatabaseCleaner::NullStrategy
336
+ end
337
+
338
+ it "returns the set strategy" do
339
+ strategum = mock("strategy")
340
+ subject.strategy = strategum
341
+ subject.strategy.should == strategum
342
+ end
343
+ end
344
+
345
+ describe "orm=" do
346
+ it "should stored the desired orm" do
347
+ subject.orm.should_not == :desired_orm
348
+ subject.orm = :desired_orm
349
+ subject.orm.should == :desired_orm
350
+ end
351
+ end
352
+
353
+ describe "orm" do
354
+ let(:mock_orm) { mock("orm") }
355
+
356
+ it "should return orm if orm set" do
357
+ subject.instance_variable_set "@orm", mock_orm
358
+ subject.orm.should == mock_orm
359
+ end
360
+
361
+ context "orm isn't set" do
362
+ before(:each) { subject.instance_variable_set "@orm", nil }
363
+
364
+ it "should run autodetect if orm isn't set" do
365
+ subject.should_receive(:autodetect)
366
+ subject.orm
367
+ end
368
+
369
+ it "should return the result of autodetect if orm isn't set" do
370
+ subject.stub(:autodetect).and_return(mock_orm)
371
+ subject.orm.should == mock_orm
372
+ end
373
+ end
374
+ end
375
+
376
+ describe "proxy methods" do
377
+ let (:strategy) { mock("strategy") }
378
+
379
+ before(:each) do
380
+ subject.stub(:strategy).and_return(strategy)
381
+ end
382
+
383
+ describe "start" do
384
+ it "should proxy start to the strategy" do
385
+ strategy.should_receive(:start)
386
+ subject.start
387
+ end
388
+ end
389
+
390
+ describe "clean" do
391
+ it "should proxy clean to the strategy" do
392
+ strategy.should_receive(:clean)
393
+ subject.clean
394
+ end
395
+ end
396
+
397
+ describe "clean!" do
398
+ it "should proxy clean! to the strategy clean" do
399
+ strategy.should_receive(:clean)
400
+ subject.clean!
401
+ end
402
+ end
403
+ end
404
+
405
+ describe "auto_detected?" do
406
+ it "should return true unless @autodetected is nil" do
407
+ subject.instance_variable_set("@autodetected","not nil")
408
+ subject.auto_detected?.should be_true
409
+ end
410
+
411
+ it "should return false if @autodetect is nil" do
412
+ subject.instance_variable_set("@autodetected",nil)
413
+ subject.auto_detected?.should be_false
414
+ end
415
+ end
416
+
417
+ describe "orm_strategy" do
418
+ let (:klass) { mock("klass") }
419
+
420
+ before(:each) do
421
+ subject.stub(:orm_module).and_return(klass)
422
+ end
423
+
424
+ context "in response to a LoadError" do
425
+ before(:each) { subject.should_receive(:require).with(anything).and_raise(LoadError) }
426
+
427
+ it "should catch LoadErrors" do
428
+ expect { subject.send(:orm_strategy,:a_strategy) }.to_not raise_error LoadError
429
+ end
430
+
431
+ it "should raise UnknownStrategySpecified" do
432
+ expect { subject.send(:orm_strategy,:a_strategy) }.to raise_error UnknownStrategySpecified
433
+ end
434
+
435
+ it "should ask orm_module if it will list available_strategies" do
436
+ klass.should_receive(:respond_to?).with(:available_strategies)
437
+
438
+ subject.stub(:orm_module).and_return(klass)
439
+
440
+ expect { subject.send(:orm_strategy,:a_strategy) }.to raise_error UnknownStrategySpecified
441
+ end
442
+
443
+ it "should use available_strategies (for the error message) if its available" do
444
+ klass.stub(:respond_to?).with(:available_strategies).and_return(true)
445
+ klass.should_receive(:available_strategies).and_return([])
446
+
447
+ subject.stub(:orm_module).and_return(klass)
448
+
449
+ expect { subject.send(:orm_strategy,:a_strategy) }.to raise_error UnknownStrategySpecified
450
+ end
451
+ end
452
+
453
+ it "should return the constant of the Strategy class requested" do
454
+ strategy_klass = mock("strategy klass")
455
+
456
+ subject.stub(:require).with(anything).and_return(true)
457
+
458
+ klass.should_receive(:const_get).with("Cunningplan").and_return(strategy_klass)
459
+
460
+ subject.send(:orm_strategy, :cunningplan).should == strategy_klass
461
+ end
462
+
463
+ end
464
+
465
+ describe 'set_default_orm_strategy' do
466
+ it 'sets strategy to :transaction for ActiveRecord' do
467
+ cleaner = DatabaseCleaner::Base.new(:active_record)
468
+ cleaner.strategy.should be_instance_of DatabaseCleaner::ActiveRecord::Transaction
469
+ end
470
+
471
+ it 'sets strategy to :transaction for DataMapper' do
472
+ cleaner = DatabaseCleaner::Base.new(:data_mapper)
473
+ cleaner.strategy.should be_instance_of DatabaseCleaner::DataMapper::Transaction
474
+ end
475
+
476
+ it 'sets strategy to :truncation for MongoMapper' do
477
+ cleaner = DatabaseCleaner::Base.new(:mongo_mapper)
478
+ cleaner.strategy.should be_instance_of DatabaseCleaner::MongoMapper::Truncation
479
+ end
480
+
481
+ it 'sets strategy to :truncation for Mongoid' do
482
+ cleaner = DatabaseCleaner::Base.new(:mongoid)
483
+ cleaner.strategy.should be_instance_of DatabaseCleaner::Mongoid::Truncation
484
+ end
485
+
486
+ it 'sets strategy to :truncation for CouchPotato' do
487
+ cleaner = DatabaseCleaner::Base.new(:couch_potato)
488
+ cleaner.strategy.should be_instance_of DatabaseCleaner::CouchPotato::Truncation
489
+ end
490
+ end
491
+
492
+ end
493
+ end