underworld 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/LICENSE +339 -0
  5. data/Rakefile +48 -0
  6. data/app/assets/fonts/DroidNaskh-Bold.ttf +0 -0
  7. data/app/assets/fonts/DroidNaskh-Regular.ttf +0 -0
  8. data/app/assets/fonts/OpenSans-Bold.ttf +0 -0
  9. data/app/assets/fonts/OpenSans-BoldItalic.ttf +0 -0
  10. data/app/assets/fonts/OpenSans-ExtraBold.ttf +0 -0
  11. data/app/assets/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  12. data/app/assets/fonts/OpenSans-Italic.ttf +0 -0
  13. data/app/assets/fonts/OpenSans-Light.ttf +0 -0
  14. data/app/assets/fonts/OpenSans-LightItalic.ttf +0 -0
  15. data/app/assets/fonts/OpenSans-Regular.ttf +0 -0
  16. data/app/assets/fonts/OpenSans-Semibold.ttf +0 -0
  17. data/app/assets/fonts/OpenSans-SemiboldItalic.ttf +0 -0
  18. data/app/assets/images/underworld/select2-spinner.gif +0 -0
  19. data/app/assets/images/underworld/select2.png +0 -0
  20. data/app/assets/images/underworld/select2x2.png +0 -0
  21. data/app/assets/javascripts/underworld/application.js +16 -0
  22. data/app/assets/javascripts/underworld/dashboard/application.js.erb +30 -0
  23. data/app/assets/javascripts/underworld/dashboard/functions.js.erb +50 -0
  24. data/app/assets/javascripts/underworld/dashboard/init.js.coffee +33 -0
  25. data/app/assets/javascripts/underworld/dashboard/lib/actions.js +7 -0
  26. data/app/assets/javascripts/underworld/dashboard/lib/amd.js.coffee.erb +0 -0
  27. data/app/assets/javascripts/underworld/dashboard/lib/flash_message.js +71 -0
  28. data/app/assets/javascripts/underworld/dashboard/lib/locale.js +14 -0
  29. data/app/assets/javascripts/underworld/dashboard/lib/misc.js +5 -0
  30. data/app/assets/javascripts/underworld/dashboard/lib/string.js +3 -0
  31. data/app/assets/javascripts/underworld/dashboard/lib/ujs_patches.js.coffee +28 -0
  32. data/app/assets/javascripts/underworld/dashboard/manifest.js +5 -0
  33. data/app/assets/javascripts/underworld/dashboard/variables.js.erb +6 -0
  34. data/app/assets/javascripts/underworld/groups.js +2 -0
  35. data/app/assets/javascripts/underworld/home.js +2 -0
  36. data/app/assets/javascripts/underworld/i18n.js +13 -0
  37. data/app/assets/javascripts/underworld/simple.js +20 -0
  38. data/app/assets/javascripts/underworld/users.js +2 -0
  39. data/app/assets/stylesheets/underworld/dashboard/loadindicator.scss +17 -0
  40. data/app/assets/stylesheets/underworld/dashboard/ltr/application.css +38 -0
  41. data/app/assets/stylesheets/underworld/dashboard/ltr/base.css.scss +0 -0
  42. data/app/assets/stylesheets/underworld/dashboard/rtl/application.css +11 -0
  43. data/app/assets/stylesheets/underworld/dashboard/rtl/base.css.scss +0 -0
  44. data/app/assets/stylesheets/underworld/dashboard/share.scss +62 -0
  45. data/app/assets/stylesheets/underworld/dashboard/variables.scss +9 -0
  46. data/app/assets/stylesheets/underworld/ltr/application.css +0 -0
  47. data/app/assets/stylesheets/underworld/rtl/application.css +0 -0
  48. data/app/assets/stylesheets/underworld/simple/ltr/application.css +2 -0
  49. data/app/assets/stylesheets/underworld/simple/rtl/application.css +2 -0
  50. data/app/assets/stylesheets/underworld/simple/rtl/rtl.scss +16 -0
  51. data/app/assets/stylesheets/underworld/simple/share.scss +11 -0
  52. data/app/controllers/underworld/api_controller.rb +133 -0
  53. data/app/controllers/underworld/application_controller.rb +16 -0
  54. data/app/controllers/underworld/assets_controller.rb +6 -0
  55. data/app/controllers/underworld/dashboard/application_controller.rb +43 -0
  56. data/app/controllers/underworld/dashboard/groups_controller.rb +85 -0
  57. data/app/controllers/underworld/dashboard/profile_controller.rb +49 -0
  58. data/app/controllers/underworld/dashboard/user_messages_controller.rb +27 -0
  59. data/app/controllers/underworld/dashboard/users_controller.rb +116 -0
  60. data/app/controllers/underworld/dashboard_controller.rb +16 -0
  61. data/app/controllers/underworld/omniauth/callbacks_controller.rb +24 -0
  62. data/app/helpers/underworld/application_helper.rb +4 -0
  63. data/app/helpers/underworld/dashboard_helper.rb +107 -0
  64. data/app/helpers/underworld/groups_helper.rb +4 -0
  65. data/app/helpers/underworld/home_helper.rb +4 -0
  66. data/app/helpers/underworld/users_helper.rb +8 -0
  67. data/app/models/application_record.rb +3 -0
  68. data/app/models/underworld/concerns/assignment.rb +16 -0
  69. data/app/models/underworld/concerns/user/auth_definitions.rb +87 -0
  70. data/app/models/underworld/concerns/user/gravatar.rb +11 -0
  71. data/app/models/underworld/concerns/user/mongoid_fields.rb +81 -0
  72. data/app/models/underworld/concerns/user/permission.rb +47 -0
  73. data/app/models/underworld/concerns/user/user_roles.rb +24 -0
  74. data/app/models/underworld/group.rb +57 -0
  75. data/app/models/underworld/permission.rb +43 -0
  76. data/app/models/underworld/user.rb +81 -0
  77. data/app/models/underworld/user_message.rb +6 -0
  78. data/app/policies/underworld/admin_only_policy.rb +66 -0
  79. data/app/policies/underworld/application_policy.rb +55 -0
  80. data/app/policies/underworld/group_policy.rb +8 -0
  81. data/app/policies/underworld/user_message_policy.rb +9 -0
  82. data/app/policies/underworld/user_policy.rb +9 -0
  83. data/app/views/angular/auth/groups/details.html +2 -0
  84. data/app/views/angular/auth/groups/index.html +2 -0
  85. data/app/views/angular/auth/groups/new.html +2 -0
  86. data/app/views/angular/auth/index.html +30 -0
  87. data/app/views/angular/auth/profile/edit.html +54 -0
  88. data/app/views/angular/auth/users/details.html +28 -0
  89. data/app/views/angular/auth/users/index.html +6 -0
  90. data/app/views/angular/auth/users/new.html +57 -0
  91. data/app/views/angular/conversations/details.html +19 -0
  92. data/app/views/angular/conversations/index.html +13 -0
  93. data/app/views/angular/conversations/new.html +39 -0
  94. data/app/views/angular/conversations/show.html +6 -0
  95. data/app/views/angular/conversations/show_details.html +15 -0
  96. data/app/views/angular/fields/boolean/boolean.html +4 -0
  97. data/app/views/angular/fields/control-combo/control-list.html +19 -0
  98. data/app/views/angular/fields/datetime/datetime.html +10 -0
  99. data/app/views/angular/fields/datetime/time.html +25 -0
  100. data/app/views/angular/fields/file/file.html.slim +0 -0
  101. data/app/views/angular/fields/float/float.html +4 -0
  102. data/app/views/angular/fields/image/image.html +1 -0
  103. data/app/views/angular/fields/integer/integer.html +4 -0
  104. data/app/views/angular/fields/relation/relation.html +44 -0
  105. data/app/views/angular/fields/string/string.html +22 -0
  106. data/app/views/angular/fields/tag/tag.html +1 -0
  107. data/app/views/angular/fields/text/text.html +4 -0
  108. data/app/views/angular/filter/index.html +15 -0
  109. data/app/views/angular/index.html +3 -0
  110. data/app/views/angular/locale/fa.po +25 -0
  111. data/app/views/angular/locale/templates.pot +24 -0
  112. data/app/views/angular/logs/index.html +6 -0
  113. data/app/views/angular/modules.html +0 -0
  114. data/app/views/angular/nav.html.erb +39 -0
  115. data/app/views/angular/underworld/views/generic_add_view.html.slim +5 -0
  116. data/app/views/devise/registrations/edit.html.erb +29 -0
  117. data/app/views/devise/registrations/new.html.erb +38 -0
  118. data/app/views/devise/sessions/new.html.erb +37 -0
  119. data/app/views/devise/shared/_links.erb +19 -0
  120. data/app/views/devise/shared/_omni_link.erb +33 -0
  121. data/app/views/kaminari/_first_page.html.slim +3 -0
  122. data/app/views/kaminari/_gap.html.slim +2 -0
  123. data/app/views/kaminari/_last_page.html.slim +3 -0
  124. data/app/views/kaminari/_next_page.html.slim +3 -0
  125. data/app/views/kaminari/_page.html.slim +3 -0
  126. data/app/views/kaminari/_paginator.html.slim +13 -0
  127. data/app/views/kaminari/_prev_page.html.slim +3 -0
  128. data/app/views/layouts/underworld/application.html.erb +79 -0
  129. data/app/views/layouts/underworld/dashboard.html.erb +52 -0
  130. data/app/views/layouts/underworld/simple.html.erb +27 -0
  131. data/app/views/underworld/api/v1/conversations/create.json.jbuilder +1 -0
  132. data/app/views/underworld/api/v1/conversations/destroy.json.jbuilder +1 -0
  133. data/app/views/underworld/api/v1/conversations/index.json.jbuilder +1 -0
  134. data/app/views/underworld/api/v1/conversations/reply.json.jbuilder +1 -0
  135. data/app/views/underworld/api/v1/conversations/show.json.jbuilder +14 -0
  136. data/app/views/underworld/api/v1/conversations/trash.json.jbuilder +1 -0
  137. data/app/views/underworld/api/v1/groups/create.json.jbuilder +4 -0
  138. data/app/views/underworld/api/v1/groups/destroy.html.erb +2 -0
  139. data/app/views/underworld/api/v1/groups/destroy.json.jbuilder +1 -0
  140. data/app/views/underworld/api/v1/groups/edit.html.erb +2 -0
  141. data/app/views/underworld/api/v1/groups/index.html.erb +2 -0
  142. data/app/views/underworld/api/v1/groups/index.json.jbuilder +6 -0
  143. data/app/views/underworld/api/v1/groups/new.html.erb +2 -0
  144. data/app/views/underworld/api/v1/groups/show.html.erb +2 -0
  145. data/app/views/underworld/api/v1/groups/show.json.jbuilder +5 -0
  146. data/app/views/underworld/api/v1/groups/update.json.jbuilder +4 -0
  147. data/app/views/underworld/api/v1/logs/index.json.jbuilder +1 -0
  148. data/app/views/underworld/api/v1/permissions/index.json.jbuilder +1 -0
  149. data/app/views/underworld/api/v1/permissions/user_permissions.json.jbuilder +1 -0
  150. data/app/views/underworld/api/v1/users/create.html.erb +2 -0
  151. data/app/views/underworld/api/v1/users/create.json.jbuilder +1 -0
  152. data/app/views/underworld/api/v1/users/destroy.json.jbuilder +1 -0
  153. data/app/views/underworld/api/v1/users/distroy.html.erb +2 -0
  154. data/app/views/underworld/api/v1/users/edit.html.erb +2 -0
  155. data/app/views/underworld/api/v1/users/index.html.erb +2 -0
  156. data/app/views/underworld/api/v1/users/index.json.jbuilder +4 -0
  157. data/app/views/underworld/api/v1/users/show.html.erb +2 -0
  158. data/app/views/underworld/api/v1/users/show.json.jbuilder +2 -0
  159. data/app/views/underworld/api/v1/users/update.json.jbuilder +1 -0
  160. data/app/views/underworld/dashboard/groups/_form.html.slim +68 -0
  161. data/app/views/underworld/dashboard/groups/create.js.erb +3 -0
  162. data/app/views/underworld/dashboard/groups/edit.html.slim +3 -0
  163. data/app/views/underworld/dashboard/groups/errors.js.erb +3 -0
  164. data/app/views/underworld/dashboard/groups/index.html.slim +47 -0
  165. data/app/views/underworld/dashboard/groups/new.html.slim +2 -0
  166. data/app/views/underworld/dashboard/groups/update.js.erb +3 -0
  167. data/app/views/underworld/dashboard/index.html.erb +0 -0
  168. data/app/views/underworld/dashboard/login_required_page.html.erb +5 -0
  169. data/app/views/underworld/dashboard/not_found.html.slim +9 -0
  170. data/app/views/underworld/dashboard/not_found.js.erb +1 -0
  171. data/app/views/underworld/dashboard/profile/_form.html.erb +33 -0
  172. data/app/views/underworld/dashboard/profile/_profile_form.html.erb +33 -0
  173. data/app/views/underworld/dashboard/profile/create.js.erb +3 -0
  174. data/app/views/underworld/dashboard/profile/edit.html.erb +2 -0
  175. data/app/views/underworld/dashboard/profile/edit_password.html.erb +2 -0
  176. data/app/views/underworld/dashboard/profile/errors.js.erb +3 -0
  177. data/app/views/underworld/dashboard/resource/_form.html.slim +33 -0
  178. data/app/views/underworld/dashboard/resource/_input.html.slim +3 -0
  179. data/app/views/underworld/dashboard/resource/create.js.erb +3 -0
  180. data/app/views/underworld/dashboard/resource/destroy.js.erb +2 -0
  181. data/app/views/underworld/dashboard/resource/edit.html.slim +3 -0
  182. data/app/views/underworld/dashboard/resource/index.html.slim +60 -0
  183. data/app/views/underworld/dashboard/resource/new.html.slim +2 -0
  184. data/app/views/underworld/dashboard/resource/show.html.slim +22 -0
  185. data/app/views/underworld/dashboard/resource/update.js.erb +3 -0
  186. data/app/views/underworld/dashboard/shared/_content_header.html.slim +15 -0
  187. data/app/views/underworld/dashboard/shared/_control_sidebar.html.slim +50 -0
  188. data/app/views/underworld/dashboard/shared/_footer.html.slim +7 -0
  189. data/app/views/underworld/dashboard/shared/_header.html.erb +98 -0
  190. data/app/views/underworld/dashboard/shared/_sidebar.html.erb +69 -0
  191. data/app/views/underworld/dashboard/shared/_toolbar.html.slim +0 -0
  192. data/app/views/underworld/dashboard/shared/errors.js.erb +3 -0
  193. data/app/views/underworld/dashboard/user_messages/_form.html.slim +0 -0
  194. data/app/views/underworld/dashboard/user_messages/create.js.erb +0 -0
  195. data/app/views/underworld/dashboard/user_messages/destroy.js.erb +0 -0
  196. data/app/views/underworld/dashboard/user_messages/new.html.slim +72 -0
  197. data/app/views/underworld/dashboard/users/_form.html.slim +73 -0
  198. data/app/views/underworld/dashboard/users/_password_form.html.slim +37 -0
  199. data/app/views/underworld/dashboard/users/create.js.erb +3 -0
  200. data/app/views/underworld/dashboard/users/destroy.js.erb +2 -0
  201. data/app/views/underworld/dashboard/users/edit.html.slim +3 -0
  202. data/app/views/underworld/dashboard/users/edit_password.html.slim +1 -0
  203. data/app/views/underworld/dashboard/users/errors.js.erb +3 -0
  204. data/app/views/underworld/dashboard/users/index.html.slim +66 -0
  205. data/app/views/underworld/dashboard/users/new.html.slim +2 -0
  206. data/app/views/underworld/dashboard/users/show.html.slim +6 -0
  207. data/app/views/underworld/dashboard/users/update.js.erb +3 -0
  208. data/app/views/underworld/dashboard/users/update_password.js.erb +3 -0
  209. data/app/views/underworld/relations/_belongs_to.json.jbuilder +11 -0
  210. data/config/initializers/devise.rb +24 -0
  211. data/config/locales/devise.en.yml +59 -0
  212. data/config/locales/devise.fa.yml +58 -0
  213. data/config/locales/underworld.en.yml +96 -0
  214. data/config/locales/underworld.fa.yml +108 -0
  215. data/config/routes.rb +43 -0
  216. data/config/spring.rb +1 -0
  217. data/db/migrate/20131013091000_devise_create_underworld_users.rb +65 -0
  218. data/db/migrate/20131020124701_create_underworld_groups.rb +15 -0
  219. data/db/migrate/20131021170923_create_underworld_permissions.rb +15 -0
  220. data/db/migrate/20131123120422_add_permissions_groups_table.rb +16 -0
  221. data/db/migrate/20140613120923_add_users_groups_table.rb +13 -0
  222. data/db/migrate/20151122115129_add_uniqueness_index_to_users_groups.rb +11 -0
  223. data/db/migrate/20160310105736_create_underworld_user_messages.rb +25 -0
  224. data/db/seeds.rb +49 -0
  225. data/lib/generators/underworld/install_generator.rb +108 -0
  226. data/lib/generators/underworld/resource_generator.rb +70 -0
  227. data/lib/generators/underworld/resources_generator.rb +20 -0
  228. data/lib/generators/underworld/templates/README +21 -0
  229. data/lib/generators/underworld/templates/SPECS +13 -0
  230. data/lib/generators/underworld/templates/api/controller.rb.erb +60 -0
  231. data/lib/generators/underworld/templates/api_controller.rb +2 -0
  232. data/lib/generators/underworld/templates/dashboard/controller.rb.erb +2 -0
  233. data/lib/generators/underworld/templates/dashboard_controller.rb +18 -0
  234. data/lib/generators/underworld/templates/devise.rb +251 -0
  235. data/lib/generators/underworld/templates/features/api.feature +92 -0
  236. data/lib/generators/underworld/templates/features/api.step.rb +7 -0
  237. data/lib/generators/underworld/templates/features/step_definitions/email_steps.rb +206 -0
  238. data/lib/generators/underworld/templates/features/support/email_spec.rb +1 -0
  239. data/lib/generators/underworld/templates/features/support/env.rb +79 -0
  240. data/lib/generators/underworld/templates/javascripts/application.js +19 -0
  241. data/lib/generators/underworld/templates/policy/application_policy.rb +2 -0
  242. data/lib/generators/underworld/templates/policy/policy.rb.erb +2 -0
  243. data/lib/generators/underworld/templates/seeds.rb +1 -0
  244. data/lib/generators/underworld/templates/spec/factories/groups.rb +5 -0
  245. data/lib/generators/underworld/templates/spec/factories/users.rb +10 -0
  246. data/lib/generators/underworld/templates/spec/spec_helper.rb +69 -0
  247. data/lib/generators/underworld/templates/spec/support/devise.rb +3 -0
  248. data/lib/generators/underworld/templates/stylesheets/dashboard/ltr/application.css +3 -0
  249. data/lib/generators/underworld/templates/stylesheets/dashboard/rtl/application.css +3 -0
  250. data/lib/generators/underworld/templates/stylesheets/ltr/application.css +3 -0
  251. data/lib/generators/underworld/templates/stylesheets/rtl/application.css +3 -0
  252. data/lib/generators/underworld/templates/underworld.rb +12 -0
  253. data/lib/generators/underworld/templates/views/create.json.jbuilder.erb +3 -0
  254. data/lib/generators/underworld/templates/views/destroy.json.jbuilder.erb +1 -0
  255. data/lib/generators/underworld/templates/views/index.json.jbuilder.erb +13 -0
  256. data/lib/generators/underworld/templates/views/show.json.jbuilder.erb +6 -0
  257. data/lib/generators/underworld/templates/views/update.json.jbuilder.erb +6 -0
  258. data/lib/generators/underworld/views_generator.rb +57 -0
  259. data/lib/tasks/docs.rake +6 -0
  260. data/lib/tasks/sync.rake +9 -0
  261. data/lib/tasks/underworld_tasks.rake +38 -0
  262. data/lib/underworld.rb +35 -0
  263. data/lib/underworld/action_dispatch.rb +3 -0
  264. data/lib/underworld/api.rb +42 -0
  265. data/lib/underworld/api/groups_api.rb +41 -0
  266. data/lib/underworld/api/permissions_api.rb +24 -0
  267. data/lib/underworld/api/root.rb +15 -0
  268. data/lib/underworld/api/users_api.rb +20 -0
  269. data/lib/underworld/concerns.rb +7 -0
  270. data/lib/underworld/concerns/authorizable.rb +81 -0
  271. data/lib/underworld/configuration.rb +97 -0
  272. data/lib/underworld/dashboard.rb +11 -0
  273. data/lib/underworld/dashboard/dsl.rb +41 -0
  274. data/lib/underworld/dashboard/dsl/base.rb +133 -0
  275. data/lib/underworld/dashboard/dsl/create.rb +116 -0
  276. data/lib/underworld/dashboard/dsl/form_fields_properties.rb +62 -0
  277. data/lib/underworld/dashboard/dsl/index.rb +45 -0
  278. data/lib/underworld/dashboard/dsl/show.rb +6 -0
  279. data/lib/underworld/dashboard/dsl/update.rb +6 -0
  280. data/lib/underworld/dashboard/helpers/box_helpers.rb +129 -0
  281. data/lib/underworld/dashboard/models.rb +2 -0
  282. data/lib/underworld/dashboard/models/sidebar.rb +139 -0
  283. data/lib/underworld/dashboard/sections.rb +2 -0
  284. data/lib/underworld/dashboard/sections/resource.rb +229 -0
  285. data/lib/underworld/dashboard/sections/resource_create.rb +263 -0
  286. data/lib/underworld/dashboard/sections/resource_destroy.rb +27 -0
  287. data/lib/underworld/dashboard/sections/resource_show.rb +96 -0
  288. data/lib/underworld/dashboard/sections/resources_index.rb +113 -0
  289. data/lib/underworld/dashboard/sections/sidebar.rb +41 -0
  290. data/lib/underworld/discovery.rb +8 -0
  291. data/lib/underworld/discovery/permissions.rb +49 -0
  292. data/lib/underworld/engine.rb +53 -0
  293. data/lib/underworld/exceptions.rb +7 -0
  294. data/lib/underworld/extension.rb +18 -0
  295. data/lib/underworld/extension/base.rb +29 -0
  296. data/lib/underworld/fake_assets.rb +5 -0
  297. data/lib/underworld/i18n.rb +101 -0
  298. data/lib/underworld/initialize.rb +0 -0
  299. data/lib/underworld/liquid.rb +7 -0
  300. data/lib/underworld/liquid/block.rb +14 -0
  301. data/lib/underworld/liquid/render_tag.rb +50 -0
  302. data/lib/underworld/liquid/tag.rb +51 -0
  303. data/lib/underworld/middlewares.rb +1 -0
  304. data/lib/underworld/middlewares/locale.rb +29 -0
  305. data/lib/underworld/omniauth.rb +8 -0
  306. data/lib/underworld/omniauth/callbacks.rb +39 -0
  307. data/lib/underworld/orm.rb +30 -0
  308. data/lib/underworld/routes.rb +117 -0
  309. data/lib/underworld/version.rb +3 -0
  310. data/test/controllers/underworld/dashboard/resource_test.rb +118 -0
  311. data/test/dummy/README.rdoc +28 -0
  312. data/test/dummy/Rakefile +6 -0
  313. data/test/dummy/app/assets/javascripts/application.js +13 -0
  314. data/test/dummy/app/assets/javascripts/dashboard/application.js +19 -0
  315. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  316. data/test/dummy/app/assets/stylesheets/dashboard/ltr/application.css +3 -0
  317. data/test/dummy/app/assets/stylesheets/dashboard/rtl/application.css +3 -0
  318. data/test/dummy/app/assets/stylesheets/ltr/application.css +3 -0
  319. data/test/dummy/app/assets/stylesheets/rtl/application.css +3 -0
  320. data/test/dummy/app/controllers/api_controller.rb +2 -0
  321. data/test/dummy/app/controllers/application_controller.rb +6 -0
  322. data/test/dummy/app/controllers/dashboard/application_controller.rb +18 -0
  323. data/test/dummy/app/helpers/application_helper.rb +2 -0
  324. data/test/dummy/app/policies/application_policy.rb +2 -0
  325. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  326. data/test/dummy/bin/bundle +3 -0
  327. data/test/dummy/bin/rails +4 -0
  328. data/test/dummy/bin/rake +4 -0
  329. data/test/dummy/config.ru +4 -0
  330. data/test/dummy/config/application.rb +23 -0
  331. data/test/dummy/config/boot.rb +5 -0
  332. data/test/dummy/config/database.yml +25 -0
  333. data/test/dummy/config/environment.rb +5 -0
  334. data/test/dummy/config/environments/development.rb +29 -0
  335. data/test/dummy/config/environments/production.rb +80 -0
  336. data/test/dummy/config/environments/test.rb +38 -0
  337. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  338. data/test/dummy/config/initializers/devise.rb +251 -0
  339. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  340. data/test/dummy/config/initializers/formstatic.rb +76 -0
  341. data/test/dummy/config/initializers/formtastic.rb +110 -0
  342. data/test/dummy/config/initializers/inflections.rb +16 -0
  343. data/test/dummy/config/initializers/kaminari_config.rb +10 -0
  344. data/test/dummy/config/initializers/mime_types.rb +5 -0
  345. data/test/dummy/config/initializers/secret_token.rb +12 -0
  346. data/test/dummy/config/initializers/session_store.rb +3 -0
  347. data/test/dummy/config/initializers/underworld.rb +11 -0
  348. data/test/dummy/config/initializers/underworld_assets.rb +1 -0
  349. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  350. data/test/dummy/config/locales/en.yml +23 -0
  351. data/test/dummy/config/routes.rb +13 -0
  352. data/test/dummy/lib/templates/slim/scaffold/_form.html.slim +8 -0
  353. data/test/dummy/public/404.html +58 -0
  354. data/test/dummy/public/422.html +58 -0
  355. data/test/dummy/public/500.html +57 -0
  356. data/test/dummy/public/favicon.ico +0 -0
  357. data/test/fabricators/underworld/groups.rb +27 -0
  358. data/test/fabricators/underworld/permissions.rb +14 -0
  359. data/test/fabricators/underworld/users.rb +17 -0
  360. data/test/generators/install_generator_test.rb +84 -0
  361. data/test/integration/underworld/authentication_test.rb +36 -0
  362. data/test/integration/underworld/dashboard_test.rb +64 -0
  363. data/test/test_helper.rb +72 -0
  364. metadata +1045 -0
  365. metadata.gz.sig +0 -0
@@ -0,0 +1,20 @@
1
+ module Underworld
2
+ module Generators
3
+ # Generate a resource on dashboard
4
+ class ResourcesGenerator < Rails::Generators::Base
5
+
6
+ desc 'Generates bunch of Underworld resource at once.'
7
+ argument :resources , type: :array, required: true
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ def generate_resources
11
+ resources.each do |resource|
12
+ generate 'underworld:resource', resource
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ ==================================================
2
+ Steps to finish up installation:
3
+
4
+ 1. Ensure you have defined default url options in your environments files. Here
5
+ is an example of default_url_options appropriate for a development environment
6
+ in config/environments/development.rb:
7
+
8
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
9
+
10
+ In production, :host should be set to the actual host of your application.
11
+
12
+ 2. Migrate your database and run `db:seed` too. For example:
13
+
14
+ $ rake db:migrate db:seed
15
+
16
+ 4. Make sure you take a look and configured config/initializers/devise.rb (optional)
17
+
18
+ NOTE: if you want to use devise with omniauth configure them in
19
+ config/initializers/devise.rb according to devise wiki
20
+
21
+ 5. Make sure you take a look and configured config/initializers/formtastic.rb (optional)
@@ -0,0 +1,13 @@
1
+ =======================================================================
2
+
3
+ Copy this snippet to your `config/application.rb`:
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec, :fixture => false
7
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
8
+ g.assets false
9
+ g.helper false
10
+ g.helper = false
11
+ g.view_specs false
12
+ g.helper_specs false
13
+ end
@@ -0,0 +1,60 @@
1
+ class API::V1::<%= resource.pluralize %>Controller < APIController
2
+ <% if allowed_fields_provided? %>allow_query_on <%= allowed_fields %><% end %>
3
+ after_action :verify_authorized, :except => :index
4
+
5
+ # GET /api/v1/<%= resource.pluralize.underscore %>
6
+ def index
7
+ @<%= resource.pluralize.underscore %> = <%= resource.camelize %>.all
8
+ authorize @<%= resource.pluralize.underscore %>
9
+ respond_with(@<%= resource.pluralize.underscore %>)
10
+ end
11
+
12
+ def create
13
+ authorize <%= resource.camelize %>, :create?
14
+ @<%= resource.underscore %> = <%= resource.camelize %>.new(resource_params)
15
+ <% fields.each do |name, type| %><% if type == "has_many" %>
16
+ <%= name.underscore %> = <%= name.singularize.camelize %>.where({:id => params[:<%= resource.underscore %>][:<%= name %>]})
17
+ @<%= resource.underscore %>.<%= name.underscore %> = <%= name.underscore %><% end %><% end %>
18
+ if @<%= resource.underscore %>.save
19
+ respond_with(@<%= resource.underscore %>)
20
+ else
21
+ respond_to do |format|
22
+ format.json { render :json => {:fields => @<%= resource.underscore %>.errors}, :status => :unprocessable_entity }
23
+ end
24
+ end
25
+ end
26
+
27
+ def show
28
+ @<%= resource.underscore %> = <%= resource.camelize %>.find(params[:id])
29
+ authorize @<%= resource.underscore %>
30
+ respond_with(@<%= resource.underscore %>)
31
+ end
32
+
33
+ def update
34
+ @<%= resource.underscore %> = <%= resource.camelize %>.find(params[:id])
35
+ authorize @<%= resource.underscore %>, :update?
36
+ <% fields.each do |name, type| %><% if type == "has_many" %>
37
+ <%= name.underscore %> = <%= name.singularize.camelize %>.where({:id => params[:<%= resource.underscore %>][:<%= name %>]})
38
+ @<%= resource.underscore %>.<%= name.underscore %> = <%= name.underscore %><% end %><% end %>
39
+
40
+ if @<%= resource.underscore %>.update(resource_params)
41
+ respond_with(@<%= resource.underscore %>)
42
+ else
43
+ respond_to do |format|
44
+ format.json { render :json => {:fields => @<%= resource.underscore %>.errors}, :status => :unprocessable_entity }
45
+ end
46
+ end
47
+ end
48
+
49
+ def destroy
50
+ ids = params[:id].split(",")
51
+ @<%= resource.pluralize.underscore %> = <%= resource.camelize%>.where(:id => ids)
52
+
53
+ authorize @<%= resource.pluralize.underscore %>
54
+ @<%= resource.pluralize.underscore %>.destroy_all
55
+ end
56
+
57
+ def resource_params
58
+ params.require(:<%= resource.underscore %>).permit(:id<%= fields_as_params(:relations => true) %>)
59
+ end
60
+ end
@@ -0,0 +1,2 @@
1
+ class APIController < Underworld::APIController
2
+ end
@@ -0,0 +1,2 @@
1
+ class <%= controller_module %><%= resources.classify.pluralize %>Controller < Dashboard::ApplicationController
2
+ end
@@ -0,0 +1,18 @@
1
+ class Dashboard::ApplicationController < Underworld::Dashboard::ApplicationController
2
+
3
+ def setup_sidebar
4
+ @sidebar = sidebar(t('underworld.engine_name')) do |s|
5
+ s.underworld_entries
6
+
7
+ # Put your sidebar entries in here like this:
8
+ #
9
+ # s.menu(title, icon: 'fa fa-book') do
10
+ # s.item(title,
11
+ # url: main_app.dashboard_books_path,
12
+ # model: 'Book')
13
+ # end
14
+ #
15
+ # For more information take a look at `sidebar` section of Underworld guides.
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,251 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth.
2
+ # Many of these configuration options can be set straight in your model.
3
+ Devise.setup do |config|
4
+ # The secret key used by Devise. Devise uses this key to generate
5
+ # random tokens. Changing this key will render invalid all existing
6
+ # confirmation, reset password and unlock tokens in the database.
7
+ config.secret_key = '<%= SecureRandom.hex(64) %>'
8
+
9
+ # ==> Mailer Configuration
10
+ # Configure the e-mail address which will be shown in Devise::Mailer,
11
+ # note that it will be overwritten if you use your own mailer class
12
+ # with default "from" parameter.
13
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
14
+
15
+ # Configure the class responsible to send e-mails.
16
+ # config.mailer = 'Devise::Mailer'
17
+
18
+ # ==> ORM configuration
19
+ # Load and configure the ORM. Supports :active_record (default) and
20
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
21
+ # available as additional gems.
22
+ require 'devise/orm/<%= options[:orm] %>'
23
+
24
+ # ==> Configuration for any authentication mechanism
25
+ # Configure which keys are used when authenticating a user. The default is
26
+ # just :email. You can configure it to use [:username, :subdomain], so for
27
+ # authenticating a user, both parameters are required. Remember that those
28
+ # parameters are used only when authenticating and not when retrieving from
29
+ # session. If you need permissions, you should implement that in a before filter.
30
+ # You can also supply a hash where the value is a boolean determining whether
31
+ # or not authentication should be aborted when the value is not present.
32
+ # config.authentication_keys = [ :email ]
33
+
34
+ # Configure parameters from the request object used for authentication. Each entry
35
+ # given should be a request method and it will automatically be passed to the
36
+ # find_for_authentication method and considered in your model lookup. For instance,
37
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
38
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
39
+ # config.request_keys = []
40
+
41
+ # Configure which authentication keys should be case-insensitive.
42
+ # These keys will be downcased upon creating or modifying a user and when used
43
+ # to authenticate or find a user. Default is :email.
44
+ config.case_insensitive_keys = [ :email ]
45
+
46
+ # Configure which authentication keys should have whitespace stripped.
47
+ # These keys will have whitespace before and after removed upon creating or
48
+ # modifying a user and when used to authenticate or find a user. Default is :email.
49
+ config.strip_whitespace_keys = [ :email ]
50
+
51
+ # Tell if authentication through request.params is enabled. True by default.
52
+ # It can be set to an array that will enable params authentication only for the
53
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
54
+ # enable it only for database (email + password) authentication.
55
+ # config.params_authenticatable = true
56
+
57
+ # Tell if authentication through HTTP Auth is enabled. False by default.
58
+ # It can be set to an array that will enable http authentication only for the
59
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
60
+ # enable it only for database authentication. The supported strategies are:
61
+ # :database = Support basic authentication with authentication key + password
62
+ # config.http_authenticatable = false
63
+
64
+ # If http headers should be returned for AJAX requests. True by default.
65
+ # config.http_authenticatable_on_xhr = true
66
+
67
+ # The realm used in Http Basic Authentication. 'Application' by default.
68
+ # config.http_authentication_realm = 'Application'
69
+
70
+ # It will change confirmation, password recovery and other workflows
71
+ # to behave the same regardless if the e-mail provided was right or wrong.
72
+ # Does not affect registerable.
73
+ # config.paranoid = true
74
+
75
+ # By default Devise will store the user in session. You can skip storage for
76
+ # particular strategies by setting this option.
77
+ # Notice that if you are skipping storage for all authentication paths, you
78
+ # may want to disable generating routes to Devise's sessions controller by
79
+ # passing :skip => :sessions to `devise_for` in your config/routes.rb
80
+ config.skip_session_storage = [:http_auth]
81
+
82
+ # By default, Devise cleans up the CSRF token on authentication to
83
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
84
+ # requests for sign in and sign up, you need to get a new CSRF token
85
+ # from the server. You can disable this option at your own risk.
86
+ # config.clean_up_csrf_token_on_authentication = true
87
+
88
+ # ==> Configuration for :database_authenticatable
89
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
90
+ # using other encryptors, it sets how many times you want the password re-encrypted.
91
+ #
92
+ # Limiting the stretches to just one in testing will increase the performance of
93
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
94
+ # a value less than 10 in other environments.
95
+ config.stretches = Rails.env.test? ? 1 : 10
96
+
97
+ # Setup a pepper to generate the encrypted password.
98
+ # config.pepper = '<%= SecureRandom.hex(64) %>'
99
+
100
+ # ==> Configuration for :confirmable
101
+ # A period that the user is allowed to access the website even without
102
+ # confirming his account. For instance, if set to 2.days, the user will be
103
+ # able to access the website for two days without confirming his account,
104
+ # access will be blocked just in the third day. Default is 0.days, meaning
105
+ # the user cannot access the website without confirming his account.
106
+ # config.allow_unconfirmed_access_for = 2.days
107
+
108
+ # A period that the user is allowed to confirm their account before their
109
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
110
+ # their account within 3 days after the mail was sent, but on the fourth day
111
+ # their account can't be confirmed with the token any more.
112
+ # Default is nil, meaning there is no restriction on how long a user can take
113
+ # before confirming their account.
114
+ # config.confirm_within = 3.days
115
+
116
+ # If true, requires any email changes to be confirmed (exactly the same way as
117
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
118
+ # db field (see migrations). Until confirmed new email is stored in
119
+ # unconfirmed email column, and copied to email column on successful confirmation.
120
+ config.reconfirmable = true
121
+
122
+ # Defines which key will be used when confirming an account
123
+ # config.confirmation_keys = [ :email ]
124
+
125
+ # ==> Configuration for :rememberable
126
+ # The time the user will be remembered without asking for credentials again.
127
+ # config.remember_for = 2.weeks
128
+
129
+ # If true, extends the user's remember period when remembered via cookie.
130
+ # config.extend_remember_period = false
131
+
132
+ # Options to be passed to the created cookie. For instance, you can set
133
+ # :secure => true in order to force SSL only cookies.
134
+ # config.rememberable_options = {}
135
+
136
+ # ==> Configuration for :validatable
137
+ # Range for password length. Default is 8..128.
138
+ config.password_length = 8..128
139
+
140
+ # Email regex used to validate email formats. It simply asserts that
141
+ # one (and only one) @ exists in the given string. This is mainly
142
+ # to give user feedback and not to assert the e-mail validity.
143
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
144
+
145
+ # ==> Configuration for :timeoutable
146
+ # The time you want to timeout the user session without activity. After this
147
+ # time the user will be asked for credentials again. Default is 30 minutes.
148
+ # config.timeout_in = 30.minutes
149
+
150
+ # If true, expires auth token on session timeout.
151
+ # config.expire_auth_token_on_timeout = false
152
+
153
+ # ==> Configuration for :lockable
154
+ # Defines which strategy will be used to lock an account.
155
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
156
+ # :none = No lock strategy. You should handle locking by yourself.
157
+ # config.lock_strategy = :failed_attempts
158
+
159
+ # Defines which key will be used when locking and unlocking an account
160
+ # config.unlock_keys = [ :email ]
161
+
162
+ # Defines which strategy will be used to unlock an account.
163
+ # :email = Sends an unlock link to the user email
164
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
165
+ # :both = Enables both strategies
166
+ # :none = No unlock strategy. You should handle unlocking by yourself.
167
+ # config.unlock_strategy = :both
168
+
169
+ # Number of authentication tries before locking an account if lock_strategy
170
+ # is failed attempts.
171
+ # config.maximum_attempts = 20
172
+
173
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
174
+ # config.unlock_in = 1.hour
175
+
176
+ # ==> Configuration for :recoverable
177
+ #
178
+ # Defines which key will be used when recovering the password for an account
179
+ # config.reset_password_keys = [ :email ]
180
+
181
+ # Time interval you can reset your password with a reset password key.
182
+ # Don't put a too small interval or your users won't have the time to
183
+ # change their passwords.
184
+ config.reset_password_within = 6.hours
185
+
186
+ # ==> Configuration for :encryptable
187
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
188
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
189
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
190
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
191
+ # REST_AUTH_SITE_KEY to pepper).
192
+ #
193
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
194
+ # config.encryptor = :sha512
195
+
196
+ # ==> Scopes configuration
197
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
198
+ # "users/sessions/new". It's turned off by default because it's slower if you
199
+ # are using only default views.
200
+ # config.scoped_views = false
201
+
202
+ # Configure the default scope given to Warden. By default it's the first
203
+ # devise role declared in your routes (usually :user).
204
+ # config.default_scope = :user
205
+
206
+ # Set this configuration to false if you want /users/sign_out to sign out
207
+ # only the current scope. By default, Devise signs out all scopes.
208
+ # config.sign_out_all_scopes = true
209
+
210
+ # ==> Navigation configuration
211
+ # Lists the formats that should be treated as navigational. Formats like
212
+ # :html, should redirect to the sign in page when the user does not have
213
+ # access, but formats like :xml or :json, should return 401.
214
+ #
215
+ # If you have any extra navigational formats, like :iphone or :mobile, you
216
+ # should add them to the navigational formats lists.
217
+ #
218
+ # The "*/*" below is required to match Internet Explorer requests.
219
+ # config.navigational_formats = ['*/*', :html]
220
+
221
+ # The default HTTP method used to sign out a resource. Default is :delete.
222
+ config.sign_out_via = :delete
223
+
224
+ # ==> OmniAuth
225
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
226
+ # up on your models and hooks.
227
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
228
+
229
+ # ==> Warden configuration
230
+ # If you want to use other strategies, that are not supported by Devise, or
231
+ # change the failure app, you can configure them inside the config.warden block.
232
+ #
233
+ # config.warden do |manager|
234
+ # manager.intercept_401 = false
235
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
236
+ # end
237
+
238
+ # ==> Mountable engine configurations
239
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
240
+ # is mountable, there are some extra configurations to be taken into account.
241
+ # The following options are available, assuming the engine is mounted as:
242
+ #
243
+ # mount MyEngine, at: '/my_engine'
244
+ #
245
+ # The router that invoked `devise_for`, in the example above, would be:
246
+ # config.router_name = :my_engine
247
+ #
248
+ # When using omniauth, Devise cannot automatically set Omniauth path,
249
+ # so you need to do it manually. For the users scope, it would be:
250
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
251
+ end
@@ -0,0 +1,92 @@
1
+ Feature: <%= resource.pluralize %> API
2
+ In order to intract with <%= resource.pluralize.underscore %> from dashboard
3
+ <%= resource.pluralize %> API should be accessable by logged in users
4
+ And anonymous user should not have accesss to API
5
+
6
+ Scenario: Anonymous User should not have access to API
7
+ Given I am not authenticated
8
+ And there is a <%= resource.underscore %> named "Iran" in database
9
+ When format is json and I go to the api v1 <%= resource.pluralize.underscore %> page
10
+ Then I should get "401" status code
11
+ When format is json and I go to "/api/v1/<%= resource.pluralize.underscore %>/1"
12
+ Then I should get "401" status code
13
+ When format is json and I send patch to "/api/v1/<%= resource.pluralize.underscore %>/1" with:
14
+ """
15
+ <%= random_json_data %>
16
+ """
17
+ Then I should get "401" status code
18
+ When format is json and I send post to "/api/v1/<%= resource.pluralize.underscore %>" with:
19
+ """
20
+ <%= random_json_data %>
21
+ """
22
+ Then I should get "401" status code
23
+ When format is json and I send delete to "/api/v1/<%= resource.pluralize.underscore %>/1"
24
+ Then I should get "401" status code
25
+
26
+ Scenario: Default response should be json
27
+ Given I am authenticated
28
+ When I go to the api v1 <%= resource.pluralize.underscore %> page
29
+ Then response type should be application/json
30
+
31
+ Scenario: Anonymous User via HTTP
32
+ Given I am not authenticated
33
+ When format is html and I go to the api v1 <%= resource.pluralize.underscore %> page
34
+ Then I should be in sign in page
35
+
36
+ Scenario: Anonymous USer via JSON format
37
+ Given I am not authenticated
38
+ When format is json and I go to the api v1 <%= resource.pluralize.underscore %> page
39
+ Then I should get "401" status code
40
+
41
+ Scenario: Logged in User via HTTP
42
+ Given I am authenticated
43
+ When format is html and I go to the api v1 <%= resource.pluralize.underscore %> page
44
+ Then I should get unknown format exception
45
+ #Then I should get "406" status code
46
+
47
+ Scenario: Logged in User via JSON format
48
+ Given I am authenticated
49
+ When format is json and I go to the api v1 <%= resource.pluralize.underscore %> page
50
+ Then the JSON should have 0 keys
51
+
52
+ Scenario: Logged in User via JSON format And Initial Data
53
+ Given I am authenticated
54
+ And there is a <%= resource.underscore %> named "XYZ" in database
55
+ When format is json and I go to the api v1 <%= resource.pluralize.underscore %> page
56
+ Then the JSON should have 1 keys
57
+ And the JSON at "0/name" should be "XYZ"
58
+
59
+ Scenario: API should not response to "/new"
60
+ Given I am authenticated
61
+ When format is json and I go to "/api/v1/<%= resource.pluralize.underscore %>/new"
62
+ Then action should not be found
63
+
64
+ @javascript
65
+ Scenario: Add New <%= resource.underscore %>
66
+ Given I am authenticated
67
+ When I go to "/dashboard#/<%= resource.pluralize.underscore %>/new"
68
+ And fill in "name" with "XYZ"
69
+ And click on "save"
70
+ And wait for ajax to return
71
+ Then there should be a <%= resource.underscore %> with "XYZ" as "name"
72
+
73
+ @javascript
74
+ Scenario: Edit <%= resource.underscore %>
75
+ Given I am authenticated
76
+ And there shouldn't be any <%= resource.underscore %>
77
+ And there is a <%= resource.underscore %> named "XYZ" in database
78
+ Then there should be a <%= resource.underscore %> with "XYZ" as "name"
79
+ When I go to "/dashboard#/<%= resource.pluralize.underscore %>/1/edit"
80
+ And fill in "name" with "XYZW"
81
+ Then field "name" contains "XYZW"
82
+ When click on "save"
83
+ And wait for ajax to return
84
+ Then there should be a <%= resource.underscore %> with "XYZW" as "name"
85
+
86
+ Scenario: Delete <%= resource.underscore %>
87
+ Given I am authenticated
88
+ And there is a <%= resource.underscore %> named "ABC" in database
89
+ And there is a <%= resource.underscore %> named "XYZ" in database
90
+ When format is json and I send delete to "/api/v1/<%= resource.pluralize.underscore %>/1,2"
91
+ Then the JSON at "msg" should be "Items removed successfully."
92
+ And there shouldn't be any <%= resource.underscore %>