constructor-core 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (351) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +13 -0
  5. data/.yardopts +9 -0
  6. data/Gemfile +31 -0
  7. data/Guardfile +15 -0
  8. data/LICENSE.md +7 -0
  9. data/README.md +35 -0
  10. data/Rakefile +19 -0
  11. data/bin/rails +8 -0
  12. data/config.ru +4 -0
  13. data/config/routes.rb +3 -17
  14. data/constructor-cms.gemspec +26 -0
  15. data/{app → core/app}/assets/images/constructor_core/glyphicons-halflings-white.png +0 -0
  16. data/{app → core/app}/assets/images/constructor_core/glyphicons-halflings.png +0 -0
  17. data/{app → core/app}/assets/images/constructor_core/minus.gif +0 -0
  18. data/{app → core/app}/assets/images/constructor_core/plus.gif +0 -0
  19. data/{app → core/app}/assets/images/constructor_core/rss.png +0 -0
  20. data/{app → core/app}/assets/images/constructor_core/treeview-black-line.gif +0 -0
  21. data/{app → core/app}/assets/images/constructor_core/treeview-black.gif +0 -0
  22. data/{app → core/app}/assets/images/constructor_core/treeview-default-line.gif +0 -0
  23. data/{app → core/app}/assets/images/constructor_core/treeview-default.gif +0 -0
  24. data/{app → core/app}/assets/images/constructor_core/treeview-famfamfam-line.gif +0 -0
  25. data/{app → core/app}/assets/images/constructor_core/treeview-famfamfam.gif +0 -0
  26. data/{app → core/app}/assets/images/constructor_core/treeview-gray-line.gif +0 -0
  27. data/{app → core/app}/assets/images/constructor_core/treeview-gray.gif +0 -0
  28. data/{app → core/app}/assets/images/constructor_core/treeview-red-line.gif +0 -0
  29. data/{app → core/app}/assets/images/constructor_core/treeview-red.gif +0 -0
  30. data/{app → core/app}/assets/images/constructor_core/twitter.png +0 -0
  31. data/{app → core/app}/assets/images/constructor_core/widgets.png +0 -0
  32. data/{app → core/app}/assets/javascripts/constructor_core/application.js.coffee +0 -0
  33. data/{app → core/app}/assets/javascripts/constructor_core/bootstrap.js +0 -0
  34. data/{app → core/app}/assets/javascripts/constructor_core/jquery.cookie.js +0 -0
  35. data/{app → core/app}/assets/javascripts/constructor_core/jquery_bundle.js.coffee +0 -0
  36. data/{app → core/app}/assets/javascripts/constructor_core/keys_snippet.js +0 -0
  37. data/{app → core/app}/assets/javascripts/constructor_core/retina.js +0 -0
  38. data/{app → core/app}/assets/javascripts/constructor_core/urlify.js +0 -0
  39. data/{app → core/app}/assets/stylesheets/constructor_core/application.css.scss +0 -0
  40. data/{app → core/app}/assets/stylesheets/constructor_core/main.css.scss +0 -0
  41. data/{app → core/app}/controllers/constructor_core/application_controller.rb +0 -0
  42. data/{app → core/app}/controllers/constructor_core/sessions_controller.rb +0 -0
  43. data/{app → core/app}/controllers/constructor_core/users_controller.rb +0 -0
  44. data/{app → core/app}/helpers/constructor_core/application_helper.rb +0 -0
  45. data/{app → core/app}/models/constructor_core/user.rb +0 -0
  46. data/{app → core/app}/views/constructor_core/devise/confirmations/new.html.haml +0 -0
  47. data/{app → core/app}/views/constructor_core/devise/mailer/confirmation_instructions.html.haml +0 -0
  48. data/{app → core/app}/views/constructor_core/devise/mailer/reset_password_instructions.html.haml +0 -0
  49. data/{app → core/app}/views/constructor_core/devise/mailer/unlock_instructions.html.haml +0 -0
  50. data/{app → core/app}/views/constructor_core/devise/passwords/edit.html.haml +0 -0
  51. data/{app → core/app}/views/constructor_core/devise/passwords/new.html.haml +0 -0
  52. data/{app → core/app}/views/constructor_core/devise/registrations/edit.html.haml +0 -0
  53. data/{app → core/app}/views/constructor_core/devise/registrations/new.html.haml +0 -0
  54. data/{app → core/app}/views/constructor_core/devise/shared/_links.html.haml +0 -0
  55. data/{app → core/app}/views/constructor_core/devise/unlocks/new.html.haml +0 -0
  56. data/{app → core/app}/views/constructor_core/sessions/new.html.haml +0 -0
  57. data/{app → core/app}/views/constructor_core/users/profile.haml +0 -0
  58. data/{app → core/app}/views/layouts/constructor_core/application.haml +0 -0
  59. data/{config → core/config}/environments/production.rb +0 -0
  60. data/{config → core/config}/initializers/devise.rb +0 -0
  61. data/{config → core/config}/locales/devise.en.yml +0 -0
  62. data/{config → core/config}/locales/devise.fr.yml +0 -0
  63. data/{config → core/config}/locales/devise.ru.yml +0 -0
  64. data/{config → core/config}/locales/en.yml +0 -0
  65. data/{config → core/config}/locales/fr.yml +0 -0
  66. data/{config → core/config}/locales/ru.yml +0 -0
  67. data/core/config/routes.rb +18 -0
  68. data/{constructor-core.gemspec → core/constructor-core.gemspec} +0 -0
  69. data/{db → core/db}/migrate/1_devise_users.rb +0 -0
  70. data/{db → core/db}/migrate/2_add_default_user.rb +0 -0
  71. data/{lib → core/lib}/constructor-core.rb +0 -0
  72. data/{lib → core/lib}/constructor_core/engine.rb +0 -0
  73. data/{lib → core/lib}/constructor_core/version.rb +1 -1
  74. data/{vendor → core/vendor}/assets/javascripts/.gitkeep +0 -0
  75. data/{vendor → core/vendor}/assets/javascripts/ckeditor/ckeditor.js +0 -0
  76. data/{vendor → core/vendor}/assets/javascripts/ckeditor/config.js +0 -0
  77. data/{vendor → core/vendor}/assets/javascripts/ckeditor/lang/en.js +0 -0
  78. data/{vendor → core/vendor}/assets/javascripts/ckeditor/lang/ru.js +0 -0
  79. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/a11yhelp.js +0 -0
  80. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/_translationstatus.txt +0 -0
  81. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ar.js +0 -0
  82. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/bg.js +0 -0
  83. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ca.js +0 -0
  84. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/cs.js +0 -0
  85. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/cy.js +0 -0
  86. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/da.js +0 -0
  87. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/de.js +0 -0
  88. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/el.js +0 -0
  89. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/en.js +0 -0
  90. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/eo.js +0 -0
  91. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/es.js +0 -0
  92. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/et.js +0 -0
  93. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/fa.js +0 -0
  94. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/fi.js +0 -0
  95. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/fr.js +0 -0
  96. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/gu.js +0 -0
  97. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/he.js +0 -0
  98. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/hi.js +0 -0
  99. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/hr.js +0 -0
  100. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/hu.js +0 -0
  101. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/it.js +0 -0
  102. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ja.js +0 -0
  103. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/km.js +0 -0
  104. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ku.js +0 -0
  105. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/lt.js +0 -0
  106. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/lv.js +0 -0
  107. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/mk.js +0 -0
  108. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/mn.js +0 -0
  109. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/nb.js +0 -0
  110. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/nl.js +0 -0
  111. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/no.js +0 -0
  112. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/pl.js +0 -0
  113. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/pt-br.js +0 -0
  114. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/pt.js +0 -0
  115. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ro.js +0 -0
  116. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ru.js +0 -0
  117. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/sk.js +0 -0
  118. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/sl.js +0 -0
  119. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/sv.js +0 -0
  120. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/th.js +0 -0
  121. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/tr.js +0 -0
  122. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ug.js +0 -0
  123. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/uk.js +0 -0
  124. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/vi.js +0 -0
  125. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/zh-cn.js +0 -0
  126. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/about/dialogs/about.js +0 -0
  127. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/about/dialogs/logo_ckeditor.png +0 -0
  128. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/clipboard/dialogs/paste.js +0 -0
  129. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/colordialog/dialogs/colordialog.js +0 -0
  130. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/dialog/dialogDefinition.js +0 -0
  131. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/div/dialogs/div.js +0 -0
  132. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/fakeobjects/images/spacer.gif +0 -0
  133. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/find/dialogs/find.js +0 -0
  134. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/icons.png +0 -0
  135. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/iframe/dialogs/iframe.js +0 -0
  136. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/iframe/images/placeholder.png +0 -0
  137. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/image/dialogs/image.js +0 -0
  138. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/image/images/noimage.png +0 -0
  139. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/link/dialogs/anchor.js +0 -0
  140. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/link/dialogs/link.js +0 -0
  141. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/link/images/anchor.png +0 -0
  142. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/liststyle/dialogs/liststyle.js +0 -0
  143. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/magicline/images/icon.png +0 -0
  144. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/pastefromword/filter/default.js +0 -0
  145. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/preview/preview.html +0 -0
  146. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/scayt/LICENSE.md +0 -0
  147. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/scayt/README.md +0 -0
  148. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +0 -0
  149. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/scayt/dialogs/toolbar.css +0 -0
  150. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_address.png +0 -0
  151. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_blockquote.png +0 -0
  152. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_div.png +0 -0
  153. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_h1.png +0 -0
  154. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_h2.png +0 -0
  155. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_h3.png +0 -0
  156. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_h4.png +0 -0
  157. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_h5.png +0 -0
  158. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_h6.png +0 -0
  159. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_p.png +0 -0
  160. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/showblocks/images/block_pre.png +0 -0
  161. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/_translationstatus.txt +0 -0
  162. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/ca.js +0 -0
  163. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/cs.js +0 -0
  164. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/cy.js +0 -0
  165. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/de.js +0 -0
  166. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/el.js +0 -0
  167. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/en.js +0 -0
  168. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/eo.js +0 -0
  169. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/et.js +0 -0
  170. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/fa.js +0 -0
  171. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/fi.js +0 -0
  172. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/fr.js +0 -0
  173. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/he.js +0 -0
  174. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/hr.js +0 -0
  175. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/it.js +0 -0
  176. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/ku.js +0 -0
  177. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/lv.js +0 -0
  178. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/nb.js +0 -0
  179. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/nl.js +0 -0
  180. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/no.js +0 -0
  181. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/pl.js +0 -0
  182. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/pt-br.js +0 -0
  183. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/sk.js +0 -0
  184. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/sv.js +0 -0
  185. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/th.js +0 -0
  186. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/tr.js +0 -0
  187. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/ug.js +0 -0
  188. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/zh-cn.js +0 -0
  189. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/specialchar/dialogs/specialchar.js +0 -0
  190. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/table/dialogs/table.js +0 -0
  191. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/tabletools/dialogs/tableCell.js +0 -0
  192. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.css +0 -0
  193. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.js +0 -0
  194. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/templates/templates/default.js +0 -0
  195. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/templates/templates/images/template1.gif +0 -0
  196. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/templates/templates/images/template2.gif +0 -0
  197. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/templates/templates/images/template3.gif +0 -0
  198. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/wsc/LICENSE.md +0 -0
  199. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/wsc/README.md +0 -0
  200. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/wsc/dialogs/ciframe.html +0 -0
  201. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/wsc/dialogs/tmpFrameset.html +0 -0
  202. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/wsc/dialogs/wsc.css +0 -0
  203. data/{vendor → core/vendor}/assets/javascripts/ckeditor/plugins/wsc/dialogs/wsc.js +0 -0
  204. data/{vendor → core/vendor}/assets/javascripts/ckeditor/styles.js +0 -0
  205. data/{vendor → core/vendor}/assets/stylesheets/.gitkeep +0 -0
  206. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/contents.css +0 -0
  207. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/dialog.css +0 -0
  208. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/dialog_ie.css +0 -0
  209. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/dialog_ie7.css +0 -0
  210. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/dialog_ie8.css +0 -0
  211. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/dialog_opera.css +0 -0
  212. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/editor.css +0 -0
  213. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/editor_gecko.css +0 -0
  214. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/editor_ie.css +0 -0
  215. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/editor_ie7.css +0 -0
  216. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/editor_ie8.css +0 -0
  217. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/icons.png +0 -0
  218. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/images/arrow.png +0 -0
  219. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/images/close.png +0 -0
  220. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/images/mini.png +0 -0
  221. data/{vendor → core/vendor}/assets/stylesheets/ckeditor/skins/moono/readme.md +0 -0
  222. data/lib/constructor-cms.rb +3 -0
  223. data/lib/constructor-cms/engine.rb +6 -0
  224. data/pages/app/assets/images/constructor_pages/arrow_down.png +0 -0
  225. data/pages/app/assets/images/constructor_pages/arrow_up.png +0 -0
  226. data/pages/app/assets/images/constructor_pages/information.png +0 -0
  227. data/pages/app/assets/images/constructor_pages/page_white_edit.png +0 -0
  228. data/pages/app/assets/images/constructor_pages/photos.png +0 -0
  229. data/pages/app/assets/javascripts/constructor_pages/ajax_pages.js +61 -0
  230. data/pages/app/assets/javascripts/constructor_pages/jquery.history.js +1 -0
  231. data/pages/app/controllers/constructor_pages/application_controller.rb +20 -0
  232. data/pages/app/controllers/constructor_pages/fields_controller.rb +70 -0
  233. data/pages/app/controllers/constructor_pages/pages_controller.rb +155 -0
  234. data/pages/app/controllers/constructor_pages/templates_controller.rb +62 -0
  235. data/pages/app/helpers/constructor_pages/code_name_uniq.rb +7 -0
  236. data/pages/app/helpers/constructor_pages/fields_helper.rb +18 -0
  237. data/pages/app/helpers/constructor_pages/pages_helper.rb +22 -0
  238. data/pages/app/helpers/constructor_pages/templates_helper.rb +13 -0
  239. data/pages/app/helpers/constructor_pages/treeview_helper.rb +33 -0
  240. data/pages/app/models/constructor_pages/field.rb +59 -0
  241. data/pages/app/models/constructor_pages/page.rb +173 -0
  242. data/pages/app/models/constructor_pages/template.rb +38 -0
  243. data/pages/app/models/constructor_pages/types/boolean_type.rb +11 -0
  244. data/pages/app/models/constructor_pages/types/date_type.rb +11 -0
  245. data/pages/app/models/constructor_pages/types/float_type.rb +11 -0
  246. data/pages/app/models/constructor_pages/types/html_type.rb +11 -0
  247. data/pages/app/models/constructor_pages/types/image_type.rb +19 -0
  248. data/pages/app/models/constructor_pages/types/integer_type.rb +11 -0
  249. data/pages/app/models/constructor_pages/types/string_type.rb +11 -0
  250. data/pages/app/models/constructor_pages/types/text_type.rb +11 -0
  251. data/pages/app/views/constructor_pages/fields/_form.haml +29 -0
  252. data/pages/app/views/constructor_pages/fields/edit.haml +6 -0
  253. data/pages/app/views/constructor_pages/fields/new.haml +6 -0
  254. data/pages/app/views/constructor_pages/fields/types/_boolean.haml +1 -0
  255. data/pages/app/views/constructor_pages/fields/types/_date.haml +1 -0
  256. data/pages/app/views/constructor_pages/fields/types/_float.haml +1 -0
  257. data/pages/app/views/constructor_pages/fields/types/_html.haml +1 -0
  258. data/pages/app/views/constructor_pages/fields/types/_image.haml +7 -0
  259. data/pages/app/views/constructor_pages/fields/types/_integer.haml +1 -0
  260. data/pages/app/views/constructor_pages/fields/types/_string.haml +1 -0
  261. data/pages/app/views/constructor_pages/fields/types/_text.haml +1 -0
  262. data/pages/app/views/constructor_pages/pages/_breadcrumbs.haml +7 -0
  263. data/pages/app/views/constructor_pages/pages/_form.haml +98 -0
  264. data/pages/app/views/constructor_pages/pages/_menu.haml +8 -0
  265. data/pages/app/views/constructor_pages/pages/_submenu.haml +6 -0
  266. data/pages/app/views/constructor_pages/pages/edit.haml +6 -0
  267. data/pages/app/views/constructor_pages/pages/index.haml +42 -0
  268. data/pages/app/views/constructor_pages/pages/new.haml +6 -0
  269. data/pages/app/views/constructor_pages/pages/show.haml +5 -0
  270. data/pages/app/views/constructor_pages/partials/_arrow_buttons.haml +6 -0
  271. data/pages/app/views/constructor_pages/templates/_form.haml +53 -0
  272. data/pages/app/views/constructor_pages/templates/edit.haml +6 -0
  273. data/pages/app/views/constructor_pages/templates/index.haml +24 -0
  274. data/pages/app/views/constructor_pages/templates/new.haml +6 -0
  275. data/pages/config/initializers/dragonfly.rb +9 -0
  276. data/pages/config/locales/en.yml +65 -0
  277. data/pages/config/locales/fr.yml +65 -0
  278. data/pages/config/locales/ru.yml +100 -0
  279. data/pages/config/routes.rb +26 -0
  280. data/pages/constructor-pages.gemspec +31 -0
  281. data/pages/db/migrate/10_create_html_types.rb +15 -0
  282. data/pages/db/migrate/11_create_image_types.rb +16 -0
  283. data/pages/db/migrate/12_add_default_template.rb +13 -0
  284. data/pages/db/migrate/1_create_pages.rb +27 -0
  285. data/pages/db/migrate/2_create_templates.rb +18 -0
  286. data/pages/db/migrate/3_create_fields.rb +17 -0
  287. data/pages/db/migrate/4_create_string_types.rb +15 -0
  288. data/pages/db/migrate/5_create_float_types.rb +15 -0
  289. data/pages/db/migrate/6_create_boolean_types.rb +15 -0
  290. data/pages/db/migrate/7_create_integer_types.rb +15 -0
  291. data/pages/db/migrate/8_create_text_types.rb +15 -0
  292. data/pages/db/migrate/9_create_date_types.rb +15 -0
  293. data/pages/lib/constructor-pages.rb +6 -0
  294. data/pages/lib/constructor_pages/engine.rb +6 -0
  295. data/pages/public/hello.txt +1 -0
  296. data/pages/spec/features/constructor_pages/fields_spec.rb +217 -0
  297. data/pages/spec/features/constructor_pages/pages_spec.rb +313 -0
  298. data/pages/spec/features/constructor_pages/templates_spec.rb +267 -0
  299. data/pages/spec/helpers/constructor_pages/.keep +0 -0
  300. data/pages/spec/models/constructor_pages/field_spec.rb +135 -0
  301. data/pages/spec/models/constructor_pages/page_spec.rb +420 -0
  302. data/pages/spec/models/constructor_pages/template_spec.rb +34 -0
  303. data/pages/spec/models/constructor_pages/types/boolean_type_spec.rb +21 -0
  304. data/pages/spec/models/constructor_pages/types/date_type_spec.rb +21 -0
  305. data/pages/spec/models/constructor_pages/types/float_type_spec.rb +21 -0
  306. data/pages/spec/models/constructor_pages/types/html_type_spec.rb +63 -0
  307. data/pages/spec/models/constructor_pages/types/integer_type_spec.rb +24 -0
  308. data/pages/spec/models/constructor_pages/types/string_type_spec.rb +21 -0
  309. data/pages/spec/models/constructor_pages/types/text_type_spec.rb +63 -0
  310. data/pages/spec/routing/constructor_pages/.keep +0 -0
  311. data/spec/dummy/README.rdoc +28 -0
  312. data/spec/dummy/Rakefile +6 -0
  313. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  314. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  315. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  316. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  317. data/spec/dummy/app/mailers/.gitkeep +0 -0
  318. data/spec/dummy/app/models/.gitkeep +0 -0
  319. data/spec/dummy/app/views/html_templates/page.haml +1 -0
  320. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  321. data/spec/dummy/bin/bundle +3 -0
  322. data/spec/dummy/bin/rails +4 -0
  323. data/spec/dummy/bin/rake +4 -0
  324. data/spec/dummy/config.ru +4 -0
  325. data/spec/dummy/config/application.rb +23 -0
  326. data/spec/dummy/config/boot.rb +5 -0
  327. data/spec/dummy/config/database.yml +25 -0
  328. data/spec/dummy/config/environment.rb +5 -0
  329. data/spec/dummy/config/environments/development.rb +29 -0
  330. data/spec/dummy/config/environments/production.rb +80 -0
  331. data/spec/dummy/config/environments/test.rb +36 -0
  332. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  333. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  334. data/spec/dummy/config/initializers/inflections.rb +16 -0
  335. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  336. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  337. data/spec/dummy/config/initializers/session_store.rb +3 -0
  338. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  339. data/spec/dummy/config/locales/en.yml +5 -0
  340. data/spec/dummy/config/routes.rb +3 -0
  341. data/spec/dummy/lib/assets/.gitkeep +0 -0
  342. data/spec/dummy/lib/tasks/.gitkeep +0 -0
  343. data/spec/dummy/log/.gitkeep +0 -0
  344. data/spec/dummy/public/404.html +58 -0
  345. data/spec/dummy/public/422.html +58 -0
  346. data/spec/dummy/public/500.html +57 -0
  347. data/spec/dummy/public/favicon.ico +0 -0
  348. data/spec/dummy/public/robots.txt +5 -0
  349. data/spec/spec_helper.rb +46 -0
  350. data/tasks/constructor-cms_tasks.rake +15 -0
  351. metadata +396 -211
@@ -0,0 +1,267 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ module ConstructorPages
6
+ describe 'Templates Controller' do
7
+ before :all do
8
+ ConstructorCore::User.delete_all
9
+ @user = ConstructorCore::User.create email: 'ivanzotov@gmail.com', password: '123qweASD'
10
+ end
11
+
12
+ before :each do
13
+ Page.delete_all
14
+ Field.delete_all
15
+ Template.delete_all
16
+
17
+ Field::TYPES.each do |t|
18
+ "constructor_pages/types/#{t}_type".classify.constantize.delete_all
19
+ end
20
+
21
+ login_as @user
22
+ end
23
+
24
+ describe 'Index' do
25
+ describe 'Access' do
26
+ it 'should be accessed by pages.templates_path if logged in' do
27
+ visit pages.templates_path
28
+ current_path.should == pages.templates_path
29
+ status_code.should == 200
30
+ end
31
+
32
+ it 'should not be accessed by pages.templates_path if not logged in' do
33
+ logout
34
+ visit pages.templates_path
35
+ current_path.should == '/'
36
+ end
37
+ end
38
+
39
+ it 'should has new template link' do
40
+ visit pages.templates_path
41
+ page.should have_link 'New template', pages.new_template_path
42
+ end
43
+
44
+ it 'should has list of templates' do
45
+ Template.create name: 'Page', code_name: 'page'
46
+ visit pages.templates_path
47
+ page.should have_selector 'ul li'
48
+ page.should have_text 'Page'
49
+ end
50
+
51
+ it 'should has edit_template link' do
52
+ _template = Template.create name: 'Page', code_name: 'page'
53
+ visit pages.templates_path
54
+ page.should have_link 'Edit template', pages.edit_template_path(_template)
55
+ end
56
+
57
+ it 'should has delete_page link' do
58
+ _template = Template.create name: 'Page', code_name: 'page'
59
+ visit pages.templates_path
60
+ page.should have_link 'Delete', pages.template_path(_template)
61
+ end
62
+ end
63
+
64
+ describe 'Moving' do
65
+ it 'should move template' do
66
+ _template_first = Template.create name: 'First', code_name: 'first'
67
+ _template_second = Template.create name: 'Second', code_name: 'second'
68
+ _template_third = Template.create name: 'Third', code_name: 'third'
69
+
70
+ _template_first.left_sibling.should be_nil
71
+ _template_first.right_sibling.should == _template_second
72
+
73
+ _template_second.left_sibling.should == _template_first
74
+ _template_second.right_sibling.should == _template_third
75
+
76
+ _template_third.left_sibling.should == _template_second
77
+ _template_third.right_sibling.should be_nil
78
+
79
+ visit pages.templates_path
80
+
81
+ find("a[href='#{pages.template_move_down_path(_template_first.id)}']").click
82
+
83
+ _template_first.reload
84
+ _template_first.left_sibling.should == _template_second
85
+ _template_first.right_sibling.should == _template_third
86
+
87
+ _template_second.reload
88
+ _template_second.left_sibling.should be_nil
89
+ _template_second.right_sibling.should == _template_first
90
+
91
+ _template_third.reload
92
+ _template_third.left_sibling.should == _template_first
93
+ _template_third.right_sibling.should be_nil
94
+
95
+ find("a[href='#{pages.template_move_up_path(_template_third.id)}']").click
96
+
97
+ _template_first.reload
98
+ _template_first.left_sibling.should == _template_third
99
+ _template_first.right_sibling.should be_nil
100
+
101
+ _template_second.reload
102
+ _template_second.left_sibling.should be_nil
103
+ _template_second.right_sibling.should == _template_third
104
+
105
+ _template_third.reload
106
+ _template_third.left_sibling.should == _template_second
107
+ _template_third.right_sibling.should == _template_first
108
+ end
109
+ end
110
+
111
+ describe 'New template' do
112
+ describe 'Access' do
113
+ it 'should be accessed by new_template_path if logged in' do
114
+ visit pages.new_template_path
115
+ current_path.should == pages.new_template_path
116
+ status_code.should == 200
117
+ end
118
+
119
+ it 'should not be accessed by new_template_path if not logged in' do
120
+ logout
121
+ visit pages.new_template_path
122
+ current_path.should == '/'
123
+ end
124
+ end
125
+
126
+ it 'should has name field' do
127
+ visit pages.new_template_path
128
+ page.should have_field 'Name'
129
+ end
130
+
131
+ it 'should has code_name field' do
132
+ visit pages.new_template_path
133
+ page.should have_field 'Code name'
134
+ end
135
+
136
+ it 'should has parent and child selects' do
137
+ visit pages.new_template_path
138
+ page.should have_select 'Parent'
139
+ page.should have_select 'Child'
140
+ end
141
+
142
+ it 'should not has link new field' do
143
+ visit pages.new_template_path
144
+ page.should_not have_link 'New field'
145
+ end
146
+
147
+ it 'should not has delete link' do
148
+ visit pages.new_template_path
149
+ page.should_not have_link 'Delete template'
150
+ end
151
+
152
+ it 'should has Create Template button' do
153
+ visit pages.new_template_path
154
+ page.should have_button 'Create Template'
155
+ end
156
+
157
+ it 'should create new template' do
158
+ visit pages.new_template_path
159
+ fill_in 'Name', with: 'Brand'
160
+ fill_in 'Code name', with: 'brand'
161
+ Template.count.should == 0
162
+ click_button 'Create Template'
163
+ current_path.should == pages.templates_path
164
+ Template.count.should == 1
165
+ _template = Template.first
166
+ _template.name.should == 'Brand'
167
+ _template.code_name.should == 'brand'
168
+ page.should have_text 'added successfully'
169
+ end
170
+
171
+ it 'should validate uniqueness of code name' do
172
+ Template.create name: 'Brand', code_name: 'brand'
173
+ visit pages.new_template_path
174
+ fill_in 'Name', with: 'Brand'
175
+ fill_in 'Code name', with: 'brand'
176
+ click_button 'Create Template'
177
+ current_path.should == pages.templates_path
178
+ page.should have_text 'Code name has already been taken'
179
+ end
180
+
181
+ it 'should validate uniqueness of code name with Page' do
182
+ visit pages.new_template_path
183
+ fill_in 'Name', with: 'Brand'
184
+ fill_in 'Code name', with: 'get_field_value'
185
+ Template.count.should == 0
186
+ click_button 'Create Template'
187
+ Template.count.should == 0
188
+ page.should have_text 'Code name has already been taken'
189
+ end
190
+ end
191
+
192
+ describe 'Edit template' do
193
+ before :each do
194
+ @template = Template.create name: 'Page', code_name: 'page'
195
+ end
196
+
197
+ describe 'Access' do
198
+ it 'should be accessed by edit_template_path if logged in' do
199
+ visit pages.edit_template_path(@template)
200
+ status_code.should == 200
201
+ end
202
+
203
+ it 'should not be accessed by edit_template_path if not logged in' do
204
+ logout
205
+ visit pages.edit_template_path(@template)
206
+ current_path.should == '/'
207
+ end
208
+ end
209
+
210
+ it 'should has delete link' do
211
+ visit pages.edit_template_path(@template)
212
+ page.should have_link 'Delete template'
213
+ end
214
+
215
+ it 'should has new field link' do
216
+ visit pages.edit_template_path(@template)
217
+ page.should have_link 'New field', pages.new_field_path(@template)
218
+ end
219
+
220
+ it 'should has update template button' do
221
+ visit pages.edit_template_path(@template)
222
+ page.should have_button 'Update Template'
223
+ end
224
+
225
+ it 'should edit template' do
226
+ visit pages.edit_template_path(@template)
227
+ fill_in 'Name', with: 'New brand'
228
+ fill_in 'Code name', with: 'new_brand'
229
+ click_button 'Update Template'
230
+ @template.reload
231
+ @template.name.should == 'New brand'
232
+ @template.code_name.should == 'new_brand'
233
+ page.should have_text 'updated successfully'
234
+ end
235
+ end
236
+
237
+ describe 'Delete template' do
238
+ it 'should delete from templates index' do
239
+ Template.create name: 'Page', code_name: 'page'
240
+ visit pages.templates_path
241
+ Template.count.should == 1
242
+ click_link 'Delete'
243
+ Template.count.should == 0
244
+ page.should have_text 'removed successfully'
245
+ end
246
+
247
+ it 'should delete from template' do
248
+ _template = Template.create name: 'Page', code_name: 'page'
249
+ visit pages.edit_template_path(_template)
250
+ Template.count.should == 1
251
+ click_link 'Delete'
252
+ Template.count.should == 0
253
+ page.should have_text 'removed successfully'
254
+ end
255
+
256
+ it 'should not delete if there are any pages' do
257
+ _template = Template.create name: 'Page', code_name: 'page'
258
+ Page.create name: 'Home page', template: _template
259
+ visit pages.edit_template_path(_template)
260
+ Template.count.should == 1
261
+ click_link 'Delete'
262
+ Template.count.should == 1
263
+ page.should have_text 'Delete pages with this template before'
264
+ end
265
+ end
266
+ end
267
+ end
@@ -0,0 +1,135 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ module ConstructorPages
6
+ describe Field do
7
+ before :each do
8
+ Template.delete_all
9
+ @template = Template.create name: 'Page', code_name: 'page'
10
+
11
+ Field.delete_all
12
+ Field::TYPES.each do |t|
13
+ "constructor_pages/types/#{t}_type".classify.constantize.delete_all
14
+ end
15
+ end
16
+
17
+ describe '.create' do
18
+ it 'should be valid' do
19
+ _field = Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
20
+ _field.should be_valid
21
+ end
22
+
23
+ it 'should create page fields' do
24
+ _field = Field.create name: 'Price', code_name: 'price', template: @template, type_value: 'text'
25
+
26
+ _page = Page.create name: 'Page', template_id: @template.id
27
+ _page.price.should == ''
28
+ end
29
+ end
30
+
31
+ describe '#destroy' do
32
+ it 'should destroy page fields' do
33
+ _field = Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
34
+ _page = Page.create name: 'Page', template: @template
35
+
36
+ _page.content.should == ''
37
+ _field.destroy
38
+ _page.content.should be_nil
39
+ end
40
+ end
41
+
42
+ describe '#type_class' do
43
+ it 'should return constant of type_value' do
44
+ field = Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'html'
45
+ field.type_class.should == Types::HtmlType
46
+
47
+ field.type_value = 'text'
48
+ field.type_class.should == Types::TextType
49
+ end
50
+ end
51
+
52
+ describe '#find_type_object' do
53
+ it 'should find one object of type_value by page' do
54
+ field = Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
55
+ page = Page.create name: 'Page', template: @template
56
+
57
+ text_type = Types::TextType.find_by_field_id_and_page_id field.id, page.id
58
+
59
+ field.find_type_object(page).should == text_type
60
+ end
61
+ end
62
+
63
+ describe '#create_type_object' do
64
+ it 'should create object of type_value by page' do
65
+ field = Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
66
+ page = Page.create name: 'Page', template: @template
67
+
68
+ text_type = field.create_type_object(page)
69
+ text_type.should be_an_instance_of(Types::TextType)
70
+ text_type.page_id.should == page.id
71
+ text_type.field_id.should == field.id
72
+ end
73
+ end
74
+
75
+ describe '#remove_type_object' do
76
+ it 'should remote object of type_value by page' do
77
+ field = Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
78
+ page = Page.create name: 'Page', template: @template
79
+
80
+ field.find_type_object(page).should be_an_instance_of(Types::TextType)
81
+
82
+ field.remove_type_object(page)
83
+ field.find_type_object(page).should be_nil
84
+ end
85
+ end
86
+
87
+ describe '#get_value_for' do
88
+ it 'should get value of type field by page' do
89
+ field = Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
90
+ page = Page.create name: 'Page', template: @template
91
+ page.content = 'Hello world'
92
+
93
+ field.get_value_for(page).should == 'Hello world'
94
+ end
95
+ end
96
+
97
+ describe '#set_value_for' do
98
+ it 'should set value for type field by page' do
99
+ field = Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
100
+ page = Page.create name: 'Page', template: @template
101
+
102
+ field.set_value_for(page, 'Hello')
103
+ page.content.should == 'Hello'
104
+ end
105
+ end
106
+
107
+ describe '#code_name' do
108
+ it 'should be uniqueness in scope fields' do
109
+ Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
110
+ _field = Field.create name: 'Content 2', code_name: 'content', template: @template, type_value: 'html'
111
+
112
+ _field.should_not be_valid
113
+ end
114
+
115
+ it 'should be uniqueness in scope Page' do
116
+ _field = Field.create name: 'Content', code_name: 'get_field_value', template: @template, type_value: 'text'
117
+ _field.should_not be_valid
118
+ end
119
+
120
+ it 'should be uniqueness in scope Template branch' do
121
+ _template = Template.create name: 'Brand', code_name: 'brand', parent: @template
122
+ @template.reload
123
+
124
+ _field = Field.create name: 'Content', code_name: 'brand', template: @template, type_value: 'text'
125
+ _field.should_not be_valid
126
+
127
+ _field.code_name = 'brands'
128
+ _field.should_not be_valid
129
+
130
+ _field.code_name = 'price'
131
+ _field.should be_valid
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,420 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ module ConstructorPages
6
+ describe Page do
7
+ before :each do
8
+ Template.delete_all
9
+ @template = Template.create name: 'Page', code_name: 'page'
10
+
11
+ Page.delete_all
12
+ Field.delete_all
13
+ Types::TextType.delete_all
14
+ end
15
+
16
+ context 'CLASS METHODS' do
17
+ describe '.create' do
18
+ it 'should be valid' do
19
+ Page.create.valid?.should be_true
20
+ end
21
+
22
+ it 'should create type_fields after' do
23
+ field = Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
24
+ page = Page.create name: 'New page', template: @template
25
+
26
+ field.get_value_for(page).should == ''
27
+ end
28
+ end
29
+
30
+ describe '.find_by_request_or_first' do
31
+ before :each do
32
+ @page = Page.create name: 'New page', url: 'new-page'
33
+ end
34
+
35
+ it 'should return page by given request path' do
36
+ Page.find_by_request_or_first('/new-page').should == @page
37
+ end
38
+
39
+ it 'should return first page if no given request or request is home page' do
40
+ Page.find_by_request_or_first.should == @page
41
+ Page.find_by_request_or_first('/').should == @page
42
+ end
43
+ end
44
+
45
+ describe '.full_url_generate' do
46
+ it 'should generate full_url from parent_id and url' do
47
+ first_page = Page.create name: 'First page', url: 'first-page'
48
+ second_page = Page.create name: 'Second page', url: 'second-page', parent: first_page
49
+ Page.full_url_generate(second_page.id, 'third-page').should == '/first-page/second-page/third-page'
50
+ end
51
+ end
52
+
53
+ describe '.check_code_name' do
54
+ it 'should check existing code_name in instance_methods' do
55
+ Page.check_code_name('get_field_value').should be_false
56
+ Page.check_code_name('class').should be_false
57
+ Page.check_code_name('hello_world').should be_true
58
+ end
59
+ end
60
+ end
61
+
62
+ describe 'SEARCH' do
63
+ before :each do
64
+ @price_field = Field.create name: 'Price', code_name: 'price', template: @template, type_value: 'float'
65
+ @area_field = Field.create name: 'Area', code_name: 'area', template: @template, type_value: 'integer'
66
+
67
+ @brand_template = Template.create name: 'Brand', code_name: 'brand', parent: @template
68
+ @content_field = Field.create name: 'Content', code_name: 'content', template: @brand_template, type_value: 'text'
69
+ @check_field = Field.create name: 'Check', code_name: 'check', template: @brand_template, type_value: 'boolean'
70
+ @brand_price_field = Field.create name: 'Price', code_name: 'price', template: @brand_template, type_value: 'float'
71
+ @brand_area_field = Field.create name: 'Area', code_name: 'area', template: @brand_template, type_value: 'integer'
72
+
73
+ @page = Page.create name: 'Fresco', template: @template
74
+ @page.price = 15000
75
+ @page.area = 35
76
+
77
+ @second_page = Page.create name: 'Zanussi', template: @template
78
+ @second_page.price = 1000
79
+ @second_page.area = 10
80
+
81
+ @first_brand_page = Page.create name: 'Midea', template: @brand_template, parent: @page
82
+ @first_brand_page.price = 20000
83
+ @first_brand_page.area = 25
84
+ @first_brand_page.content = 'This is first brand page'
85
+ @first_brand_page.check = true
86
+
87
+ @second_brand_page = Page.create name: 'Dantex', template: @brand_template, parent: @page
88
+ @second_brand_page.price = 30000
89
+ @second_brand_page.area = 55
90
+ @second_brand_page.content = 'This is second brand page'
91
+ @second_brand_page.check = false
92
+
93
+ @third_brand_page = Page.create name: 'LG', template: @brand_template, parent: @second_page
94
+ @third_brand_page.price = 10000
95
+ @third_brand_page.area = 38
96
+ @third_brand_page.content = 'This is third brand page'
97
+ @third_brand_page.check = true
98
+
99
+ @page.reload
100
+ @second_page.reload
101
+ end
102
+
103
+ context 'search in all pages' do
104
+ it 'should search with what search' do
105
+ Page.search.should == [@page, @first_brand_page, @second_brand_page, @second_page, @third_brand_page]
106
+ Page.search(:hello).should == []
107
+ Page.search(:brand).should == [@first_brand_page, @second_brand_page, @third_brand_page]
108
+ Page.search(:brands).should == [@first_brand_page, @second_brand_page, @third_brand_page]
109
+ end
110
+
111
+ it 'should search with where string search' do
112
+ Page.search_in('/world').should == []
113
+ end
114
+
115
+ it 'should search with where page search' do
116
+ Page.search_in(@page).should == [@first_brand_page, @second_brand_page]
117
+ Page.in(@second_page).search(:brands).should == [@third_brand_page]
118
+ Page.in(@second_page).search(:brand).should == [@third_brand_page]
119
+ Page.in(@second_page).search('brand').should == [@third_brand_page]
120
+ end
121
+
122
+ it 'it should search with by params' do
123
+ Page.in(@page).search_by(area: 25).should == [@first_brand_page]
124
+ Page.search_by(area: 10).should == [@second_page]
125
+ Page.search_by(price: 15000).should == [@page]
126
+ Page.in(@page).by(area: 25).search(:brand).should == [@first_brand_page]
127
+ Page.in(@second_page).by(area: 38).search(:brand).should == [@third_brand_page]
128
+ Page.in(@second_page).by(area: 40).search(:brand).should == []
129
+ Page.in('/world').search_by(area: 10).should == []
130
+ end
131
+
132
+ it 'should search with less' do
133
+ pending#Page.search(price: ['<', 20000]).should == [@page]
134
+ end
135
+
136
+ it 'should search with more' do
137
+ pending#Page.search(price: ['<', 20000], price: ['>', 5000]).should == [@page, @second_page]
138
+ end
139
+ end
140
+
141
+ context 'search in certain page' do
142
+ it 'should search with what search' do
143
+ @page.search.should == [@first_brand_page, @second_brand_page]
144
+ @page.search(:hello).should == []
145
+ @page.search(:brand).should == [@first_brand_page, @second_brand_page]
146
+ @second_page.search(:brand).should == [@third_brand_page]
147
+ end
148
+
149
+ it 'it should search with by params' do
150
+ @page.search_by(area: 25).should == [@first_brand_page]
151
+ @page.search_by(price: 30000).should == [@second_brand_page]
152
+ @page.by(price: 30000).search.should == [@second_brand_page]
153
+ @page.search_by(area: 10).should == []
154
+ @page.by(area: 10).search.should == []
155
+ end
156
+ end
157
+ end
158
+
159
+
160
+ context 'INSTANCE METHODS' do
161
+ context 'Getting and setting field value' do
162
+ before :each do
163
+ @template = Template.create name: 'Page template', code_name: 'page_template'
164
+ @page = Page.create name: 'Home page', template: @template
165
+ @field = Field.create name: 'Desc', code_name: 'desc', template: @template, type_value: 'text'
166
+ end
167
+
168
+ describe '#get_field' do
169
+ it 'should get value from type_field' do
170
+ @field.set_value_for(@page, 'Hello world')
171
+ @page.get_field_value('desc').should == 'Hello world'
172
+ end
173
+ end
174
+
175
+ describe '#set_field' do
176
+ it 'should set value for type_field' do
177
+ @page.set_field_value('desc', 'my world')
178
+ @field.get_value_for(@page).should == 'my world'
179
+ end
180
+ end
181
+ end
182
+
183
+ context 'Updating and removing fields values' do
184
+ before :each do
185
+ @template = Template.create name: 'New template', code_name: 'brand'
186
+ @field = Field.create name: 'Price', code_name: 'price', template: @template, type_value: 'float'
187
+ @page = Page.create name: 'New page', template: @template
188
+ @page.price = 500
189
+ end
190
+
191
+ describe '#update_fields_values' do
192
+ it 'should update fields values with params' do
193
+ @template.reload
194
+ Field.create name: 'Count', code_name: 'amount', template: @template, type_value: 'integer'
195
+
196
+ @page.reload
197
+
198
+ @page.amount = 10
199
+
200
+ @page.update_fields_values({price: 1000, amount: 20})
201
+
202
+ @page.price.should == 1000
203
+ @page.amount.should == 20
204
+ end
205
+
206
+ it 'should reset boolean fields' do
207
+ Field.create name: 'Check', code_name: 'check', template: @template, type_value: 'boolean'
208
+
209
+ @page.check = true
210
+
211
+ @page.update_fields_values({price: 1000})
212
+
213
+ @page.price.should == 1000
214
+ @page.check.should be_false
215
+ end
216
+ end
217
+
218
+ describe '#remove_fields_values' do
219
+ it 'should destroy all type_values fields' do
220
+ @field.find_type_object(@page).value.should == 500
221
+
222
+ @page.remove_fields_values
223
+ @field.find_type_object(@page).should be_nil
224
+ end
225
+ end
226
+ end
227
+
228
+ describe '#find_page_in_branch' do
229
+ it 'should find page(s) in same branch pages and templates by template_code_name' do
230
+ brand_template = Template.create name: 'Brand', code_name: 'brand'
231
+ series_template = Template.create name: 'Series', code_name: 'series', parent: brand_template
232
+
233
+ brand_page = Page.create name: 'Zanussi', template: brand_template
234
+ series_page = Page.create name: 'Fresco', template: series_template, parent: brand_page
235
+ brand_page.reload
236
+
237
+ series_page.find_page_in_branch('brand').should == brand_page
238
+ brand_page.find_pages_in_branch('series').should == [series_page]
239
+ end
240
+ end
241
+
242
+ describe '#as_json' do
243
+ context 'should return page hash attributes with fields' do
244
+ before :each do
245
+ @template = Template.create name: 'Json', code_name: 'json_template'
246
+ @page = Page.create name: 'Test json', template: @template
247
+ end
248
+
249
+ it 'should return defaults name and title attrs' do
250
+ @page.as_json.should == {name: @page.name, title: @page.title}
251
+ end
252
+
253
+ it 'should add fields to hash' do
254
+ Field.create name: 'Content', code_name: 'content', template: @template, type_value: 'text'
255
+ @page.content = 'Hello world'
256
+ @page.reload
257
+
258
+ @page.as_json.should == {name: @page.name, title: @page.title, content: 'Hello world'}
259
+ end
260
+ end
261
+ end
262
+
263
+ describe '#redirect?' do
264
+ it 'should check if link specified or not' do
265
+ page = Page.create name: 'Test redirection'
266
+ page.redirect?.should be_false
267
+
268
+ page.link = ''
269
+ page.save
270
+
271
+ page.redirect?.should be_false
272
+
273
+ page.link = '/hello-redirect'
274
+ page.save
275
+
276
+ page.redirect?.should be_true
277
+ end
278
+ end
279
+ end
280
+
281
+ context 'ATTRIBUTES' do
282
+ describe '#auto_url' do
283
+ it 'should be true by default' do
284
+ page = Page.create
285
+ page.auto_url.should be_true
286
+ end
287
+ end
288
+
289
+ describe '#template' do
290
+ context 'if there is no template' do
291
+ it 'should not be valid' do
292
+ Template.delete_all
293
+
294
+ page = Page.create
295
+ page.valid?.should_not be_true
296
+ end
297
+ end
298
+
299
+ context 'if template_id is nil' do
300
+ it 'should be first template' do
301
+ page = Page.create
302
+ page.template.should == Template.first
303
+ end
304
+ end
305
+ end
306
+
307
+ describe '#url' do
308
+ context 'if url is empty or if auto_url is true' do
309
+ it 'should be generated from name' do
310
+ page = Page.create name: 'Hello world'
311
+ page.url.should == 'hello-world'
312
+ end
313
+
314
+ it 'should translit utf-8' do
315
+ page = Page.create name: 'Проверка'
316
+ page.full_url.should == '/proverka'
317
+
318
+ page_two = Page.create name: 'Тест', parent: page
319
+ page_two.full_url.should == '/proverka/test'
320
+ end
321
+ end
322
+
323
+ context 'else' do
324
+ it 'should get url field value' do
325
+ page = Page.create name: 'Hello', auto_url: true
326
+ page.url.should == 'hello'
327
+
328
+ page.auto_url = false
329
+ page.url = 'world'
330
+ page.save
331
+ page.url.should == 'world'
332
+
333
+ page.auto_url = true
334
+ page.name = 'Another world'
335
+ page.url = 'world-two'
336
+ page.save
337
+ page.url.should == 'another-world'
338
+ end
339
+ end
340
+ end
341
+
342
+ describe '#full_url' do
343
+ it 'should be generated from url and ancestors' do
344
+ page = Page.create name: 'Hello'
345
+ page.full_url.should == '/hello'
346
+
347
+ page_two = Page.create name: 'World', parent: page
348
+ page_two.full_url.should == '/hello/world'
349
+ end
350
+
351
+ context 'if parent or url has been changed' do
352
+ it 'should update full_url' do
353
+ page = Page.create name: 'Change url', url: 'change-url', auto_url: false
354
+ child_page = Page.create name: 'Child page', url: 'child', auto_url: false, parent: page
355
+ page.reload
356
+
357
+ page.full_url.should == '/change-url'
358
+ child_page.full_url.should == '/change-url/child'
359
+
360
+ page.url = 'another-change-url'
361
+ page.save
362
+ page.full_url.should == '/another-change-url'
363
+
364
+ child_page.reload
365
+ child_page.full_url.should == '/another-change-url/child'
366
+ end
367
+ end
368
+
369
+ context 'if parent is root or nil' do
370
+ it 'should be as /self.url' do
371
+ page = Page.create name: 'Page', url: 'page', auto_url: false, parent_id: nil
372
+ page.full_url.should == '/page'
373
+
374
+ parent = Page.create name: 'Parent'
375
+ page.parent = parent
376
+ page.save
377
+
378
+ page.full_url.should == '/parent/page'
379
+
380
+ page.parent = nil
381
+ page.save
382
+ page.full_url.should == '/page'
383
+ end
384
+ end
385
+ end
386
+
387
+ describe 'method_missing' do
388
+ context 'Getting and setting field value' do
389
+ before :each do
390
+ @template = Template.create name: 'Page', code_name: 'page_template'
391
+ @page = Page.create name: 'No method', template: @template
392
+ @field = Field.create name: 'Content', code_name: 'desc', template: @template, type_value: 'text'
393
+ end
394
+
395
+ it 'should return value of type_value for missing method' do
396
+ @field.set_value_for(@page, 'my world')
397
+ @page.desc.should == 'my world'
398
+ end
399
+
400
+ it 'should set value for type_value for missing method' do
401
+ @page.desc = 'my world 2'
402
+ @field.get_value_for(@page).should == 'my world 2'
403
+ end
404
+ end
405
+
406
+ it 'should find page in branch template if no field found' do
407
+ brand_template = Template.create name: 'Brand', code_name: 'brand'
408
+ series_template = Template.create name: 'Series', code_name: 'series', parent: brand_template
409
+
410
+ brand_page = Page.create name: 'Zanussi', template: brand_template
411
+ series_page = Page.create name: 'Fresco', template: series_template, parent: brand_page
412
+ brand_page.reload
413
+
414
+ series_page.brand.should == brand_page
415
+ brand_page.series.should == [series_page]
416
+ end
417
+ end
418
+ end
419
+ end
420
+ end