storytime 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (359) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +10 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +17 -0
  7. data/Gemfile.lock +448 -0
  8. data/Guardfile +24 -0
  9. data/MIT-LICENSE +1 -1
  10. data/README.md +160 -0
  11. data/app/assets/{javascripts/storytime/subscriptions.js → images/storytime/.keep} +0 -0
  12. data/app/assets/images/storytime/storytime-logo-nav-light.png +0 -0
  13. data/app/assets/images/storytime/storytime-logo-nav.png +0 -0
  14. data/app/assets/images/storytime/storytime-logo.png +0 -0
  15. data/app/assets/javascripts/storytime/application.js +11 -3
  16. data/app/assets/javascripts/storytime/base.js.coffee +44 -6
  17. data/app/assets/javascripts/storytime/blog_posts.js.coffee +16 -0
  18. data/app/assets/javascripts/storytime/blogs.js.coffee +18 -0
  19. data/app/assets/javascripts/storytime/character_counter.js.coffee +26 -0
  20. data/app/assets/javascripts/storytime/contenteditable.js.coffee +15 -0
  21. data/app/assets/javascripts/storytime/custom_posts.js.coffee +16 -0
  22. data/app/assets/javascripts/storytime/editor.js.coffee +50 -134
  23. data/app/assets/javascripts/storytime/media.js.coffee +91 -22
  24. data/app/assets/javascripts/storytime/pages.js.coffee +16 -0
  25. data/app/assets/javascripts/storytime/posts.js.coffee +28 -1
  26. data/app/assets/javascripts/storytime/sites.js.coffee +1 -16
  27. data/app/assets/javascripts/storytime/snippets.js.coffee +6 -3
  28. data/app/assets/javascripts/storytime/tags.js.coffee +17 -0
  29. data/app/assets/javascripts/storytime/users.js.coffee +10 -0
  30. data/app/assets/javascripts/storytime/wysiwyg.js.coffee +183 -0
  31. data/app/assets/stylesheets/storytime/_buttons.scss +70 -0
  32. data/app/assets/stylesheets/storytime/_dropdowns.scss +5 -0
  33. data/app/assets/stylesheets/storytime/_forms.scss +3 -0
  34. data/app/assets/stylesheets/storytime/_list-group.scss +13 -0
  35. data/app/assets/stylesheets/storytime/_pagination.scss +14 -0
  36. data/app/assets/stylesheets/storytime/_panels.scss +8 -0
  37. data/app/assets/stylesheets/storytime/_tabs.scss +38 -0
  38. data/app/assets/stylesheets/storytime/_type.scss +13 -0
  39. data/app/assets/stylesheets/storytime/_wells.scss +14 -0
  40. data/app/assets/stylesheets/storytime/admin.scss +42 -0
  41. data/app/assets/stylesheets/storytime/application.scss +75 -0
  42. data/app/assets/stylesheets/storytime/{comments.css.scss → comments.scss} +0 -0
  43. data/app/assets/stylesheets/storytime/icons.scss +79 -0
  44. data/app/assets/stylesheets/storytime/layout.scss +21 -0
  45. data/app/assets/stylesheets/storytime/media.scss +65 -0
  46. data/app/assets/stylesheets/storytime/modals.scss +46 -0
  47. data/app/assets/stylesheets/storytime/navigation.scss +137 -0
  48. data/app/assets/stylesheets/storytime/posts.scss +76 -0
  49. data/app/assets/stylesheets/storytime/scroll-panels.scss +19 -0
  50. data/app/assets/stylesheets/storytime/snippets.scss +11 -0
  51. data/app/assets/stylesheets/storytime/{sites.css.scss → subscriptions.scss} +0 -0
  52. data/app/assets/stylesheets/storytime/versions.scss +21 -0
  53. data/app/controllers/storytime/application_controller.rb +36 -16
  54. data/app/controllers/storytime/blog_homepage_controller.rb +10 -0
  55. data/app/controllers/storytime/blogs_controller.rb +56 -0
  56. data/app/controllers/storytime/comments_controller.rb +5 -1
  57. data/app/controllers/storytime/dashboard/autosaves_controller.rb +7 -3
  58. data/app/controllers/storytime/dashboard/blog_posts_controller.rb +60 -0
  59. data/app/controllers/storytime/dashboard/blogs_controller.rb +66 -0
  60. data/app/controllers/storytime/dashboard/custom_posts_controller.rb +51 -0
  61. data/app/controllers/storytime/dashboard/media_controller.rb +9 -7
  62. data/app/controllers/storytime/dashboard/memberships_controller.rb +49 -0
  63. data/app/controllers/storytime/dashboard/pages_controller.rb +24 -0
  64. data/app/controllers/storytime/dashboard/posts_controller.rb +29 -38
  65. data/app/controllers/storytime/dashboard/roles_controller.rb +16 -2
  66. data/app/controllers/storytime/dashboard/sites_controller.rb +25 -11
  67. data/app/controllers/storytime/dashboard/snippets_controller.rb +19 -14
  68. data/app/controllers/storytime/dashboard/subscriptions_controller.rb +9 -5
  69. data/app/controllers/storytime/dashboard/users_controller.rb +24 -22
  70. data/app/controllers/storytime/dashboard_controller.rb +9 -3
  71. data/app/controllers/storytime/homepage_controller.rb +10 -0
  72. data/app/controllers/storytime/pages_controller.rb +30 -13
  73. data/app/controllers/storytime/posts_controller.rb +22 -53
  74. data/app/controllers/storytime/subscriptions_controller.rb +5 -4
  75. data/app/helpers/storytime/application_helper.rb +28 -7
  76. data/app/helpers/storytime/dashboard/sites_helper.rb +2 -5
  77. data/app/helpers/storytime/subscriptions_helper.rb +0 -7
  78. data/app/inputs/date_time_picker_input.rb +1 -1
  79. data/app/mailers/storytime/subscription_mailer.rb +1 -3
  80. data/app/models/concerns/storytime/post_comments.rb +17 -0
  81. data/app/models/concerns/storytime/post_excerpt.rb +14 -0
  82. data/app/models/concerns/storytime/post_featured_images.rb +8 -0
  83. data/app/models/concerns/storytime/post_partial_inheritance.rb +29 -0
  84. data/app/models/concerns/storytime/post_tags.rb +41 -0
  85. data/app/models/concerns/storytime/scoped_to_site.rb +11 -0
  86. data/app/models/storytime/action.rb +1 -0
  87. data/app/models/storytime/autosave.rb +7 -1
  88. data/app/models/storytime/blog.rb +16 -0
  89. data/app/models/storytime/blog_post.rb +12 -1
  90. data/app/models/storytime/comment.rb +4 -1
  91. data/app/models/storytime/media.rb +2 -0
  92. data/app/models/storytime/membership.rb +17 -0
  93. data/app/models/storytime/page.rb +0 -5
  94. data/app/models/storytime/permission.rb +26 -20
  95. data/app/models/storytime/post.rb +29 -82
  96. data/app/models/storytime/role.rb +12 -0
  97. data/app/models/storytime/site.rb +42 -12
  98. data/app/models/storytime/snippet.rb +3 -0
  99. data/app/models/storytime/subscription.rb +2 -1
  100. data/app/models/storytime/tag.rb +5 -1
  101. data/app/models/storytime/tagging.rb +1 -0
  102. data/app/models/storytime/version.rb +1 -0
  103. data/app/policies/admin_policy.rb +30 -0
  104. data/app/policies/storytime/comment_policy.rb +5 -1
  105. data/app/policies/storytime/membership_policy.rb +32 -0
  106. data/app/policies/storytime/post_policy.rb +6 -4
  107. data/app/policies/storytime/site_policy.rb +7 -2
  108. data/app/policies/storytime/snippet_policy.rb +3 -2
  109. data/app/policies/storytime/subscription_policy.rb +3 -2
  110. data/app/policies/user_policy.rb +2 -5
  111. data/app/views/kaminari/_first_page.html.erb +13 -0
  112. data/app/views/kaminari/_gap.html.erb +8 -0
  113. data/app/views/kaminari/_last_page.html.erb +13 -0
  114. data/app/views/kaminari/_next_page.html.erb +13 -0
  115. data/app/views/kaminari/_page.html.erb +12 -0
  116. data/app/views/kaminari/_paginator.html.erb +24 -0
  117. data/app/views/kaminari/_prev_page.html.erb +13 -0
  118. data/app/views/layouts/storytime/application.html.erb +1 -1
  119. data/app/views/layouts/storytime/dashboard.html.erb +22 -6
  120. data/app/views/storytime/application/storytime/_disqus_comment_counts.html.erb +14 -0
  121. data/app/views/storytime/application/storytime/_header.html.erb +3 -4
  122. data/app/views/storytime/application/storytime/_navigation.html.erb +14 -1
  123. data/app/views/storytime/blogs/_tags.html.erb +3 -0
  124. data/app/views/storytime/{posts/index.atom.builder → blogs/show.atom.builder} +1 -1
  125. data/app/views/storytime/{posts/index.html.erb → blogs/show.html.erb} +1 -1
  126. data/app/views/storytime/comments/_discourse.html.erb +18 -0
  127. data/app/views/storytime/comments/_disqus.html.erb +2 -2
  128. data/app/views/storytime/comments/_form.html.erb +2 -2
  129. data/app/views/storytime/dashboard/_navigation.html.erb +109 -41
  130. data/app/views/storytime/dashboard/_settings_tabs.html.erb +32 -0
  131. data/app/views/storytime/dashboard/autosaves/_autosave_info.html.erb +7 -4
  132. data/app/views/storytime/dashboard/blog_posts/_form.html.erb +157 -0
  133. data/app/views/storytime/dashboard/blog_posts/edit.html.erb +55 -0
  134. data/app/views/storytime/dashboard/blog_posts/new.html.erb +31 -0
  135. data/app/views/storytime/dashboard/blogs/_blog.html.erb +3 -0
  136. data/app/views/storytime/dashboard/blogs/_form.html.erb +25 -0
  137. data/app/views/storytime/dashboard/blogs/edit.json.jbuilder +1 -0
  138. data/app/views/storytime/dashboard/blogs/index.json.jbuilder +1 -0
  139. data/app/views/storytime/dashboard/blogs/new.json.jbuilder +1 -0
  140. data/app/views/storytime/dashboard/media/_form.html.erb +3 -3
  141. data/app/views/storytime/dashboard/media/{_gallery.html → _gallery.html.erb} +7 -4
  142. data/app/views/storytime/dashboard/media/_media.html.erb +6 -13
  143. data/app/views/storytime/dashboard/media/_modal.html.erb +3 -3
  144. data/app/views/storytime/dashboard/media/index.html.erb +15 -5
  145. data/app/views/storytime/dashboard/memberships/_form.html.erb +12 -0
  146. data/app/views/storytime/dashboard/memberships/_index.html.erb +39 -0
  147. data/app/views/storytime/dashboard/memberships/_membership.html.erb +12 -0
  148. data/app/views/storytime/dashboard/memberships/index.json.jbuilder +2 -0
  149. data/app/views/storytime/dashboard/memberships/save.json.jbuilder +1 -0
  150. data/app/views/storytime/dashboard/pages/_form.html.erb +88 -0
  151. data/app/views/storytime/dashboard/pages/_index_title.html.erb +1 -0
  152. data/app/views/storytime/dashboard/pages/_new_button.html.erb +1 -0
  153. data/app/views/storytime/dashboard/pages/edit.html.erb +49 -0
  154. data/app/views/storytime/dashboard/pages/new.html.erb +28 -0
  155. data/app/views/storytime/dashboard/posts/_form.html.erb +128 -122
  156. data/app/views/storytime/dashboard/posts/_image_toolbar.html.erb +32 -0
  157. data/app/views/storytime/dashboard/posts/_index_title.html.erb +1 -0
  158. data/app/views/storytime/dashboard/posts/_list.html.erb +23 -24
  159. data/app/views/storytime/dashboard/posts/_new_button.html.erb +10 -0
  160. data/app/views/storytime/dashboard/posts/edit.html.erb +56 -13
  161. data/app/views/storytime/dashboard/posts/index.html.erb +56 -7
  162. data/app/views/storytime/dashboard/posts/new.html.erb +29 -8
  163. data/app/views/storytime/dashboard/roles/_form.html.erb +41 -0
  164. data/app/views/storytime/dashboard/roles/edit.json.jbuilder +1 -0
  165. data/app/views/storytime/dashboard/sites/_form.html.erb +31 -15
  166. data/app/views/storytime/dashboard/sites/new.html.erb +21 -8
  167. data/app/views/storytime/dashboard/sites/site.json.jbuilder +2 -0
  168. data/app/views/storytime/dashboard/snippets/_form.html.erb +26 -12
  169. data/app/views/storytime/dashboard/snippets/_index.html.erb +17 -0
  170. data/app/views/storytime/dashboard/snippets/_snippet.html.erb +12 -0
  171. data/app/views/storytime/dashboard/snippets/edit.json.jbuilder +1 -0
  172. data/app/views/storytime/dashboard/snippets/index.json.jbuilder +4 -0
  173. data/app/views/storytime/dashboard/snippets/new.json.jbuilder +1 -0
  174. data/app/views/storytime/dashboard/subscriptions/_form.html.erb +19 -0
  175. data/app/views/storytime/dashboard/subscriptions/_index.html.erb +19 -0
  176. data/app/views/storytime/dashboard/subscriptions/_subscription.html.erb +9 -10
  177. data/app/views/storytime/dashboard/subscriptions/form.json.jbuilder +1 -0
  178. data/app/views/storytime/dashboard/subscriptions/index.json.jbuilder +1 -0
  179. data/app/views/storytime/dashboard/users/_edit.html.erb +26 -0
  180. data/app/views/storytime/dashboard/users/_new.html.erb +25 -0
  181. data/app/views/storytime/dashboard/users/edit.json.jbuilder +2 -0
  182. data/app/views/storytime/dashboard/users/new.json.jbuilder +2 -0
  183. data/app/views/storytime/dashboard/versions/_version.html.erb +14 -0
  184. data/app/views/storytime/dashboard/versions/_versions_info.html.erb +1 -16
  185. data/app/views/storytime/pages/show.html.erb +1 -1
  186. data/app/views/storytime/posts/_post.html.erb +8 -0
  187. data/app/views/storytime/posts/_tags.html.erb +1 -1
  188. data/app/views/storytime/posts/show.html.erb +1 -1
  189. data/app/views/storytime/sites/_google_analytics_code.html.erb +2 -2
  190. data/app/views/storytime/snippets/_snippet.html.erb +9 -0
  191. data/app/views/storytime/subscription_mailer/new_post_email.html.erb +2 -2
  192. data/app/views/storytime/subscription_mailer/new_post_email.text.erb +2 -2
  193. data/app/views/storytime/subscriptions/_form.html.erb +0 -1
  194. data/app/views/storytime/subscriptions/_modal.html.erb +18 -10
  195. data/bin/rails +12 -0
  196. data/bin/storytime +4 -0
  197. data/circle.yml +3 -0
  198. data/config/initializers/storytime_admin.rb +3 -0
  199. data/config/initializers/url_for_patch.rb +2 -37
  200. data/config/locales/en.yml +33 -13
  201. data/config/routes.rb +47 -19
  202. data/db/migrate/20150128185746_seed_new_actions_and_permissions.rb +9 -0
  203. data/db/migrate/20150206201847_add_site_id_to_storytime_post.rb +7 -0
  204. data/db/migrate/20150206201919_add_site_id_to_storytime_snippet.rb +7 -0
  205. data/db/migrate/20150206201931_add_site_id_to_storytime_tag.rb +7 -0
  206. data/db/migrate/20150206205256_add_notification_fields_to_storytime_post.rb +6 -0
  207. data/db/migrate/20150216211257_add_subdomain_to_storytime_sites.rb +5 -0
  208. data/db/migrate/20150216225045_add_site_to_storytime_media.rb +6 -0
  209. data/db/migrate/20150219210528_remove_root_page_content_from_storytime_sites.rb +12 -0
  210. data/db/migrate/20150220184902_add_blog_id_to_posts.rb +6 -0
  211. data/db/migrate/20150224192138_add_homepage_path_to_storytime_sites.rb +5 -0
  212. data/db/migrate/20150224193151_add_subscription_email_from_to_storytime_sites.rb +5 -0
  213. data/db/migrate/20150224193551_add_layout_to_storytime_sites.rb +5 -0
  214. data/db/migrate/20150224194559_add_disqus_forum_shortname_to_storytime_sites.rb +5 -0
  215. data/db/migrate/20150224212453_remove_homepage_path_from_storytime_sites.rb +5 -0
  216. data/db/migrate/20150225143516_add_site_id_to_storytime_autosaves.rb +6 -0
  217. data/db/migrate/20150225143826_add_site_id_to_storytime_comments.rb +6 -0
  218. data/db/migrate/20150225145119_add_site_id_to_storytime_versions.rb +6 -0
  219. data/db/migrate/20150225145316_add_site_id_to_storytime_taggings.rb +6 -0
  220. data/db/migrate/20150225145608_update_storytime_site_id_columns.rb +11 -0
  221. data/db/migrate/20150225164232_add_site_id_to_storytime_permissions.rb +6 -0
  222. data/db/migrate/20150225212917_create_storytime_memberships.rb +11 -0
  223. data/db/migrate/20150225213535_create_memberships_for_storytime_users.rb +8 -0
  224. data/db/migrate/20150226201739_add_custom_domain_to_storytime_sites.rb +5 -0
  225. data/db/migrate/20150302171500_add_site_id_to_storytime_media.rb +8 -0
  226. data/db/migrate/20150302171722_set_site_layout.rb +8 -0
  227. data/db/migrate/20150302185138_remove_storytime_role_id_from_users.rb +5 -0
  228. data/db/migrate/20150302192525_transfer_posts_to_blogs.rb +8 -0
  229. data/db/migrate/20150302192759_seed_permissions.rb +9 -0
  230. data/db/migrate/20150331162329_add_discourse_name_to_storytime_sites.rb +5 -0
  231. data/db/migrate/20150402161427_remove_subdomain_from_storytime_site.rb +5 -0
  232. data/lib/generators/storytime/install_generator.rb +17 -0
  233. data/lib/generators/storytime/views_generator.rb +21 -9
  234. data/lib/generators/templates/storytime.rb +70 -27
  235. data/lib/storytime/cli/install.rb +274 -0
  236. data/lib/storytime/cli.rb +28 -0
  237. data/lib/storytime/concerns/current_site.rb +10 -0
  238. data/lib/storytime/concerns/has_versions.rb +22 -3
  239. data/lib/storytime/concerns/storytime_user.rb +31 -7
  240. data/lib/storytime/constraints/blog_constraint.rb +11 -0
  241. data/lib/storytime/constraints/blog_homepage_constraint.rb +11 -0
  242. data/lib/storytime/constraints/page_constraint.rb +13 -0
  243. data/lib/storytime/constraints/page_homepage_constraint.rb +11 -0
  244. data/lib/storytime/engine.rb +43 -14
  245. data/lib/storytime/generators/initializer.rb +45 -0
  246. data/lib/storytime/migrators/v1.rb +122 -0
  247. data/lib/storytime/post_notifier.rb +19 -0
  248. data/lib/storytime/post_url_handler.rb +47 -0
  249. data/lib/storytime/storytime_helpers.rb +12 -0
  250. data/lib/storytime/version.rb +1 -1
  251. data/lib/storytime.rb +57 -56
  252. data/screenshots/admin.png +0 -0
  253. data/screenshots/media.png +0 -0
  254. data/screenshots/page-list.png +0 -0
  255. data/screenshots/post-editor.png +0 -0
  256. data/screenshots/site-settings.png +0 -0
  257. data/screenshots/text-snippets.png +0 -0
  258. data/screenshots/user-management.png +0 -0
  259. data/spec/controllers/dashboard_controller_spec.rb +3 -1
  260. data/{app/assets/stylesheets/storytime/subscriptions.css.scss → spec/dummy/app/assets/images/.keep} +0 -0
  261. data/spec/dummy/app/assets/javascripts/application.js +3 -0
  262. data/spec/dummy/app/controllers/application_controller.rb +5 -1
  263. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  264. data/spec/dummy/app/controllers/storytime_admin/widgets_controller.rb +5 -0
  265. data/spec/dummy/app/mailers/.keep +0 -0
  266. data/spec/dummy/app/models/.keep +0 -0
  267. data/spec/dummy/app/models/concerns/.keep +0 -0
  268. data/spec/dummy/app/models/user.rb +5 -1
  269. data/spec/dummy/app/models/video_post.rb +2 -0
  270. data/spec/dummy/app/models/widget.rb +3 -0
  271. data/spec/dummy/app/views/layouts/application.html.erb +1 -1
  272. data/spec/dummy/app/views/storytime/dashboard/posts/_video_post_fields.html.erb +1 -0
  273. data/spec/dummy/app/views/widgets/storytime/dashboard/admin/_headers.html.erb +1 -0
  274. data/spec/dummy/app/views/widgets/storytime/dashboard/admin/_row.html.erb +1 -0
  275. data/spec/dummy/config/database.yml +9 -5
  276. data/spec/dummy/config/environments/test.rb +1 -0
  277. data/spec/dummy/config/initializers/devise.rb +1 -1
  278. data/spec/dummy/config/initializers/session_store.rb +1 -1
  279. data/spec/dummy/config/initializers/storytime.rb +7 -14
  280. data/spec/dummy/db/development.sqlite3 +0 -0
  281. data/spec/dummy/db/migrate/20150127172846_create_widgets.rb +9 -0
  282. data/spec/dummy/db/migrate/20150206203824_add_video_url_to_storytime_posts.rb +5 -0
  283. data/spec/dummy/db/schema.rb +76 -21
  284. data/spec/dummy/db/test.sqlite3 +0 -0
  285. data/spec/dummy/lib/assets/.keep +0 -0
  286. data/spec/dummy/log/.keep +0 -0
  287. data/spec/factories/comment_factories.rb +1 -0
  288. data/spec/factories/membership_factories.rb +7 -0
  289. data/spec/factories/site_factories.rb +3 -2
  290. data/spec/factories/user_factories.rb +3 -3
  291. data/spec/factories/widget_factories.rb +5 -0
  292. data/spec/features/blogs_spec.rb +28 -0
  293. data/spec/features/comments_spec.rb +8 -9
  294. data/spec/features/dashboard/media_spec.rb +14 -30
  295. data/spec/features/dashboard/memberships_spec.rb +58 -0
  296. data/spec/features/dashboard/pages_spec.rb +67 -44
  297. data/spec/features/dashboard/posts_spec.rb +84 -62
  298. data/spec/features/dashboard/sites_spec.rb +28 -23
  299. data/spec/features/dashboard/snippets_spec.rb +44 -44
  300. data/spec/features/dashboard/subscription_spec.rb +36 -28
  301. data/spec/features/dashboard/users_spec.rb +48 -29
  302. data/spec/features/pages_spec.rb +2 -2
  303. data/spec/features/posts_spec.rb +2 -20
  304. data/spec/features/subscription_spec.rb +4 -4
  305. data/spec/models/post_spec.rb +26 -17
  306. data/spec/policies/comment_policy_spec.rb +22 -6
  307. data/spec/policies/post_policy_spec.rb +21 -3
  308. data/spec/requests/routings_spec.rb +27 -17
  309. data/spec/spec_helper.rb +12 -1
  310. data/spec/support/database_cleaner.rb +5 -5
  311. data/spec/support/domains.rb +18 -0
  312. data/spec/support/feature_macros.rb +18 -9
  313. data/storytime.gemspec +59 -0
  314. data/vendor/assets/javascripts/.DS_Store +0 -0
  315. data/vendor/assets/javascripts/codemirror/modes/css.js +717 -0
  316. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +120 -0
  317. data/vendor/assets/javascripts/codemirror/modes/javascript.js +686 -0
  318. data/vendor/assets/javascripts/codemirror/modes/liquid.js +40 -0
  319. data/vendor/assets/javascripts/codemirror/modes/overlay.js +85 -0
  320. data/vendor/assets/javascripts/codemirror/{xml.js → modes/xml.js} +2 -2
  321. data/vendor/assets/javascripts/medium-editor.min.js +2450 -0
  322. data/vendor/assets/javascripts/phantom_js_bind_polyfill.js +24 -0
  323. data/vendor/assets/javascripts/tidy.js +30 -0
  324. data/vendor/assets/stylesheets/.DS_Store +0 -0
  325. data/vendor/assets/stylesheets/chosen-bootstrap-3.css +148 -0
  326. data/vendor/assets/stylesheets/{chosen.css.scss → chosen.scss} +1 -1
  327. data/vendor/assets/stylesheets/disable-transitions-for-test-env.css +7 -0
  328. data/vendor/assets/stylesheets/medium-editor-default.min.css +1 -0
  329. data/vendor/assets/stylesheets/medium-editor.min.css +1 -0
  330. metadata +297 -47
  331. data/app/assets/stylesheets/storytime/admin.css.scss +0 -121
  332. data/app/assets/stylesheets/storytime/application.css.scss +0 -22
  333. data/app/assets/stylesheets/storytime/layout.css.scss +0 -17
  334. data/app/assets/stylesheets/storytime/media.css.scss +0 -68
  335. data/app/assets/stylesheets/storytime/pagination.css.scss +0 -4
  336. data/app/assets/stylesheets/storytime/posts.css.scss +0 -30
  337. data/app/assets/stylesheets/storytime/versions.css.scss +0 -21
  338. data/app/helpers/storytime/dashboard/posts_helper.rb +0 -21
  339. data/app/views/storytime/blog_posts/_blog_post.html.erb +0 -8
  340. data/app/views/storytime/dashboard/posts/_basic_new_post_button.html.erb +0 -3
  341. data/app/views/storytime/dashboard/posts/_new_post_dropdown_button.html.erb +0 -10
  342. data/app/views/storytime/dashboard/sites/edit.html.erb +0 -25
  343. data/app/views/storytime/dashboard/snippets/_list.html.erb +0 -21
  344. data/app/views/storytime/dashboard/snippets/edit.html.erb +0 -13
  345. data/app/views/storytime/dashboard/snippets/index.html.erb +0 -13
  346. data/app/views/storytime/dashboard/snippets/new.html.erb +0 -12
  347. data/app/views/storytime/dashboard/subscriptions/edit.html.erb +0 -10
  348. data/app/views/storytime/dashboard/subscriptions/index.html.erb +0 -19
  349. data/app/views/storytime/dashboard/subscriptions/new.html.erb +0 -9
  350. data/app/views/storytime/dashboard/users/_user.html.erb +0 -11
  351. data/app/views/storytime/dashboard/users/edit.html.erb +0 -10
  352. data/app/views/storytime/dashboard/users/index.html.erb +0 -22
  353. data/app/views/storytime/dashboard/users/new.html.erb +0 -11
  354. data/spec/lib/storytime_spec.rb +0 -23
  355. data/vendor/assets/javascripts/codemirror/codemirror.js +0 -7831
  356. data/vendor/assets/javascripts/summernote.js +0 -5338
  357. data/vendor/assets/stylesheets/codemirror/codemirror.css +0 -309
  358. data/vendor/assets/stylesheets/codemirror/monokai.css +0 -31
  359. data/vendor/assets/stylesheets/summernote.css +0 -1
@@ -5,76 +5,99 @@ describe "In the dashboard, Pages" do
5
5
  login_admin
6
6
  end
7
7
 
8
- it "lists pages" do
9
- post = FactoryGirl.create(:post)
10
- 3.times{ FactoryGirl.create(:page) }
11
- visit url_for([:dashboard, Storytime::Post, type: Storytime::Page.type_name])
12
-
13
- Storytime::Page.all.each do |p|
14
- page.should have_link(p.title, href: url_for([:edit, :dashboard, p, only_path: true]))
15
- page.should_not have_content(p.content)
8
+ describe "index" do
9
+ before do
10
+ 3.times{ FactoryGirl.create(:page, site: current_site) }
11
+ 3.times{ FactoryGirl.create(:page, published_at: nil, site: current_site) }
12
+ end
13
+
14
+ let!(:other_site_page){ FactoryGirl.create(:page) }
15
+
16
+ it "lists draft pages" do
17
+ visit dashboard_pages_path
18
+
19
+ current_site.pages.each do |p|
20
+ expect(page).to have_link_to_post(p) if p.published_at.nil?
21
+ expect(page).not_to have_link_to_post(p) if p.published_at.present?
22
+ expect(page).not_to have_content(p.content)
23
+ end
24
+
25
+ expect(page).not_to have_link_to_post(other_site_page)
16
26
  end
17
27
 
18
- page.should_not have_link(post.title, href: url_for([:edit, :dashboard, post, only_path: true]))
28
+ it "lists published pages" do
29
+ visit dashboard_pages_path(published: true)
30
+
31
+ # need the type designation so Blogs, which are Page subclasses, don't show up in the query
32
+ current_site.pages.where(type: "Storytime::Page").each do |p|
33
+ expect(page).not_to have_link_to_post(p) if p.published_at.nil?
34
+ expect(page).to have_link_to_post(p) if p.published_at.present?
35
+ expect(page).not_to have_content(p.content)
36
+ end
37
+
38
+ expect(page).not_to have_link_to_post(other_site_page)
39
+ end
19
40
  end
20
41
 
21
- it "creates a page" do
22
- Storytime::Page.count.should == 0
23
- media = FactoryGirl.create(:media)
42
+ it "creates a page", js: true do
43
+ page_count = Storytime::Page.count
44
+
45
+ visit new_dashboard_page_path
24
46
 
25
- visit url_for([:new, :dashboard, :post, type: Storytime::Page.type_name, only_path: true])
26
- fill_in "post_title", with: "The Story"
27
- fill_in "post_draft_content", with: "It was a dark and stormy night..."
28
- find("#featured_media_id").set media.id
47
+ find('#post-title-input').set("The Page")
48
+ find('#medium-editor-post').set("The content of my page")
29
49
 
50
+ click_link "Save / Publish"
30
51
  click_button "Save Draft"
31
52
 
32
- page.should have_content(I18n.t('flash.posts.create.success'))
33
- Storytime::Page.count.should == 1
53
+ expect(page).to have_content(I18n.t('flash.posts.create.success'))
54
+ expect(Storytime::Page.count).to eq(page_count + 1)
34
55
 
35
56
  pg = Storytime::Page.last
36
- pg.title.should == "The Story"
37
- pg.draft_content.should == "It was a dark and stormy night..."
38
- pg.user.should == current_user
39
- pg.should_not be_published
40
- pg.type.should == "Storytime::Page"
41
- pg.featured_media.should == media
57
+ expect(pg.title).to eq("The Page")
58
+ expect(pg.draft_content).to eq("<p>The content of my page</p>")
59
+ expect(pg.user).to eq(current_user)
60
+ expect(pg.site).to eq(current_site)
61
+ expect(pg.type).to eq("Storytime::Page")
62
+ expect(pg.slug).to eq("The Page".parameterize)
63
+ expect(pg).to_not be_published
42
64
  end
43
65
 
44
- it "updates a page" do
45
- pg = FactoryGirl.create(:page, published_at: nil)
66
+ it "updates a page", js: true do
67
+ pg = FactoryGirl.create(:page, site: current_site, published_at: nil)
46
68
  original_creator = pg.user
47
- Storytime::Page.count.should == 1
69
+ page_count = Storytime::Page.count
70
+
71
+ visit edit_dashboard_page_path(pg)
72
+ find('#post-title-input').set("The Story")
73
+ find('#medium-editor-post').set("It was a dark and stormy night...")
48
74
 
49
- visit url_for([:edit, :dashboard, pg])
50
- fill_in "post_title", with: "The Story"
51
- fill_in "post_draft_content", with: "It was a dark and stormy night..."
75
+ click_link "advanced-settings-panel-toggle"
52
76
  click_button "Save Draft"
53
77
 
54
- page.should have_content(I18n.t('flash.posts.update.success'))
55
- Storytime::Page.count.should == 1
78
+ expect(page).to have_content(I18n.t('flash.posts.update.success'))
79
+ expect(Storytime::Page.count).to eq(page_count)
56
80
 
57
81
  pg = Storytime::Page.last
58
- pg.title.should == "The Story"
59
- pg.draft_content.should == "It was a dark and stormy night..."
60
- pg.user.should == original_creator
61
- pg.should_not be_published
62
- pg.type.should == "Storytime::Page"
82
+ expect(pg.title).to eq("The Story")
83
+ expect(pg.draft_content).to eq("<p>It was a dark and stormy night...</p>")
84
+ expect(pg.user).to eq(original_creator)
85
+ expect(pg.type).to eq("Storytime::Page")
86
+ expect(pg).to_not be_published
63
87
  end
64
88
 
65
89
  it "deletes a page", js: true do
66
- 3.times{|i| FactoryGirl.create(:page) }
67
- expect(Storytime::Page.count).to eq(3)
90
+ storytime_page = FactoryGirl.create(:page, site: current_site)
91
+ page_count = Storytime::Page.count
68
92
 
69
- storytime_page = Storytime::Page.first
70
- visit url_for([:edit, :dashboard, storytime_page, type: Storytime::Page.type_name, only_path: true])
93
+ visit edit_dashboard_page_path(storytime_page)
71
94
 
95
+ click_button "post-utilities"
72
96
  click_link "Delete"
73
97
 
74
- expect { storytime_page.reload }.to raise_error
75
-
76
98
  expect(page).to_not have_content(storytime_page.title)
77
- expect(Storytime::Page.count).to eq(2)
99
+ expect { storytime_page.reload }.to raise_error
100
+ expect(Storytime::Page.count).to eq(page_count - 1)
78
101
  end
79
102
 
80
103
  end
@@ -1,121 +1,143 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "In the dashboard, Posts" do
4
- before{ login_admin }
4
+ before do
5
+ login_admin
6
+ end
5
7
 
6
- it "lists posts" do
7
- 3.times{ FactoryGirl.create(:post) }
8
+ it "lists draft posts" do
9
+ blog = @current_site.blogs.first
10
+ 3.times{ FactoryGirl.create(:post, blog: blog, site: @current_site, published_at: nil) }
11
+ 3.times{ FactoryGirl.create(:post, blog: blog, site: @current_site, published_at: 2.hours.ago) }
8
12
  FactoryGirl.create(:post)
9
13
  static_page = FactoryGirl.create(:page)
10
- visit url_for([:dashboard, Storytime::Post, type: Storytime::BlogPost.type_name, only_path: true])
14
+
15
+ visit url_for([storytime, :dashboard, blog, :blog_page_post_index, only_path: true])
11
16
 
12
- within "#list" do
13
- Storytime::Post.primary_feed.each do |p|
14
- expect(page).to have_content(p.title)
17
+ within "#main" do
18
+ blog.posts.each do |p|
19
+ expect(page).to have_content(p.title) if p.published_at.nil?
20
+ expect(page).not_to have_content(p.title) if p.published_at.present?
15
21
  end
16
22
 
17
23
  expect(page).not_to have_content(static_page.title)
18
24
  end
19
25
  end
20
26
 
21
- it "creates a post" do
22
- Storytime::BlogPost.count.should == 0
27
+ it "creates a post", js: true do
28
+ post_count = Storytime::BlogPost.count
23
29
  media = FactoryGirl.create(:media)
30
+ Rails.logger.warn "==> STARTING CREATE POST"
31
+ visit url_for([:new, :dashboard, @current_site.blogs.first, :blog_post, only_path: true])
24
32
 
25
- visit url_for([:new, :dashboard, :post])
26
- fill_in "post_title", with: "The Story"
27
- fill_in "post_excerpt", with: "It was a dark and stormy night..."
28
- fill_in "post_draft_content", with: "It was a dark and stormy night..."
29
- find("#featured_media_id").set media.id
30
- click_button "Save Draft"
33
+ find('#post-title-input').set("The Story")
34
+ find('#medium-editor-post').set("It was a dark and stormy night...")
35
+
36
+ click_link "Save / Publish"
37
+
38
+ fill_in "blog_post_excerpt", with: "It was a dark and stormy night..."
39
+ find("#featured_media_id", visible: false).set media.id
40
+
41
+ click_button "save-draft-submit"
31
42
 
32
- page.should have_content(I18n.t('flash.posts.create.success'))
33
- Storytime::BlogPost.count.should == 1
43
+ expect(page).to have_content(I18n.t('flash.posts.create.success'))
44
+ expect(Storytime::BlogPost.count).to eq(post_count + 1)
34
45
 
35
46
  post = Storytime::BlogPost.last
36
- post.title.should == "The Story"
37
- post.draft_content.should == "It was a dark and stormy night..."
38
- post.user.should == current_user
39
- post.should_not be_published
40
- post.type.should == "Storytime::BlogPost"
41
- post.featured_media.should == media
47
+ expect(post.title).to eq("The Story")
48
+ expect(post.draft_content).to eq("<p>It was a dark and stormy night...</p>")
49
+ expect(post.user).to eq(current_user)
50
+ expect(post.type).to eq("Storytime::BlogPost")
51
+ expect(post.featured_media).to eq(media)
52
+ expect(post).to_not be_published
42
53
  end
43
54
 
44
55
  it "saves a post when previewing a new post", js: true do
45
- Storytime::BlogPost.count.should == 0
56
+ post_count = Storytime::BlogPost.count
46
57
 
47
- visit url_for([:new, :dashboard, :post, only_path: true])
48
- fill_in "post_title", with: "Snow Crash"
49
- fill_in "post_excerpt", with: "The Deliverator belongs to an elite order, a hallowed sub-category."
58
+ visit url_for([:new, :dashboard, @current_site.blogs.first, :blog_post, only_path: true])
50
59
 
51
- # Use find(".note-editable").set instead of fill_in "post_draft_content" because of Summernote (js)
52
- find(".note-editable").set "The Deliverator belongs to an elite order, a hallowed sub-category."
60
+ find('#post-title-input').set("Snow Crash")
61
+ find('#medium-editor-post').set("It was a dark and stormy night...")
62
+ find('#blog_post_excerpt', visible: false).set("It was a dark and stormy night...")
63
+
53
64
  click_button "Preview"
54
65
 
55
- page.should have_content(I18n.t('flash.posts.create.success'))
56
- Storytime::BlogPost.count.should == 1
66
+ expect(page).to have_content(I18n.t('flash.posts.create.success'))
67
+ expect(Storytime::BlogPost.count).to eq(post_count + 1)
57
68
 
58
69
  post = Storytime::BlogPost.last
59
- post.title.should == "Snow Crash"
60
- post.draft_content.should == "<p>The Deliverator belongs to an elite order, a hallowed sub-category.</p>"
61
- post.user.should == current_user
62
- post.should_not be_published
63
- post.type.should == "Storytime::BlogPost"
70
+ expect(post.title).to eq("Snow Crash")
71
+ expect(post.draft_content).to eq("<p>It was a dark and stormy night...</p>")
72
+ expect(post.user).to eq(current_user)
73
+ expect(post.type).to eq("Storytime::BlogPost")
74
+ expect(post).to_not be_published
64
75
  end
65
76
 
66
77
  it "autosaves a post when editing", js: true do
67
- post = FactoryGirl.create(:post, published_at: nil, title: "A Scandal in Bohemia",
78
+ blog = @current_site.blogs.first
79
+ post = FactoryGirl.create(:post, blog: blog, site: @current_site, published_at: nil,
80
+ title: "A Scandal in Bohemia",
68
81
  draft_content: "To Sherlock Holmes she was always the woman.")
82
+
69
83
  original_creator = post.user
70
- Storytime::BlogPost.count.should == 1
84
+ post_count = Storytime::BlogPost.count
71
85
 
72
- post.autosave.should == nil
86
+ expect(post.autosave).to be_nil
73
87
 
74
88
  visit url_for([:edit, :dashboard, post, only_path: true])
75
89
 
76
- page.execute_script "Storytime.instance.editor.autosavePostForm()"
90
+ find('#medium-editor-post').set("Some content to autosave")
91
+
92
+ page.execute_script "Storytime.instance.editor.editor.autosavePostForm()"
93
+
94
+ expect(page).to have_content("Draft saved at")
77
95
 
78
96
  visit url_for([:edit, :dashboard, post, only_path: true])
79
97
 
80
- page.should have_content("View the autosave.")
98
+ expect(page).to have_content("View the autosave")
81
99
 
82
100
  post.reload
83
101
  expect(post.autosave).not_to be_nil
84
- expect(post.autosave.content).to eq("To Sherlock Holmes she was always the woman.")
102
+ expect(post.autosave.content).to eq("<p>Some content to autosave</p>")
103
+ expect(Storytime::BlogPost.count).to eq(post_count)
85
104
  end
86
105
 
87
- it "updates a post" do
88
- post = FactoryGirl.create(:post, published_at: nil)
106
+ it "updates a post", js: true do
107
+ blog = @current_site.blogs.first
108
+ post = FactoryGirl.create(:post, blog: blog, site: @current_site, published_at: nil)
89
109
  original_creator = post.user
90
- Storytime::BlogPost.count.should == 1
110
+ post_count = Storytime::BlogPost.count
111
+ # page.driver.debug
91
112
 
92
113
  visit url_for([:edit, :dashboard, post, only_path: true])
93
- fill_in "post_title", with: "The Story"
94
- fill_in "post_draft_content", with: "It was a dark and stormy night..."
114
+ find('#post-title-input').set("The Story")
115
+ find('#medium-editor-post').set("It was a dark and stormy night...")
116
+ click_link "advanced-settings-panel-toggle"
95
117
  click_button "Save Draft"
96
-
97
- page.should have_content(I18n.t('flash.posts.update.success'))
98
- Storytime::BlogPost.count.should == 1
99
118
 
100
- post = Storytime::BlogPost.last
101
- post.title.should == "The Story"
102
- post.draft_content.should == "It was a dark and stormy night..."
103
- post.user.should == original_creator
104
- post.should_not be_published
119
+ expect(page).to have_content(I18n.t('flash.posts.update.success'))
120
+ expect(Storytime::BlogPost.count).to eq(post_count)
121
+
122
+ post = post.reload
123
+ post.draft_content = nil # clear the cached copy of draft_content so it reloads
124
+ expect(post.title).to eq("The Story")
125
+ expect(post.draft_content).to eq("<p>It was a dark and stormy night...</p>")
126
+ expect(post.user).to eq(original_creator)
127
+ expect(post).to_not be_published
105
128
  end
106
129
 
107
130
  it "deletes a post", js: true do
108
- 3.times{|i| FactoryGirl.create(:post) }
131
+ blog = @current_site.blogs.first
132
+ 3.times{ FactoryGirl.create(:post, blog: blog, site: @current_site) }
109
133
  expect(Storytime::BlogPost.count).to eq(3)
110
134
 
111
135
  post = Storytime::BlogPost.first
112
136
  visit url_for([:edit, :dashboard, post, only_path: true])
113
137
 
114
- click_link "Delete"
115
-
116
- expect { post.reload }.to raise_error
117
-
118
- expect(page).to_not have_content(post.title)
119
- expect(Storytime::Post.count).to eq(2)
138
+ expect{
139
+ click_button "post-utilities"
140
+ click_link "Delete"
141
+ }.to change(Storytime::BlogPost, :count).by(-1)
120
142
  end
121
143
  end
@@ -3,41 +3,46 @@ require 'spec_helper'
3
3
  describe "In the dashboard, Sites" do
4
4
 
5
5
  it "creates a site" do
6
- login FactoryGirl.create(:admin), true
7
- Storytime::Site.count.should == 0
8
-
6
+ login FactoryGirl.create(:user), true
7
+ expect(Storytime::Site.count).to eq(0)
8
+
9
9
  visit new_dashboard_site_path
10
+
10
11
  fill_in "site_title", with: "The Site"
11
- click_button "Create Site"
12
+ fill_in "site_custom_domain", with: "example.lvh.me"
13
+ fill_in "site_subscription_email_from", with: "test@example.com"
14
+
15
+ click_button "Save"
16
+
17
+ # since creating a site redirects you to a new domain, you are not logged in
18
+ fill_in "user_email", with: current_user.email
19
+ fill_in "user_password", with: current_user.password
20
+ click_on "Log in"
12
21
 
13
- page.should have_content(I18n.t('flash.sites.create.success'))
14
- Storytime::Site.count.should == 1
22
+ expect(page).to have_content("Pages")
23
+ expect(Storytime::Site.count).to eq(1)
15
24
 
16
- page = Storytime::Site.last
17
- page.title.should == "The Site"
25
+ site = Storytime::Site.last
26
+ expect(site.title).to eq("The Site")
27
+ expect(site.custom_domain).to eq("example.lvh.me")
28
+ expect(site.subscription_email_from).to eq("test@example.com")
18
29
  end
19
30
 
20
31
  context "as a logged in user" do
21
32
  before{ login_admin }
22
33
 
23
- it "updates a site" do
24
- Storytime::Site.count.should == 1
34
+ it "updates a site", js: true do
35
+ site = Storytime::Site.last
25
36
 
26
- visit edit_dashboard_site_path(current_site)
37
+ visit storytime.dashboard_path
38
+ click_link "utility-menu-toggle"
39
+ click_link "site-settings-link"
27
40
  fill_in "site_title", with: "The Site's New Name"
28
- click_button "Update Site"
41
+ click_button "Save"
29
42
 
30
- page.should have_content(I18n.t('flash.sites.update.success'))
31
- Storytime::Site.count.should == 1
32
-
33
- s = Storytime::Site.last
34
- s.title.should == "The Site's New Name"
35
- end
36
-
37
- it "new redirects to edit if a site already exists" do
38
- visit new_dashboard_site_path
39
- page.should have_content("Site Settings")
40
- page.should have_content("Permissions")
43
+ expect(page).to have_content("Your changes were saved successfully")
44
+ site.reload
45
+ expect(site.title).to eq "The Site's New Name"
41
46
  end
42
47
  end
43
48
  end
@@ -5,63 +5,63 @@ describe "In the dashboard, Snippets" do
5
5
  login_admin
6
6
  end
7
7
 
8
- it "lists snippets" do
9
- 3.times{ FactoryGirl.create(:snippet) }
10
- visit url_for([:dashboard, Storytime::Snippet])
8
+ it "lists snippets", js: true do
9
+ 3.times{ FactoryGirl.create(:snippet, site: @current_site) }
10
+ visit storytime.dashboard_url
11
+ find("#snippets-link").trigger('click')
11
12
 
12
- Storytime::Snippet.all.each do |s|
13
- expect(page).to have_link(s.name, href: url_for([:edit, :dashboard, s, only_path: true]))
14
- expect(page).to_not have_content(s.content)
13
+ within "#storytime-modal" do
14
+ Storytime::Snippet.all.each do |s|
15
+ expect(page).to have_link(s.name, href: url_for([:edit, :dashboard, s, only_path: true]))
16
+ expect(page).to_not have_content(s.content)
17
+ end
15
18
  end
16
19
  end
17
20
 
18
- it "creates a snippet" do
19
- expect(Storytime::Snippet.count).to eq(0)
21
+ it "creates a snippet", js: true do
22
+ visit storytime.dashboard_url
23
+ find("#snippets-link").trigger('click')
24
+ click_link "new-snippet-link"
20
25
 
21
- visit url_for([:new, :dashboard, :snippet, only_path: true])
22
- fill_in "snippet_name", with: "jumbotron-text"
23
- fill_in "snippet_content", with: "Hooray Writing!"
24
-
25
- click_button "Create Snippet"
26
-
27
- expect(page).to have_content(I18n.t('flash.snippets.create.success'))
28
- expect(Storytime::Snippet.count).to eq(1)
26
+ within "#storytime-modal" do
27
+ fill_in "snippet_name", with: "jumbotron-text"
28
+ find("#medium-editor-snippet").set("Hooray Writing!")
29
+ click_button "Save"
30
+ end
29
31
 
30
- snippet = Storytime::Snippet.last
31
- expect(snippet.name).to eq("jumbotron-text")
32
- expect(snippet.content).to eq("Hooray Writing!")
32
+ within "#storytime-modal" do
33
+ expect(page).to have_content "jumbotron-text"
34
+ end
33
35
  end
34
36
 
35
- it "updates a snippet" do
36
- snippet = FactoryGirl.create(:snippet)
37
- expect(Storytime::Snippet.count).to eq(1)
38
-
39
- visit url_for([:edit, :dashboard, snippet])
40
- fill_in "snippet_name", with: "new-name"
41
- fill_in "snippet_content", with: "It was a dark and stormy night..."
42
- click_button "Update Snippet"
43
-
44
- expect(page).to have_content(I18n.t('flash.snippets.update.success'))
45
- expect(Storytime::Snippet.count).to eq(1)
37
+ it "updates a snippet", js: true do
38
+ snippet = FactoryGirl.create(:snippet, site: @current_site, content: "Test")
46
39
 
47
- snippet = Storytime::Snippet.last
48
- expect(snippet.name).to eq("new-name")
49
- expect(snippet.content).to eq("It was a dark and stormy night...")
50
- end
40
+ visit storytime.dashboard_url
41
+ find("#snippets-link").trigger('click')
51
42
 
52
- it "deletes a snippet" do
53
- 3.times{|i| FactoryGirl.create(:snippet) }
54
- expect(Storytime::Snippet.count).to eq(3)
43
+ click_link "edit-snippet-#{snippet.id}"
55
44
 
56
- snippet = Storytime::Snippet.first
57
- visit url_for([:edit, :dashboard, snippet, only_path: true])
45
+ fill_in "snippet_name", with: "new-name"
46
+ find("#medium-editor-snippet").set("It was a dark and stormy night...")
47
+ click_button "Save"
48
+
49
+ within "#storytime-modal" do
50
+ expect(page).to have_content "new-name"
51
+ end
52
+ end
58
53
 
59
- click_link "Delete"
54
+ it "deletes a snippet", js: true do
55
+ snippet = FactoryGirl.create :snippet, site: @current_site
60
56
 
61
- expect { snippet.reload }.to raise_error
57
+ visit storytime.dashboard_url
58
+ find("#snippets-link").trigger('click')
62
59
 
63
- expect(page).to_not have_content(snippet.name)
64
- expect(Storytime::Snippet.count).to eq(2)
60
+ find("#snippet_#{snippet.id}").hover()
61
+ click_link "delete_snippet_#{snippet.id}"
62
+
63
+ within "#storytime-modal" do
64
+ expect(page).to_not have_content snippet.name
65
+ end
65
66
  end
66
-
67
67
  end
@@ -5,48 +5,56 @@ describe "In the dashboard, Subscriptions" do
5
5
  login_admin
6
6
  end
7
7
 
8
- it "lists subscriptions" do
9
- 3.times{ FactoryGirl.create(:subscription) }
10
- visit url_for([:dashboard, Storytime::Subscription])
8
+ it "lists subscriptions", js: true do
9
+ 3.times{ FactoryGirl.create(:subscription, site: @current_site) }
10
+ visit storytime.dashboard_path
11
+ click_link "utility-menu-toggle"
12
+ click_link "subscriptions-link"
13
+ # wait_for_ajax
11
14
 
12
15
  Storytime::Subscription.all.each do |s|
13
- expect(page).to have_link("Edit", href: url_for([:edit, :dashboard, s]))
16
+ expect(page).to have_content s.email
14
17
  end
15
18
  end
16
19
 
17
- it "creates a subscription" do
18
- expect(Storytime::Subscription.count).to eq(0)
20
+ it "creates a subscription", js: true do
21
+ visit storytime.dashboard_path
22
+ click_link "utility-menu-toggle"
23
+ click_link "subscriptions-link"
24
+ # wait_for_ajax
25
+ click_link "new-subscription-link"
26
+ # wait_for_ajax
19
27
 
20
- visit url_for([:new, :dashboard, :subscription, only_path: true])
21
28
  fill_in "subscription_email", with: "some_random_email@example.com"
22
-
23
- click_button "Create Subscription"
24
-
25
- expect(page).to have_content(I18n.t('flash.subscriptions.create.success'))
26
- expect(Storytime::Subscription.count).to eq(1)
27
-
28
- subscription = Storytime::Subscription.last
29
-
30
- expect(subscription.email).to eq("some_random_email@example.com")
31
- expect(subscription.token).to_not eq(nil)
29
+ click_button "Save"
30
+
31
+ within "#storytime-modal" do
32
+ expect(page).to have_content "some_random_email@example.com"
33
+ end
32
34
  end
33
35
 
34
- it "updates a subscription" do
35
- subscription = FactoryGirl.create(:subscription)
36
+ it "updates a subscription", js: true do
37
+ subscription = FactoryGirl.create(:subscription, site: @current_site)
36
38
 
37
39
  expect(Storytime::Subscription.count).to eq(1)
38
40
  expect(subscription.subscribed?).to eq(true)
39
41
 
40
- visit url_for([:edit, :dashboard, subscription])
41
- fill_in "subscription_email", with: "johndoe@example.com"
42
- uncheck "subscription_subscribed"
43
- click_button "Update Subscription"
44
-
45
- expect(page).to have_content(I18n.t('flash.subscriptions.update.success'))
42
+ visit storytime.dashboard_path
43
+ click_link "utility-menu-toggle"
44
+ click_link "subscriptions-link"
45
+
46
+ within "#storytime-modal" do
47
+ click_link "edit-subscription-#{subscription.id}"
48
+ end
46
49
 
47
- subscription.reload
50
+ within "#storytime-modal" do
51
+ fill_in "subscription_email", with: "johndoe@example.com"
52
+ uncheck "subscription_subscribed"
53
+ click_button "Save"
54
+ end
48
55
 
49
- expect(subscription.email).to eq("johndoe@example.com")
50
- expect(subscription.subscribed?).to eq(false)
56
+ within "#storytime-modal" do
57
+ expect(page).to have_content "johndoe@example.com"
58
+ end
51
59
  end
52
60
  end