active_admin-state_machine 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +136 -0
  4. data/Rakefile +17 -0
  5. data/lib/active_admin/state_machine.rb +6 -0
  6. data/lib/active_admin/state_machine/dsl.rb +60 -0
  7. data/lib/active_admin/state_machine/version.rb +5 -0
  8. data/spec/dummy/README.rdoc +261 -0
  9. data/spec/dummy/Rakefile +7 -0
  10. data/spec/dummy/app/admin/admin_users.rb +20 -0
  11. data/spec/dummy/app/admin/categories.rb +5 -0
  12. data/spec/dummy/app/admin/dashboard.rb +33 -0
  13. data/spec/dummy/app/admin/posts.rb +21 -0
  14. data/spec/dummy/app/assets/javascripts/active_admin.js +1 -0
  15. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  16. data/spec/dummy/app/assets/stylesheets/active_admin.css.scss +29 -0
  17. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  18. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  19. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  20. data/spec/dummy/app/models/ability.rb +12 -0
  21. data/spec/dummy/app/models/admin_user.rb +11 -0
  22. data/spec/dummy/app/models/category.rb +4 -0
  23. data/spec/dummy/app/models/post.rb +31 -0
  24. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  25. data/spec/dummy/config.ru +4 -0
  26. data/spec/dummy/config/application.rb +65 -0
  27. data/spec/dummy/config/boot.rb +10 -0
  28. data/spec/dummy/config/database.sample.yml +25 -0
  29. data/spec/dummy/config/database.travis.yml +4 -0
  30. data/spec/dummy/config/database.yml +12 -0
  31. data/spec/dummy/config/environment.rb +5 -0
  32. data/spec/dummy/config/environments/development.rb +38 -0
  33. data/spec/dummy/config/environments/production.rb +67 -0
  34. data/spec/dummy/config/environments/test.rb +37 -0
  35. data/spec/dummy/config/initializers/active_admin.rb +211 -0
  36. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  37. data/spec/dummy/config/initializers/devise.rb +252 -0
  38. data/spec/dummy/config/initializers/inflections.rb +15 -0
  39. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  40. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  41. data/spec/dummy/config/initializers/session_store.rb +8 -0
  42. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  43. data/spec/dummy/config/locales/devise.en.yml +59 -0
  44. data/spec/dummy/config/locales/en.yml +10 -0
  45. data/spec/dummy/config/routes.rb +61 -0
  46. data/spec/dummy/db/development.sqlite3 +0 -0
  47. data/spec/dummy/db/migrate/20130817004304_devise_create_admin_users.rb +52 -0
  48. data/spec/dummy/db/migrate/20130817004306_create_admin_notes.rb +17 -0
  49. data/spec/dummy/db/migrate/20130817004307_move_admin_notes_to_comments.rb +26 -0
  50. data/spec/dummy/db/migrate/20130817005638_create_posts.rb +11 -0
  51. data/spec/dummy/db/migrate/20130829000200_create_categories.rb +11 -0
  52. data/spec/dummy/db/migrate/20131025231118_add_super_admin_to_admin_users.rb +5 -0
  53. data/spec/dummy/db/schema.rb +65 -0
  54. data/spec/dummy/db/seeds.rb +1 -0
  55. data/spec/dummy/db/test.sqlite3 +0 -0
  56. data/spec/dummy/log/development.log +9116 -0
  57. data/spec/dummy/log/test.log +2969 -0
  58. data/spec/dummy/public/404.html +26 -0
  59. data/spec/dummy/public/422.html +26 -0
  60. data/spec/dummy/public/500.html +25 -0
  61. data/spec/dummy/public/favicon.ico +0 -0
  62. data/spec/dummy/script/rails +6 -0
  63. data/spec/dummy/tmp/cache/assets/C6E/0F0/sprockets%2F930c17aa4002b266315478d747cec213 +0 -0
  64. data/spec/dummy/tmp/cache/assets/CA3/0F0/sprockets%2F6111c5f7d680071cae83281d5237bb52 +0 -0
  65. data/spec/dummy/tmp/cache/assets/CAE/C10/sprockets%2Fa28299b4afd821b21049164940fe6a29 +0 -0
  66. data/spec/dummy/tmp/cache/assets/CDB/040/sprockets%2Fc732474e67003a4eb840eb44c5ca9385 +0 -0
  67. data/spec/dummy/tmp/cache/assets/CE1/700/sprockets%2F9e9ac16860d51b9e1245e02a8bd98125 +0 -0
  68. data/spec/dummy/tmp/cache/assets/CE6/660/sprockets%2F90e738777deb87d405d03a2f251b547d +0 -0
  69. data/spec/dummy/tmp/cache/assets/CED/B50/sprockets%2F23b334e745d2ceb50b677668a367de99 +0 -0
  70. data/spec/dummy/tmp/cache/assets/CF3/0A0/sprockets%2F75abab8c479e90729ca78828102e5e78 +0 -0
  71. data/spec/dummy/tmp/cache/assets/CF6/EE0/sprockets%2F3f96414b8e9655fb831972cc81b6b95d +0 -0
  72. data/spec/dummy/tmp/cache/assets/D00/800/sprockets%2F5fe66f0484322d5cda7408c0cb030c36 +0 -0
  73. data/spec/dummy/tmp/cache/assets/D09/E60/sprockets%2Fd61ab529e52f740f6d26a7b3bc082914 +0 -0
  74. data/spec/dummy/tmp/cache/assets/D0B/400/sprockets%2Ff4f1a7e6cca869f56232e07440d0242e +0 -0
  75. data/spec/dummy/tmp/cache/assets/D0D/8D0/sprockets%2Fb048e1909af567b1e61c8f18dd3b4134 +0 -0
  76. data/spec/dummy/tmp/cache/assets/D0E/750/sprockets%2F535f852b14c3f64b6d4498e281ba6aa3 +0 -0
  77. data/spec/dummy/tmp/cache/assets/D1B/330/sprockets%2Fb7c84f061393bf7dac846cd173863c57 +0 -0
  78. data/spec/dummy/tmp/cache/assets/D20/AE0/sprockets%2F25d0f6af9dd375937908ad493464d3ce +0 -0
  79. data/spec/dummy/tmp/cache/assets/D2F/A20/sprockets%2F006e5a12b1bb0fc15555ad556589be6b +0 -0
  80. data/spec/dummy/tmp/cache/assets/D38/540/sprockets%2F86e1ad844bc9df4491a2a52b870421db +0 -0
  81. data/spec/dummy/tmp/cache/assets/D3E/AA0/sprockets%2F77115ed12f0f2812dd9284b1badf974e +0 -0
  82. data/spec/dummy/tmp/cache/assets/D45/B50/sprockets%2F3eb36e58b929a7cb215ec6cd90730f38 +0 -0
  83. data/spec/dummy/tmp/cache/assets/D45/BD0/sprockets%2F2def1531b613ed7a7dbfb87119f63667 +0 -0
  84. data/spec/dummy/tmp/cache/assets/D48/640/sprockets%2F9f4f18d910b678b1d0777e04cdaf6f24 +0 -0
  85. data/spec/dummy/tmp/cache/assets/D4C/C80/sprockets%2F298e59aa2551dcef562bdfd65908462d +0 -0
  86. data/spec/dummy/tmp/cache/assets/D59/D70/sprockets%2Fed9f0de1b65ae8d7ef89087c83728461 +0 -0
  87. data/spec/dummy/tmp/cache/assets/D63/930/sprockets%2F8877deb95181465893a12fc98feefea9 +0 -0
  88. data/spec/dummy/tmp/cache/assets/D67/9A0/sprockets%2F2b5fbe497968ed201d0ff0dca410d319 +0 -0
  89. data/spec/dummy/tmp/cache/assets/D78/560/sprockets%2Fdbe66652ccfa390de76149634dd82e1f +0 -0
  90. data/spec/dummy/tmp/cache/assets/D93/4C0/sprockets%2F857ecd2092cee11f740b3cf2e373ad2a +0 -0
  91. data/spec/dummy/tmp/cache/assets/D9A/FA0/sprockets%2Fe32c0ff23c6a4084195aafcff444fe63 +0 -0
  92. data/spec/dummy/tmp/cache/assets/DA3/450/sprockets%2Ff6563ad6efdc449e5219ea221c75fcc3 +0 -0
  93. data/spec/dummy/tmp/cache/assets/DA4/050/sprockets%2Fb09f488a4f238bf22bc82cef50a6f84d +0 -0
  94. data/spec/dummy/tmp/cache/assets/DD7/FE0/sprockets%2Ff00de35ea71cb4fc5fc5e96860f5ee55 +0 -0
  95. data/spec/dummy/tmp/cache/assets/DDE/420/sprockets%2Ffb8b186d5bf0307f86f65fc787d2adeb +0 -0
  96. data/spec/dummy/tmp/cache/assets/DE6/B50/sprockets%2Febd2b61aa5d1e7bd84e31523e1bc71ac +0 -0
  97. data/spec/dummy/tmp/cache/assets/DF0/870/sprockets%2F1e4ab2eb47da0bb42b6e37e38639cbae +0 -0
  98. data/spec/dummy/tmp/cache/assets/DFA/CD0/sprockets%2F6bb1e8a62edbd48cf00dc678d1f0f65a +0 -0
  99. data/spec/dummy/tmp/cache/assets/E32/990/sprockets%2F2f6fe5d3fae5b4dba7e7cc36ca68e415 +0 -0
  100. data/spec/dummy/tmp/cache/sass/021f0a44d22f3712e4de7c01de2d6b99f65f2482/_bourbon-deprecated-upcoming.scssc +0 -0
  101. data/spec/dummy/tmp/cache/sass/021f0a44d22f3712e4de7c01de2d6b99f65f2482/_bourbon.scssc +0 -0
  102. data/spec/dummy/tmp/cache/sass/0733f78978a3764d0f20e2bea650007fb2bf064b/_compact.scssc +0 -0
  103. data/spec/dummy/tmp/cache/sass/0733f78978a3764d0f20e2bea650007fb2bf064b/_flex-grid.scssc +0 -0
  104. data/spec/dummy/tmp/cache/sass/0733f78978a3764d0f20e2bea650007fb2bf064b/_grid-width.scssc +0 -0
  105. data/spec/dummy/tmp/cache/sass/0733f78978a3764d0f20e2bea650007fb2bf064b/_linear-gradient.scssc +0 -0
  106. data/spec/dummy/tmp/cache/sass/0733f78978a3764d0f20e2bea650007fb2bf064b/_modular-scale.scssc +0 -0
  107. data/spec/dummy/tmp/cache/sass/0733f78978a3764d0f20e2bea650007fb2bf064b/_px-to-em.scssc +0 -0
  108. data/spec/dummy/tmp/cache/sass/0733f78978a3764d0f20e2bea650007fb2bf064b/_radial-gradient.scssc +0 -0
  109. data/spec/dummy/tmp/cache/sass/0733f78978a3764d0f20e2bea650007fb2bf064b/_tint-shade.scssc +0 -0
  110. data/spec/dummy/tmp/cache/sass/0733f78978a3764d0f20e2bea650007fb2bf064b/_transition-property-name.scssc +0 -0
  111. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_batch_actions.css.scssc +0 -0
  112. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_blank_slates.scssc +0 -0
  113. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_breadcrumbs.scssc +0 -0
  114. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_buttons.scssc +0 -0
  115. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_columns.scssc +0 -0
  116. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_comments.css.scssc +0 -0
  117. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_date_picker.css.scssc +0 -0
  118. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_dropdown_menu.scssc +0 -0
  119. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_flash_messages.css.scssc +0 -0
  120. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_grid.scssc +0 -0
  121. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_index_list.scssc +0 -0
  122. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_links.scssc +0 -0
  123. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_pagination.scssc +0 -0
  124. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_panels.scssc +0 -0
  125. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_popovers.css.scssc +0 -0
  126. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_scopes.scssc +0 -0
  127. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_status_tags.scssc +0 -0
  128. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_table_tools.css.scssc +0 -0
  129. data/spec/dummy/tmp/cache/sass/2fd82df35090e4bb74fb9a41455f20a1e79db68a/_tables.css.scssc +0 -0
  130. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_all.css.scssc +0 -0
  131. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_buttons.css.scssc +0 -0
  132. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_gradients.css.scssc +0 -0
  133. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_icons.css.scssc +0 -0
  134. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_reset.css.scssc +0 -0
  135. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_rounded.css.scssc +0 -0
  136. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_sections.css.scssc +0 -0
  137. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_shadows.css.scssc +0 -0
  138. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_typography.scssc +0 -0
  139. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_utilities.scssc +0 -0
  140. data/spec/dummy/tmp/cache/sass/49a924645aad7b7327372ccd94e45cbdf78ae4ff/_variables.css.scssc +0 -0
  141. data/spec/dummy/tmp/cache/sass/97d1d5c145c2924a55e7b5d99d290112170b74f0/_footer.scssc +0 -0
  142. data/spec/dummy/tmp/cache/sass/97d1d5c145c2924a55e7b5d99d290112170b74f0/_main_structure.scssc +0 -0
  143. data/spec/dummy/tmp/cache/sass/97d1d5c145c2924a55e7b5d99d290112170b74f0/_title_bar.scssc +0 -0
  144. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_button.scssc +0 -0
  145. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_clearfix.scssc +0 -0
  146. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_font-family.scssc +0 -0
  147. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_hide-text.scssc +0 -0
  148. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_html5-input-types.scssc +0 -0
  149. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_position.scssc +0 -0
  150. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_prefixer.scssc +0 -0
  151. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_retina-image.scssc +0 -0
  152. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_size.scssc +0 -0
  153. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_timing-functions.scssc +0 -0
  154. data/spec/dummy/tmp/cache/sass/a88ac2680a1680d7d2a5f8b0c7dc7f5e3131ade5/_triangle.scssc +0 -0
  155. data/spec/dummy/tmp/cache/sass/c10713f51b89c2fd0ebe39519f07849be30ad7dc/_deprecated-webkit-gradient.scssc +0 -0
  156. data/spec/dummy/tmp/cache/sass/c10713f51b89c2fd0ebe39519f07849be30ad7dc/_gradient-positions-parser.scssc +0 -0
  157. data/spec/dummy/tmp/cache/sass/c10713f51b89c2fd0ebe39519f07849be30ad7dc/_linear-positions-parser.scssc +0 -0
  158. data/spec/dummy/tmp/cache/sass/c10713f51b89c2fd0ebe39519f07849be30ad7dc/_radial-arg-parser.scssc +0 -0
  159. data/spec/dummy/tmp/cache/sass/c10713f51b89c2fd0ebe39519f07849be30ad7dc/_radial-positions-parser.scssc +0 -0
  160. data/spec/dummy/tmp/cache/sass/c10713f51b89c2fd0ebe39519f07849be30ad7dc/_render-gradients.scssc +0 -0
  161. data/spec/dummy/tmp/cache/sass/c10713f51b89c2fd0ebe39519f07849be30ad7dc/_shape-size-stripper.scssc +0 -0
  162. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_animation.scssc +0 -0
  163. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_appearance.scssc +0 -0
  164. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_backface-visibility.scssc +0 -0
  165. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_background-image.scssc +0 -0
  166. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_background.scssc +0 -0
  167. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_border-image.scssc +0 -0
  168. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_border-radius.scssc +0 -0
  169. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_box-sizing.scssc +0 -0
  170. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_columns.scssc +0 -0
  171. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_flex-box.scssc +0 -0
  172. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_font-face.scssc +0 -0
  173. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_hidpi-media-query.scssc +0 -0
  174. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_image-rendering.scssc +0 -0
  175. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_inline-block.scssc +0 -0
  176. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_keyframes.scssc +0 -0
  177. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_linear-gradient.scssc +0 -0
  178. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_perspective.scssc +0 -0
  179. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_placeholder.scssc +0 -0
  180. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_radial-gradient.scssc +0 -0
  181. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_transform.scssc +0 -0
  182. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_transition.scssc +0 -0
  183. data/spec/dummy/tmp/cache/sass/c440ddc8eb3b4ee623e7dfe6ab824cc1e13dc16d/_user-select.scssc +0 -0
  184. data/spec/dummy/tmp/cache/sass/c7fb764b3bec96a92cf65b0d831789c5ca3c5ed7/active_admin.css.scssc +0 -0
  185. data/spec/dummy/tmp/cache/sass/cb0cbb3d3d7b7c51feca169c780bb955b45511b4/_dashboard.scssc +0 -0
  186. data/spec/dummy/tmp/cache/sass/cb0cbb3d3d7b7c51feca169c780bb955b45511b4/_logged_out.scssc +0 -0
  187. data/spec/dummy/tmp/cache/sass/eeb938f07a558025f0485a33a8e74dcc19262df9/_base.css.scssc +0 -0
  188. data/spec/dummy/tmp/cache/sass/eeb938f07a558025f0485a33a8e74dcc19262df9/_forms.css.scssc +0 -0
  189. data/spec/dummy/tmp/cache/sass/eeb938f07a558025f0485a33a8e74dcc19262df9/_header.css.scssc +0 -0
  190. data/spec/dummy/tmp/cache/sass/eeb938f07a558025f0485a33a8e74dcc19262df9/_mixins.css.scssc +0 -0
  191. data/spec/dummy/tmp/cache/sass/eeb938f07a558025f0485a33a8e74dcc19262df9/_typography.css.scssc +0 -0
  192. data/spec/dummy/tmp/cache/sass/eeb938f07a558025f0485a33a8e74dcc19262df9/print.css.scssc +0 -0
  193. data/spec/dummy/tmp/pids/server.pid +1 -0
  194. data/spec/factories/admin_users.rb +8 -0
  195. data/spec/factories/categories.rb +17 -0
  196. data/spec/factories/posts.rb +11 -0
  197. data/spec/features/authorization_spec.rb +23 -0
  198. data/spec/features/custom_block_spec.rb +25 -0
  199. data/spec/features/js_confirmation_spec.rb +51 -0
  200. data/spec/spec_helper.rb +54 -0
  201. data/spec/support/post_helpers.rb +22 -0
  202. metadata +605 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e049302abed3ba262229510939b32ea1c0b2b29a
4
+ data.tar.gz: 358e8e518b0336990d53e2d60352a4e1d7ba8726
5
+ SHA512:
6
+ metadata.gz: 4c2a7762b15928fae7f3eaa022f9d665b0f596acb3abdaf1b9ef69ff14fa3593a91d9d67936ea708fe9699d974640f405143443a4cbb95f05580f1a21c18cd22
7
+ data.tar.gz: 70b0792619f378084dc4b36581d23127916cc9f67a5283cf6e1b6a0f5229cfbeba77f2bf0cdc445fe1a2b78e091ce0bbdfa6294e95f0e36b0171747b5a9c6318
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,136 @@
1
+ # ActiveAdmin-StateMachine
2
+
3
+ This gem provides an easy integration between the awesome [state_machine](https://github.com/pluginaweek/state_machine) and [active_admin](https://github.com/gregbell/active_admin) gems.
4
+
5
+ ## Features
6
+
7
+ This gem provides you with a DSL extension to ActiveAdmin that allows you to easily define action item buttons for your resource to transition through your state_machine.
8
+
9
+ * Integration with ActiveAdmin authorization adapater layer - the button won't show if the user isn't authorized
10
+ * Provide custom permission to authorize against
11
+ * Provide confirmation message to prompt user before performing
12
+ * Button only shown if state_machine can transition
13
+ * Localizable button titles and flash messages
14
+ * Pass a block to customize the behavior
15
+
16
+ ## Installation
17
+
18
+ This gem requires both `active_admin` and `state_machine`. Add the gem to your Gemfile to get started and bundle.
19
+
20
+ ```ruby
21
+ gem 'active_admin-state-machine'
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ You will need to define a state_machine in a model, and have that model registered as a resource with ActiveAdmin.
27
+
28
+ **A basic model**
29
+
30
+ ```
31
+ # app/models/post.rb
32
+ class Post < ActiveRecord::Base
33
+ attr_accessible :body, :status, :title
34
+
35
+ validates :title, presence: true, uniqueness: true
36
+ validates :body, presence: true
37
+
38
+ DRAFT = 'draft'
39
+ REVIEWED = 'reviewed'
40
+ PUBLISHED = 'published'
41
+
42
+ state_machine :status, initial: DRAFT do
43
+ event :peer_review do
44
+ transition DRAFT => REVIEWED
45
+ end
46
+
47
+ event :publish do
48
+ transition REVIEWED => PUBLISHED
49
+ end
50
+ end
51
+ end
52
+ ```
53
+
54
+ **Corresponding ActiveAdmin resource**
55
+
56
+ ```
57
+ ActiveAdmin.register Post do
58
+
59
+ state_action :peer_review
60
+ state_action :publish
61
+
62
+ form do |f|
63
+ f.inputs "Post Details" do
64
+ f.input :title
65
+ f.input :body
66
+ end
67
+ f.actions
68
+ end
69
+
70
+ end
71
+ ```
72
+
73
+ In the above example, the `state_action` method is defined by this gem and provides you with the following functionality:
74
+
75
+ 1. The `:peer_review` is assumed to be an event in your state_machine definition on the Post model.
76
+ 2. Calling `state_action` will add an action item button to your ActiveAdmin resource on the `#show` page, if the user is authorized to perform this action via the ActiveAdmin authorization adapter, and if the resource itself returns true to `#can_peer_review?`, which is provided by default with this event in state_machine.
77
+ 3. Clicking the button will call `#peer_review!` on the resource, and redirect you back to `smart_resource_url`.
78
+ 4. Fully localizable, provide translations for `"posts.peer_review.label"`for the button title and `"posts.peer_review.flash.success` for the flash message when completed.
79
+ 5. You can pass a block to customize this behavior.
80
+
81
+ ### Custom Block
82
+
83
+ ```
84
+ ActiveAdmin.register Post do
85
+
86
+ state_action :peer_review
87
+
88
+ # Block to be called when submitted
89
+ state_action :publish do
90
+ PostPublicationService.publish!(resource)
91
+ flash[:notice] = "Post published"
92
+ redirect_to collection_path
93
+ end
94
+
95
+ end
96
+ ```
97
+
98
+ ### Custom Permission
99
+
100
+ ```
101
+ ActiveAdmin.register Post do
102
+
103
+ # by default, permission would be :peer_review
104
+ state_action :peer_review, permission: :read
105
+ end
106
+ ```
107
+
108
+ ### Confirmation
109
+
110
+ ```
111
+ ActiveAdmin.register Post do
112
+
113
+ # Lookup 'posts.peer_review.prompt'
114
+ state_action :peer_review, confirm: :true
115
+
116
+ # Pass proc
117
+ state_action :peer_review, confirm: ->{ I18n.t("posts.peer_review.confirm") }
118
+ end
119
+ ```
120
+
121
+ ### Using without state_machine model
122
+
123
+ If you really want to use without a state_machine on your model, you essentially just need to provide the following methods, contining with our `:peer_review` example:
124
+
125
+ ```
126
+ class Post < ActiveRecord::Base
127
+ def can_peer_review?
128
+ author.present? && !published?
129
+ end
130
+
131
+ def peer_review!
132
+ self.published_at = Time.now
133
+ save!
134
+ end
135
+ end
136
+ ```
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
9
+ Bundler::GemHelper.install_tasks
10
+
11
+ require 'rspec/core'
12
+ require 'rspec/core/rake_task'
13
+
14
+ desc "Run all specs in spec directory (excluding plugin specs)"
15
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
16
+
17
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ require 'active_admin'
2
+ require 'state_machine'
3
+
4
+ require 'active_admin/state_machine/dsl'
5
+
6
+ ActiveAdmin::DSL.send :include, ActiveAdmin::StateMachine::DSL
@@ -0,0 +1,60 @@
1
+ module ActiveAdmin
2
+ module StateMachine
3
+ module DSL
4
+
5
+ #
6
+ # Easily tie into a state_machine action
7
+ #
8
+ # @param [Symbol] state machine event, ie: :publish
9
+ # @param [Hash] options
10
+ # - permission [Symbol] permission to check authorization against
11
+ # - http_verb [Symbol] :put, :post, :get, etc
12
+ #
13
+ # Will call "resource.publish!", if "resource.can_publish?" returns true
14
+ #
15
+
16
+ def state_action(action, options={}, &controller_action)
17
+ singular = config.resource_name.singular
18
+ plural = config.resource_name.plural
19
+
20
+ options[:permission] ||= controller.new.send(:action_to_permission, action)
21
+ confirmation = options.fetch(:confirm, false)
22
+ if confirmation == true
23
+ default = "Are you sure you want to #{action.to_s.humanize.downcase}?"
24
+ confirmation = ->{ I18n.t(:confirm, scope: "#{plural}.#{action}", default: default) }
25
+ end
26
+
27
+ http_verb = options.fetch :http_verb, :put
28
+
29
+ action_item only: :show do
30
+ if resource.send("can_#{action}?") && authorized?(options[:permission], resource)
31
+ path = resource_path << "/#{action}"
32
+ label = I18n.t("#{plural}.#{action}.label", default: action.to_s.titleize)
33
+
34
+ link_options = {}
35
+ if confirmation.is_a?(Proc)
36
+ link_options[:data] ||= {}
37
+ link_options[:data][:confirm] = instance_exec(&confirmation)
38
+ end
39
+
40
+ link_options[:class] = "btn btn-large"
41
+ link_options[:method] = http_verb
42
+
43
+ link_to label, path, link_options
44
+ end
45
+ end
46
+
47
+ unless block_given?
48
+ controller_action = -> do
49
+ resource.send("#{action}!")
50
+ flash[:notice] = t("#{plural}.#{action}.flash.success")
51
+ redirect_to smart_resource_url
52
+ end
53
+ end
54
+
55
+ member_action action, method: http_verb, &controller_action
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,5 @@
1
+ module ActiveAdmin
2
+ module StateMachine
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,261 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application framework that includes everything needed to create
4
+ database-backed web applications according to the Model-View-Control pattern.
5
+
6
+ This pattern splits the view (also called the presentation) into "dumb"
7
+ templates that are primarily responsible for inserting pre-built data in between
8
+ HTML tags. The model contains the "smart" domain objects (such as Account,
9
+ Product, Person, Post) that holds all the business logic and knows how to
10
+ persist themselves to a database. The controller handles the incoming requests
11
+ (such as Save New Account, Update Product, Show Post) by manipulating the model
12
+ and directing data to the view.
13
+
14
+ In Rails, the model is handled by what's called an object-relational mapping
15
+ layer entitled Active Record. This layer allows you to present the data from
16
+ database rows as objects and embellish these data objects with business logic
17
+ methods. You can read more about Active Record in
18
+ link:files/vendor/rails/activerecord/README.html.
19
+
20
+ The controller and view are handled by the Action Pack, which handles both
21
+ layers by its two parts: Action View and Action Controller. These two layers
22
+ are bundled in a single package due to their heavy interdependence. This is
23
+ unlike the relationship between the Active Record and Action Pack that is much
24
+ more separate. Each of these packages can be used independently outside of
25
+ Rails. You can read more about Action Pack in
26
+ link:files/vendor/rails/actionpack/README.html.
27
+
28
+
29
+ == Getting Started
30
+
31
+ 1. At the command prompt, create a new Rails application:
32
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
33
+
34
+ 2. Change directory to <tt>myapp</tt> and start the web server:
35
+ <tt>cd myapp; rails server</tt> (run with --help for options)
36
+
37
+ 3. Go to http://localhost:3000/ and you'll see:
38
+ "Welcome aboard: You're riding Ruby on Rails!"
39
+
40
+ 4. Follow the guidelines to start developing your application. You can find
41
+ the following resources handy:
42
+
43
+ * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
44
+ * Ruby on Rails Tutorial Book: http://www.railstutorial.org/
45
+
46
+
47
+ == Debugging Rails
48
+
49
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
50
+ will help you debug it and get it back on the rails.
51
+
52
+ First area to check is the application log files. Have "tail -f" commands
53
+ running on the server.log and development.log. Rails will automatically display
54
+ debugging and runtime information to these files. Debugging info will also be
55
+ shown in the browser on requests from 127.0.0.1.
56
+
57
+ You can also log your own messages directly into the log file from your code
58
+ using the Ruby logger class from inside your controllers. Example:
59
+
60
+ class WeblogController < ActionController::Base
61
+ def destroy
62
+ @weblog = Weblog.find(params[:id])
63
+ @weblog.destroy
64
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
65
+ end
66
+ end
67
+
68
+ The result will be a message in your log file along the lines of:
69
+
70
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
71
+
72
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
73
+
74
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
75
+ several books available online as well:
76
+
77
+ * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
78
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
79
+
80
+ These two books will bring you up to speed on the Ruby language and also on
81
+ programming in general.
82
+
83
+
84
+ == Debugger
85
+
86
+ Debugger support is available through the debugger command when you start your
87
+ Mongrel or WEBrick server with --debugger. This means that you can break out of
88
+ execution at any point in the code, investigate and change the model, and then,
89
+ resume execution! You need to install ruby-debug to run the server in debugging
90
+ mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
91
+
92
+ class WeblogController < ActionController::Base
93
+ def index
94
+ @posts = Post.all
95
+ debugger
96
+ end
97
+ end
98
+
99
+ So the controller will accept the action, run the first line, then present you
100
+ with a IRB prompt in the server window. Here you can do things like:
101
+
102
+ >> @posts.inspect
103
+ => "[#<Post:0x14a6be8
104
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
105
+ #<Post:0x14a6620
106
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
107
+ >> @posts.first.title = "hello from a debugger"
108
+ => "hello from a debugger"
109
+
110
+ ...and even better, you can examine how your runtime objects actually work:
111
+
112
+ >> f = @posts.first
113
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
114
+ >> f.
115
+ Display all 152 possibilities? (y or n)
116
+
117
+ Finally, when you're ready to resume execution, you can enter "cont".
118
+
119
+
120
+ == Console
121
+
122
+ The console is a Ruby shell, which allows you to interact with your
123
+ application's domain model. Here you'll have all parts of the application
124
+ configured, just like it is when the application is running. You can inspect
125
+ domain models, change values, and save to the database. Starting the script
126
+ without arguments will launch it in the development environment.
127
+
128
+ To start the console, run <tt>rails console</tt> from the application
129
+ directory.
130
+
131
+ Options:
132
+
133
+ * Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
134
+ made to the database.
135
+ * Passing an environment name as an argument will load the corresponding
136
+ environment. Example: <tt>rails console production</tt>.
137
+
138
+ To reload your controllers and models after launching the console run
139
+ <tt>reload!</tt>
140
+
141
+ More information about irb can be found at:
142
+ link:http://www.rubycentral.org/pickaxe/irb.html
143
+
144
+
145
+ == dbconsole
146
+
147
+ You can go to the command line of your database directly through <tt>rails
148
+ dbconsole</tt>. You would be connected to the database with the credentials
149
+ defined in database.yml. Starting the script without arguments will connect you
150
+ to the development database. Passing an argument will connect you to a different
151
+ database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
152
+ PostgreSQL and SQLite 3.
153
+
154
+ == Description of Contents
155
+
156
+ The default directory structure of a generated Ruby on Rails application:
157
+
158
+ |-- app
159
+ | |-- assets
160
+ | | |-- images
161
+ | | |-- javascripts
162
+ | | `-- stylesheets
163
+ | |-- controllers
164
+ | |-- helpers
165
+ | |-- mailers
166
+ | |-- models
167
+ | `-- views
168
+ | `-- layouts
169
+ |-- config
170
+ | |-- environments
171
+ | |-- initializers
172
+ | `-- locales
173
+ |-- db
174
+ |-- doc
175
+ |-- lib
176
+ | |-- assets
177
+ | `-- tasks
178
+ |-- log
179
+ |-- public
180
+ |-- script
181
+ |-- test
182
+ | |-- fixtures
183
+ | |-- functional
184
+ | |-- integration
185
+ | |-- performance
186
+ | `-- unit
187
+ |-- tmp
188
+ | `-- cache
189
+ | `-- assets
190
+ `-- vendor
191
+ |-- assets
192
+ | |-- javascripts
193
+ | `-- stylesheets
194
+ `-- plugins
195
+
196
+ app
197
+ Holds all the code that's specific to this particular application.
198
+
199
+ app/assets
200
+ Contains subdirectories for images, stylesheets, and JavaScript files.
201
+
202
+ app/controllers
203
+ Holds controllers that should be named like weblogs_controller.rb for
204
+ automated URL mapping. All controllers should descend from
205
+ ApplicationController which itself descends from ActionController::Base.
206
+
207
+ app/models
208
+ Holds models that should be named like post.rb. Models descend from
209
+ ActiveRecord::Base by default.
210
+
211
+ app/views
212
+ Holds the template files for the view that should be named like
213
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
214
+ eRuby syntax by default.
215
+
216
+ app/views/layouts
217
+ Holds the template files for layouts to be used with views. This models the
218
+ common header/footer method of wrapping views. In your views, define a layout
219
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
220
+ Inside default.html.erb, call <% yield %> to render the view using this
221
+ layout.
222
+
223
+ app/helpers
224
+ Holds view helpers that should be named like weblogs_helper.rb. These are
225
+ generated for you automatically when using generators for controllers.
226
+ Helpers can be used to wrap functionality for your views into methods.
227
+
228
+ config
229
+ Configuration files for the Rails environment, the routing map, the database,
230
+ and other dependencies.
231
+
232
+ db
233
+ Contains the database schema in schema.rb. db/migrate contains all the
234
+ sequence of Migrations for your schema.
235
+
236
+ doc
237
+ This directory is where your application documentation will be stored when
238
+ generated using <tt>rake doc:app</tt>
239
+
240
+ lib
241
+ Application specific libraries. Basically, any kind of custom code that
242
+ doesn't belong under controllers, models, or helpers. This directory is in
243
+ the load path.
244
+
245
+ public
246
+ The directory available for the web server. Also contains the dispatchers and the
247
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
248
+ server.
249
+
250
+ script
251
+ Helper scripts for automation and generation.
252
+
253
+ test
254
+ Unit and functional tests along with fixtures. When using the rails generate
255
+ command, template test files will be generated for you and placed in this
256
+ directory.
257
+
258
+ vendor
259
+ External libraries that the application depends on. Also includes the plugins
260
+ subdirectory. If the app has frozen rails, those gems also go here, under
261
+ vendor/rails/. This directory is in the load path.