rules_engine 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (505) hide show
  1. data/LICENSE +0 -0
  2. data/README.textile +12 -12
  3. data/VERSION +1 -1
  4. data/lib/rules_engine.rb +4 -18
  5. data/lib/rules_engine/cache.rb +1 -1
  6. data/lib/rules_engine/discovery.rb +14 -5
  7. data/lib/rules_engine/process/auditor.rb +62 -0
  8. data/lib/rules_engine/process/auditor/db_auditor.rb +48 -0
  9. data/lib/rules_engine/process/runner.rb +147 -0
  10. data/lib/rules_engine/process/runner/db_runner.rb +78 -0
  11. data/lib/rules_engine/publish/publisher.rb +53 -0
  12. data/lib/rules_engine/publish/publisher/db_publisher.rb +93 -0
  13. data/lib/rules_engine/rule.rb +6 -6
  14. data/lib/rules_engine/rule_outcome.rb +4 -4
  15. data/lib/rules_engine_view.rb +14 -0
  16. data/lib/rules_engine_view/boxes.rb +0 -0
  17. data/lib/rules_engine_view/buttons.rb +0 -0
  18. data/lib/rules_engine_view/defer.rb +19 -3
  19. data/lib/rules_engine_view/form_fields.rb +0 -0
  20. data/lib/rules_engine_view/model_loader.rb +6 -2
  21. data/lib/rules_engine_view/navigate.rb +1 -3
  22. data/rails_generators/manifests/rule_complex.rb +30 -0
  23. data/rails_generators/manifests/rule_complex.yml +24 -0
  24. data/rails_generators/manifests/rule_simple.rb +26 -0
  25. data/rails_generators/manifests/rule_simple.yml +21 -0
  26. data/rails_generators/manifests/rules_engine.rb +244 -276
  27. data/rails_generators/manifests/rules_engine.yml +37 -59
  28. data/rails_generators/rules_engine_generator.rb +16 -32
  29. data/rails_generators/templates/app/controllers/re_plan_workflow_rules_controller.rb +142 -0
  30. data/rails_generators/templates/app/controllers/re_plan_workflows_controller.rb +139 -0
  31. data/rails_generators/templates/app/controllers/re_plans_controller.rb +131 -0
  32. data/rails_generators/templates/app/controllers/re_processes_controller.rb +15 -0
  33. data/rails_generators/templates/app/controllers/re_publications_controller.rb +15 -0
  34. data/rails_generators/templates/app/controllers/{re_pipeline_rules_controller.rb → re_workflow_rules_controller.rb} +12 -12
  35. data/rails_generators/templates/app/controllers/re_workflows_controller.rb +96 -0
  36. data/rails_generators/templates/app/helpers/rules_engine_helper.rb +42 -0
  37. data/rails_generators/templates/app/models/re_plan.rb +126 -0
  38. data/rails_generators/templates/app/models/re_plan_workflow.rb +10 -0
  39. data/rails_generators/templates/app/models/re_rule.rb +47 -60
  40. data/rails_generators/templates/app/models/re_rule_expected_outcome.rb +3 -21
  41. data/rails_generators/templates/app/models/re_workflow.rb +61 -0
  42. data/rails_generators/templates/app/rules/{complex_rule.rb → rule_complex.rb} +30 -30
  43. data/rails_generators/templates/app/rules/{simple_rule.rb → rule_simple.rb} +13 -14
  44. data/rails_generators/templates/app/views/layouts/rules_engine.html.erb +6 -9
  45. data/rails_generators/templates/app/views/re_plan_workflow_rules/edit.html.erb +13 -0
  46. data/rails_generators/templates/app/views/re_plan_workflow_rules/edit.js.erb +9 -0
  47. data/rails_generators/templates/app/views/re_plan_workflow_rules/error.html.erb +12 -0
  48. data/rails_generators/templates/app/views/re_plan_workflow_rules/error.js.erb +7 -0
  49. data/rails_generators/templates/app/views/re_plan_workflow_rules/help.html.erb +12 -0
  50. data/rails_generators/templates/app/views/re_plan_workflow_rules/help.js.erb +4 -0
  51. data/rails_generators/templates/app/views/re_plan_workflow_rules/new.html.erb +16 -0
  52. data/rails_generators/templates/app/views/re_plan_workflow_rules/new.js.erb +10 -0
  53. data/rails_generators/templates/app/views/re_plan_workflow_rules/update.js.erb +19 -0
  54. data/rails_generators/templates/app/views/re_plan_workflows/change.html.erb +78 -0
  55. data/rails_generators/templates/app/views/re_plan_workflows/edit.html.erb +12 -0
  56. data/rails_generators/templates/app/views/re_plan_workflows/edit.js.erb +8 -0
  57. data/rails_generators/templates/app/views/re_plan_workflows/new.html.erb +12 -0
  58. data/rails_generators/templates/app/views/re_plan_workflows/new.js.erb +5 -0
  59. data/rails_generators/templates/app/views/re_plan_workflows/show.html.erb +70 -0
  60. data/rails_generators/templates/app/views/re_plan_workflows/update.js.erb +19 -0
  61. data/rails_generators/templates/app/views/re_plans/_change.html.erb +39 -0
  62. data/rails_generators/templates/app/views/re_plans/_edit.html.erb +20 -0
  63. data/rails_generators/templates/app/views/re_plans/_empty.html.erb +12 -0
  64. data/rails_generators/templates/app/views/re_plans/_index.html.erb +42 -0
  65. data/rails_generators/templates/app/views/re_plans/_menu.html.erb +26 -0
  66. data/rails_generators/templates/app/views/re_plans/_new.html.erb +18 -0
  67. data/rails_generators/templates/app/views/re_plans/_preview.html.erb +47 -0
  68. data/rails_generators/templates/app/views/re_plans/_show.html.erb +27 -0
  69. data/rails_generators/templates/app/views/re_plans/_workflow_change.html.erb +44 -0
  70. data/rails_generators/templates/app/views/re_plans/_workflow_preview.html.erb +24 -0
  71. data/rails_generators/templates/app/views/re_plans/_workflow_show.html.erb +32 -0
  72. data/rails_generators/templates/app/views/re_plans/change.html.erb +118 -0
  73. data/rails_generators/templates/app/views/re_plans/create.js.erb +9 -0
  74. data/rails_generators/templates/app/views/re_plans/edit.html.erb +11 -0
  75. data/rails_generators/templates/app/views/re_plans/edit.js.erb +8 -0
  76. data/rails_generators/templates/app/views/re_plans/index.html.erb +33 -0
  77. data/rails_generators/templates/app/views/re_plans/index.js.erb +18 -0
  78. data/rails_generators/templates/app/views/re_plans/new.html.erb +9 -0
  79. data/rails_generators/templates/app/views/re_plans/new.js.erb +5 -0
  80. data/rails_generators/templates/app/views/re_plans/preview.html.erb +6 -0
  81. data/rails_generators/templates/app/views/re_plans/preview.js.erb +4 -0
  82. data/rails_generators/templates/app/views/re_plans/re_process.html.erb +12 -0
  83. data/rails_generators/templates/app/views/re_plans/re_process.js.erb +4 -0
  84. data/rails_generators/templates/app/views/re_plans/show.html.erb +56 -0
  85. data/rails_generators/templates/app/views/{re_pipelines → re_plans}/template.html.erb +1 -1
  86. data/rails_generators/templates/app/views/re_plans/update.js.erb +15 -0
  87. data/rails_generators/templates/app/views/re_processes/_index_prepare.html.erb +12 -0
  88. data/rails_generators/templates/app/views/re_processes/_index_update.html.erb +20 -0
  89. data/rails_generators/templates/app/views/re_processes/_show.html.erb +30 -0
  90. data/rails_generators/templates/app/views/re_processes/index.html.erb +11 -0
  91. data/rails_generators/templates/app/views/re_processes/index.js.erb +4 -0
  92. data/rails_generators/templates/app/views/re_processes/show.html.erb +8 -0
  93. data/rails_generators/templates/app/views/re_processes/show.js.erb +4 -0
  94. data/rails_generators/templates/app/views/re_publications/_show_prepare.html.erb +14 -0
  95. data/rails_generators/templates/app/views/re_publications/_show_update.html.erb +16 -0
  96. data/rails_generators/templates/app/views/re_publications/show.html.erb +11 -0
  97. data/rails_generators/templates/app/views/re_publications/show.js.erb +4 -0
  98. data/rails_generators/templates/app/views/re_rule_definitions/rule_complex/_edit.html.erb +7 -0
  99. data/rails_generators/templates/app/views/re_rule_definitions/{complex_rule → rule_complex}/_help.html.erb +1 -1
  100. data/rails_generators/templates/app/views/re_rule_definitions/rule_complex/_new.html.erb +7 -0
  101. data/rails_generators/templates/app/views/re_rule_definitions/rule_complex/_script.html.erb +25 -0
  102. data/rails_generators/templates/app/views/re_rule_definitions/{complex_rule → rule_complex}/_title.html.erb +0 -0
  103. data/rails_generators/templates/app/views/re_rule_definitions/{complex_rule → rule_complex}/_word.html.erb +0 -0
  104. data/rails_generators/templates/app/views/re_rule_definitions/{complex_rule → rule_complex}/_words.html.erb +2 -2
  105. data/rails_generators/templates/app/views/re_rule_definitions/{complex_rule/_pipeline.html.erb → rule_complex/_workflow.html.erb} +5 -5
  106. data/rails_generators/templates/app/views/re_rule_definitions/rule_simple/_edit.html.erb +1 -0
  107. data/rails_generators/templates/app/views/re_rule_definitions/{simple_rule → rule_simple}/_form.html.erb +1 -1
  108. data/rails_generators/templates/app/views/re_rule_definitions/{simple_rule → rule_simple}/_help.html.erb +0 -0
  109. data/rails_generators/templates/app/views/re_rule_definitions/rule_simple/_new.html.erb +1 -0
  110. data/rails_generators/templates/app/views/re_workflow_rules/_edit.html.erb +19 -0
  111. data/rails_generators/templates/app/views/{re_pipeline_rules → re_workflow_rules}/_error.html.erb +0 -0
  112. data/rails_generators/templates/app/views/re_workflow_rules/_help.html.erb +15 -0
  113. data/rails_generators/templates/app/views/{re_pipeline_rules → re_workflow_rules}/_new.html.erb +6 -3
  114. data/rails_generators/templates/app/views/re_workflow_rules/edit.html.erb +13 -0
  115. data/rails_generators/templates/app/views/re_workflow_rules/edit.js.erb +9 -0
  116. data/rails_generators/templates/app/views/re_workflow_rules/error.html.erb +12 -0
  117. data/rails_generators/templates/app/views/re_workflow_rules/error.js.erb +7 -0
  118. data/rails_generators/templates/app/views/re_workflow_rules/help.html.erb +12 -0
  119. data/rails_generators/templates/app/views/re_workflow_rules/help.js.erb +4 -0
  120. data/rails_generators/templates/app/views/re_workflow_rules/new.html.erb +15 -0
  121. data/rails_generators/templates/app/views/{re_pipeline_rules → re_workflow_rules}/new.js.erb +1 -1
  122. data/rails_generators/templates/app/views/re_workflow_rules/update.js.erb +17 -0
  123. data/rails_generators/templates/app/views/re_workflows/_add_prepare.html.erb +15 -0
  124. data/rails_generators/templates/app/views/re_workflows/_add_update.html.erb +21 -0
  125. data/rails_generators/templates/app/views/re_workflows/_edit.html.erb +23 -0
  126. data/rails_generators/templates/app/views/re_workflows/_empty.html.erb +12 -0
  127. data/rails_generators/templates/app/views/re_workflows/_index.html.erb +41 -0
  128. data/rails_generators/templates/app/views/re_workflows/_menu.html.erb +92 -0
  129. data/rails_generators/templates/app/views/re_workflows/_new.html.erb +21 -0
  130. data/rails_generators/templates/app/views/re_workflows/_plan_prepare.html.erb +14 -0
  131. data/rails_generators/templates/app/views/re_workflows/_plan_update.html.erb +21 -0
  132. data/rails_generators/templates/app/views/re_workflows/_preview.html.erb +30 -0
  133. data/rails_generators/templates/app/views/re_workflows/_rule_change.html.erb +65 -0
  134. data/rails_generators/templates/app/views/re_workflows/_rule_empty.html.erb +13 -0
  135. data/rails_generators/templates/app/views/{re_pipeline_rules/_index.html.erb → re_workflows/_rule_preview.html.erb} +20 -11
  136. data/rails_generators/templates/app/views/re_workflows/_rule_show.html.erb +46 -0
  137. data/rails_generators/templates/app/views/re_workflows/_show.html.erb +24 -0
  138. data/rails_generators/templates/app/views/re_workflows/add.html.erb +11 -0
  139. data/rails_generators/templates/app/views/re_workflows/add.js.erb +6 -0
  140. data/rails_generators/templates/app/views/re_workflows/change.html.erb +53 -0
  141. data/rails_generators/templates/app/views/re_workflows/create.js.erb +9 -0
  142. data/rails_generators/templates/app/views/re_workflows/edit.html.erb +11 -0
  143. data/rails_generators/templates/app/views/re_workflows/edit.js.erb +8 -0
  144. data/rails_generators/templates/app/views/re_workflows/index.html.erb +34 -0
  145. data/rails_generators/templates/app/views/re_workflows/new.html.erb +9 -0
  146. data/rails_generators/templates/app/views/re_workflows/new.js.erb +5 -0
  147. data/rails_generators/templates/app/views/re_workflows/plan.html.erb +12 -0
  148. data/rails_generators/templates/app/views/re_workflows/plan.js.erb +4 -0
  149. data/rails_generators/templates/app/views/re_workflows/preview.html.erb +5 -0
  150. data/rails_generators/templates/app/views/re_workflows/preview.js.erb +4 -0
  151. data/rails_generators/templates/app/views/re_workflows/show.html.erb +47 -0
  152. data/rails_generators/templates/app/views/re_workflows/update.js.erb +17 -0
  153. data/rails_generators/templates/config/initializers/rules_engine.rb +9 -0
  154. data/rails_generators/templates/db/migrate/20100308225008_create_rules_engine.rb +113 -0
  155. data/rails_generators/templates/doc/README.rules_engine +113 -98
  156. data/rails_generators/templates/lib/tasks/rules_engine.rake +29 -10
  157. data/rails_generators/templates/public/javascripts/rules_engine/re_plan_change.js +85 -0
  158. data/rails_generators/templates/public/javascripts/rules_engine/re_plan_new.js +29 -0
  159. data/rails_generators/templates/public/javascripts/rules_engine/re_plan_preview.js +18 -0
  160. data/rails_generators/templates/public/javascripts/rules_engine/re_process_index.js +43 -0
  161. data/rails_generators/templates/public/javascripts/rules_engine/re_process_show.js +18 -0
  162. data/rails_generators/templates/public/javascripts/rules_engine/re_publication_show.js +39 -0
  163. data/rails_generators/templates/public/javascripts/{re_view.js → rules_engine/re_view.js} +19 -3
  164. data/rails_generators/templates/public/javascripts/rules_engine/re_workflow_add.js +124 -0
  165. data/rails_generators/templates/public/javascripts/rules_engine/re_workflow_change.js +185 -0
  166. data/rails_generators/templates/public/javascripts/rules_engine/re_workflow_new.js +29 -0
  167. data/rails_generators/templates/public/javascripts/rules_engine/re_workflow_plan.js +38 -0
  168. data/rails_generators/templates/public/javascripts/rules_engine/re_workflow_preview.js +18 -0
  169. data/rails_generators/templates/public/stylesheets/{re_view_box → rules_engine/images/re_view_box}/shadowbox.png +0 -0
  170. data/rails_generators/templates/public/stylesheets/{re_view_box → rules_engine/images/re_view_box}/whitebox.jpg +0 -0
  171. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/checked-off.gif +0 -0
  172. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/checked-on.gif +0 -0
  173. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/icon-add.png +0 -0
  174. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/icon-delete.png +0 -0
  175. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/oval-blue-left.gif +0 -0
  176. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/oval-blue-right.gif +0 -0
  177. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/oval-gray-left.gif +0 -0
  178. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/oval-gray-right.gif +0 -0
  179. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/oval-green-left.gif +0 -0
  180. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/oval-green-right.gif +0 -0
  181. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/oval-orange-left.gif +0 -0
  182. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/oval-orange-right.gif +0 -0
  183. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/oval-red-left.gif +0 -0
  184. data/rails_generators/templates/public/stylesheets/{re_view_button → rules_engine/images/re_view_button}/oval-red-right.gif +0 -0
  185. data/rails_generators/templates/public/stylesheets/{re_view_error → rules_engine/images/re_view_error}/re-alert-close.png +0 -0
  186. data/rails_generators/templates/public/stylesheets/{re_view_navigate → rules_engine/images/re_view_navigate}/breadcrumb.png +0 -0
  187. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/next-disabled-14.png → images/rules_engine/re_common/list-next-disabled-14.png} +0 -0
  188. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/next-enabled-14.png → images/rules_engine/re_common/list-next-enabled-14.png} +0 -0
  189. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/prev-disabled-14.png → images/rules_engine/re_common/list-prev-disabled-14.png} +0 -0
  190. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/prev-enabled-14.png → images/rules_engine/re_common/list-prev-enabled-14.png} +0 -0
  191. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/loadingAnimation.gif → images/rules_engine/re_common/loading.gif} +0 -0
  192. data/rails_generators/templates/public/stylesheets/rules_engine/{re_pipeline/alert-18.png → images/rules_engine/re_common/status-changed-18.png} +0 -0
  193. data/rails_generators/templates/public/stylesheets/rules_engine/{re_pipeline/alert-25.png → images/rules_engine/re_common/status-changed-25.png} +0 -0
  194. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/info-18.png → images/rules_engine/re_common/status-draft-18.png} +0 -0
  195. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/info-25.png → images/rules_engine/re_common/status-draft-25.png} +0 -0
  196. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/error-14.png → images/rules_engine/re_common/status-error-14.png} +0 -0
  197. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/info-14.png → images/rules_engine/re_common/status-info-14.png} +0 -0
  198. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/success-18.png → images/rules_engine/re_common/status-published-18.png} +0 -0
  199. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/success-25.png → images/rules_engine/re_common/status-published-25.png} +0 -0
  200. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/success-14.png → images/rules_engine/re_common/status-success-14.png} +0 -0
  201. data/rails_generators/templates/public/stylesheets/rules_engine/{re_pipeline/current-14.png → images/rules_engine/re_common/status-valid-14.png} +0 -0
  202. data/rails_generators/templates/public/stylesheets/rules_engine/{re_pipeline/current-18.png → images/rules_engine/re_common/status-valid-18.png} +0 -0
  203. data/rails_generators/templates/public/stylesheets/rules_engine/{re_pipeline/draft-14.png → images/rules_engine/re_common/status-verify-14.png} +0 -0
  204. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/error-18.png → images/rules_engine/re_common/status-verify-18.png} +0 -0
  205. data/rails_generators/templates/public/stylesheets/rules_engine/{re_job/error-25.png → images/rules_engine/re_common/status-verify-25.png} +0 -0
  206. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/alert-25.png +0 -0
  207. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/change-25.png +0 -0
  208. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/delete-25.png +0 -0
  209. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/edit-25.png +0 -0
  210. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/list-25.png +0 -0
  211. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/new-25.png +0 -0
  212. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/preview-18.png +0 -0
  213. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/publish-25.png +0 -0
  214. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/revert-25.png +0 -0
  215. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/show-25.png +0 -0
  216. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/title-plural.png +0 -0
  217. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_plan/title-single.png +0 -0
  218. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule/stop-failure-14.png → images/rules_engine/re_process/error-14.png} +0 -0
  219. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_process/info-14.png +0 -0
  220. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_process/list-25.png +0 -0
  221. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule/stop-success-14.png → images/rules_engine/re_process/success-14.png} +0 -0
  222. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_publication/show-25.png +0 -0
  223. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule_class → images/rules_engine/re_rule}/add-14.png +0 -0
  224. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_rule/alert-25.png +0 -0
  225. data/rails_generators/templates/public/stylesheets/rules_engine/{re_pipeline → images/rules_engine/re_rule}/destroy-25.png +0 -0
  226. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_rule/edit-25.png +0 -0
  227. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_rule/error-25.png +0 -0
  228. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule_class → images/rules_engine/re_rule}/help-14.png +0 -0
  229. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_rule/help-25.png +0 -0
  230. data/rails_generators/templates/public/stylesheets/rules_engine/{re_pipeline/current-25.png → images/rules_engine/re_rule/icon-ad-25.png} +0 -0
  231. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule → images/rules_engine/re_rule}/move-down-25.png +0 -0
  232. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule → images/rules_engine/re_rule}/move-down-off-25.png +0 -0
  233. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule → images/rules_engine/re_rule}/move-up-25.png +0 -0
  234. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule → images/rules_engine/re_rule}/move-up-off-25.png +0 -0
  235. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_rule/new-25.png +0 -0
  236. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule/next-change-25.png → images/rules_engine/re_rule/next-down-25.png} +0 -0
  237. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule/next-show-18.png → images/rules_engine/re_rule/next-right-18.png} +0 -0
  238. data/rails_generators/templates/public/stylesheets/rules_engine/{re_pipeline/change-25.png → images/rules_engine/re_rule/show-25.png} +0 -0
  239. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule → images/rules_engine/re_rule}/start-pipeline-18.png +0 -0
  240. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule → images/rules_engine/re_rule}/stop-failure-18.png +0 -0
  241. data/rails_generators/templates/public/stylesheets/rules_engine/{re_rule → images/rules_engine/re_rule}/stop-success-18.png +0 -0
  242. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_rule/title-plural.png +0 -0
  243. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_rule/title-single.png +0 -0
  244. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/add-14.png +0 -0
  245. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/add-25.png +0 -0
  246. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/add-off-14.png +0 -0
  247. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/alert-25.png +0 -0
  248. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/change-18.png +0 -0
  249. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/change-25.png +0 -0
  250. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/delete-25.png +0 -0
  251. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/edit-25.png +0 -0
  252. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/is-default-18.png +0 -0
  253. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/list-25.png +0 -0
  254. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/make-default-18.png +0 -0
  255. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/make-default-off-18.png +0 -0
  256. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/new-25.png +0 -0
  257. data/rails_generators/templates/public/stylesheets/rules_engine/{re_pipeline/revert-25.png → images/rules_engine/re_workflow/plan-25.png} +0 -0
  258. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/preview-18.png +0 -0
  259. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/remove-18.png +0 -0
  260. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/show-18.png +0 -0
  261. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/show-25.png +0 -0
  262. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/title-plural.png +0 -0
  263. data/rails_generators/templates/public/stylesheets/rules_engine/images/rules_engine/re_workflow/title-single.png +0 -0
  264. data/rails_generators/templates/public/stylesheets/rules_engine/screen.css +1580 -0
  265. data/rails_generators/templates/spec/controllers/re_plans_controller_spec.rb +409 -0
  266. data/rails_generators/templates/spec/helpers/rules_engine_helper_spec.rb +86 -0
  267. data/rails_generators/templates/spec/lib/rules/rule_complex_spec.rb +331 -0
  268. data/rails_generators/templates/spec/lib/rules/rule_simple_spec.rb +161 -0
  269. data/rails_generators/templates/spec/models/re_plan_spec.rb +349 -0
  270. data/rails_generators/templates/spec/models/re_plan_workflow_spec.rb +6 -0
  271. data/rails_generators/templates/spec/models/re_rule_expected_outcome_spec.rb +7 -51
  272. data/rails_generators/templates/spec/models/re_rule_spec.rb +108 -152
  273. data/rails_generators/templates/spec/models/re_workflow_spec.rb +186 -0
  274. data/rails_generators/templates/spec/support/rules_engine_blueprints.rb +27 -0
  275. data/spec/railsenv/log/debug.log +7061 -1
  276. data/spec/railsenv/log/empty.txt +1 -0
  277. data/spec/railsenv/log/test.log +492 -1
  278. data/spec/rules_engine/discovery_spec.rb +40 -4
  279. data/spec/rules_engine/process/auditor/db_auditor_spec.rb +115 -0
  280. data/spec/rules_engine/process/auditor_spec.rb +111 -0
  281. data/spec/rules_engine/process/runner/db_runner_spec.rb +229 -0
  282. data/spec/rules_engine/process/runner_spec.rb +236 -0
  283. data/spec/rules_engine/publish/publisher/db_publisher_spec.rb +280 -0
  284. data/spec/rules_engine/publish/publisher_spec.rb +64 -0
  285. data/spec/rules_engine/rule_spec.rb +7 -11
  286. data/spec/rules_engine_view/defer_spec.rb +30 -0
  287. data/spec/rules_engine_view/model_loader_spec.rb +3 -3
  288. data/spec/spec_helper.rb +36 -1
  289. metadata +268 -292
  290. data/lib/rules_engine/job.rb +0 -127
  291. data/rails_generators/manifests/rules_engine_complex.rb +0 -30
  292. data/rails_generators/manifests/rules_engine_complex.yml +0 -24
  293. data/rails_generators/manifests/rules_engine_simple.rb +0 -26
  294. data/rails_generators/manifests/rules_engine_simple.yml +0 -21
  295. data/rails_generators/templates/app/controllers/re_jobs_controller.rb +0 -20
  296. data/rails_generators/templates/app/controllers/re_pipeline_jobs_controller.rb +0 -16
  297. data/rails_generators/templates/app/controllers/re_pipelines_controller.rb +0 -171
  298. data/rails_generators/templates/app/helpers/re_pipeline_helper.rb +0 -14
  299. data/rails_generators/templates/app/models/re_job.rb +0 -122
  300. data/rails_generators/templates/app/models/re_job_audit.rb +0 -18
  301. data/rails_generators/templates/app/models/re_pipeline.rb +0 -47
  302. data/rails_generators/templates/app/models/re_pipeline_activated.rb +0 -29
  303. data/rails_generators/templates/app/models/re_pipeline_activated_observer.rb +0 -11
  304. data/rails_generators/templates/app/models/re_pipeline_base.rb +0 -63
  305. data/rails_generators/templates/app/views/re_jobs/_empty.html.erb +0 -14
  306. data/rails_generators/templates/app/views/re_jobs/_index_large.html.erb +0 -79
  307. data/rails_generators/templates/app/views/re_jobs/_index_small.html.erb +0 -41
  308. data/rails_generators/templates/app/views/re_jobs/_show.html.erb +0 -38
  309. data/rails_generators/templates/app/views/re_jobs/index.html.erb +0 -14
  310. data/rails_generators/templates/app/views/re_jobs/index.js.erb +0 -12
  311. data/rails_generators/templates/app/views/re_jobs/show.html.erb +0 -14
  312. data/rails_generators/templates/app/views/re_jobs/show.js.erb +0 -4
  313. data/rails_generators/templates/app/views/re_pipeline_jobs/index.html.erb +0 -15
  314. data/rails_generators/templates/app/views/re_pipeline_jobs/index.js.erb +0 -12
  315. data/rails_generators/templates/app/views/re_pipeline_rules/_change.html.erb +0 -57
  316. data/rails_generators/templates/app/views/re_pipeline_rules/_edit.html.erb +0 -16
  317. data/rails_generators/templates/app/views/re_pipeline_rules/_empty.html.erb +0 -12
  318. data/rails_generators/templates/app/views/re_pipeline_rules/_empty.js.erb +0 -7
  319. data/rails_generators/templates/app/views/re_pipeline_rules/_help.html.erb +0 -13
  320. data/rails_generators/templates/app/views/re_pipeline_rules/_menu.html.erb +0 -37
  321. data/rails_generators/templates/app/views/re_pipeline_rules/_show.html.erb +0 -44
  322. data/rails_generators/templates/app/views/re_pipeline_rules/destroy.js.erb +0 -14
  323. data/rails_generators/templates/app/views/re_pipeline_rules/edit.html.erb +0 -12
  324. data/rails_generators/templates/app/views/re_pipeline_rules/edit.js.erb +0 -8
  325. data/rails_generators/templates/app/views/re_pipeline_rules/error.html.erb +0 -12
  326. data/rails_generators/templates/app/views/re_pipeline_rules/error.js.erb +0 -7
  327. data/rails_generators/templates/app/views/re_pipeline_rules/help.html.erb +0 -12
  328. data/rails_generators/templates/app/views/re_pipeline_rules/help.js.erb +0 -4
  329. data/rails_generators/templates/app/views/re_pipeline_rules/new.html.erb +0 -15
  330. data/rails_generators/templates/app/views/re_pipeline_rules/update.js.erb +0 -21
  331. data/rails_generators/templates/app/views/re_pipelines/_change.html.erb +0 -48
  332. data/rails_generators/templates/app/views/re_pipelines/_change_actions.html.erb +0 -34
  333. data/rails_generators/templates/app/views/re_pipelines/_confirm.html.erb +0 -39
  334. data/rails_generators/templates/app/views/re_pipelines/_edit.html.erb +0 -20
  335. data/rails_generators/templates/app/views/re_pipelines/_empty.html.erb +0 -13
  336. data/rails_generators/templates/app/views/re_pipelines/_index.html.erb +0 -64
  337. data/rails_generators/templates/app/views/re_pipelines/_new.html.erb +0 -18
  338. data/rails_generators/templates/app/views/re_pipelines/_show.html.erb +0 -36
  339. data/rails_generators/templates/app/views/re_pipelines/change.html.erb +0 -37
  340. data/rails_generators/templates/app/views/re_pipelines/create.js.erb +0 -9
  341. data/rails_generators/templates/app/views/re_pipelines/edit.html.erb +0 -12
  342. data/rails_generators/templates/app/views/re_pipelines/edit.js.erb +0 -8
  343. data/rails_generators/templates/app/views/re_pipelines/index.html.erb +0 -61
  344. data/rails_generators/templates/app/views/re_pipelines/index.js.erb +0 -18
  345. data/rails_generators/templates/app/views/re_pipelines/new.html.erb +0 -9
  346. data/rails_generators/templates/app/views/re_pipelines/new.js.erb +0 -5
  347. data/rails_generators/templates/app/views/re_pipelines/show.html.erb +0 -39
  348. data/rails_generators/templates/app/views/re_pipelines/update.js.erb +0 -14
  349. data/rails_generators/templates/app/views/re_rule_definitions/complex_rule/_edit.html.erb +0 -7
  350. data/rails_generators/templates/app/views/re_rule_definitions/complex_rule/_new.html.erb +0 -7
  351. data/rails_generators/templates/app/views/re_rule_definitions/complex_rule/_script.html.erb +0 -26
  352. data/rails_generators/templates/app/views/re_rule_definitions/simple_rule/_edit.html.erb +0 -1
  353. data/rails_generators/templates/app/views/re_rule_definitions/simple_rule/_new.html.erb +0 -1
  354. data/rails_generators/templates/db/migrate/20100308225008_create_re_pipelines.rb +0 -77
  355. data/rails_generators/templates/features/support/blueprint_re_pipelines.rb +0 -20
  356. data/rails_generators/templates/public/javascripts/re_job_index.js +0 -75
  357. data/rails_generators/templates/public/javascripts/re_pipeline_change.js +0 -194
  358. data/rails_generators/templates/public/javascripts/re_pipeline_index.js +0 -40
  359. data/rails_generators/templates/public/javascripts/re_pipeline_index_jobs.js +0 -10
  360. data/rails_generators/templates/public/javascripts/re_pipeline_new.js +0 -30
  361. data/rails_generators/templates/public/javascripts/re_pipeline_show_jobs.js +0 -11
  362. data/rails_generators/templates/public/stylesheets/re_view.css +0 -120
  363. data/rails_generators/templates/public/stylesheets/re_view_box.css +0 -119
  364. data/rails_generators/templates/public/stylesheets/re_view_box/accept.png +0 -0
  365. data/rails_generators/templates/public/stylesheets/re_view_box/exclamation.png +0 -0
  366. data/rails_generators/templates/public/stylesheets/re_view_box/shadowbox.jpg +0 -0
  367. data/rails_generators/templates/public/stylesheets/re_view_button.css +0 -118
  368. data/rails_generators/templates/public/stylesheets/re_view_error.css +0 -61
  369. data/rails_generators/templates/public/stylesheets/re_view_form.css +0 -121
  370. data/rails_generators/templates/public/stylesheets/re_view_navigate.css +0 -46
  371. data/rails_generators/templates/public/stylesheets/re_view_table.css +0 -137
  372. data/rails_generators/templates/public/stylesheets/rules_engine.css +0 -520
  373. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/error-48.png +0 -0
  374. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/info-48.png +0 -0
  375. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/list-14.png +0 -0
  376. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/list-18.png +0 -0
  377. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/list-25.png +0 -0
  378. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/list-48.png +0 -0
  379. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/next-disabled-18.png +0 -0
  380. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/next-disabled-25.png +0 -0
  381. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/next-disabled-48.png +0 -0
  382. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/next-enabled-18.png +0 -0
  383. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/next-enabled-25.png +0 -0
  384. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/next-enabled-48.png +0 -0
  385. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/prev-disabled-18.png +0 -0
  386. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/prev-disabled-25.png +0 -0
  387. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/prev-disabled-48.png +0 -0
  388. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/prev-enabled-18.png +0 -0
  389. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/prev-enabled-25.png +0 -0
  390. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/prev-enabled-48.png +0 -0
  391. data/rails_generators/templates/public/stylesheets/rules_engine/re_job/success-48.png +0 -0
  392. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/activate-14.png +0 -0
  393. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/activate-18.png +0 -0
  394. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/activate-25.png +0 -0
  395. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/activate-48.png +0 -0
  396. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/alert-14.png +0 -0
  397. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/alert-48.png +0 -0
  398. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/change-14.png +0 -0
  399. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/change-18.png +0 -0
  400. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/change-48.png +0 -0
  401. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/changed-14.png +0 -0
  402. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/changed-18.png +0 -0
  403. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/changed-25.png +0 -0
  404. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/changed-48.png +0 -0
  405. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/current-48.png +0 -0
  406. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/deactivate-14.png +0 -0
  407. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/deactivate-18.png +0 -0
  408. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/deactivate-25.png +0 -0
  409. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/deactivate-48.png +0 -0
  410. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/destroy-14.png +0 -0
  411. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/destroy-18.png +0 -0
  412. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/destroy-48.png +0 -0
  413. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/draft-18.png +0 -0
  414. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/draft-25.png +0 -0
  415. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/draft-48.png +0 -0
  416. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/edit-14.png +0 -0
  417. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/edit-18.png +0 -0
  418. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/edit-25.png +0 -0
  419. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/edit-48.png +0 -0
  420. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/list-14.png +0 -0
  421. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/list-18.png +0 -0
  422. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/list-25.png +0 -0
  423. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/list-48.png +0 -0
  424. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/list-down.png +0 -0
  425. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/list-right.png +0 -0
  426. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/new-14.png +0 -0
  427. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/new-18.png +0 -0
  428. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/new-25.png +0 -0
  429. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/new-48.png +0 -0
  430. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/revert-14.png +0 -0
  431. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/revert-18.png +0 -0
  432. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/revert-48.png +0 -0
  433. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/show-14.png +0 -0
  434. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/show-18.png +0 -0
  435. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/show-25.png +0 -0
  436. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/show-48.png +0 -0
  437. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/verify-14.png +0 -0
  438. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/verify-18.png +0 -0
  439. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/verify-25.png +0 -0
  440. data/rails_generators/templates/public/stylesheets/rules_engine/re_pipeline/verify-48.png +0 -0
  441. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/destroy-14.png +0 -0
  442. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/destroy-18.png +0 -0
  443. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/destroy-25.png +0 -0
  444. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/destroy-48.png +0 -0
  445. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/edit-14.png +0 -0
  446. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/edit-18.png +0 -0
  447. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/edit-25.png +0 -0
  448. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/edit-48.png +0 -0
  449. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-down-14.png +0 -0
  450. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-down-18.png +0 -0
  451. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-down-48.png +0 -0
  452. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-down-off-14.png +0 -0
  453. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-down-off-18.png +0 -0
  454. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-down-off-48.png +0 -0
  455. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-up-14.png +0 -0
  456. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-up-18.png +0 -0
  457. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-up-48.png +0 -0
  458. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-up-off-14.png +0 -0
  459. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-up-off-18.png +0 -0
  460. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/move-up-off-48.png +0 -0
  461. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/next-change-14.png +0 -0
  462. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/next-change-18.png +0 -0
  463. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/next-change-48.png +0 -0
  464. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/next-show-14.png +0 -0
  465. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/next-show-25.png +0 -0
  466. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/next-show-48.png +0 -0
  467. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/start-pipeline-14.png +0 -0
  468. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/stop-failure-25.png +0 -0
  469. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/stop-failure-48.png +0 -0
  470. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/stop-success-25.png +0 -0
  471. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/stop-success-48.png +0 -0
  472. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/valid-14.png +0 -0
  473. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/valid-18.png +0 -0
  474. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/valid-25.png +0 -0
  475. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/valid-48.png +0 -0
  476. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/verify-14.png +0 -0
  477. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/verify-18.png +0 -0
  478. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/verify-25.png +0 -0
  479. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule/verify-48.png +0 -0
  480. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/add-18.png +0 -0
  481. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/add-25.png +0 -0
  482. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/add-48.png +0 -0
  483. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/help-18.png +0 -0
  484. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/help-25.png +0 -0
  485. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/help-48.png +0 -0
  486. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/list-down.png +0 -0
  487. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/list-right.png +0 -0
  488. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/new-14.png +0 -0
  489. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/new-18.png +0 -0
  490. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/new-25.png +0 -0
  491. data/rails_generators/templates/public/stylesheets/rules_engine/re_rule_class/new-48.png +0 -0
  492. data/rails_generators/templates/spec/controllers/re_jobs_controller_spec.rb +0 -50
  493. data/rails_generators/templates/spec/controllers/re_pipeline_jobs_controller_spec.rb +0 -37
  494. data/rails_generators/templates/spec/controllers/re_pipeline_rules_controller_spec.rb +0 -390
  495. data/rails_generators/templates/spec/controllers/re_pipelines_controller_spec.rb +0 -497
  496. data/rails_generators/templates/spec/helpers/re_pipeline_helper_spec.rb +0 -29
  497. data/rails_generators/templates/spec/lib/rules/complex_rule_spec.rb +0 -336
  498. data/rails_generators/templates/spec/lib/rules/simple_rule_spec.rb +0 -171
  499. data/rails_generators/templates/spec/models/re_job_audit_spec.rb +0 -23
  500. data/rails_generators/templates/spec/models/re_job_spec.rb +0 -163
  501. data/rails_generators/templates/spec/models/re_pipeline_activated_observer_spec.rb +0 -28
  502. data/rails_generators/templates/spec/models/re_pipeline_activated_spec.rb +0 -71
  503. data/rails_generators/templates/spec/models/re_pipeline_base_spec.rb +0 -164
  504. data/rails_generators/templates/spec/models/re_pipeline_spec.rb +0 -198
  505. data/spec/rules_engine/job_spec.rb +0 -323
@@ -0,0 +1,349 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe RePlan do
4
+ def valid_attributes
5
+ {
6
+ :code => "AA MOCK",
7
+ :title => "Mock Title"
8
+ }
9
+ end
10
+
11
+ it "should be valid with valid attributes" do
12
+ RePlan.new(valid_attributes).should be_valid
13
+ end
14
+
15
+ should_have_many :re_plan_workflows
16
+ should_have_many :re_workflows, :through => :re_plan_workflows
17
+
18
+ should_validate_presence_of :code
19
+ should_validate_presence_of :title
20
+
21
+ describe "unique attributes" do
22
+ before(:each) do
23
+ RePlan.create!(valid_attributes)
24
+ end
25
+
26
+ should_validate_uniqueness_of :code, :case_sensitive => false, :message=>"alread taken."
27
+ end
28
+
29
+ describe "creating a plan" do
30
+ it "should set the plan_status to draft" do
31
+ re_plan = RePlan.create!(valid_attributes.except(:plan_status))
32
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_DRAFT
33
+ end
34
+ end
35
+
36
+ describe "changing a plan" do
37
+ describe "changing a plan back to it's reverted state" do
38
+ it "should mark the plan as published when saving" do
39
+ re_plan = RePlan.create!(valid_attributes)
40
+ re_plan.plan_status = RePlan::PLAN_STATUS_REVERTED
41
+ re_plan.save
42
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_PUBLISHED
43
+ end
44
+
45
+ it "should not mark the plan as changed" do
46
+ re_plan = RePlan.create!(valid_attributes)
47
+ re_plan.plan_status = RePlan::PLAN_STATUS_REVERTED
48
+ re_plan.title = "new title"
49
+ re_plan.should_not_receive(:changed!)
50
+ re_plan.save
51
+ end
52
+ end
53
+
54
+ it "should mark the plan as changed" do
55
+ re_plan = RePlan.create!(valid_attributes)
56
+ re_plan.title = "new title"
57
+ re_plan.should_receive(:changed!).with(false)
58
+ re_plan.save
59
+ end
60
+
61
+ it "should not be changed if the field changed was an ignore attribute" do
62
+ re_plan = RePlan.create!(valid_attributes)
63
+ re_plan.updated_at = Time.now + 5.days
64
+ re_plan.should_not_receive(:changed!)
65
+ re_plan.save
66
+ end
67
+ end
68
+
69
+ it "should replace any nonprint cahracters with an _" do
70
+ re_plan = RePlan.new(valid_attributes.merge(:code => "my code"))
71
+ re_plan.save!
72
+ re_plan.code.should == "my_code"
73
+ end
74
+
75
+ it "should change the code to lower case when creating" do
76
+ re_plan = RePlan.new(valid_attributes.merge(:code => "My code"))
77
+ re_plan.save!
78
+ re_plan.code.should == "my_code"
79
+ end
80
+
81
+ it "should strip any leading or trailing spaces" do
82
+ re_plan = RePlan.new(valid_attributes.merge(:code => " My code "))
83
+ re_plan.save!
84
+ re_plan.code.should == "my_code"
85
+ end
86
+
87
+ describe "code cannot be changed after creation" do
88
+ it "should save the code with a new record" do
89
+ re_plan = RePlan.new(valid_attributes.merge(:code => "my code"))
90
+ re_plan.save!
91
+ re_plan.code.should == "my_code"
92
+ end
93
+
94
+ it "should ignore the code attribute for an existing record" do
95
+ re_plan = RePlan.new(valid_attributes.merge(:code => "my code"))
96
+ re_plan.save!
97
+ re_plan.code = "new_code"
98
+ re_plan.save!
99
+ re_plan.code.should == "my_code"
100
+ end
101
+ end
102
+
103
+ describe "publish" do
104
+ it "should convert the plan to a hash" do
105
+ re_plan = RePlan.new(valid_attributes)
106
+ re_plan.stub!(:re_workflows).and_return([mock('workflow one', :code => 'one', :publish => {"workflow" => "one"}),
107
+ mock('workflow two', :code => 'two', :publish => {"workflow" => "two"})])
108
+ publish_data = re_plan.publish
109
+ publish_data["code"].should == 'aa_mock'
110
+ publish_data["title"].should == valid_attributes[:title]
111
+ publish_data["description"].should == valid_attributes[:description]
112
+ publish_data["first_workflow"].should == "one"
113
+ publish_data["workflow_one"]["workflow"].should == "one"
114
+ publish_data["workflow_one"]["next_workflow"].should == "two"
115
+ publish_data["workflow_two"]["workflow"].should == "two"
116
+ publish_data["workflow_two"]["next_workflow"].should == ""
117
+ end
118
+ end
119
+
120
+ describe "revert!" do
121
+ it "should return self" do
122
+ re_plan = RePlan.new
123
+ re_plan.revert!({}).should == re_plan
124
+ end
125
+
126
+ it "should set the plan as reverted" do
127
+ re_plan = RePlan.new
128
+ re_plan.revert!({})
129
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_REVERTED
130
+ end
131
+
132
+ it "should set the plan based on the data" do
133
+ re_workflow_1 = mock_model(ReWorkflow)
134
+ re_workflow_2 = mock_model(ReWorkflow)
135
+ re_workflow_1.should_receive(:revert!).with(hash_including('workflow' => 'one')).and_return(re_workflow_1)
136
+ re_workflow_2.should_receive(:revert!).with(hash_including('workflow' => 'two')).and_return(re_workflow_2)
137
+ ReWorkflow.stub!(:new).and_return(re_workflow_1, re_workflow_2)
138
+
139
+ re_plan = RePlan.new
140
+ re_plan.should_receive(:re_workflows=).with([re_workflow_1, re_workflow_2])
141
+
142
+ re_plan.revert!({"code" => "mock_workflow_code",
143
+ "title" => "mock_title",
144
+ "description" => "mock_description",
145
+ "first_workflow" => "one",
146
+ "workflow_one" => {"workflow" => "one", "next_workflow" => "two"},
147
+ "workflow_two" => {"workflow" => "two", "next_workflow" => ""}
148
+ })
149
+
150
+ re_plan.code.should == "mock_workflow_code"
151
+ re_plan.title.should == "mock_title"
152
+ re_plan.description.should == "mock_description"
153
+ end
154
+ end
155
+
156
+ describe "adding a workflow" do
157
+ it "should be false if it already has the workflow" do
158
+ re_plan = RePlan.new
159
+ re_workflow = mock_model(ReWorkflow)
160
+ re_plan.stub!(:re_workflows).and_return([re_workflow])
161
+ re_plan.add_workflow(re_workflow).should == false
162
+ end
163
+
164
+ it "should add the workflow" do
165
+ re_plan = RePlan.new
166
+ re_workflow = mock_model(ReWorkflow)
167
+ re_workflows = []
168
+ re_plan.stub!(:re_workflows).and_return(re_workflows)
169
+ re_plan.add_workflow(re_workflow)
170
+ re_workflows.should == [re_workflow]
171
+ end
172
+
173
+ it "should mark the plan as changed" do
174
+ re_plan = RePlan.new
175
+ re_workflow = mock_model(ReWorkflow)
176
+ re_plan.should_receive(:changed!)
177
+ re_plan.add_workflow(re_workflow)
178
+ end
179
+ end
180
+
181
+ describe "removing a workflow" do
182
+ it "should be false if it does not have the workflow" do
183
+ re_plan = RePlan.new
184
+ re_workflow = mock_model(ReWorkflow)
185
+ re_plan.stub!(:re_workflows).and_return([])
186
+ re_plan.remove_workflow(re_workflow).should == false
187
+ end
188
+
189
+ it "should remove the workflow" do
190
+ re_plan = RePlan.new
191
+ re_workflow = mock_model(ReWorkflow)
192
+ re_workflows = [re_workflow]
193
+ re_plan.stub!(:re_workflows).and_return(re_workflows)
194
+ re_plan.remove_workflow(re_workflow)
195
+ re_workflows.should == []
196
+ end
197
+
198
+ it "should mark the plan as changed" do
199
+ re_plan = RePlan.new
200
+ re_workflow = mock_model(ReWorkflow)
201
+ re_plan.stub!(:re_workflows).and_return([re_workflow])
202
+ re_plan.should_receive(:changed!)
203
+ re_plan.remove_workflow(re_workflow)
204
+ end
205
+ end
206
+
207
+ describe "setting thew default workflow" do
208
+
209
+ it "should not change the list if the workflow is not in the list" do
210
+ re_plan = RePlan.new
211
+ re_workflow = mock_model(ReWorkflow, :id => 1001)
212
+ re_plan.stub!(:re_workflows).and_return([])
213
+
214
+ re_plan.should_not_receive(:changed!)
215
+ re_plan.default_workflow = re_workflow
216
+ end
217
+
218
+ it "should not change the list if the workflow is alreasy the default" do
219
+ re_plan = RePlan.new
220
+ re_workflow = mock_model(ReWorkflow, :id => 1001)
221
+ re_plan.stub!(:re_workflows).and_return([re_workflow])
222
+
223
+ re_plan.should_not_receive(:changed!)
224
+ re_plan.default_workflow = re_workflow
225
+ end
226
+
227
+ it "should move the workflow to the top of the list" do
228
+ re_plan = RePlan.new
229
+ re_workflow = mock_model(ReWorkflow, :id => 1001)
230
+ re_plan.stub!(:re_workflows).and_return([mock_model(ReWorkflow, :id => 1001), re_workflow])
231
+
232
+ re_plan_workflow = mock_model(RePlanWorkflow, :re_workflow_id => 1001)
233
+ re_plan.stub!(:re_plan_workflows).and_return([re_plan_workflow])
234
+
235
+ re_plan_workflow.should_receive(:move_to_top)
236
+ re_plan.default_workflow = re_workflow
237
+ end
238
+
239
+ it "should mark the plan as changed" do
240
+ re_plan = RePlan.new
241
+ re_workflow = mock_model(ReWorkflow, :id => 1001)
242
+ re_plan.stub!(:re_workflows).and_return([mock_model(ReWorkflow, :id => 1001), re_workflow])
243
+
244
+ re_plan_workflow = mock_model(RePlanWorkflow, :re_workflow_id => 1001)
245
+ re_plan_workflow.stub!(:move_to_top)
246
+ re_plan.stub!(:re_plan_workflows).and_return([re_plan_workflow])
247
+
248
+ re_plan.should_receive(:changed!)
249
+ re_plan.default_workflow = re_workflow
250
+ end
251
+ end
252
+
253
+ describe "getting the default workflow" do
254
+ it "should return nil if the workflow list empty" do
255
+ re_plan = RePlan.new
256
+ re_plan.stub!(:re_workflows).and_return([])
257
+ re_plan.default_workflow.should == nil
258
+ end
259
+
260
+ it "should return the first workflow in the list" do
261
+ re_workflow_1 = mock_model(ReWorkflow)
262
+ re_workflow_2 = mock_model(ReWorkflow)
263
+ re_plan = RePlan.new
264
+ re_plan.stub!(:re_workflows).and_return([re_workflow_1, re_workflow_2])
265
+ re_plan.default_workflow.should == re_workflow_1
266
+ end
267
+ end
268
+
269
+ describe "checking for plan errors" do
270
+ before(:each) do
271
+ @re_workflow_1 = mock_model(ReRule, :title => "workflow 1")
272
+ @re_workflow_1.stub!(:workflow_error).and_return(nil)
273
+
274
+ @re_workflow_2 = mock_model(ReRule, :title => "workflow 2")
275
+ @re_workflow_2.stub!(:workflow_error).and_return(nil)
276
+
277
+ @re_plan = RePlan.new
278
+ @re_plan.stub!(:re_workflows).and_return([@re_workflow_1, @re_workflow_2])
279
+ end
280
+
281
+ it "should return a failed message if there are no workflows" do
282
+ src = RePlan.new(valid_attributes)
283
+ src.plan_error.should == "workflows req'd"
284
+ end
285
+
286
+ it "should validate each workflow" do
287
+ @re_workflow_1.should_receive(:workflow_error).at_least(:once).and_return(nil)
288
+ @re_workflow_2.should_receive(:workflow_error).at_least(:once).and_return(nil)
289
+
290
+ @re_plan.plan_error.should be_nil
291
+ end
292
+
293
+ it "should stop on the first workflow error" do
294
+ @re_workflow_1.should_receive(:workflow_error).at_least(:once).and_return("oops")
295
+ @re_workflow_2.should_not_receive(:workflow)
296
+
297
+ @re_plan.plan_error.should == "workflow error"
298
+ end
299
+ end
300
+
301
+ describe "published!" do
302
+ it "should update the status to PLAN_STATUS_PUBLISHED" do
303
+ re_plan = RePlan.create!(valid_attributes)
304
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_DRAFT
305
+ re_plan.published!
306
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_PUBLISHED
307
+ end
308
+ end
309
+
310
+ describe "changed!" do
311
+ it "should not update the status when PLAN_STATUS_DRAFT" do
312
+ re_plan = RePlan.create!(valid_attributes)
313
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_DRAFT
314
+ re_plan.should_not_receive(:save!)
315
+ re_plan.changed!
316
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_DRAFT
317
+ end
318
+
319
+ it "should not update the status when PLAN_STATUS_CHANGED" do
320
+ re_plan = RePlan.create!(valid_attributes)
321
+ re_plan.published!
322
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_PUBLISHED
323
+ re_plan.update_attributes({:title => "new title"})
324
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_CHANGED
325
+ re_plan.should_not_receive(:save!)
326
+ re_plan.changed!
327
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_CHANGED
328
+ end
329
+
330
+ it "should update the status to PLAN_STATUS_CHANGED changed when PLAN_STATUS_PUBLISHED" do
331
+ re_plan = RePlan.create!(valid_attributes)
332
+ re_plan.published!
333
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_PUBLISHED
334
+ re_plan.should_receive(:save!)
335
+ re_plan.changed!
336
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_CHANGED
337
+ end
338
+
339
+ it "should not save the plan whe the save flag is false" do
340
+ re_plan = RePlan.create!(valid_attributes)
341
+ re_plan.published!
342
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_PUBLISHED
343
+ re_plan.should_not_receive(:save!)
344
+ re_plan.changed!(false)
345
+ re_plan.plan_status.should == RePlan::PLAN_STATUS_CHANGED
346
+ end
347
+ end
348
+
349
+ end
@@ -0,0 +1,6 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe RePlanWorkflow do
4
+ should_belong_to :re_plan
5
+ should_belong_to :re_workflow
6
+ end
@@ -13,61 +13,17 @@ describe ReRuleExpectedOutcome do
13
13
 
14
14
  should_validate_presence_of :outcome
15
15
 
16
- describe "START PIPELINE" do
17
- it "should be invalid when the outcome pipeline code is blank" do
18
- re_rule_expected_outcome = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE)
16
+ describe "START WORKFLOW" do
17
+ it "should be invalid when the outcome workflow code is blank" do
18
+ re_rule_expected_outcome = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
19
19
  re_rule_expected_outcome.should_not be_valid
20
- re_rule_expected_outcome.errors.on(:pipeline_code).should_not be_blank
20
+ re_rule_expected_outcome.errors.on(:workflow_code).should_not be_blank
21
21
  end
22
-
23
- it "should be valid when outcome pipeline code is present" do
24
- re_rule_expected_outcome = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE, :pipeline_code => "mock code")
22
+
23
+ it "should be valid when outcome workflow code is present" do
24
+ re_rule_expected_outcome = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW, :workflow_code => "mock code")
25
25
  re_rule_expected_outcome.should be_valid
26
26
  end
27
27
  end
28
28
 
29
- describe "copying the details from another rule outcome" do
30
-
31
- %W(pipeline_code).each do |key|
32
- it "should copy the attribute #{key}" do
33
- src = ReRuleExpectedOutcome.new(valid_attributes.merge(key.to_sym => "mock source value"))
34
- dest = ReRuleExpectedOutcome.new(valid_attributes.merge(key.to_sym => "mock dest value"))
35
- dest.copy!(src)
36
- dest.read_attribute(key).should == "mock source value"
37
- end
38
- end
39
-
40
- %W(outcome).each do |key|
41
- it "should copy the attribute #{key}" do
42
- src = ReRuleExpectedOutcome.new(valid_attributes.merge(key.to_sym => 101))
43
- dest = ReRuleExpectedOutcome.new(valid_attributes.merge(key.to_sym => 202))
44
- dest.copy!(src)
45
- dest.read_attribute(key).should == 101
46
- end
47
- end
48
- end
49
-
50
- describe "comparing rule outcomes" do
51
- it "should be equal if the attributes are equal" do
52
- src = ReRuleExpectedOutcome.new(valid_attributes)
53
- dest = ReRuleExpectedOutcome.new(valid_attributes)
54
- dest.equals?(src).should be_true
55
- end
56
-
57
- %W(outcome).each do |key|
58
- it "should not be equal if the attribute #{key} are different" do
59
- src = ReRuleExpectedOutcome.new(valid_attributes.merge(key.to_sym => 101))
60
- dest = ReRuleExpectedOutcome.new(valid_attributes.merge(key.to_sym => 202))
61
- dest.equals?(src).should be_false
62
- end
63
- end
64
-
65
- it "should not be equal if the outcome is OUTCOME_START_PIPELINE and pipeline_code are different" do
66
- src = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE, :pipeline_code => "value 1")
67
- dest = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE, :pipeline_code => "value 2")
68
- dest.equals?(src).should be_false
69
- end
70
-
71
- end
72
-
73
29
  end
@@ -6,7 +6,7 @@ describe ReRule do
6
6
  :rule_class_name => "MockRuleClass",
7
7
  :title => "Mock Title",
8
8
  :summary => "Mock Summary",
9
- :data => "Lots Of Data"
9
+ :data => '["Rule Title", ["one", "two"], "start_workflow", "Other Pipeline"]'
10
10
  }
11
11
  end
12
12
 
@@ -15,22 +15,25 @@ describe ReRule do
15
15
  @rule.stub!(:title=)
16
16
  @rule.stub!(:summary=)
17
17
  @rule.stub!(:data=)
18
- @rule.stub!(:after_add_to_pipeline)
19
- @rule.stub!(:before_remove_from_pipeline)
18
+ @rule.stub!(:after_add_to_workflow)
19
+ @rule.stub!(:before_remove_from_workflow)
20
20
  @rule.stub!(:expected_outcomes).and_return([])
21
21
  @rule.stub!(:valid?).and_return(true)
22
22
  @rule_class = mock("MockRuleClass")
23
23
  @rule_class.stub!(:new).and_return(@rule)
24
24
  RulesEngine::Discovery.stub!(:rule_class).and_return(@rule_class)
25
+
26
+ @re_workflow = mock('workflow', :valid? => true)
27
+ @re_workflow.stub!(:code).and_return('mock code')
28
+ @re_workflow.stub!(:changed!)
25
29
  end
26
30
 
27
31
  it "should be valid with valid attributes" do
28
32
  ReRule.new(valid_attributes).should be_valid
29
33
  end
30
-
31
- should_have_many :re_rule_expected_outcomes
32
- should_have_many :re_job_audits
33
34
 
35
+ should_belong_to :re_workflow
36
+ should_have_many :re_rule_expected_outcomes
34
37
  should_validate_presence_of :rule_class_name
35
38
 
36
39
  describe "validate the rule" do
@@ -49,102 +52,6 @@ describe ReRule do
49
52
  end
50
53
  end
51
54
 
52
-
53
- describe "copying the rule" do
54
-
55
- %W(rule_class_name title summary data).each do |key|
56
- it "should copy the attribute #{key}" do
57
- src = ReRule.new(valid_attributes.merge(key.to_sym => "mock source value"))
58
- dest = ReRule.new(valid_attributes.merge(key.to_sym => "mock dest value"))
59
- dest.copy!(src)
60
- dest.read_attribute(key).should == "mock source value"
61
- end
62
- end
63
-
64
- %W(position).each do |key|
65
- it "should copy the attribute #{key}" do
66
- src = ReRule.new(valid_attributes.merge(key.to_sym => 101))
67
- dest = ReRule.new(valid_attributes.merge(key.to_sym => 202))
68
- dest.copy!(src)
69
- dest.read_attribute(key).should == 101
70
- end
71
- end
72
-
73
- it "should copy the rule outcomes" do
74
- src = ReRule.new(valid_attributes)
75
- dest = ReRule.new(valid_attributes)
76
-
77
- src_outcome = mock_model(ReRuleExpectedOutcome)
78
- dest_outcome = mock_model(ReRuleExpectedOutcome )
79
-
80
- ReRuleExpectedOutcome.should_receive(:new).and_return(dest_outcome)
81
- dest_outcome.should_receive(:copy!).with(src_outcome).and_return(dest_outcome)
82
-
83
- src.should_receive(:re_rule_expected_outcomes).and_return([src_outcome])
84
- dest.should_receive(:re_rule_expected_outcomes=).with([dest_outcome])
85
-
86
- dest.copy!(src)
87
- end
88
- end
89
-
90
- describe "comparing rules" do
91
- it "should be equal if the attributes are equal" do
92
- src = ReRule.new(valid_attributes)
93
- dest = ReRule.new(valid_attributes)
94
- dest.equals?(src).should be_true
95
- end
96
-
97
- %W(rule_class_name title summary data).each do |key|
98
- it "should not be equal if the attribute #{key} are different" do
99
- src = ReRule.new(valid_attributes.merge(key.to_sym => "mock source value"))
100
- dest = ReRule.new(valid_attributes.merge(key.to_sym => "mock dest value"))
101
- dest.equals?(src).should be_false
102
- end
103
- end
104
-
105
- %W(position).each do |key|
106
- it "should not be equal if the attribute #{key} are different" do
107
- src = ReRule.new(valid_attributes.merge(key.to_sym => 101))
108
- dest = ReRule.new(valid_attributes.merge(key.to_sym => 202))
109
- dest.equals?(src).should be_false
110
- end
111
- end
112
-
113
- describe "equals rule outcome" do
114
- before(:each) do
115
- @re_rule_re_rule_expected_outcome_1 = mock_model(ReRuleExpectedOutcome)
116
- @re_rule_re_rule_expected_outcome_2 = mock_model(ReRuleExpectedOutcome)
117
- @re_rule_1 = ReRule.new(valid_attributes)
118
- @re_rule_2 = ReRule.new(valid_attributes)
119
- @re_rule_1.stub!(:re_rule_expected_outcomes).and_return([@re_rule_re_rule_expected_outcome_1, @re_rule_re_rule_expected_outcome_2])
120
- @re_rule_2.stub!(:re_rule_expected_outcomes).and_return([@re_rule_re_rule_expected_outcome_1, @re_rule_re_rule_expected_outcome_2])
121
-
122
- end
123
- it "should not compare the outcomes if the the number is different" do
124
- @re_rule_2.stub!(:re_rule_expected_outcomes).and_return([@re_rule_re_rule_expected_outcome_1])
125
-
126
- @re_rule_re_rule_expected_outcome_1.should_not_receive(:equals?)
127
- @re_rule_re_rule_expected_outcome_2.should_not_receive(:equals?)
128
-
129
- @re_rule_1.equals?(@re_rule_2)
130
- end
131
-
132
- it "should check the equals status of each rule outcome" do
133
- @re_rule_re_rule_expected_outcome_1.should_receive(:equals?).with(@re_rule_re_rule_expected_outcome_1).and_return(true)
134
- @re_rule_re_rule_expected_outcome_2.should_receive(:equals?).with(@re_rule_re_rule_expected_outcome_2).and_return(true)
135
-
136
- @re_rule_1.equals?(@re_rule_2).should be_true
137
- end
138
-
139
- it "should stop on the rule outcome equals error" do
140
- @re_rule_re_rule_expected_outcome_1.should_receive(:equals?).with(@re_rule_re_rule_expected_outcome_1).and_return(false)
141
- @re_rule_re_rule_expected_outcome_2.should_not_receive(:equals?)
142
-
143
- @re_rule_1.equals?(@re_rule_2).should be_false
144
- end
145
- end
146
- end
147
-
148
55
  describe "loading a rule" do
149
56
  before(:each) do
150
57
  @re_rule = ReRule.new(valid_attributes)
@@ -176,7 +83,7 @@ describe ReRule do
176
83
  end
177
84
 
178
85
  it "should set the rule data with the model data attribute" do
179
- @rule.should_receive(:data=).with("Lots Of Data")
86
+ @rule.should_receive(:data=).with(valid_attributes[:data])
180
87
  @re_rule.rule
181
88
  end
182
89
  end
@@ -196,18 +103,26 @@ describe ReRule do
196
103
  end
197
104
 
198
105
  describe "saving a re_rule" do
106
+ before(:each) do
107
+ @re_rule = ReRule.new(valid_attributes)
108
+ @re_rule.stub!(:re_workflow).and_return(@re_workflow)
109
+ end
110
+
199
111
  it "should fail if the rule does not exist" do
200
- re_rule = ReRule.new(valid_attributes)
201
- re_rule.should_receive(:rule).and_return(nil)
202
- re_rule.save.should == false
112
+ @re_rule.should_receive(:rule).and_return(nil)
113
+ @re_rule.save.should == false
203
114
  end
204
-
115
+
116
+ it "should set tell the workflow the rule has changed" do
117
+ @re_workflow.should_receive(:changed!)
118
+ @re_rule.save
119
+ end
120
+
205
121
  describe "a valid rule" do
206
122
  before(:each) do
207
- @re_rule = ReRule.new(valid_attributes)
208
123
  @re_rule.stub(:rule).and_return(@rule)
209
124
  end
210
-
125
+
211
126
  it "should be successful" do
212
127
  @re_rule.save.should == true
213
128
  end
@@ -229,9 +144,9 @@ describe ReRule do
229
144
 
230
145
  it "should set the expected outcomes to the expected outcomes generated by the rule" do
231
146
  re_rule_expected_outcome = ReRuleExpectedOutcome.new
232
- ReRuleExpectedOutcome.should_receive(:new).with(:outcome => 101, :pipeline_code => "one").and_return(re_rule_expected_outcome)
233
- ReRuleExpectedOutcome.should_receive(:new).with(:outcome => 202, :pipeline_code => "two").and_return(re_rule_expected_outcome)
234
- @rule.stub(:expected_outcomes).and_return([{:outcome => 101, :pipeline_code => "one"}, {:outcome => 202, :pipeline_code => "two"}])
147
+ ReRuleExpectedOutcome.should_receive(:new).with(:outcome => 101, :workflow_code => "one").and_return(re_rule_expected_outcome)
148
+ ReRuleExpectedOutcome.should_receive(:new).with(:outcome => 202, :workflow_code => "two").and_return(re_rule_expected_outcome)
149
+ @rule.stub(:expected_outcomes).and_return([{:outcome => 101, :workflow_code => "one"}, {:outcome => 202, :workflow_code => "two"}])
235
150
  @re_rule.save
236
151
  @re_rule.re_rule_expected_outcomes.should == [re_rule_expected_outcome, re_rule_expected_outcome]
237
152
  end
@@ -240,23 +155,28 @@ describe ReRule do
240
155
 
241
156
  describe "after saving a re_rule" do
242
157
  it "should notify the rule" do
243
- @re_rule = ReRule.new(valid_attributes)
244
- @re_pipeline_id = nil
245
- @re_rule_id = nil
246
- @rule.should_receive(:after_add_to_pipeline) do |re_pipeline_id, re_rule_id|
247
- @re_pipeline_id = re_pipeline_id
248
- @re_rule_id = re_rule_id
158
+ re_rule = ReRule.new(valid_attributes)
159
+ re_rule.stub!(:re_workflow).and_return(@re_workflow)
160
+
161
+ @re_workflow.stub!(:code).and_return('1001')
162
+ re_rule.stub!(:rule).and_return(@rule)
163
+
164
+ updated_code = nil
165
+ @rule.should_receive(:after_add_to_workflow) do |re_workflow_code|
166
+ updated_code = re_workflow_code
249
167
  end
250
- @re_rule.save
251
- @re_rule.re_pipeline_id.should == @re_pipeline_id
252
- @re_rule.id.should == @re_rule_id
168
+ re_rule.save
169
+ updated_code.should == '1001'
253
170
  end
254
171
  end
255
-
172
+
256
173
  describe "before destroying a re_rule" do
257
174
  it "should notify the rule" do
258
- @re_rule = ReRule.create(valid_attributes)
259
- @rule.should_receive(:before_remove_from_pipeline).with(@re_rule.re_pipeline_id, @re_rule.id)
175
+ @re_workflow = mock('re_workflow', :code => "1001", :valid? => true)
176
+ @re_rule = ReRule.new(valid_attributes)
177
+ @re_rule.stub!(:re_workflow).and_return(@re_workflow)
178
+
179
+ @rule.should_receive(:before_remove_from_workflow).with("1001")
260
180
  @re_rule.destroy
261
181
  end
262
182
  end
@@ -290,12 +210,12 @@ describe ReRule do
290
210
  @re_rule.re_rule_expected_outcome_failure.should == outcome_1
291
211
  end
292
212
 
293
- it "should return all outcomes that are a OUTCOME_START_PIPELINE" do
294
- outcome_1 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE)
295
- outcome_2 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE)
213
+ it "should return all outcomes that are a OUTCOME_START_WORKFLOW" do
214
+ outcome_1 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
215
+ outcome_2 = ReRuleExpectedOutcome.new(:outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
296
216
  @re_rule.re_rule_expected_outcomes << outcome_1
297
217
  @re_rule.re_rule_expected_outcomes << outcome_2
298
- @re_rule.re_rule_expected_outcomes_start_pipeline.should == [outcome_1, outcome_2]
218
+ @re_rule.re_rule_expected_outcomes_start_workflow.should == [outcome_1, outcome_2]
299
219
  end
300
220
  end
301
221
 
@@ -309,54 +229,90 @@ describe ReRule do
309
229
 
310
230
  it "should return '[title] class [class] invalid' if the rule is missing" do
311
231
  @re_rule.should_receive(:rule).and_return(nil)
312
- @re_rule.rule_error.should == "Mock Title class MockRuleClass invalid"
232
+ @re_rule.rule_error.should == "class MockRuleClass missing"
313
233
  end
314
234
 
315
- it "should ignore outcomes where the pipeline_code is nil" do
316
- re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :pipeline_code => nil)
235
+ it "should ignore outcomes where the workflow_code is nil" do
236
+ re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :workflow_code => nil)
317
237
  @re_rule.stub!(:re_rule_expected_outcomes).and_return([re_rule_expected_outcome])
318
238
  @re_rule.rule_error.should be_nil
319
239
  end
320
-
321
- it "should validate the pipeline is present and activated" do
322
- re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :pipeline_code => "mock_pipeline_code", :outcome => RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE)
323
- RePipeline.should_receive(:find_by_code).and_return(mock("RePipeline", :pipeline_error => nil))
240
+
241
+ it "should validate the workflow is present and activated" do
242
+ re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :workflow_code => "mock_workflow_code", :outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
243
+ ReWorkflow.should_receive(:find_by_code).and_return(mock("ReWorkflow", :workflow_error => nil))
324
244
  @re_rule.stub!(:re_rule_expected_outcomes).and_return([re_rule_expected_outcome])
325
245
  @re_rule.rule_error.should be_nil
326
246
  end
327
247
 
328
- it "should return '[pipeline_code] missing' if the required pipeline is missing" do
329
- re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :pipeline_code => "mock_pipeline_code", :outcome => RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE)
330
- RePipeline.should_receive(:find_by_code).and_return(nil)
248
+ it "should return '[workflow_code] missing' if the required workflow is missing" do
249
+ re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :workflow_code => "mock_workflow_code", :outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
250
+ ReWorkflow.should_receive(:find_by_code).and_return(nil)
331
251
  @re_rule.stub!(:re_rule_expected_outcomes).and_return([re_rule_expected_outcome])
332
- @re_rule.rule_error.should == "mock_pipeline_code missing"
252
+ @re_rule.rule_error.should == "mock_workflow_code missing"
333
253
  end
334
254
 
335
- it "should return '[pipeline_code] invalid' if the required pipeline has errors" do
336
- re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :pipeline_code => "mock_pipeline_code", :outcome => RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE)
337
- RePipeline.should_receive(:find_by_code).and_return(mock("RePipeline", :pipeline_error => "pipeline error"))
255
+ it "should return '[workflow_code] invalid' if the required workflow has errors" do
256
+ re_rule_expected_outcome = mock_model(ReRuleExpectedOutcome, :workflow_code => "mock_workflow_code", :outcome => RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW)
257
+ ReWorkflow.should_receive(:find_by_code).and_return(mock("ReWorkflow", :workflow_error => "workflow error"))
338
258
  @re_rule.stub!(:re_rule_expected_outcomes).and_return([re_rule_expected_outcome])
339
- @re_rule.rule_error.should == "mock_pipeline_code invalid"
259
+ @re_rule.rule_error.should == "mock_workflow_code invalid"
340
260
  end
341
261
 
342
262
  end
343
263
 
344
264
  describe "moving items in a list" do
345
265
  it "should move a rule down in the list" do
346
- re_pipeline = RePipelineBase.create!(:code => "AA-MOCK",:title => "Mock Title")
347
-
266
+ re_workflow = ReWorkflow.create!(:code => "AA-MOCK",:title => "Mock Title")
267
+
348
268
  re_rule_1 = ReRule.new(valid_attributes)
349
269
  re_rule_2 = ReRule.new(valid_attributes)
350
- re_pipeline.re_rules << re_rule_1
351
- re_pipeline.re_rules << re_rule_2
270
+ re_workflow.re_rules << re_rule_1
271
+ re_workflow.re_rules << re_rule_2
352
272
 
353
- re_pipeline.reload
273
+ re_workflow.reload
354
274
 
355
- re_pipeline.re_rules.should == [re_rule_1, re_rule_2]
356
- re_pipeline.re_rules[1].move_higher
357
- re_pipeline.reload
275
+ re_workflow.re_rules.should == [re_rule_1, re_rule_2]
276
+ re_workflow.re_rules[1].move_higher
277
+ re_workflow.reload
358
278
 
359
- re_pipeline.re_rules.should == [re_rule_2, re_rule_1]
279
+ re_workflow.re_rules.should == [re_rule_2, re_rule_1]
360
280
  end
361
281
  end
282
+
283
+ describe "publish" do
284
+ it "should convert the rule to a hash" do
285
+ re_rule = ReRule.new(valid_attributes)
286
+
287
+ publish_data = re_rule.publish
288
+ publish_data["rule_class_name"].should == valid_attributes[:rule_class_name]
289
+ publish_data["title"].should == valid_attributes[:title]
290
+ publish_data["summary"].should == valid_attributes[:summary]
291
+ publish_data["data"].should == valid_attributes[:data]
292
+ end
293
+ end
294
+
295
+ describe "revert!" do
296
+ it "should return self" do
297
+ re_rule = ReRule.new
298
+ re_rule.revert!({}).should == re_rule
299
+ end
300
+
301
+ it "should set the rule based on the data" do
302
+ re_rule = ReRule.new
303
+ RulesEngine::Discovery.should_receive(:rule_class).with('mock_rule_class_name').and_return(@rule_class)
304
+
305
+ re_rule.revert!({
306
+ "rule_class_name" => 'mock_rule_class_name',
307
+ "title" => 'mock title',
308
+ "summary" => 'mock summary',
309
+ "data" => 'mock data'
310
+ })
311
+
312
+ re_rule[:rule_class_name].should == 'mock_rule_class_name'
313
+ re_rule[:title].should == 'mock title'
314
+ re_rule[:summary].should == 'mock summary'
315
+ re_rule[:data].should == 'mock data'
316
+ end
317
+ end
362
318
  end