sunrise-cms 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (335) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +24 -0
  3. data/.rubocop.yml +87 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +52 -0
  6. data/Rakefile +3 -2
  7. data/app/controllers/sunrise/activities_controller.rb +7 -5
  8. data/app/controllers/sunrise/application_controller.rb +17 -17
  9. data/app/controllers/sunrise/dashboard_controller.rb +6 -5
  10. data/app/controllers/sunrise/manager_controller.rb +106 -105
  11. data/app/controllers/sunrise/settings_controller.rb +5 -3
  12. data/app/helpers/sunrise/activities_helper.rb +8 -7
  13. data/app/helpers/sunrise/application_helper.rb +11 -9
  14. data/app/helpers/sunrise/dashboard_helper.rb +3 -1
  15. data/app/helpers/sunrise/manager_helper.rb +28 -27
  16. data/app/helpers/sunrise/structure_helper.rb +11 -8
  17. data/config/locales/defaults/datetime.rb +7 -7
  18. data/config/locales/defaults/pluralize.rb +5 -3
  19. data/config/routes.rb +22 -20
  20. data/db/migrate/20111216144515_create_assets.rb +9 -7
  21. data/db/migrate/20111216144915_create_structures.rb +14 -12
  22. data/db/migrate/20111216145015_create_users.rb +20 -18
  23. data/db/migrate/20120611095315_create_settings.rb +7 -5
  24. data/lib/generators/sunrise/install_generator.rb +51 -49
  25. data/lib/generators/sunrise/templates/config/active_record/sunrise.rb +12 -10
  26. data/lib/generators/sunrise/templates/config/mongoid/sunrise.rb +14 -12
  27. data/lib/generators/sunrise/templates/config/seeds.rb +7 -7
  28. data/lib/generators/sunrise/templates/models/active_record/ability.rb +4 -3
  29. data/lib/generators/sunrise/templates/models/active_record/asset.rb +5 -3
  30. data/lib/generators/sunrise/templates/models/active_record/attachment_file.rb +4 -2
  31. data/lib/generators/sunrise/templates/models/active_record/avatar.rb +7 -5
  32. data/lib/generators/sunrise/templates/models/active_record/picture.rb +6 -4
  33. data/lib/generators/sunrise/templates/models/active_record/position_type.rb +5 -3
  34. data/lib/generators/sunrise/templates/models/active_record/role_type.rb +6 -4
  35. data/lib/generators/sunrise/templates/models/active_record/settings.rb +5 -3
  36. data/lib/generators/sunrise/templates/models/active_record/structure.rb +3 -1
  37. data/lib/generators/sunrise/templates/models/active_record/structure_type.rb +7 -5
  38. data/lib/generators/sunrise/templates/models/active_record/user.rb +5 -3
  39. data/lib/generators/sunrise/templates/models/mongoid/ability.rb +4 -3
  40. data/lib/generators/sunrise/templates/models/mongoid/asset.rb +18 -16
  41. data/lib/generators/sunrise/templates/models/mongoid/attachment_file.rb +4 -2
  42. data/lib/generators/sunrise/templates/models/mongoid/avatar.rb +7 -5
  43. data/lib/generators/sunrise/templates/models/mongoid/picture.rb +4 -2
  44. data/lib/generators/sunrise/templates/models/mongoid/position_type.rb +5 -3
  45. data/lib/generators/sunrise/templates/models/mongoid/role_type.rb +6 -4
  46. data/lib/generators/sunrise/templates/models/mongoid/settings.rb +9 -7
  47. data/lib/generators/sunrise/templates/models/mongoid/structure.rb +12 -10
  48. data/lib/generators/sunrise/templates/models/mongoid/structure_type.rb +7 -5
  49. data/lib/generators/sunrise/templates/models/mongoid/user.rb +37 -35
  50. data/lib/generators/sunrise/templates/models/sunrise/sunrise_navigation.rb +9 -7
  51. data/lib/generators/sunrise/templates/models/sunrise/sunrise_page.rb +5 -3
  52. data/lib/generators/sunrise/templates/models/sunrise/sunrise_structure.rb +10 -9
  53. data/lib/generators/sunrise/templates/models/sunrise/sunrise_user.rb +15 -13
  54. data/lib/generators/sunrise/templates/spec/controllers/pages_controller_spec.rb +12 -10
  55. data/lib/generators/sunrise/templates/spec/controllers/welcome_controller_spec.rb +8 -6
  56. data/lib/generators/sunrise/templates/spec/factories/structure_factory.rb +6 -5
  57. data/lib/generators/sunrise/templates/spec/factories/user_factory.rb +19 -18
  58. data/lib/generators/sunrise/templates/spec/spec_helper.rb +9 -7
  59. data/lib/generators/sunrise/templates/spec/support/helpers/controller_macros.rb +10 -9
  60. data/lib/generators/sunrise/templates/uploaders/attachment_file_uploader.rb +4 -2
  61. data/lib/generators/sunrise/templates/uploaders/avatar_uploader.rb +10 -7
  62. data/lib/generators/sunrise/templates/uploaders/picture_uploader.rb +9 -6
  63. data/lib/sunrise-cms.rb +2 -0
  64. data/lib/sunrise.rb +20 -13
  65. data/lib/sunrise/abstract_model.rb +100 -103
  66. data/lib/sunrise/carrierwave/base_uploader.rb +43 -46
  67. data/lib/sunrise/carrierwave/file_size_validator.rb +16 -11
  68. data/lib/sunrise/carrierwave/glue.rb +9 -9
  69. data/lib/sunrise/config.rb +14 -12
  70. data/lib/sunrise/config/association.rb +4 -3
  71. data/lib/sunrise/config/base.rb +15 -13
  72. data/lib/sunrise/config/export.rb +5 -3
  73. data/lib/sunrise/config/field.rb +26 -24
  74. data/lib/sunrise/config/form.rb +2 -0
  75. data/lib/sunrise/config/group.rb +9 -6
  76. data/lib/sunrise/config/has_fields.rb +6 -5
  77. data/lib/sunrise/config/has_groups.rb +4 -2
  78. data/lib/sunrise/config/index.rb +9 -7
  79. data/lib/sunrise/config/model.rb +16 -14
  80. data/lib/sunrise/config/navigation.rb +21 -19
  81. data/lib/sunrise/config/navigation_item.rb +7 -5
  82. data/lib/sunrise/config/nested_field.rb +13 -12
  83. data/lib/sunrise/config/page_presenter.rb +5 -2
  84. data/lib/sunrise/config/show.rb +2 -0
  85. data/lib/sunrise/core_ext.rb +2 -0
  86. data/lib/sunrise/core_ext/i18n.rb +9 -9
  87. data/lib/sunrise/core_ext/string.rb +4 -2
  88. data/lib/sunrise/engine.rb +16 -16
  89. data/lib/sunrise/hooks/adapters/active_record.rb +3 -1
  90. data/lib/sunrise/hooks/adapters/mongoid.rb +4 -2
  91. data/lib/sunrise/models/ability.rb +10 -8
  92. data/lib/sunrise/models/asset.rb +43 -43
  93. data/lib/sunrise/models/position_type.rb +7 -6
  94. data/lib/sunrise/models/role_type.rb +8 -7
  95. data/lib/sunrise/models/structure.rb +27 -28
  96. data/lib/sunrise/models/structure_type.rb +7 -6
  97. data/lib/sunrise/models/user.rb +39 -37
  98. data/lib/sunrise/utils.rb +16 -17
  99. data/lib/sunrise/utils/csv_document.rb +23 -23
  100. data/lib/sunrise/utils/eval_helpers.rb +41 -39
  101. data/lib/sunrise/utils/search_wrapper.rb +8 -7
  102. data/lib/sunrise/utils/transliteration.rb +42 -41
  103. data/lib/sunrise/version.rb +3 -1
  104. data/lib/sunrise/views/date_time_input.rb +19 -17
  105. data/lib/sunrise/views/form_builder.rb +15 -13
  106. data/lib/sunrise/views/helper.rb +32 -32
  107. data/lib/sunrise/views/search_wrapper.rb +5 -3
  108. data/lib/tasks/assets.rake +11 -9
  109. data/sunrise-cms.gemspec +52 -0
  110. metadata +44 -531
  111. data/spec/controllers/sunrise/activities_controller_spec.rb +0 -33
  112. data/spec/controllers/sunrise/manager_controller_spec.rb +0 -64
  113. data/spec/controllers/sunrise/settings_controller_spec.rb +0 -45
  114. data/spec/dummy/Rakefile +0 -7
  115. data/spec/dummy/app/assets/javascripts/application.js +0 -9
  116. data/spec/dummy/app/assets/javascripts/sunrise/plugins.js +0 -0
  117. data/spec/dummy/app/assets/javascripts/welcome.js +0 -2
  118. data/spec/dummy/app/assets/stylesheets/application.css +0 -7
  119. data/spec/dummy/app/assets/stylesheets/sunrise/plugins.css +0 -0
  120. data/spec/dummy/app/assets/stylesheets/welcome.css +0 -4
  121. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  122. data/spec/dummy/app/controllers/welcome_controller.rb +0 -5
  123. data/spec/dummy/app/helpers/application_helper.rb +0 -12
  124. data/spec/dummy/app/helpers/welcome_helper.rb +0 -2
  125. data/spec/dummy/app/models/active_record/post.rb +0 -18
  126. data/spec/dummy/app/models/mongoid/post.rb +0 -27
  127. data/spec/dummy/app/sunrise/sunrise_post.rb +0 -34
  128. data/spec/dummy/app/views/layouts/application.html.erb +0 -20
  129. data/spec/dummy/app/views/public_activity/post/_create.html.erb +0 -5
  130. data/spec/dummy/app/views/public_activity/post/_destroy.html.erb +0 -5
  131. data/spec/dummy/app/views/public_activity/post/_update.html.erb +0 -5
  132. data/spec/dummy/app/views/sunrise/manager/users/thumbs/_record.html.erb +0 -34
  133. data/spec/dummy/app/views/welcome/index.html.erb +0 -2
  134. data/spec/dummy/config.ru +0 -4
  135. data/spec/dummy/config/application.rb +0 -55
  136. data/spec/dummy/config/boot.rb +0 -10
  137. data/spec/dummy/config/database.yml +0 -42
  138. data/spec/dummy/config/database.yml.sample +0 -34
  139. data/spec/dummy/config/environment.rb +0 -5
  140. data/spec/dummy/config/environments/development.rb +0 -33
  141. data/spec/dummy/config/environments/production.rb +0 -66
  142. data/spec/dummy/config/environments/test.rb +0 -41
  143. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  144. data/spec/dummy/config/initializers/devise.rb +0 -216
  145. data/spec/dummy/config/initializers/inflections.rb +0 -10
  146. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  147. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  148. data/spec/dummy/config/initializers/session_store.rb +0 -8
  149. data/spec/dummy/config/initializers/sunrise.rb +0 -51
  150. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  151. data/spec/dummy/config/locales/en.yml +0 -5
  152. data/spec/dummy/config/mongoid.yml +0 -80
  153. data/spec/dummy/config/routes.rb +0 -10
  154. data/spec/dummy/db/migrate/20111227111941_install_acts_as_audited.rb +0 -28
  155. data/spec/dummy/db/migrate/20111227143901_create_page_parts.rb +0 -20
  156. data/spec/dummy/db/migrate/20111228152051_create_posts.rb +0 -14
  157. data/spec/dummy/db/migrate/20120105114018_create_meta_tags.rb +0 -21
  158. data/spec/dummy/db/migrate/20130214090723_create_activities.rb +0 -23
  159. data/spec/dummy/db/schema.rb +0 -90
  160. data/spec/dummy/log/test.log +0 -235
  161. data/spec/dummy/public/404.html +0 -26
  162. data/spec/dummy/public/422.html +0 -26
  163. data/spec/dummy/public/500.html +0 -26
  164. data/spec/dummy/public/favicon.ico +0 -0
  165. data/spec/dummy/script/rails +0 -6
  166. data/spec/dummy/tmp/cache/696/1F0/settings%3Ato_key +0 -1
  167. data/spec/dummy/tmp/cache/87C/5D0/settings%3Apersisted%3F +0 -1
  168. data/spec/dummy/tmp/cache/91C/830/settings%3Asome_setting +0 -1
  169. data/spec/dummy/tmp/cache/94E/D10/settings%3Asome_setting2 +0 -1
  170. data/spec/dummy/tmp/cache/assets/test/sass/f4a02ee710d6db0936c29533f2166c1526a55a9e/select2.scssc +0 -0
  171. data/spec/dummy/tmp/cache/assets/test/sprockets/03bae0b322a9c8706915fdb4f8d50961 +0 -0
  172. data/spec/dummy/tmp/cache/assets/test/sprockets/0a4412d6feb107cf35e452cc82a01134 +0 -0
  173. data/spec/dummy/tmp/cache/assets/test/sprockets/0c538631f0f094ca39bdb1448da8a4bc +0 -0
  174. data/spec/dummy/tmp/cache/assets/test/sprockets/0c94e795dfbbbf3599fdf312aeb577b9 +0 -0
  175. data/spec/dummy/tmp/cache/assets/test/sprockets/0e7270936d642e566d747ab335c44ec2 +0 -0
  176. data/spec/dummy/tmp/cache/assets/test/sprockets/0f894abd40c0b6114a9dff3a0599af7e +0 -0
  177. data/spec/dummy/tmp/cache/assets/test/sprockets/0fdc292bf2b2ddb2d0bf079950c8e770 +0 -0
  178. data/spec/dummy/tmp/cache/assets/test/sprockets/10bb80e2753b3d1716765b02ad9a2db3 +0 -0
  179. data/spec/dummy/tmp/cache/assets/test/sprockets/1349c61c2b491567c1632fcae44110a0 +0 -0
  180. data/spec/dummy/tmp/cache/assets/test/sprockets/13e20c0d57b7b851a7f025f5606f833f +0 -0
  181. data/spec/dummy/tmp/cache/assets/test/sprockets/146ce2f3522fd98d4a8a1501f16c7092 +0 -0
  182. data/spec/dummy/tmp/cache/assets/test/sprockets/172c139e25cc08516d5a8c72c777dd4d +0 -0
  183. data/spec/dummy/tmp/cache/assets/test/sprockets/18b64b11b8b00cc21a396da25a5ff156 +0 -0
  184. data/spec/dummy/tmp/cache/assets/test/sprockets/197d8d604ec08a638b656e053944b734 +0 -0
  185. data/spec/dummy/tmp/cache/assets/test/sprockets/1b73ae25962d8ff98f9f008b73c64bf4 +0 -0
  186. data/spec/dummy/tmp/cache/assets/test/sprockets/1bdb903463fe67323dbadb0f78337c70 +0 -0
  187. data/spec/dummy/tmp/cache/assets/test/sprockets/1ea532f332f1ff667097010cda704c99 +0 -0
  188. data/spec/dummy/tmp/cache/assets/test/sprockets/20215d59350863282208d478ea94cf08 +0 -0
  189. data/spec/dummy/tmp/cache/assets/test/sprockets/212fc15df4fd708ebdef5bd3be2191c1 +0 -0
  190. data/spec/dummy/tmp/cache/assets/test/sprockets/256dcb01e7f35659d770584fd71a85d2 +0 -0
  191. data/spec/dummy/tmp/cache/assets/test/sprockets/27ec6453d976c5e273e6f2c25830492c +0 -0
  192. data/spec/dummy/tmp/cache/assets/test/sprockets/3006732de695a5dfe249dcbf6852b543 +0 -0
  193. data/spec/dummy/tmp/cache/assets/test/sprockets/3008328e1cba59ad00ac79ac20275f17 +0 -0
  194. data/spec/dummy/tmp/cache/assets/test/sprockets/31ffcb9d2aba762160a2f4341e5cfd50 +0 -0
  195. data/spec/dummy/tmp/cache/assets/test/sprockets/32ae3cda2e7c692fc9711ab76fcf1c62 +0 -0
  196. data/spec/dummy/tmp/cache/assets/test/sprockets/35948a84ebda6147e5e5b67191ae37d8 +0 -0
  197. data/spec/dummy/tmp/cache/assets/test/sprockets/37766ae8287a873cb196a187f3253e66 +0 -0
  198. data/spec/dummy/tmp/cache/assets/test/sprockets/37b44bd55598f75d532d9edbe8c98336 +0 -0
  199. data/spec/dummy/tmp/cache/assets/test/sprockets/383908afbabb6096b774ab7c1856a102 +0 -0
  200. data/spec/dummy/tmp/cache/assets/test/sprockets/38611f05ed0bf72a4755c136796ff5d4 +0 -0
  201. data/spec/dummy/tmp/cache/assets/test/sprockets/3b99bacd5915b4ff7fb2664bc2aa30d0 +0 -0
  202. data/spec/dummy/tmp/cache/assets/test/sprockets/443ca9dc693ccf91d6e1cecaffe0fa9a +0 -0
  203. data/spec/dummy/tmp/cache/assets/test/sprockets/45c759123f4f6b42cdcff44b446655a5 +0 -0
  204. data/spec/dummy/tmp/cache/assets/test/sprockets/4ca01587005a9b895bca383881bec87d +0 -0
  205. data/spec/dummy/tmp/cache/assets/test/sprockets/4cffdba2a7aac80c1765e060b152b382 +0 -0
  206. data/spec/dummy/tmp/cache/assets/test/sprockets/4d38783b41d7c000fed2419b5173f87a +0 -0
  207. data/spec/dummy/tmp/cache/assets/test/sprockets/51fe2df168cee49df9d4136f59c87872 +0 -0
  208. data/spec/dummy/tmp/cache/assets/test/sprockets/564db16c8d964c3505bfca526e3fccf2 +0 -0
  209. data/spec/dummy/tmp/cache/assets/test/sprockets/56e5bd2f3c94d7a9d0da7c4e05c7ad78 +0 -0
  210. data/spec/dummy/tmp/cache/assets/test/sprockets/5807e61754ed8b16702f6ad7ba34d439 +0 -0
  211. data/spec/dummy/tmp/cache/assets/test/sprockets/593d990734170367188181754939b317 +0 -0
  212. data/spec/dummy/tmp/cache/assets/test/sprockets/5a44970074ecbfeae2cc9798ed7da7aa +0 -0
  213. data/spec/dummy/tmp/cache/assets/test/sprockets/5e7901fbee32b66040fd6376a8c981d8 +0 -0
  214. data/spec/dummy/tmp/cache/assets/test/sprockets/5ecbfe03cab317594d2bc1c6866d26db +0 -0
  215. data/spec/dummy/tmp/cache/assets/test/sprockets/609ce9936a503352d73f954f68be7f81 +0 -0
  216. data/spec/dummy/tmp/cache/assets/test/sprockets/65224b6e799d399f4e6cf4bf98155de2 +0 -0
  217. data/spec/dummy/tmp/cache/assets/test/sprockets/6a1e72555b75237fffccb5de8937b4d4 +0 -0
  218. data/spec/dummy/tmp/cache/assets/test/sprockets/6a8187f5c6f2e115d1a1c21ca2ec81a0 +0 -0
  219. data/spec/dummy/tmp/cache/assets/test/sprockets/6c9a2f7ab6f8d1f8e3e4cf1d7d6cc68a +0 -0
  220. data/spec/dummy/tmp/cache/assets/test/sprockets/6f4f668f70fb14b2132289fed6718f0e +0 -0
  221. data/spec/dummy/tmp/cache/assets/test/sprockets/727e0f830601f307d4c8b9a76e464c1a +0 -0
  222. data/spec/dummy/tmp/cache/assets/test/sprockets/749bd767d6654c80265f5ca0959dc8e1 +0 -0
  223. data/spec/dummy/tmp/cache/assets/test/sprockets/7a92952d5fff10f09ce91b852d6a744f +0 -0
  224. data/spec/dummy/tmp/cache/assets/test/sprockets/7ad564910e515e335bb008989a97efb7 +0 -0
  225. data/spec/dummy/tmp/cache/assets/test/sprockets/7b55037b89f2debe558b43fe7542e409 +0 -0
  226. data/spec/dummy/tmp/cache/assets/test/sprockets/7bb04b7318793726b5414daaa4f049d4 +0 -0
  227. data/spec/dummy/tmp/cache/assets/test/sprockets/7c5f37d1af8a5557b67d6ffb8afcc2b5 +0 -0
  228. data/spec/dummy/tmp/cache/assets/test/sprockets/7f5092f53db371ea56be62557677a506 +0 -0
  229. data/spec/dummy/tmp/cache/assets/test/sprockets/7f9ced6d264f71631c80df15194abf4d +0 -0
  230. data/spec/dummy/tmp/cache/assets/test/sprockets/80870efa2a2ddb1de325c224daff5712 +0 -0
  231. data/spec/dummy/tmp/cache/assets/test/sprockets/831e225c0e792be993a1d1dc58f20e54 +0 -0
  232. data/spec/dummy/tmp/cache/assets/test/sprockets/83f98047f864c578534b34068cb015e0 +0 -0
  233. data/spec/dummy/tmp/cache/assets/test/sprockets/84361af51e20dcfad7fae0f32f284ab7 +0 -0
  234. data/spec/dummy/tmp/cache/assets/test/sprockets/894aeaae9cc8483fa9f7a5146ff6ff6f +0 -0
  235. data/spec/dummy/tmp/cache/assets/test/sprockets/89567cbb5e7770a065e88360dcd02833 +0 -0
  236. data/spec/dummy/tmp/cache/assets/test/sprockets/89a5be65dc0d00fa22be4375c029d69c +0 -0
  237. data/spec/dummy/tmp/cache/assets/test/sprockets/8bf0319a2b612416dfde2d3b939dbf99 +0 -0
  238. data/spec/dummy/tmp/cache/assets/test/sprockets/8cfeb6443a5f7398e67010a202ee2de2 +0 -0
  239. data/spec/dummy/tmp/cache/assets/test/sprockets/8e3769f6378278754105f0924e6dd1ff +0 -0
  240. data/spec/dummy/tmp/cache/assets/test/sprockets/96c321f84bd796096692021bc4a87eed +0 -0
  241. data/spec/dummy/tmp/cache/assets/test/sprockets/97e875e2282fba5939cf71198faab1f0 +0 -0
  242. data/spec/dummy/tmp/cache/assets/test/sprockets/9911ee0fc41f519a1c4faa7912547cce +0 -0
  243. data/spec/dummy/tmp/cache/assets/test/sprockets/9ac84ed11232b2f7fc9f80c18844abc8 +0 -0
  244. data/spec/dummy/tmp/cache/assets/test/sprockets/9ba0cab624f25b68f79447e62fbc6112 +0 -0
  245. data/spec/dummy/tmp/cache/assets/test/sprockets/9e9edfa954375fd0cc6498f70b883e8e +0 -0
  246. data/spec/dummy/tmp/cache/assets/test/sprockets/a3863764f2fbc185e0d2ea584c7e2174 +0 -0
  247. data/spec/dummy/tmp/cache/assets/test/sprockets/a4c4a00b0d2b8334de3ee3169064adad +0 -0
  248. data/spec/dummy/tmp/cache/assets/test/sprockets/a744e8f2a7ce02e7af9784f40c711ed5 +0 -0
  249. data/spec/dummy/tmp/cache/assets/test/sprockets/a78a33e8cea959257da93b3e67786300 +0 -0
  250. data/spec/dummy/tmp/cache/assets/test/sprockets/a9956bd25bbe4c811a1a758f71aec748 +0 -0
  251. data/spec/dummy/tmp/cache/assets/test/sprockets/aa4822def20c419f0e50e2a38e73a1df +0 -0
  252. data/spec/dummy/tmp/cache/assets/test/sprockets/aaa24da6bd0fcf694077519e189b7392 +0 -0
  253. data/spec/dummy/tmp/cache/assets/test/sprockets/b0493d9dbe3afb3268b7ffce2b87bf78 +0 -0
  254. data/spec/dummy/tmp/cache/assets/test/sprockets/b2c398b7a51a65be12ba944bdea13415 +0 -0
  255. data/spec/dummy/tmp/cache/assets/test/sprockets/b81381e4a978aa69cc2ab1f892a40e97 +0 -0
  256. data/spec/dummy/tmp/cache/assets/test/sprockets/b82707486d5133da748e4382c62de995 +0 -0
  257. data/spec/dummy/tmp/cache/assets/test/sprockets/bb83cb3c179681d65c77a41e98f1c70f +0 -0
  258. data/spec/dummy/tmp/cache/assets/test/sprockets/bbc50f2009705d8fd7b91330bc24dcb8 +0 -0
  259. data/spec/dummy/tmp/cache/assets/test/sprockets/bcb7548b203cc2c5a484ef7649911c2d +0 -0
  260. data/spec/dummy/tmp/cache/assets/test/sprockets/becade26fead85d486f136be49b45e23 +0 -0
  261. data/spec/dummy/tmp/cache/assets/test/sprockets/bfc0fef30976427a03ddccb1ce78d6e7 +0 -0
  262. data/spec/dummy/tmp/cache/assets/test/sprockets/c0dd93a468e038b3653ed4d28874e0cb +0 -0
  263. data/spec/dummy/tmp/cache/assets/test/sprockets/c1d2340cbfe5e80d388f95e7a08698d9 +0 -0
  264. data/spec/dummy/tmp/cache/assets/test/sprockets/c25afdb537c84a18bd62fc782164d298 +0 -0
  265. data/spec/dummy/tmp/cache/assets/test/sprockets/c3dc3ada4560805584739bfe7c2b24d9 +0 -0
  266. data/spec/dummy/tmp/cache/assets/test/sprockets/c4dc50a79ec929d33d9e2835d1926fd9 +0 -0
  267. data/spec/dummy/tmp/cache/assets/test/sprockets/c5f990ee58d3727faeb4cfd3f5667e8a +0 -0
  268. data/spec/dummy/tmp/cache/assets/test/sprockets/c622effcf1aa225bf2920d2b63ca525c +0 -0
  269. data/spec/dummy/tmp/cache/assets/test/sprockets/d09dc20f2dc66183aa23ce1fd8fc9f2c +0 -0
  270. data/spec/dummy/tmp/cache/assets/test/sprockets/d60bdefb444e91b75e4cc2f3fc49228b +0 -0
  271. data/spec/dummy/tmp/cache/assets/test/sprockets/d7c40ebee2fb9471bab352337570ba40 +0 -0
  272. data/spec/dummy/tmp/cache/assets/test/sprockets/d9bc94e1e0cc114986f8760bc4eb42ce +0 -0
  273. data/spec/dummy/tmp/cache/assets/test/sprockets/da4488b32bd6fb75c655a077956c9034 +0 -0
  274. data/spec/dummy/tmp/cache/assets/test/sprockets/daeb51b1ca3de2a1f2146dea431249d3 +0 -0
  275. data/spec/dummy/tmp/cache/assets/test/sprockets/dd0e13880601ea049b7c6d8c76ea535f +0 -0
  276. data/spec/dummy/tmp/cache/assets/test/sprockets/dd15d7b9860a8a187c4a6c167dc56547 +0 -0
  277. data/spec/dummy/tmp/cache/assets/test/sprockets/dd8ed9b0203321fd815ba48a5867620e +0 -0
  278. data/spec/dummy/tmp/cache/assets/test/sprockets/e1e036b04a3a20b2fb589420ad03b926 +0 -0
  279. data/spec/dummy/tmp/cache/assets/test/sprockets/e4f46080338c0c52e3933999a7f8106d +0 -0
  280. data/spec/dummy/tmp/cache/assets/test/sprockets/e59a3c2ff941e0fdc7987168580bf4cc +0 -0
  281. data/spec/dummy/tmp/cache/assets/test/sprockets/e6cfe2e09e34ec2b24494a74eed5243a +0 -0
  282. data/spec/dummy/tmp/cache/assets/test/sprockets/e8e088454cc6f38324bd168e299cf08f +0 -0
  283. data/spec/dummy/tmp/cache/assets/test/sprockets/e949207f9e9578cfd48ab90bb82ea384 +0 -0
  284. data/spec/dummy/tmp/cache/assets/test/sprockets/ee5a41236d43159aac87f9224a0bcfb8 +0 -0
  285. data/spec/dummy/tmp/cache/assets/test/sprockets/ef5f76363cd723089ce62b8c207415a4 +0 -0
  286. data/spec/dummy/tmp/cache/assets/test/sprockets/f2de4855fd4840abb2f6e80afee5f4ed +0 -0
  287. data/spec/dummy/tmp/cache/assets/test/sprockets/f5165c4d7cee0e7cb99bc069fd4c09b9 +0 -0
  288. data/spec/dummy/tmp/cache/assets/test/sprockets/f660938bc4a80358883ba6c576e1dd13 +0 -0
  289. data/spec/dummy/tmp/cache/assets/test/sprockets/f7379cc2d3a2fc4b87d64c68d2d8684f +0 -0
  290. data/spec/dummy/tmp/cache/assets/test/sprockets/f81b83e98592ff24dd8518985baa48cd +0 -0
  291. data/spec/dummy/tmp/cache/assets/test/sprockets/f94b13174ed1cc7f087a66c0094ef4cf +0 -0
  292. data/spec/dummy/tmp/cache/assets/test/sprockets/f975cba8c490022ddfc45bab0b512879 +0 -0
  293. data/spec/dummy/tmp/cache/assets/test/sprockets/face6eb5e3ee8802296bdc38e5704d72 +0 -0
  294. data/spec/dummy/tmp/cache/assets/test/sprockets/fc9155176668e1a56a5ca3843febe3c3 +0 -0
  295. data/spec/dummy/tmp/cache/assets/test/sprockets/fd7e46e0b42a510b40f17d1f1bacf80e +0 -0
  296. data/spec/factories/asset_factory.rb +0 -21
  297. data/spec/factories/files/rails.png +0 -0
  298. data/spec/factories/files/silicon_valley.jpg +0 -0
  299. data/spec/factories/page_factory.rb +0 -10
  300. data/spec/factories/post_factory.rb +0 -9
  301. data/spec/factories/structure_factory.rb +0 -22
  302. data/spec/factories/user_factory.rb +0 -49
  303. data/spec/generators/install_generator_spec.rb +0 -55
  304. data/spec/models/avatar_spec.rb +0 -138
  305. data/spec/models/i18n_backend.rb +0 -30
  306. data/spec/models/structure_spec.rb +0 -120
  307. data/spec/models/sunrise/abstract_model_spec.rb +0 -88
  308. data/spec/models/sunrise/carrierwave/picture_uploader_spec.rb +0 -49
  309. data/spec/models/sunrise/search_wrapper_spec.rb +0 -21
  310. data/spec/models/user_spec.rb +0 -63
  311. data/spec/orm/active_record.rb +0 -5
  312. data/spec/orm/kaminari/active_record.rb +0 -18
  313. data/spec/orm/kaminari/mongoid.rb +0 -20
  314. data/spec/orm/mongoid.rb +0 -15
  315. data/spec/requests/activities_spec.rb +0 -41
  316. data/spec/requests/dashboard_spec.rb +0 -35
  317. data/spec/requests/manager/default/create_spec.rb +0 -43
  318. data/spec/requests/manager/default/destroy_spec.rb +0 -36
  319. data/spec/requests/manager/default/edit_spec.rb +0 -72
  320. data/spec/requests/manager/default/export_spec.rb +0 -121
  321. data/spec/requests/manager/default/index_spec.rb +0 -67
  322. data/spec/requests/manager/default/new_spec.rb +0 -59
  323. data/spec/requests/manager/default/show_spec.rb +0 -41
  324. data/spec/requests/manager/default/update_spec.rb +0 -73
  325. data/spec/requests/manager/many/create_spec.rb +0 -52
  326. data/spec/requests/manager/many/destroy_spec.rb +0 -41
  327. data/spec/requests/manager/many/edit_spec.rb +0 -43
  328. data/spec/requests/manager/many/index_spec.rb +0 -54
  329. data/spec/requests/manager/many/new_spec.rb +0 -40
  330. data/spec/requests/manager/many/update_spec.rb +0 -55
  331. data/spec/spec_helper.rb +0 -90
  332. data/spec/sunrise_spec.rb +0 -29
  333. data/spec/support/helpers/controller_helper.rb +0 -27
  334. data/spec/support/helpers/controller_macros.rb +0 -40
  335. data/spec/support/hooks/structure.rb +0 -5
@@ -1,20 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe PagesController do
5
+ describe PagesController, type: :controller do
4
6
  render_views
5
-
7
+
6
8
  before(:all) do
7
9
  @root = FactoryGirl.create(:structure_main)
8
10
  end
9
-
10
- context "page" do
11
- before(:each) { @page = FactoryGirl.create(:structure_page, :parent => @root) }
12
-
13
- it "should render show action" do
14
- get :show, :id => @page.slug
15
-
11
+
12
+ context 'page' do
13
+ before(:each) { @page = FactoryGirl.create(:structure_page, parent: @root) }
14
+
15
+ it 'should render show action' do
16
+ get :show, id: @page.slug
17
+
16
18
  assigns(:structure).should == @page
17
-
19
+
18
20
  response.should be_success
19
21
  response.should render_template('show')
20
22
  end
@@ -1,17 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe WelcomeController do
5
+ describe WelcomeController, type: :controller do
4
6
  render_views
5
-
7
+
6
8
  before(:each) do
7
9
  @root = FactoryGirl.create(:structure_main)
8
10
  end
9
-
10
- it "should render index action" do
11
+
12
+ it 'should render index action' do
11
13
  get :index
12
-
14
+
13
15
  assigns(:structure).should == @root
14
-
16
+
15
17
  response.should be_success
16
18
  response.should render_template('index')
17
19
  end
@@ -1,6 +1,7 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  FactoryGirl.define do
3
- factory :structure_page, :class => Structure do
4
+ factory :structure_page, class: Structure do
4
5
  title 'Structure'
5
6
  slug { FactoryGirl.generate(:slug) }
6
7
  structure_type StructureType.page
@@ -8,9 +9,9 @@ FactoryGirl.define do
8
9
  is_visible true
9
10
  end
10
11
 
11
- factory :structure_main, :class => Structure do
12
- title "Main page"
13
- slug "main-page"
12
+ factory :structure_main, class: Structure do
13
+ title 'Main page'
14
+ slug 'main-page'
14
15
  structure_type StructureType.main
15
16
  position_type PositionType.default
16
17
  is_visible true
@@ -1,54 +1,55 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  FactoryGirl.define do
3
- factory :admin_user, :class => User do |user|
4
+ factory :admin_user, class: User do |user|
4
5
  user.name 'Admin'
5
6
  user.email { FactoryGirl.generate(:email) }
6
7
  user.password 'password'
7
8
  user.password_confirmation 'password'
8
-
9
- user.after(:build) do |u|
10
- u.roles.build(:role_type => RoleType.admin)
9
+
10
+ user.after(:build) do |u|
11
+ u.roles.build(role_type: RoleType.admin)
11
12
  u.skip_confirmation!
12
13
  end
13
14
  end
14
15
 
15
- factory :redactor_user, :class => User do |user|
16
+ factory :redactor_user, class: User do |user|
16
17
  user.name 'Redactor'
17
18
  user.email { FactoryGirl.generate(:email) }
18
19
  user.password 'password'
19
20
  user.password_confirmation 'password'
20
-
21
- user.after(:build) do |u|
22
- u.roles.build(:role_type => RoleType.redactor)
21
+
22
+ user.after(:build) do |u|
23
+ u.roles.build(role_type: RoleType.redactor)
23
24
  u.skip_confirmation!
24
25
  end
25
26
  end
26
27
 
27
- factory :moderator_user, :class => User do |user|
28
+ factory :moderator_user, class: User do |user|
28
29
  user.name 'Redactor'
29
30
  user.email { FactoryGirl.generate(:email) }
30
31
  user.password 'password'
31
32
  user.password_confirmation 'password'
32
-
33
- user.after(:build) do |u|
34
- u.roles.build(:role_type => RoleType.moderator)
33
+
34
+ user.after(:build) do |u|
35
+ u.roles.build(role_type: RoleType.moderator)
35
36
  u.skip_confirmation!
36
37
  end
37
38
  end
38
39
 
39
- factory :default_user, :class => User do |user|
40
+ factory :default_user, class: User do |user|
40
41
  user.name 'Test'
41
42
  user.email { FactoryGirl.generate(:email) }
42
43
  user.password 'password'
43
44
  user.password_confirmation 'password'
44
-
45
- user.after(:build) do |u|
46
- u.roles.build(:role_type => RoleType.default)
45
+
46
+ user.after(:build) do |u|
47
+ u.roles.build(role_type: RoleType.default)
47
48
  u.skip_confirmation!
48
49
  end
49
50
  end
50
51
 
51
- factory :user, :class => User do |user|
52
+ factory :user, class: User do |user|
52
53
  user.name 'Test'
53
54
  user.email { FactoryGirl.generate(:email) }
54
55
  user.password 'password'
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV["RAILS_ENV"] ||= 'test'
3
- require File.expand_path("../../config/environment", __FILE__)
4
+ ENV['RAILS_ENV'] ||= 'test'
5
+ require File.expand_path('../config/environment', __dir__)
4
6
  require 'rspec/rails'
5
7
 
6
8
  # Requires supporting ruby files with custom matchers and macros, etc,
7
9
  # in spec/support/ and its subdirectories.
8
- Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
10
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
9
11
 
10
12
  RSpec.configure do |config|
11
13
  # == Mock Framework
@@ -16,15 +18,15 @@ RSpec.configure do |config|
16
18
  # config.mock_with :flexmock
17
19
  # config.mock_with :rr
18
20
  config.mock_with :rspec
19
-
20
- config.include Devise::TestHelpers, :type => :controller
21
- config.extend ControllerMacros, :type => :controller
21
+
22
+ config.include Devise::TestHelpers, type: :controller
23
+ config.extend ControllerMacros, type: :controller
22
24
 
23
25
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
24
26
  # examples within a transaction, remove the following line or assign false
25
27
  # instead of true.
26
28
  config.use_transactional_fixtures = false
27
-
29
+
28
30
  require 'database_cleaner'
29
31
  config.before(:suite) do
30
32
  DatabaseCleaner.strategy = :truncation
@@ -1,49 +1,50 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  module ControllerMacros
3
4
  def login_admin
4
5
  before(:all) do
5
6
  @admin = FactoryGirl.create(:admin_user)
6
7
  end
7
-
8
+
8
9
  before(:each) do
9
10
  sign_out :user
10
11
  sign_in @admin
11
12
  end
12
13
  end
13
-
14
+
14
15
  def login_default
15
16
  before(:all) do
16
17
  @user = FactoryGirl.create(:default_user)
17
18
  end
18
-
19
+
19
20
  before(:each) do
20
21
  sign_out :user
21
22
  sign_in @user
22
23
  end
23
24
  end
24
-
25
+
25
26
  def login_redactor
26
27
  before(:all) do
27
28
  @user = FactoryGirl.create(:redactor_user)
28
29
  end
29
-
30
+
30
31
  before(:each) do
31
32
  sign_out :user
32
33
  sign_in @user
33
34
  end
34
35
  end
35
-
36
+
36
37
  def login_moderator
37
38
  before(:all) do
38
39
  @user = FactoryGirl.create(:moderator_user)
39
40
  end
40
-
41
+
41
42
  before(:each) do
42
43
  sign_out :user
43
44
  sign_in @user
44
45
  end
45
46
  end
46
-
47
+
47
48
  def user_logout
48
49
  before(:each) do
49
50
  sign_out :user
@@ -1,5 +1,7 @@
1
- class AttachmentFileUploader < Sunrise::CarrierWave::BaseUploader
1
+ # frozen_string_literal: true
2
+
3
+ class AttachmentFileUploader < Sunrise::CarrierWave::BaseUploader
2
4
  def extension_white_list
3
- %w(pdf doc docx xls xlsx ppt pptx zip rar csv)
5
+ %w[pdf doc docx xls xlsx ppt pptx zip rar csv]
4
6
  end
5
7
  end
@@ -1,15 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AvatarUploader < Sunrise::CarrierWave::BaseUploader
2
- process :quality => 90
3
-
4
+ process quality: 90
5
+ process :set_dimensions
6
+
4
7
  version :thumb do
5
- process :resize_to_fill => [100, 100]
8
+ process resize_to_fill: [100, 100]
6
9
  end
7
-
10
+
8
11
  version :small do
9
- process :resize_to_fill => [32, 32]
12
+ process resize_to_fill: [32, 32]
10
13
  end
11
-
14
+
12
15
  def extension_white_list
13
- %w(jpg jpeg gif png)
16
+ %w[jpg jpeg gif png]
14
17
  end
15
18
  end
@@ -1,15 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PictureUploader < Sunrise::CarrierWave::BaseUploader
2
- process :quality => 90
3
-
4
+ process quality: 90
5
+ process :set_dimensions
6
+
4
7
  version :thumb do
5
- process :resize_to_fill => [50, 50]
8
+ process resize_to_fill: [50, 50]
6
9
  end
7
10
 
8
11
  version :content do
9
- process :resize_to_fit => [575, 500]
12
+ process resize_to_fit: [575, 500]
10
13
  end
11
-
14
+
12
15
  def extension_white_list
13
- %w(jpg jpeg gif png)
16
+ %w[jpg jpeg gif png]
14
17
  end
15
18
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sunrise'
@@ -1,5 +1,12 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'pathname'
4
+ require 'meta_manager'
5
+ require 'page_parts'
6
+ require 'public_activity'
7
+ require 'rails-uploader'
8
+ require 'cancan'
9
+
3
10
  require 'sunrise/core_ext'
4
11
  require 'sunrise/version'
5
12
 
@@ -7,7 +14,7 @@ module Sunrise
7
14
  autoload :Utils, 'sunrise/utils'
8
15
  autoload :Config, 'sunrise/config'
9
16
  autoload :AbstractModel, 'sunrise/abstract_model'
10
-
17
+
11
18
  module Models
12
19
  autoload :Asset, 'sunrise/models/asset'
13
20
  autoload :Structure, 'sunrise/models/structure'
@@ -20,13 +27,13 @@ module Sunrise
20
27
  autoload :Ability, 'sunrise/models/ability'
21
28
  autoload :Settings, 'sunrise/models/settings'
22
29
  end
23
-
30
+
24
31
  module CarrierWave
25
32
  autoload :Glue, 'sunrise/carrierwave/glue'
26
33
  autoload :BaseUploader, 'sunrise/carrierwave/base_uploader'
27
34
  autoload :FileSizeValidator, 'sunrise/carrierwave/file_size_validator'
28
35
  end
29
-
36
+
30
37
  module Views
31
38
  autoload :FormBuilder, 'sunrise/views/form_builder'
32
39
  autoload :SearchWrapper, 'sunrise/views/search_wrapper'
@@ -39,17 +46,17 @@ module Sunrise
39
46
  autoload :Mongoid, 'sunrise/hooks/adapters/mongoid'
40
47
  end
41
48
  end
42
-
49
+
43
50
  # Regexp machers for context-based russian month names and day names translation
44
- LOCALIZE_ABBR_MONTH_NAMES_MATCH = /(%[-\d]?d|%e)(.*)(%b)/
45
- LOCALIZE_MONTH_NAMES_MATCH = /(%[-\d]?d|%e)(.*)(%B)/
46
- LOCALIZE_STANDALONE_ABBR_DAY_NAMES_MATCH = /^%a/
47
- LOCALIZE_STANDALONE_DAY_NAMES_MATCH = /^%A/
48
-
51
+ LOCALIZE_ABBR_MONTH_NAMES_MATCH = /(%[-\d]?d|%e)(.*)(%b)/.freeze
52
+ LOCALIZE_MONTH_NAMES_MATCH = /(%[-\d]?d|%e)(.*)(%B)/.freeze
53
+ LOCALIZE_STANDALONE_ABBR_DAY_NAMES_MATCH = /^%a/.freeze
54
+ LOCALIZE_STANDALONE_DAY_NAMES_MATCH = /^%A/.freeze
55
+
49
56
  def self.root_path
50
- @root_path ||= Pathname.new(File.dirname(File.expand_path('../', __FILE__)))
57
+ @root_path ||= Pathname.new(File.dirname(File.expand_path(__dir__)))
51
58
  end
52
-
59
+
53
60
  def self.setup
54
61
  yield Config
55
62
  end
@@ -58,7 +65,7 @@ module Sunrise
58
65
  if defined?(Mongoid::Document)
59
66
  PublicActivity::Activity.desc(:created_at)
60
67
  else
61
- PublicActivity::Activity.order("created_at DESC")
68
+ PublicActivity::Activity.order('created_at DESC')
62
69
  end
63
70
  end
64
71
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sunrise/config/model'
2
4
  require 'ostruct'
3
5
 
@@ -6,7 +8,6 @@ module Sunrise
6
8
  extend ::ActiveModel::Callbacks
7
9
 
8
10
  class << self
9
-
10
11
  # Gets the resource_name
11
12
  def resource_name
12
13
  # Not using superclass_delegating_reader. See +site+ for explanation
@@ -16,24 +17,22 @@ module Sunrise
16
17
  superclass.proxy.dup.freeze
17
18
  end
18
19
  end
19
-
20
+
20
21
  # Set resource_name
21
- def resource_name=(name)
22
- @resource_name = name
23
- end
24
-
22
+ attr_writer :resource_name
23
+
25
24
  def config
26
25
  @config ||= Config::Model.new(self)
27
26
  end
28
-
27
+
29
28
  def model
30
29
  @model ||= Utils.lookup(resource_name.to_s.camelize)
31
30
  end
32
-
31
+
33
32
  def abstract_class?
34
33
  defined?(@abstract_class) && @abstract_class == true
35
34
  end
36
-
35
+
37
36
  # Act as a proxy for the section configurations that actually
38
37
  # store the configurations.
39
38
  def method_missing(m, *args, &block)
@@ -44,15 +43,15 @@ module Sunrise
44
43
  end
45
44
  end
46
45
  end
47
-
46
+
48
47
  attr_accessor :model_name, :current_list, :sort_column, :available_list_view
49
-
50
- delegate :config, :model, :to => 'self.class'
51
- delegate :label, :to => 'self.class.config'
52
- delegate :param_key, :singular, :plural, :route_key, :to => :model_name
53
48
 
54
- define_model_callbacks :sort, :mass_destroy, :only => [:before, :after]
55
-
49
+ delegate :config, :model, to: 'self.class'
50
+ delegate :label, to: 'self.class.config'
51
+ delegate :param_key, :singular, :plural, :route_key, to: :model_name
52
+
53
+ define_model_callbacks :sort, :mass_destroy, only: [:before, :after]
54
+
56
55
  def initialize(params = {})
57
56
  @model_name = model.model_name
58
57
  @current_list = config.default_index_view
@@ -65,60 +64,59 @@ module Sunrise
65
64
  def model_params
66
65
  @request_params[param_key.to_sym] || {}
67
66
  end
68
-
67
+
69
68
  # Save current list view
70
69
  def current_list=(value)
71
- if value && @available_index_views.include?(value.to_sym)
72
- @current_list = value.to_sym
73
- end
70
+ @current_list = value.to_sym if value && @available_index_views.include?(value.to_sym)
74
71
  end
75
-
72
+
76
73
  # Load association record
77
74
  def parent_record
78
75
  @parent_record ||= find_parent_record
79
76
  end
80
-
77
+
81
78
  # Convert parent id and class name into hash
82
79
  def parent_hash
83
- @parent_hash ||= { :parent_id => parent_record.id, :parent_type => parent_record.class.name.underscore } if parent_record
80
+ if parent_record
81
+ @parent_hash ||= { parent_id: parent_record.id, parent_type: parent_record.class.name.underscore }
82
+ end
84
83
  @parent_hash ||= {}
85
84
  end
86
-
85
+
87
86
  # Get current list settings
88
87
  def list
89
88
  return false if without_index?
89
+
90
90
  config.index(current_list)
91
91
  end
92
-
92
+
93
93
  # Is index config disabled
94
94
  def without_index?
95
95
  config.index === false
96
96
  end
97
-
97
+
98
98
  def search_available?
99
99
  list && !list.groups[:search].nil?
100
100
  end
101
-
101
+
102
102
  def sort_available?
103
103
  list && !list.groups[:sort].nil?
104
104
  end
105
-
105
+
106
106
  def sort_fields
107
- @sort_fields ||= list.groups[:sort].fields.inject([]) do |items, field|
107
+ @sort_fields ||= list.groups[:sort].fields.each_with_object([]) do |field, items|
108
108
  [:desc, :asc].each do |direction|
109
109
  name = [field.name, direction].join('_')
110
- items << OpenStruct.new(:name => I18n.t(name, :scope => [:manage, :sort_columns]), :value => name)
110
+ items << OpenStruct.new(name: I18n.t(name, scope: [:manage, :sort_columns]), value: name)
111
111
  end
112
-
113
- items
114
112
  end
115
113
  end
116
-
114
+
117
115
  def update_sort(params)
118
116
  run_callbacks :sort do
119
- if !params[:ids].blank?
117
+ if params[:ids].present?
120
118
  update_sort_column(params[:ids])
121
- elsif !params[:tree].blank?
119
+ elsif params[:tree].present?
122
120
  update_sort_tree(params[:tree])
123
121
  end
124
122
  end
@@ -128,31 +126,31 @@ module Sunrise
128
126
  return if params[:ids].blank?
129
127
 
130
128
  run_callbacks :mass_destroy do
131
- model.where(:id => params[:ids]).destroy_all
129
+ model.where(id: params[:ids]).destroy_all
132
130
  end
133
131
  end
134
-
132
+
135
133
  # Update nested tree
136
134
  # {"id"=>{"parent_id"=>"root", "depth"=>"0", "left"=>"1", "right"=>"22"}
137
135
  #
138
136
  def update_sort_tree(ids)
139
137
  return nil if ids.empty?
140
-
138
+
141
139
  ids.each do |key, value|
142
- hash = { :parent_id => nil, :depth => value[:depth], :lft => value[:left], :rgt => value[:right] }
143
- hash[:parent_id] = value[:parent_id] unless value[:parent_id] == "root"
144
- model.where(:id => key).update_all(hash)
140
+ hash = { parent_id: nil, depth: value[:depth], lft: value[:left], rgt: value[:right] }
141
+ hash[:parent_id] = value[:parent_id] unless value[:parent_id] == 'root'
142
+ model.where(id: key).update_all(hash)
145
143
  end
146
144
  end
147
-
145
+
148
146
  def update_sort_column(ids)
149
147
  return nil if ids.empty?
150
148
 
151
- ids.each do |key, value|
152
- model.where(:id => key).update_all(@sort_column => value)
149
+ ids.each do |key, value|
150
+ model.where(id: key).update_all(@sort_column => value)
153
151
  end
154
152
  end
155
-
153
+
156
154
  # Initialize new model, sets parent record and call build_defaults method
157
155
  def build_record
158
156
  record = model.new
@@ -160,12 +158,13 @@ module Sunrise
160
158
  record.build_defaults if record.respond_to?(:build_defaults)
161
159
  record
162
160
  end
163
-
161
+
164
162
  # Convert request params to model scopes
165
163
  def apply_scopes(params = nil, pagination = true)
166
- raise ::AbstractController::ActionNotFound.new("List config is turn off") if without_index?
164
+ raise ::AbstractController::ActionNotFound, 'List config is turn off' if without_index?
165
+
167
166
  params ||= @request_params
168
-
167
+
169
168
  scope = default_scope(params)
170
169
 
171
170
  if current_list == :tree
@@ -176,61 +175,61 @@ module Sunrise
176
175
 
177
176
  scope
178
177
  end
179
-
178
+
180
179
  # Apply default scopes: sort, search and association.
181
180
  def default_scope(params = nil)
182
181
  params ||= @request_params
183
-
184
- scope = model.sunrise_search(params[:search]) if model.respond_to?(:sunrise_search) && !params[:search].blank?
182
+
183
+ if model.respond_to?(:sunrise_search) && params[:search].present?
184
+ scope = model.sunrise_search(params[:search])
185
+ end
185
186
  scope ||= model.where(nil)
186
-
187
+
187
188
  scope = scope.merge(association_scope) unless parent_record.nil?
188
- scope = scope.merge(sort_scope(params[:sort])) unless params[:sort].blank?
189
+ scope = scope.merge(sort_scope(params[:sort])) if params[:sort].present?
189
190
  scope = scope.merge(list.scope) unless list.scope.nil?
190
-
191
+
191
192
  scope
192
193
  end
193
-
194
+
194
195
  def association_scope
195
- if parent_record
196
- parent_record.send(parent_association.relation_name)
197
- end
196
+ parent_record&.send(parent_association.relation_name)
198
197
  end
199
-
198
+
200
199
  def page_scope(scope, page = 1, per_page = nil)
201
200
  page = 1 if page.blank? || page.to_i <= 0
202
201
  per_page ||= list.items_per_page
203
-
202
+
204
203
  scope.page(page).per(per_page)
205
204
  end
206
-
205
+
207
206
  def sort_scope(options = nil)
208
207
  options = Utils.sort_to_hash(options) if options.is_a?(String)
209
- options = { :column => list.sort_column, :mode => list.sort_mode }.merge(options || {})
210
-
208
+ options = { column: list.sort_column, mode: list.sort_mode }.merge(options || {})
209
+
211
210
  options[:column] = list.sort_column if options[:column].blank?
212
211
  options[:mode] = list.sort_mode if options[:mode].blank?
213
-
212
+
214
213
  model.order([options[:column], options[:mode]].join(' '))
215
214
  end
216
-
215
+
217
216
  # List of columns names to be exported
218
217
  def export_columns
219
218
  @export_columns ||= (config.export ? config.export.fields.map(&:name) : model.column_names)
220
219
  end
221
-
220
+
222
221
  # Filename for export data
223
222
  def export_filename
224
- @export_filename ||= [plural, Time.now.strftime("%Y-%m-%d_%Hh%Mm%S")].join('_')
223
+ @export_filename ||= [plural, Time.zone.now.strftime('%Y-%m-%d_%Hh%Mm%S')].join('_')
225
224
  end
226
225
 
227
226
  def export_options
228
- {
229
- :filename => export_filename,
230
- :columns => export_columns
227
+ {
228
+ filename: export_filename,
229
+ columns: export_columns
231
230
  }
232
231
  end
233
-
232
+
234
233
  def form_fields
235
234
  config.form.fields || []
236
235
  end
@@ -239,9 +238,9 @@ module Sunrise
239
238
  value = config.form.permited_attributes
240
239
 
241
240
  attrs = case value
242
- when Proc then value.call(user)
243
- when String then value.to_sym
244
- else value
241
+ when Proc then value.call(user)
242
+ when String then value.to_sym
243
+ else value
245
244
  end
246
245
 
247
246
  if attrs == :all
@@ -251,54 +250,52 @@ module Sunrise
251
250
  params.require(param_key).permit(*attrs)
252
251
  end
253
252
  end
254
-
253
+
255
254
  # Has translated columns
256
255
  def translate?
257
- !config.form.groups[:translate].blank?
256
+ config.form.groups[:translate].present?
258
257
  end
259
-
258
+
260
259
  # Files to translate
261
260
  def translate_fields
262
261
  config.form.groups[:translate].try(:fields) || []
263
262
  end
264
-
263
+
265
264
  # Find sidebar groups
266
265
  def sidebar_groups
267
266
  @sidebar_groups ||= config.form.groups.values.select { |v| v.sidebar? }
268
267
  end
269
-
268
+
270
269
  # Check if sidebar groups exists
271
270
  def sidebar_groups?
272
271
  !sidebar_groups.empty?
273
272
  end
274
-
273
+
275
274
  # Find bottom groups
276
275
  def bottom_groups
277
276
  @bottom_groups ||= config.form.groups.values.select { |v| v.bottom? }
278
277
  end
279
-
278
+
280
279
  protected
281
-
282
- # Try to find parent object if any association present
283
- def find_parent_record
284
- if parent_present? && parent_valid?
285
- parent_association.model.find(@request_params[:parent_id])
286
- end
287
- end
288
-
289
- # Find related association in model config
290
- def parent_association
291
- @parent_association ||= config.associations.detect { |relation| relation.is_this?(@request_params[:parent_type]) }
292
- end
293
-
294
- # Parent association exists
295
- def parent_valid?
296
- !parent_association.nil?
297
- end
298
-
299
- # Check parent record in request params
300
- def parent_present?
301
- !(@request_params[:parent_id].blank? || @request_params[:parent_type].blank?)
302
- end
280
+
281
+ # Try to find parent object if any association present
282
+ def find_parent_record
283
+ parent_association.model.find(@request_params[:parent_id]) if parent_present? && parent_valid?
284
+ end
285
+
286
+ # Find related association in model config
287
+ def parent_association
288
+ @parent_association ||= config.associations.detect { |relation| relation.is_this?(@request_params[:parent_type]) }
289
+ end
290
+
291
+ # Parent association exists
292
+ def parent_valid?
293
+ !parent_association.nil?
294
+ end
295
+
296
+ # Check parent record in request params
297
+ def parent_present?
298
+ !(@request_params[:parent_id].blank? || @request_params[:parent_type].blank?)
299
+ end
303
300
  end
304
301
  end