workarea-blog 3.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.eslintignore +2 -0
  4. data/.eslintrc +24 -0
  5. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  6. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  7. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  8. data/.gitignore +16 -0
  9. data/.rspec +2 -0
  10. data/.scss-lint.yml +188 -0
  11. data/.tailor +180 -0
  12. data/.yardopts +1 -0
  13. data/CHANGELOG.md +1123 -0
  14. data/CODE_OF_CONDUCT.md +3 -0
  15. data/CONTRIBUTING.md +3 -0
  16. data/Gemfile +7 -0
  17. data/LICENSE +52 -0
  18. data/README.md +140 -0
  19. data/Rakefile +42 -0
  20. data/app/assets/images/workarea/admin/blog/content_block_types/blog_entry.svg +1 -0
  21. data/app/assets/images/workarea/admin/blog/icons/blog.svg +1 -0
  22. data/app/assets/images/workarea/admin/blog/icons/blog_entry.svg +1 -0
  23. data/app/assets/images/workarea/admin/blog/icons/blog_post_comment.svg +1 -0
  24. data/app/assets/javascripts/workarea/storefront/blog/modules/blog_comment_placeholder.js +33 -0
  25. data/app/assets/stylesheets/workarea/admin/blog/components/_blog_entry_card.scss +14 -0
  26. data/app/assets/stylesheets/workarea/storefront/blog/components/_blog_entry.scss +91 -0
  27. data/app/assets/stylesheets/workarea/storefront/blog/components/_blog_entry_summary.scss +74 -0
  28. data/app/assets/stylesheets/workarea/storefront/blog/components/_featured_entry_content_block.scss +22 -0
  29. data/app/controllers/workarea/admin/application_controller.decorator +5 -0
  30. data/app/controllers/workarea/admin/content_blog_comments_controller.rb +54 -0
  31. data/app/controllers/workarea/admin/content_blog_entries_controller.rb +70 -0
  32. data/app/controllers/workarea/admin/content_blogs_controller.rb +56 -0
  33. data/app/controllers/workarea/admin/create_content_blog_entries_controller.rb +69 -0
  34. data/app/controllers/workarea/storefront/blog_comments_controller.rb +14 -0
  35. data/app/controllers/workarea/storefront/blog_entries_controller.rb +48 -0
  36. data/app/controllers/workarea/storefront/blogs_controller.rb +19 -0
  37. data/app/helpers/workarea/admin/blogs_helper.rb +61 -0
  38. data/app/models/workarea/content/blog.rb +26 -0
  39. data/app/models/workarea/content/blog_comment.rb +67 -0
  40. data/app/models/workarea/content/blog_entry.rb +35 -0
  41. data/app/models/workarea/content/fields/blog_entry_id.rb +11 -0
  42. data/app/models/workarea/content/fields/blog_id.rb +8 -0
  43. data/app/models/workarea/search/admin/content_blog.rb +27 -0
  44. data/app/models/workarea/search/admin/content_blog_entry.rb +37 -0
  45. data/app/queries/workarea/metadata/content_blog.rb +6 -0
  46. data/app/queries/workarea/metadata/content_blog_entry.rb +6 -0
  47. data/app/queries/workarea/search/admin_blog_entries.rb +24 -0
  48. data/app/queries/workarea/search/admin_blogs.rb +20 -0
  49. data/app/seeds/workarea/blog_comments_seeds.rb +26 -0
  50. data/app/seeds/workarea/blog_entry_seeds.rb +73 -0
  51. data/app/seeds/workarea/blog_seeds.rb +53 -0
  52. data/app/services/workarea/search/queries/blog_admin.rb +20 -0
  53. data/app/services/workarea/search/queries/blog_entry_admin.rb +13 -0
  54. data/app/services/workarea/set_navigable.decorator +10 -0
  55. data/app/view_models/workarea/admin/blog_comments_view_model.rb +45 -0
  56. data/app/view_models/workarea/admin/blog_entries_view_model.rb +31 -0
  57. data/app/view_models/workarea/admin/blog_entry_view_model.rb +29 -0
  58. data/app/view_models/workarea/admin/blog_search_view_model.rb +6 -0
  59. data/app/view_models/workarea/admin/blog_view_model.rb +13 -0
  60. data/app/view_models/workarea/storefront/blog_entry_view_model.rb +43 -0
  61. data/app/view_models/workarea/storefront/blog_index_view_model.rb +17 -0
  62. data/app/view_models/workarea/storefront/blog_view_model.rb +83 -0
  63. data/app/view_models/workarea/storefront/content_blocks/blog_entry_content_block_view_model.rb +63 -0
  64. data/app/views/workarea/admin/activities/_content_blog_comment_create.html.haml +12 -0
  65. data/app/views/workarea/admin/activities/_content_blog_comment_destroy.html.haml +9 -0
  66. data/app/views/workarea/admin/activities/_content_blog_comment_update.html.haml +10 -0
  67. data/app/views/workarea/admin/activities/_content_blog_create.html.haml +12 -0
  68. data/app/views/workarea/admin/activities/_content_blog_destroy.html.haml +10 -0
  69. data/app/views/workarea/admin/activities/_content_blog_entry_create.html.haml +12 -0
  70. data/app/views/workarea/admin/activities/_content_blog_entry_destroy.html.haml +10 -0
  71. data/app/views/workarea/admin/activities/_content_blog_entry_update.html.haml +10 -0
  72. data/app/views/workarea/admin/activities/_content_blog_update.html.haml +10 -0
  73. data/app/views/workarea/admin/blog/_dashboard_navigation.html.haml +1 -0
  74. data/app/views/workarea/admin/blog/_menu.html.haml +13 -0
  75. data/app/views/workarea/admin/content_blocks/_blog_entry_id.html.haml +4 -0
  76. data/app/views/workarea/admin/content_blocks/_blog_id.html.haml +3 -0
  77. data/app/views/workarea/admin/content_blog_comments/_summary.html.haml +24 -0
  78. data/app/views/workarea/admin/content_blog_comments/edit.html.haml +60 -0
  79. data/app/views/workarea/admin/content_blog_comments/index.html.haml +49 -0
  80. data/app/views/workarea/admin/content_blog_entries/_aux_navigation.html.haml +4 -0
  81. data/app/views/workarea/admin/content_blog_entries/_cards.html.haml +113 -0
  82. data/app/views/workarea/admin/content_blog_entries/_summary.html.haml +10 -0
  83. data/app/views/workarea/admin/content_blog_entries/edit.html.haml +75 -0
  84. data/app/views/workarea/admin/content_blog_entries/index.html.haml +80 -0
  85. data/app/views/workarea/admin/content_blog_entries/index.json.jbuilder +5 -0
  86. data/app/views/workarea/admin/content_blog_entries/show.html.haml +20 -0
  87. data/app/views/workarea/admin/content_blog_entries/thumbnail_image.html.haml +55 -0
  88. data/app/views/workarea/admin/content_blogs/_aux_navigation.html.haml +2 -0
  89. data/app/views/workarea/admin/content_blogs/_cards.html.haml +58 -0
  90. data/app/views/workarea/admin/content_blogs/_summary.html.haml +6 -0
  91. data/app/views/workarea/admin/content_blogs/edit.html.haml +51 -0
  92. data/app/views/workarea/admin/content_blogs/index.html.haml +76 -0
  93. data/app/views/workarea/admin/content_blogs/index.json.jbuilder +4 -0
  94. data/app/views/workarea/admin/content_blogs/new.html.haml +33 -0
  95. data/app/views/workarea/admin/content_blogs/show.html.haml +19 -0
  96. data/app/views/workarea/admin/create_content_blog_entries/content.html.haml +28 -0
  97. data/app/views/workarea/admin/create_content_blog_entries/featured_products.html.haml +71 -0
  98. data/app/views/workarea/admin/create_content_blog_entries/publish.html.haml +51 -0
  99. data/app/views/workarea/admin/create_content_blog_entries/setup.html.haml +61 -0
  100. data/app/views/workarea/admin/create_content_blog_entries/thumbnail_image.html.haml +48 -0
  101. data/app/views/workarea/storefront/blog_comments/index.html.haml +31 -0
  102. data/app/views/workarea/storefront/blog_entries/_summary.html.haml +25 -0
  103. data/app/views/workarea/storefront/blog_entries/show.html.haml +85 -0
  104. data/app/views/workarea/storefront/blog_metadata/_publisher.html.haml +7 -0
  105. data/app/views/workarea/storefront/blogs/_blog_navigation.html.haml +7 -0
  106. data/app/views/workarea/storefront/blogs/index.html.haml +25 -0
  107. data/app/views/workarea/storefront/blogs/show.atom.builder +26 -0
  108. data/app/views/workarea/storefront/blogs/show.html.haml +31 -0
  109. data/app/views/workarea/storefront/content_blocks/_blog_entry.html.haml +20 -0
  110. data/app/workers/workarea/generate_content_metadata.decorator +15 -0
  111. data/bin/rails +18 -0
  112. data/config/initializers/appends.rb +26 -0
  113. data/config/initializers/content_block_types.rb +13 -0
  114. data/config/initializers/jump_to_navigation.rb +3 -0
  115. data/config/initializers/seeds.rb +5 -0
  116. data/config/initializers/workarea.rb +15 -0
  117. data/config/locales/en.yml +244 -0
  118. data/config/routes.rb +49 -0
  119. data/data/blog_thumbnails/thumbnail_1.png +0 -0
  120. data/data/blog_thumbnails/thumbnail_2.png +0 -0
  121. data/data/blog_thumbnails/thumbnail_3.png +0 -0
  122. data/lib/tasks/import_wordpress.rake +13 -0
  123. data/lib/tasks/import_wordpress_attachments.rake +18 -0
  124. data/lib/tasks/import_wordpress_pages.rake +21 -0
  125. data/lib/tasks/import_wordpress_posts.rake +25 -0
  126. data/lib/workarea/blog/engine.rb +8 -0
  127. data/lib/workarea/blog/import/wordpress/attachment.rb +40 -0
  128. data/lib/workarea/blog/import/wordpress/content_cleaner.rb +64 -0
  129. data/lib/workarea/blog/import/wordpress/entry.rb +76 -0
  130. data/lib/workarea/blog/import/wordpress/entry_parser.rb +64 -0
  131. data/lib/workarea/blog/import/wordpress/page.rb +69 -0
  132. data/lib/workarea/blog/import/wordpress/page_parser.rb +50 -0
  133. data/lib/workarea/blog/version.rb +5 -0
  134. data/lib/workarea/blog.rb +11 -0
  135. data/test/dummy/Rakefile +6 -0
  136. data/test/dummy/app/assets/config/manifest.js +4 -0
  137. data/test/dummy/app/assets/images/.keep +0 -0
  138. data/test/dummy/app/assets/javascripts/application.js +13 -0
  139. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  140. data/test/dummy/app/controllers/application_controller.rb +3 -0
  141. data/test/dummy/app/controllers/concerns/.keep +0 -0
  142. data/test/dummy/app/helpers/application_helper.rb +2 -0
  143. data/test/dummy/app/jobs/application_job.rb +2 -0
  144. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  145. data/test/dummy/app/models/concerns/.keep +0 -0
  146. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  147. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  148. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  149. data/test/dummy/bin/bundle +3 -0
  150. data/test/dummy/bin/rails +4 -0
  151. data/test/dummy/bin/rake +4 -0
  152. data/test/dummy/bin/setup +34 -0
  153. data/test/dummy/bin/update +29 -0
  154. data/test/dummy/config/application.rb +26 -0
  155. data/test/dummy/config/boot.rb +5 -0
  156. data/test/dummy/config/cable.yml +9 -0
  157. data/test/dummy/config/environment.rb +5 -0
  158. data/test/dummy/config/environments/development.rb +59 -0
  159. data/test/dummy/config/environments/production.rb +86 -0
  160. data/test/dummy/config/environments/test.rb +43 -0
  161. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  162. data/test/dummy/config/initializers/assets.rb +11 -0
  163. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  164. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  165. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  166. data/test/dummy/config/initializers/inflections.rb +16 -0
  167. data/test/dummy/config/initializers/mime_types.rb +4 -0
  168. data/test/dummy/config/initializers/new_framework_defaults.rb +18 -0
  169. data/test/dummy/config/initializers/session_store.rb +3 -0
  170. data/test/dummy/config/initializers/workarea.rb +3 -0
  171. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  172. data/test/dummy/config/locales/en.yml +23 -0
  173. data/test/dummy/config/puma.rb +47 -0
  174. data/test/dummy/config/routes.rb +5 -0
  175. data/test/dummy/config/secrets.yml +22 -0
  176. data/test/dummy/config/spring.rb +6 -0
  177. data/test/dummy/config.ru +5 -0
  178. data/test/dummy/db/seeds.rb +2 -0
  179. data/test/dummy/lib/assets/.keep +0 -0
  180. data/test/dummy/log/.keep +0 -0
  181. data/test/factories/blog.rb +33 -0
  182. data/test/factories/wordpress_import.rb +17 -0
  183. data/test/fixtures/test_wordpress.xml +493 -0
  184. data/test/integration/workarea/blog/admin_integration_test.rb +55 -0
  185. data/test/integration/workarea/blog/create_blog_entries_integration_test.rb +106 -0
  186. data/test/integration/workarea/blog/storefront_integration_test.rb +112 -0
  187. data/test/integration/workarea/blog/wordpress_import_integration_test.rb +26 -0
  188. data/test/lib/workarea/blog/import/wordpress/attachment_test.rb +20 -0
  189. data/test/lib/workarea/blog/import/wordpress/content_cleaner_test.rb +65 -0
  190. data/test/lib/workarea/blog/import/wordpress/entry_parser_test.rb +42 -0
  191. data/test/lib/workarea/blog/import/wordpress/entry_test.rb +61 -0
  192. data/test/lib/workarea/blog/import/wordpress/page_parser_test.rb +35 -0
  193. data/test/lib/workarea/blog/import/wordpress/page_test.rb +52 -0
  194. data/test/models/workarea/content/blog_comment_test.rb +57 -0
  195. data/test/models/workarea/content/blog_entry_test.rb +17 -0
  196. data/test/queries/workarea/metadata/content_blog_entry_test.rb +36 -0
  197. data/test/queries/workarea/metadata/content_blog_test.rb +36 -0
  198. data/test/support/workarea/blog/stub_wordpress_assets.rb +19 -0
  199. data/test/system/workarea/admin/blog_entries_system_test.rb +103 -0
  200. data/test/system/workarea/admin/blog_system_test.rb +93 -0
  201. data/test/system/workarea/admin/blog_taxonomy_system_test.rb +21 -0
  202. data/test/system/workarea/admin/blog_user_comments_system_test.rb +138 -0
  203. data/test/system/workarea/storefront/blog_content_block_system_test.rb +36 -0
  204. data/test/system/workarea/storefront/blog_system_test.rb +256 -0
  205. data/test/test_helper.rb +9 -0
  206. data/test/view_models/workarea/admin/blog_comments_view_model_test.rb +77 -0
  207. data/test/view_models/workarea/admin/blog_entries_view_model_test.rb +36 -0
  208. data/test/view_models/workarea/storefront/blog_entry_content_block_view_model_test.rb +100 -0
  209. data/test/view_models/workarea/storefront/blog_entry_view_model_test.rb +47 -0
  210. data/test/view_models/workarea/storefront/blog_view_model_test.rb +149 -0
  211. data/test/workers/workarea/generate_content_blog_metadata_test.rb +18 -0
  212. data/workarea-blog.gemspec +19 -0
  213. metadata +274 -0
@@ -0,0 +1,103 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Admin
5
+ class BlogEntrySystemTest < Workarea::SystemTest
6
+ include Admin::IntegrationTest
7
+
8
+ setup :blog
9
+
10
+ def blog
11
+ @blog ||= create_blog(
12
+ name: 'Test Blog',
13
+ entries: [
14
+ { name: 'Entry 1', author: 'Ben Crouse' },
15
+ { name: 'Entry 2', author: 'Ben Crouse' }
16
+ ]
17
+ )
18
+ end
19
+
20
+ def test_creating_a_blog_entry
21
+ visit admin.content_blog_blog_entries_path(content_blog_id: blog)
22
+
23
+ click_link t('workarea.admin.content_blog_entries.index.new_blog_entry')
24
+
25
+ fill_in 'blog_entry[name]', with: 'Test Entry'
26
+ fill_in 'blog_entry[author]', with: 'Eric Pigeon'
27
+ fill_in 'blog_entry[summary]', with: 'A test blog entry'
28
+
29
+ click_button t('workarea.admin.create_content_blog_entries.setup.button')
30
+
31
+ create_asset(name: 'Test Asset', file: product_image_file, tag_list: 'foo,bar,baz')
32
+ click_link t('workarea.admin.content_blocks.asset.select_an_asset')
33
+ within '#takeover' do
34
+ click_link 'Test Asset'
35
+ end
36
+
37
+ click_button t('workarea.admin.create_content_blog_entries.thumbnail_image.button')
38
+ click_link t('workarea.admin.create_content_blog_entries.content.button')
39
+ end
40
+
41
+ def test_editing_attributes
42
+ entry = blog.entries.first
43
+
44
+ visit admin.edit_content_blog_entry_path(entry)
45
+
46
+ fill_in 'blog_entry[name]', with: 'Test Entry'
47
+ fill_in 'blog_entry[author]', with: 'Eric Pigeon'
48
+ fill_in 'blog_entry[summary]', with: 'A test blog entry'
49
+
50
+ click_button 'save_blog_entry'
51
+
52
+ assert(page.has_content?(t('workarea.admin.content_blog_entries.flash_messages.updated')))
53
+ assert(page.has_current_path?(admin.edit_content_blog_entry_path(entry)))
54
+ end
55
+
56
+ def test_editing_thumbnail
57
+ entry = blog.entries.first
58
+
59
+ visit admin.thumbnail_image_content_blog_entry_path(entry)
60
+
61
+ click_button 'save_blog_entry'
62
+
63
+ assert(page.has_content?(t('workarea.admin.content_blog_entries.flash_messages.updated')))
64
+ assert(page.has_current_path?(admin.thumbnail_image_content_blog_entry_path(entry)))
65
+ end
66
+
67
+ def test_deleting_a_blog_entry
68
+ visit admin.content_blog_entry_path(blog.entries.first)
69
+ click_link t('workarea.admin.actions.delete')
70
+
71
+ assert page.has_text?(t('workarea.admin.content_blog_entries.flash_messages.deleted'))
72
+ end
73
+
74
+ def test_importing_and_exporting
75
+ file = create_tempfile(
76
+ DataFile::Csv.new.serialize(blog.entries),
77
+ extension: 'csv'
78
+ )
79
+
80
+ visit admin.content_blog_blog_entries_path(content_blog_id: blog)
81
+ click_link t('workarea.admin.shared.bulk_actions.import')
82
+ attach_file 'import[file]', file.path
83
+ click_button 'create_import'
84
+
85
+ assert_current_path(admin.content_blog_blog_entries_path(content_blog_id: blog))
86
+ assert(page.has_content?('Success'))
87
+
88
+ click_button t('workarea.admin.shared.bulk_actions.export')
89
+
90
+ Workarea.config.data_file_formats[1..-1].each do |format|
91
+ click_link format.upcase
92
+ assert(page.has_content?(format.upcase))
93
+ end
94
+
95
+ fill_in 'export[emails_list]', with: 'bcrouse@weblinc.com'
96
+ click_button 'create_export'
97
+
98
+ assert_current_path(admin.content_blog_blog_entries_path(content_blog_id: blog))
99
+ assert(page.has_content?('Success'))
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,93 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Admin
5
+ class BlogSystemTest < Workarea::SystemTest
6
+ include Admin::IntegrationTest
7
+
8
+ setup :blog
9
+
10
+ def blog
11
+ @blog ||= create_blog(
12
+ name: 'Test Blog',
13
+ entries: [
14
+ { name: 'Entry 1', author: 'Ben Crouse' },
15
+ { name: 'Entry 2', author: 'Ben Crouse' }
16
+ ]
17
+ )
18
+ end
19
+
20
+ def test_creating_a_blog
21
+ visit admin.content_blogs_path
22
+ click_link 'add_blog'
23
+
24
+ fill_in 'blog_name', with: 'New Blog'
25
+ click_button 'save_blog'
26
+ assert(page.has_content?('Success'))
27
+
28
+ visit admin.content_blogs_path
29
+ assert(page.has_content?('New Blog'))
30
+ end
31
+
32
+ def test_managing_blogs
33
+ visit admin.content_blog_path(blog)
34
+ click_link t('workarea.admin.cards.attributes.title')
35
+
36
+ fill_in 'blog_name', with: 'Edited Test Blog'
37
+ click_button 'save_blog'
38
+ assert(page.has_content?('Success'))
39
+
40
+ visit admin.content_blogs_path
41
+ assert(page.has_content?('Edited Test Blog'))
42
+ end
43
+
44
+ def test_deleting_blogs
45
+ visit admin.content_blogs_path
46
+ click_link 'Test Blog'
47
+
48
+ visit admin.content_blog_path(blog)
49
+
50
+ click_link t('workarea.admin.actions.delete')
51
+ assert(page.has_content?('Success'))
52
+
53
+ assert(page.has_no_content?('Edited Test Blog'))
54
+ end
55
+
56
+ def test_shows_the_admin_toolbar_for_blogs
57
+ visit admin.toolbar_path(id: blog.to_global_id.to_param)
58
+ click_link 'View Test Blog admin'
59
+ assert(page.has_current_path?(admin.content_blog_path(blog)))
60
+
61
+ visit admin.toolbar_path(id: blog.to_global_id.to_param)
62
+ click_link t('workarea.admin.toolbar.edit_content')
63
+ assert(page.has_current_path?(admin.edit_content_path(Content.for(blog))))
64
+ end
65
+
66
+ def test_importing_and_exporting
67
+ blogs = Array.new(2) { |i| create_blog }
68
+ file = create_tempfile(DataFile::Csv.new.serialize(blogs), extension: 'csv')
69
+
70
+ visit admin.content_blogs_path
71
+ click_link t('workarea.admin.shared.bulk_actions.import')
72
+ attach_file 'import[file]', file.path
73
+ click_button 'create_import'
74
+
75
+ assert_current_path(admin.content_blogs_path)
76
+ assert(page.has_content?('Success'))
77
+
78
+ click_button t('workarea.admin.shared.bulk_actions.export')
79
+
80
+ Workarea.config.data_file_formats[1..-1].each do |format|
81
+ click_link format.upcase
82
+ assert(page.has_content?(format.upcase))
83
+ end
84
+
85
+ fill_in 'export[emails_list]', with: 'bcrouse@weblinc.com'
86
+ click_button 'create_export'
87
+
88
+ assert_current_path(admin.content_blogs_path)
89
+ assert(page.has_content?('Success'))
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Admin
5
+ class BlogTaxonomySystemTest < Workarea::SystemTest
6
+ include Admin::IntegrationTest
7
+
8
+ def test_blog_and_blog_entry_can_be_added_as_taxon
9
+ visit admin.navigation_taxons_path
10
+ find('.menu-editor__add-item-button--last-position').click
11
+
12
+ assert(page.has_content?('Add Taxonomy'))
13
+
14
+ dropdown = page.find('#navigable_type')
15
+ options = dropdown.all('option').map(&:text)
16
+ assert_includes(options, 'Blog')
17
+ assert_includes(options, 'Blog Entry')
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,138 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Admin
5
+ class BlogUserCommentsSystemTest < Workarea::SystemTest
6
+ include Admin::IntegrationTest
7
+
8
+ setup :blog
9
+
10
+ def blog
11
+ @blog ||= create_blog(
12
+ name: 'Test Blog',
13
+ entries: [
14
+ { name: 'Entry 1', author: 'Ben Crouse' },
15
+ { name: 'Entry 2', author: 'Ben Crouse' }
16
+ ]
17
+ )
18
+ end
19
+
20
+ def test_approving_comments
21
+ blog_entry = blog.entries.first
22
+ blog_entry.comments.create!(
23
+ user_id: Workarea::User.first.id,
24
+ user_info: 'UC',
25
+ body: 'test test test',
26
+ pending: true
27
+ )
28
+
29
+ visit admin.content_blog_user_comments_path
30
+
31
+ assert(page.has_content?('Blog Entry'))
32
+ assert(page.has_content?('Pending'))
33
+
34
+ click_link('Edit')
35
+
36
+ find('label[for=blog_comment_approved_true]').click
37
+ click_button 'save_blog_comment'
38
+
39
+ assert(page.has_content?('Success'))
40
+ assert(page.has_no_content?('Pending'))
41
+
42
+ visit admin.activity_path
43
+ assert(page.has_content?('blog comment'))
44
+ end
45
+
46
+ def test_deleting_a_comment
47
+ blog_entry = blog.entries.first
48
+ blog_entry.comments.create!(
49
+ user_id: Workarea::User.first.id,
50
+ user_info: 'UC',
51
+ body: 'Test Comment',
52
+ pending: true,
53
+ updated_at: Time.now - 2.days
54
+ )
55
+
56
+ visit admin.content_blog_user_comments_path
57
+
58
+ within '.comments__comment', match: :first do
59
+ click_button('Delete')
60
+ end
61
+
62
+ assert(page.has_content?(t('workarea.admin.content_blogs_comments.flash_messages.destroyed')))
63
+ assert(page.has_no_content?('Test Comment'))
64
+ end
65
+
66
+ def test_view_and_sort_comments_for_only_that_blog_entry
67
+ blog.entries.first.comments.create!(
68
+ user_id: Workarea::User.first.id,
69
+ body: 'One Thought',
70
+ approved: false,
71
+ pending: true,
72
+ updated_at: Time.now - 1.day
73
+ )
74
+ blog.entries.first.comments.create!(
75
+ user_id: Workarea::User.first.id,
76
+ body: 'Two Thoughts',
77
+ approved: false,
78
+ pending: true,
79
+ created_at: Time.now - 2.days
80
+ )
81
+ blog.entries.last.comments.create!(
82
+ user_id: Workarea::User.first.id,
83
+ body: 'Comment For Another Entry',
84
+ approved: false,
85
+ pending: true,
86
+ created_at: Time.now - 1.day
87
+ )
88
+
89
+ entry = blog.entries.order_by(:created_at.asc).first
90
+
91
+ visit admin.content_blog_user_comments_path(content_blog_entry_id: entry.slug)
92
+
93
+ assert(page.has_content?('One Thought'))
94
+ assert(page.has_no_content?('First Comment'))
95
+
96
+ select 'Newest', from: 'sort'
97
+
98
+ assert(page.has_no_content?('Comment For Another Entry'))
99
+ assert(page.has_ordered_text?('One Thought', 'Two Thoughts'))
100
+ end
101
+
102
+ def test_importing_and_exporting
103
+ entry = blog.entries.first
104
+ comments = Array.new(2) do |i|
105
+ entry.comments.create!(
106
+ user_id: Workarea::User.first.id,
107
+ user_info: 'UC',
108
+ body: 'test test test',
109
+ pending: true
110
+ )
111
+ end
112
+
113
+ file = create_tempfile(DataFile::Csv.new.serialize(comments), extension: 'csv')
114
+
115
+ visit admin.content_blog_user_comments_path(content_blog_entry_id: entry.slug)
116
+ click_link t('workarea.admin.shared.bulk_actions.import')
117
+ attach_file 'import[file]', file.path
118
+ click_button 'create_import'
119
+
120
+ assert_current_path(admin.content_blog_user_comments_path(content_blog_entry_id: entry.slug))
121
+ assert(page.has_content?('Success'))
122
+
123
+ click_link t('workarea.admin.shared.bulk_actions.export')
124
+
125
+ Workarea.config.data_file_formats[1..-1].each do |format|
126
+ click_link format.upcase
127
+ assert(page.has_content?(format.upcase))
128
+ end
129
+
130
+ fill_in 'export[emails_list]', with: 'bcrouse@weblinc.com'
131
+ click_button 'create_export'
132
+
133
+ assert_current_path(admin.content_blog_user_comments_path(content_blog_entry_id: entry.slug))
134
+ assert(page.has_content?('Success'))
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,36 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class BlogContentBlockSystemTest < Workarea::SystemTest
6
+ include BreakpointHelpers
7
+ setup :set_content_page
8
+
9
+ def set_content_page
10
+ @content_page = create_page(name: 'Integration Page')
11
+ end
12
+
13
+ def test_blog_entry_content_block
14
+ blog = create_blog(name: 'Test')
15
+
16
+ blog.entries.create!(name: 'Test', author: 'BC', summary: 'Summary text')
17
+
18
+ content = Content.for(@content_page)
19
+ content.blocks.build(
20
+ type: :blog_entry,
21
+ data: {
22
+ number_of_entries: '1',
23
+ use_manual_entries: 'true',
24
+ blog_entry: [blog.entries.first.id]
25
+ }
26
+ )
27
+ content.save!
28
+
29
+ visit storefront.page_path(@content_page)
30
+ assert(page.has_content?(blog.entries.first.name))
31
+ assert(page.has_content?(blog.entries.first.author))
32
+ assert(page.has_content?(blog.entries.first.summary))
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,256 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class BlogSystemTest < Workarea::SystemTest
6
+ include Storefront::SystemTest
7
+
8
+ setup :blog
9
+ setup :set_entries_on_index
10
+ teardown :unset_entries_on_index
11
+
12
+ def blog
13
+ @blog ||= create_blog(
14
+ entries: [
15
+ { name: 'Entry 1', author: 'Ben Crouse', summary: 'A short summary about the entry' },
16
+ { name: 'Entry 2', author: 'Ben Crouse', summary: 'A different summary for this entry' }
17
+ ]
18
+ )
19
+ end
20
+
21
+ def set_entries_on_index
22
+ @blog_entries_on_index = Workarea.config.blog_entries_on_index
23
+ Workarea.config.blog_entries_on_index = 4
24
+ end
25
+
26
+ def unset_entries_on_index
27
+ Workarea.config.blog_entries_on_index = @blog_entries_on_index
28
+ end
29
+
30
+ def test_display
31
+ visit storefront.blog_path(blog)
32
+
33
+ assert(page.has_content?('Entry 1'))
34
+ assert(page.has_content?('A short summary about the entry'))
35
+ assert(page.has_content?('Entry 2'))
36
+ assert(page.has_content?('A different summary for this entry'))
37
+
38
+ entry_content = Workarea::Content.for(blog.entries.first)
39
+ entry_content.blocks.build(
40
+ area: :blog_content,
41
+ type: :text,
42
+ data: { text: 'Body' }
43
+ )
44
+ entry_content.save!
45
+
46
+ click_link 'Entry 1'
47
+
48
+ assert(page.has_current_path?(storefront.blog_entry_path(blog.entries.first)))
49
+ assert(page.has_content?('Entry 1'))
50
+ assert(page.has_content?('Body'))
51
+ end
52
+
53
+ def test_blog_index
54
+ create_blog(
55
+ entries: [
56
+ {
57
+ name: 'Entry 1',
58
+ author: 'Ben Crouse',
59
+ summary: 'A short summary about the entry',
60
+ written_at: Time.now - 1.day
61
+ },
62
+ {
63
+ name: 'Entry 2',
64
+ author: 'Ben Crouse',
65
+ summary: 'A different summary for this entry',
66
+ written_at: Time.now - 2.day
67
+ },
68
+ {
69
+ name: 'Entry 3',
70
+ author: 'Ben Crouse',
71
+ summary: 'This is the third post',
72
+ written_at: Time.now - 3.day
73
+ },
74
+ {
75
+ name: 'Entry 4',
76
+ author: 'Ben Crouse',
77
+ summary: 'This post should not be shown on index',
78
+ written_at: Time.now - 4.day
79
+ },
80
+ {
81
+ name: 'Entry 5',
82
+ author: 'Ben Crouse',
83
+ summary: 'This post is featured and should show first',
84
+ written_at: Time.now - 5.day,
85
+ featured: true
86
+ }
87
+ ]
88
+ )
89
+
90
+ visit storefront.blogs_path
91
+
92
+ assert(page.has_content?('Test Blog'))
93
+
94
+ assert(page.has_content?('Entry 5'))
95
+ assert(page.has_content?('This post is featured and should show first'))
96
+ assert(page.has_content?('Entry 1'))
97
+ assert(page.has_content?('A short summary about the entry'))
98
+ assert(page.has_content?('Entry 2'))
99
+ assert(page.has_content?('A different summary for this entry'))
100
+ assert(page.has_content?('Entry 3'))
101
+ assert(page.has_content?('This is the third post'))
102
+
103
+ assert(page.has_no_content?('Entry 4'))
104
+ assert(page.has_no_content?('And this is the fourth post'))
105
+ end
106
+
107
+ def test_tags
108
+ blog = create_blog(
109
+ entries: [
110
+ { name: 'Entry 1', author: 'Ben Crouse' },
111
+ { name: 'Entry 2', author: 'Ben Crouse', tag_list: 'foo,bar' }
112
+ ]
113
+ )
114
+
115
+ visit storefront.blog_path(blog)
116
+
117
+ assert(page.has_content?('foo (1)'))
118
+ assert(page.has_content?('bar (1)'))
119
+
120
+ click_link 'foo (1)'
121
+
122
+ assert(page.has_content?('Entry 2'))
123
+ assert(page.has_no_content?('Entry 1'))
124
+
125
+ visit storefront.blog_entry_path(blog.entries.first)
126
+
127
+ assert(page.has_content?('foo (1)'))
128
+ assert(page.has_content?('bar (1)'))
129
+ end
130
+
131
+ def test_related_products
132
+ create_product(
133
+ name: 'Related Product',
134
+ id: 'product_1',
135
+ variants: [
136
+ { sku: 'SKU1', regular: 10.to_m },
137
+ { sku: 'SKU2', regular: 20.to_m }
138
+ ]
139
+ )
140
+
141
+ blog = create_blog(
142
+ entries: [
143
+ { name: 'Entry 2', author: 'Ben Crouse', product_ids: ['product_1'] }
144
+ ]
145
+ )
146
+
147
+ visit storefront.blog_entry_path(blog.entries.first)
148
+
149
+ assert(page.has_content?(/Related Product/i))
150
+ end
151
+
152
+ def test_comments
153
+ blog = create_blog(
154
+ entries: [
155
+ { name: 'Entry 1', author: 'Ben Crouse' }
156
+ ]
157
+ )
158
+
159
+ create_user(email: 'test@workarea.com', password: 'w3bl1nc', name: 'Ben Crouse')
160
+ visit storefront.login_path
161
+
162
+ within '#login_form' do
163
+ fill_in 'email', with: 'test@workarea.com'
164
+ fill_in 'password', with: 'w3bl1nc'
165
+ click_button 'login'
166
+ end
167
+
168
+ visit storefront.blog_entry_path(blog.entries.first)
169
+ fill_in 'body', with: 'test comment'
170
+ click_button 'submit_comment'
171
+
172
+ assert_equal(storefront.blog_entry_path(blog.entries.first), current_path)
173
+ assert(page.has_content?('Success'))
174
+
175
+ Workarea::Content::BlogComment.first.update_attributes(approved: true)
176
+
177
+ clear_driver_cache if respond_to?(:clear_driver_cache)
178
+ visit storefront.blog_entry_path(blog.entries.first)
179
+ assert(page.has_content?('test comment'))
180
+
181
+ assert(page.has_content?('1 Comment'))
182
+
183
+ visit storefront.blog_entry_path(blog.entries.first)
184
+ fill_in 'body', with: 'test comment 2'
185
+ click_button 'submit_comment'
186
+
187
+ assert_equal(storefront.blog_entry_path(blog.entries.first), current_path)
188
+ assert(page.has_content?('Success'))
189
+
190
+ Workarea::Content::BlogComment
191
+ .where(body: 'test comment 2')
192
+ .first
193
+ .update_attributes!(approved: true)
194
+
195
+ clear_driver_cache if respond_to?(:clear_driver_cache)
196
+ visit storefront.blog_entry_path(blog.entries.first)
197
+
198
+ assert(page.has_content?('test comment 2'))
199
+ assert(page.has_content?('2 Comments'))
200
+
201
+ Workarea::Content::BlogComment
202
+ .where(body: 'test comment')
203
+ .first
204
+ .destroy
205
+
206
+ clear_driver_cache if respond_to?(:clear_driver_cache)
207
+ visit storefront.blog_entry_path(blog.entries.first)
208
+ assert(page.has_content?('test comment 2'))
209
+ assert(page.has_content?('1 Comment'))
210
+ end
211
+
212
+ def test_featured_blog_entries_display_first
213
+ blog = create_blog(
214
+ entries: [
215
+ {
216
+ name: 'entry',
217
+ author: 'jberesford',
218
+ slug: 'entry-slug',
219
+ featured: false
220
+ },
221
+ {
222
+ name: 'featured entry',
223
+ author: 'jberesford',
224
+ slug: 'featured-entry-slug',
225
+ featured: true
226
+ }
227
+ ]
228
+ )
229
+
230
+ visit storefront.blog_path(blog)
231
+
232
+ assert_match(/featured entry.*entry/m, page.html)
233
+ end
234
+
235
+ def test_showing_a_featured_blog_entry_content_block
236
+ content_page = create_page(name: 'Integration Page')
237
+ entry = blog.entries.first
238
+
239
+ content = Content.for(content_page)
240
+ content.blocks.build(
241
+ type: :blog_entry,
242
+ data: {
243
+ use_manual_entries: 'true',
244
+ blog_entry: [entry.id]
245
+ }
246
+ )
247
+ content.save!
248
+
249
+ visit storefront.page_path(content_page)
250
+
251
+ assert(page.has_content?('Entry 1'))
252
+ assert(page.has_content?('A short summary about the entry'))
253
+ end
254
+ end
255
+ end
256
+ end
@@ -0,0 +1,9 @@
1
+ # Configure Rails Environment
2
+ ENV['RAILS_ENV'] = 'test'
3
+ require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
4
+ require 'rails/test_help'
5
+ require 'workarea/test_help'
6
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
7
+ # to be shown.
8
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
9
+ require 'factories/blog'