proclaim 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +5 -38
  3. data/app/assets/config/proclaim_manifest.js +2 -0
  4. data/app/assets/images/{ajax_loader.gif → proclaim/ajax_loader.gif} +0 -0
  5. data/app/assets/javascripts/proclaim.js +7 -7
  6. data/app/assets/javascripts/proclaim/{comments_handler.js.coffee → comments_handler.coffee} +16 -10
  7. data/app/assets/javascripts/proclaim/editor.coffee +55 -0
  8. data/app/assets/stylesheets/{proclaim.css.scss → proclaim.scss} +7 -8
  9. data/app/assets/stylesheets/proclaim/{comments.css.scss → comments.scss} +0 -0
  10. data/app/assets/stylesheets/proclaim/{posts.css.scss → posts.scss} +60 -25
  11. data/app/assets/stylesheets/proclaim/{subscriptions.css.scss → subscriptions.scss} +0 -0
  12. data/app/controllers/proclaim/application_controller.rb +60 -56
  13. data/app/controllers/proclaim/comments_controller.rb +13 -42
  14. data/app/controllers/proclaim/posts_controller.rb +25 -57
  15. data/app/controllers/proclaim/subscriptions_controller.rb +3 -3
  16. data/app/jobs/proclaim/application_job.rb +4 -0
  17. data/app/mailers/proclaim/application_mailer.rb +5 -0
  18. data/app/mailers/proclaim/subscription_mailer.rb +19 -17
  19. data/app/models/proclaim/application_record.rb +5 -0
  20. data/app/models/proclaim/comment.rb +6 -1
  21. data/app/models/proclaim/post.rb +20 -28
  22. data/app/models/proclaim/subscription.rb +33 -11
  23. data/app/views/layouts/proclaim/subscription_mailer.html.erb +15 -36
  24. data/app/views/proclaim/comments/_comment.html.erb +7 -7
  25. data/app/views/proclaim/comments/_form.html.erb +7 -5
  26. data/app/views/proclaim/posts/_form.html.erb +34 -21
  27. data/app/views/proclaim/posts/show.html.erb +16 -3
  28. data/app/views/proclaim/subscription_mailer/welcome_email.html.erb +2 -6
  29. data/config/initializers/friendly_id.rb +20 -1
  30. data/config/routes.rb +1 -5
  31. data/db/migrate/20141108222616_create_proclaim_posts.rb +8 -1
  32. data/db/migrate/20141114235359_create_proclaim_comments.rb +1 -1
  33. data/db/migrate/20141115022230_create_proclaim_comment_hierarchies.rb +1 -1
  34. data/db/migrate/20141210234057_create_proclaim_subscriptions.rb +5 -4
  35. data/db/migrate/20150213015321_create_friendly_id_slugs.rb +1 -1
  36. data/lib/generators/proclaim/install_generator.rb +1 -1
  37. data/lib/generators/proclaim/templates/initialize_proclaim.rb +31 -29
  38. data/lib/generators/proclaim/views_generator.rb +1 -1
  39. data/lib/proclaim.rb +15 -15
  40. data/lib/proclaim/engine.rb +21 -19
  41. data/lib/proclaim/version.rb +1 -1
  42. data/vendor/assets/fonts/KaTeX_AMS-Regular.ttf +0 -0
  43. data/vendor/assets/fonts/KaTeX_AMS-Regular.woff +0 -0
  44. data/vendor/assets/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  45. data/vendor/assets/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  46. data/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  47. data/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  48. data/vendor/assets/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  49. data/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  50. data/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  51. data/vendor/assets/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  52. data/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  53. data/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  54. data/vendor/assets/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  55. data/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  56. data/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  57. data/vendor/assets/fonts/KaTeX_Main-Bold.ttf +0 -0
  58. data/vendor/assets/fonts/KaTeX_Main-Bold.woff +0 -0
  59. data/vendor/assets/fonts/KaTeX_Main-Bold.woff2 +0 -0
  60. data/vendor/assets/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  61. data/vendor/assets/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  62. data/vendor/assets/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  63. data/vendor/assets/fonts/KaTeX_Main-Italic.ttf +0 -0
  64. data/vendor/assets/fonts/KaTeX_Main-Italic.woff +0 -0
  65. data/vendor/assets/fonts/KaTeX_Main-Italic.woff2 +0 -0
  66. data/vendor/assets/fonts/KaTeX_Main-Regular.ttf +0 -0
  67. data/vendor/assets/fonts/KaTeX_Main-Regular.woff +0 -0
  68. data/vendor/assets/fonts/KaTeX_Main-Regular.woff2 +0 -0
  69. data/vendor/assets/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  70. data/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  71. data/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  72. data/vendor/assets/fonts/KaTeX_Math-Italic.ttf +0 -0
  73. data/vendor/assets/fonts/KaTeX_Math-Italic.woff +0 -0
  74. data/vendor/assets/fonts/KaTeX_Math-Italic.woff2 +0 -0
  75. data/vendor/assets/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  76. data/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  77. data/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  78. data/vendor/assets/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  79. data/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  80. data/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  81. data/vendor/assets/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  82. data/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  83. data/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  84. data/vendor/assets/fonts/KaTeX_Script-Regular.ttf +0 -0
  85. data/vendor/assets/fonts/KaTeX_Script-Regular.woff +0 -0
  86. data/vendor/assets/fonts/KaTeX_Script-Regular.woff2 +0 -0
  87. data/vendor/assets/fonts/KaTeX_Size1-Regular.ttf +0 -0
  88. data/vendor/assets/fonts/KaTeX_Size1-Regular.woff +0 -0
  89. data/vendor/assets/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  90. data/vendor/assets/fonts/KaTeX_Size2-Regular.ttf +0 -0
  91. data/vendor/assets/fonts/KaTeX_Size2-Regular.woff +0 -0
  92. data/vendor/assets/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  93. data/vendor/assets/fonts/KaTeX_Size3-Regular.ttf +0 -0
  94. data/vendor/assets/fonts/KaTeX_Size3-Regular.woff +0 -0
  95. data/vendor/assets/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  96. data/vendor/assets/fonts/KaTeX_Size4-Regular.ttf +0 -0
  97. data/vendor/assets/fonts/KaTeX_Size4-Regular.woff +0 -0
  98. data/vendor/assets/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  99. data/vendor/assets/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  100. data/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  101. data/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  102. data/vendor/assets/javascripts/contrib/auto-render.js +339 -0
  103. data/vendor/assets/javascripts/contrib/auto-render.min.js +1 -0
  104. data/vendor/assets/javascripts/contrib/auto-render.mjs +215 -0
  105. data/vendor/assets/javascripts/contrib/copy-tex.css +14 -0
  106. data/vendor/assets/javascripts/contrib/copy-tex.js +213 -0
  107. data/vendor/assets/javascripts/contrib/copy-tex.min.css +1 -0
  108. data/vendor/assets/javascripts/contrib/copy-tex.min.js +1 -0
  109. data/vendor/assets/javascripts/contrib/copy-tex.mjs +85 -0
  110. data/vendor/assets/javascripts/contrib/mathtex-script-type.js +137 -0
  111. data/vendor/assets/javascripts/contrib/mathtex-script-type.min.js +1 -0
  112. data/vendor/assets/javascripts/contrib/mathtex-script-type.mjs +24 -0
  113. data/vendor/assets/javascripts/contrib/mhchem.js +3241 -0
  114. data/vendor/assets/javascripts/contrib/mhchem.min.js +1 -0
  115. data/vendor/assets/javascripts/contrib/mhchem.mjs +3109 -0
  116. data/vendor/assets/javascripts/katex.js +16517 -0
  117. data/vendor/assets/javascripts/katex.min.js +1 -0
  118. data/vendor/assets/javascripts/katex.mjs +16122 -0
  119. data/vendor/assets/javascripts/quill.core.js +8522 -0
  120. data/vendor/assets/javascripts/quill.js +11489 -0
  121. data/vendor/assets/javascripts/quill.min.js +8 -0
  122. data/vendor/assets/javascripts/quill.min.js.map +1 -0
  123. data/vendor/assets/stylesheets/katex.css +1011 -0
  124. data/vendor/assets/stylesheets/katex.min.css +1 -0
  125. data/vendor/assets/stylesheets/quill.bubble.css +952 -0
  126. data/vendor/assets/stylesheets/quill.core.css +397 -0
  127. data/vendor/assets/stylesheets/quill.snow.css +945 -0
  128. metadata +169 -278
  129. data/CHANGELOG +0 -77
  130. data/Gemfile +0 -14
  131. data/VERSION +0 -1
  132. data/app/assets/javascripts/proclaim/editor.js.coffee +0 -52
  133. data/app/assets/javascripts/proclaim/images.js.coffee +0 -3
  134. data/app/assets/javascripts/proclaim/subscriptions.js.coffee +0 -3
  135. data/app/assets/stylesheets/proclaim/images.scss +0 -3
  136. data/app/controllers/proclaim/images_controller.rb +0 -67
  137. data/app/helpers/proclaim/comments_helper.rb +0 -4
  138. data/app/helpers/proclaim/images_helper.rb +0 -4
  139. data/app/helpers/proclaim/subscriptions_helper.rb +0 -4
  140. data/app/models/proclaim/image.rb +0 -19
  141. data/app/policies/proclaim/image_policy.rb +0 -29
  142. data/app/uploaders/proclaim/image_uploader.rb +0 -82
  143. data/db/migrate/20141222224905_create_proclaim_images.rb +0 -12
  144. data/db/migrate/20150123115226_add_name_to_subscriptions.rb +0 -7
  145. data/db/migrate/20150213015850_add_slug_to_posts.rb +0 -20
  146. data/proclaim.gemspec +0 -51
  147. data/test/controllers/proclaim/comments_controller_test.rb +0 -228
  148. data/test/controllers/proclaim/images_controller_test.rb +0 -166
  149. data/test/controllers/proclaim/posts_controller_test.rb +0 -465
  150. data/test/controllers/proclaim/subscriptions_controller_test.rb +0 -154
  151. data/test/dummy/README.rdoc +0 -28
  152. data/test/dummy/Rakefile +0 -6
  153. data/test/dummy/app/assets/javascripts/application.js +0 -14
  154. data/test/dummy/app/assets/stylesheets/application.css +0 -16
  155. data/test/dummy/app/controllers/application_controller.rb +0 -15
  156. data/test/dummy/app/helpers/application_helper.rb +0 -28
  157. data/test/dummy/app/models/user.rb +0 -7
  158. data/test/dummy/app/views/layouts/application.html.erb +0 -16
  159. data/test/dummy/bin/bundle +0 -3
  160. data/test/dummy/bin/rails +0 -4
  161. data/test/dummy/bin/rake +0 -4
  162. data/test/dummy/config.ru +0 -4
  163. data/test/dummy/config/application.rb +0 -24
  164. data/test/dummy/config/boot.rb +0 -5
  165. data/test/dummy/config/database.yml +0 -25
  166. data/test/dummy/config/environment.rb +0 -5
  167. data/test/dummy/config/environments/development.rb +0 -45
  168. data/test/dummy/config/environments/production.rb +0 -80
  169. data/test/dummy/config/environments/test.rb +0 -49
  170. data/test/dummy/config/initializers/assets.rb +0 -8
  171. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  172. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  173. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  174. data/test/dummy/config/initializers/inflections.rb +0 -16
  175. data/test/dummy/config/initializers/mime_types.rb +0 -4
  176. data/test/dummy/config/initializers/session_store.rb +0 -3
  177. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  178. data/test/dummy/config/locales/en.yml +0 -23
  179. data/test/dummy/config/routes.rb +0 -5
  180. data/test/dummy/config/secrets.yml +0 -22
  181. data/test/dummy/db/migrate/20141117214323_create_users.rb +0 -10
  182. data/test/dummy/db/schema.rb +0 -91
  183. data/test/dummy/public/404.html +0 -67
  184. data/test/dummy/public/422.html +0 -67
  185. data/test/dummy/public/500.html +0 -66
  186. data/test/dummy/public/favicon.ico +0 -0
  187. data/test/factories/proclaim/comment.rb +0 -11
  188. data/test/factories/proclaim/image.rb +0 -6
  189. data/test/factories/proclaim/post.rb +0 -14
  190. data/test/factories/proclaim/subscription.rb +0 -14
  191. data/test/factories/user.rb +0 -6
  192. data/test/helpers/proclaim/comments_helper_test.rb +0 -6
  193. data/test/helpers/proclaim/posts_helper_test.rb +0 -6
  194. data/test/helpers/proclaim/subscriptions_helper_test.rb +0 -6
  195. data/test/integration/with_javascript/comment_test.rb +0 -391
  196. data/test/integration/with_javascript/post_form_test.rb +0 -225
  197. data/test/integration/with_javascript/post_show_test.rb +0 -47
  198. data/test/integration/with_javascript/post_subscription_test.rb +0 -302
  199. data/test/integration/without_javascript/blog_subscription_test.rb +0 -114
  200. data/test/integration/without_javascript/manage_subscriptions_test.rb +0 -37
  201. data/test/integration/without_javascript/post_test.rb +0 -234
  202. data/test/integration/without_javascript/subscription_email_test.rb +0 -95
  203. data/test/integration/without_javascript/unsubscribe_test.rb +0 -32
  204. data/test/mailers/previews/proclaim/subscription_mailer_preview.rb +0 -22
  205. data/test/mailers/proclaim/subscription_mailer_test.rb +0 -91
  206. data/test/models/proclaim/comment_test.rb +0 -41
  207. data/test/models/proclaim/image_test.rb +0 -70
  208. data/test/models/proclaim/post_test.rb +0 -193
  209. data/test/models/proclaim/subscription_test.rb +0 -77
  210. data/test/policies/application_policy_test.rb +0 -87
  211. data/test/policies/proclaim/comment_policy_test.rb +0 -71
  212. data/test/policies/proclaim/image_policy_test.rb +0 -83
  213. data/test/policies/proclaim/post_policy_test.rb +0 -98
  214. data/test/policies/proclaim/subscription_policy_test.rb +0 -103
  215. data/test/proclaim_test.rb +0 -7
  216. data/test/support/images/test.jpg +0 -0
  217. data/test/support/pages/posts/edit_page.rb +0 -5
  218. data/test/support/pages/posts/show_page.rb +0 -47
  219. data/test/support/wait_for_ajax.rb +0 -11
  220. data/test/test_helper.rb +0 -71
  221. data/test/unit/proclaim/new_comment_callback_test.rb +0 -62
  222. data/test/unit/proclaim/new_subscription_callback_test.rb +0 -62
  223. data/test/unit/proclaim/post_published_callback_test.rb +0 -74
  224. data/vendor/assets/images/link.png +0 -0
  225. data/vendor/assets/images/remove.png +0 -0
  226. data/vendor/assets/images/resize-bigger.png +0 -0
  227. data/vendor/assets/images/resize-smaller.png +0 -0
  228. data/vendor/assets/images/unlink.png +0 -0
  229. data/vendor/assets/javascripts/addons/medium-editor-insert-embeds.js +0 -197
  230. data/vendor/assets/javascripts/addons/medium-editor-insert-images.js +0 -572
  231. data/vendor/assets/javascripts/addons/medium-editor-insert-maps.js +0 -50
  232. data/vendor/assets/javascripts/addons/medium-editor-insert-plugin.js +0 -496
  233. data/vendor/assets/javascripts/addons/medium-editor-insert-tables.js +0 -132
  234. data/vendor/assets/javascripts/medium-editor-insert-plugin.all.js +0 -1415
  235. data/vendor/assets/stylesheets/medium-editor-insert-plugin-frontend.css.scss +0 -55
  236. data/vendor/assets/stylesheets/medium-editor-insert-plugin.css.scss +0 -277
@@ -1,225 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PostFormTest < ActionDispatch::IntegrationTest
4
- include WaitForAjax
5
- self.use_transactional_fixtures = false
6
-
7
- setup do
8
- ApplicationController.any_instance.stubs(:current_user).returns(nil)
9
- ApplicationController.any_instance.stubs(:authenticate_user).returns(false)
10
-
11
- DatabaseCleaner.strategy = :truncation
12
- DatabaseCleaner.start
13
-
14
- Capybara.current_driver = :selenium
15
-
16
- @edit_page = EditPage.new
17
- end
18
-
19
- teardown do
20
- DatabaseCleaner.clean
21
- Capybara.use_default_driver
22
-
23
- image = Proclaim::Image.new
24
- FileUtils.rm_rf(File.join(Rails.public_path, image.image.cache_dir))
25
- FileUtils.rm_rf(File.join(Rails.public_path, image.image.store_dir))
26
- end
27
-
28
- test "should create post" do
29
- user = FactoryGirl.create(:user)
30
- sign_in user
31
-
32
- visit proclaim.new_post_path
33
-
34
- within('#new_post') do
35
- element = find('h1.editable')
36
- element.click()
37
- element.set("Post Title") # Set the title text
38
- element = find('div.editable')
39
- element.click() # Select the element
40
- element.set("Paragraph 1\nParagraph 2") # Set the body text
41
- end
42
-
43
- assert_difference('Proclaim::Post.count', 1,
44
- "A post should have been created") do
45
- click_button "Create"
46
- assert page.has_text?("Post Title"), "Post title should be shown"
47
- assert page.has_text?("Paragraph 1\nParagraph 2"),
48
- "Post body should be shown"
49
- wait_for_ajax
50
- end
51
- end
52
-
53
- test "should delete cached image" do
54
- user = FactoryGirl.create(:user)
55
- sign_in user
56
-
57
- image = FactoryGirl.build(:image, post: nil)
58
- post = FactoryGirl.create(:post, body: @edit_page.medium_inserted_image_html(image))
59
-
60
- cache_file_path = File.join(Rails.public_path, image.image.cache_dir, image.image.cache_name)
61
- cache_path = File.dirname(cache_file_path)
62
-
63
- assert File.exist?(cache_file_path), "File should have been cached: #{cache_file_path}"
64
-
65
- visit proclaim.edit_post_path(post)
66
-
67
- find("img[src='#{image.image.url}']").hover
68
- find("a.mediumInsert-imageRemove").click
69
-
70
- assert page.has_no_css?("img[src='#{image.image.url}']"), "Image should have been removed!"
71
-
72
- wait_for_ajax
73
-
74
- refute File.exist?(cache_file_path), "Should have removed cache file: #{cache_file_path}"
75
- refute File.exist?(cache_path), "Should have removed cache path: #{cache_path}"
76
- end
77
-
78
- test "should delete saved image" do
79
- user = FactoryGirl.create(:user)
80
- sign_in user
81
-
82
- image = FactoryGirl.create(:image)
83
- image.post.body = "<p>test</p>" + @edit_page.medium_inserted_image_html(image)
84
- image.post.save
85
-
86
- save_path = File.join(Rails.public_path, image.image.store_dir)
87
- saved_file_path = File.join(save_path, image.image_identifier)
88
-
89
- assert File.exist?(saved_file_path), "File should be saved: #{saved_file_path}"
90
-
91
- visit proclaim.edit_post_path(image.post)
92
-
93
- find("img[src='#{image.image.url}']").hover
94
- find("a.mediumInsert-imageRemove").click
95
-
96
- assert page.has_no_css?("img[src='#{image.image.url}']"), "Image should have been removed!"
97
-
98
- wait_for_ajax
99
-
100
- assert File.exist?(saved_file_path), "File should still be saved: #{saved_file_path}"
101
-
102
- click_button "Update Post"
103
- assert page.has_no_css?("div#error_explanation"), "This update should have succeeded!"
104
-
105
- assert page.has_no_css?("img[src='#{image.image.url}']"), "Image should still be removed!"
106
-
107
- refute File.exist?(saved_file_path), "Should have removed file: #{saved_file_path}"
108
- refute File.exist?(save_path), "Should have removed saved path: #{save_path}"
109
- end
110
-
111
- test "delete saved image but not save should still show image" do
112
- user = FactoryGirl.create(:user)
113
- sign_in user
114
-
115
- image = FactoryGirl.create(:image)
116
- image.post.body = @edit_page.medium_inserted_image_html(image)
117
- image.post.save
118
-
119
- save_path = File.join(Rails.public_path, image.image.store_dir)
120
- saved_file_path = File.join(save_path, image.image_identifier)
121
-
122
- assert File.exist?(saved_file_path), "File should be saved: #{saved_file_path}"
123
-
124
- visit proclaim.edit_post_path(image.post)
125
-
126
- find("img[src='#{image.image.url}']").hover
127
- find("a.mediumInsert-imageRemove").click
128
-
129
- assert page.has_no_css?("img[src='#{image.image.url}']"), "Image should have been removed!"
130
-
131
- wait_for_ajax
132
-
133
- assert File.exist?(saved_file_path), "File should still be saved: #{saved_file_path}"
134
-
135
- # Don't save. Just visit the post's show page
136
- visit proclaim.post_path(image.post)
137
-
138
- assert page.has_css?("img[src='#{image.image.url}']"), "Image should still be present!"
139
- assert File.exist?(saved_file_path), "File should still be saved: #{saved_file_path}"
140
- end
141
-
142
- test "form should not replace non-alphanumeric text in title with HTML entities" do
143
- user = FactoryGirl.create(:user)
144
- sign_in user
145
-
146
- visit proclaim.new_post_path
147
-
148
- within('#new_post') do
149
- element = find('h1.editable')
150
- element.click()
151
- element.set("\"quotes\"") # Set the title text
152
- # Don't fill in body
153
- end
154
-
155
- click_button "Create"
156
-
157
- assert page.has_css? "div#error_explanation"
158
-
159
- assert page.has_text?("\"quotes\""), "Form should still be showing quotes in title!"
160
- assert page.has_no_text?("&quot;quotes&quot;"), "Form should not be showing HTML entities in title!"
161
- end
162
-
163
- test "show should not replace non-alphanumeric text in title with HTML entities" do
164
- user = FactoryGirl.create(:user)
165
- sign_in user
166
-
167
- visit proclaim.new_post_path
168
-
169
- within('#new_post') do
170
- element = find('h1.editable')
171
- element.click()
172
- element.set("\"quotes\"") # Set the title text
173
- element = find('div.editable')
174
- element.click() # Select the element
175
- element.set("Paragraph 1\nParagraph 2") # Set the body text
176
- end
177
-
178
- click_button "Create"
179
-
180
- assert page.has_text?("\"quotes\""), "Show page should be showing quotes in title!"
181
- assert page.has_no_text?("&quot;quotes&quot;"), "Show page should not be showing HTML entities in title!"
182
- end
183
-
184
- test "new should show error without title" do
185
- user = FactoryGirl.create(:user)
186
- sign_in user
187
-
188
- visit proclaim.new_post_path
189
-
190
- within('#new_post') do
191
- # Don't fill in title
192
- element = find('div.editable')
193
- element.click() # Select the element
194
- element.set("Paragraph 1\nParagraph 2") # Set the text
195
- end
196
-
197
- assert_no_difference('Proclaim::Post.count',
198
- "No post should have been created without a title") do
199
- click_button "Create"
200
- assert page.has_css?("div#error_explanation"),
201
- "Should show error complaining about lack of title"
202
- wait_for_ajax
203
- end
204
- end
205
-
206
- test "new should show error without body" do
207
- user = FactoryGirl.create(:user)
208
- sign_in user
209
-
210
- visit proclaim.new_post_path
211
-
212
- within('#new_post') do
213
- element = find('h1.editable')
214
- element.click()
215
- element.set("Post Title") # Set the title text
216
- # Don't fill in the body
217
- end
218
-
219
- assert_no_difference('Proclaim::Post.count') do
220
- click_button "Create"
221
- assert page.has_css? "div#error_explanation"
222
- wait_for_ajax
223
- end
224
- end
225
- end
@@ -1,47 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PostShowTest < ActionDispatch::IntegrationTest
4
- self.use_transactional_fixtures = false
5
-
6
- setup do
7
- ApplicationController.any_instance.stubs(:current_user).returns(nil)
8
- ApplicationController.any_instance.stubs(:authenticate_user).returns(false)
9
-
10
- DatabaseCleaner.strategy = :truncation
11
- DatabaseCleaner.start
12
-
13
- Capybara.current_driver = :selenium
14
-
15
- @show_pag = ShowPage.new
16
- end
17
-
18
- teardown do
19
- DatabaseCleaner.clean
20
- Capybara.use_default_driver
21
- end
22
-
23
- test "show should include edit/delete buttons if logged in" do
24
- user = FactoryGirl.create(:user)
25
- sign_in user
26
-
27
- post = FactoryGirl.create(:published_post)
28
-
29
- visit proclaim.post_path(post)
30
-
31
- assert page.has_css?('a', text: "Edit"),
32
- "The show page should include a link to edit if logged in!"
33
- assert page.has_css?('a', text: "Delete"),
34
- "The show page should include a link to delete if logged in!"
35
- end
36
-
37
- test "show should not include edit/delete buttons if not logged in" do
38
- post = FactoryGirl.create(:published_post)
39
-
40
- visit proclaim.post_path(post)
41
-
42
- assert page.has_no_css?('a', text: "Edit"),
43
- "The show page should not include a link to edit if not logged in!"
44
- assert page.has_no_css?('a', text: "Delete"),
45
- "The show page should not include a link to delete if not logged in!"
46
- end
47
- end
@@ -1,302 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PostSubscriptionTest < ActionDispatch::IntegrationTest
4
- include WaitForAjax
5
- self.use_transactional_fixtures = false
6
-
7
- setup do
8
- ApplicationController.any_instance.stubs(:current_user).returns(nil)
9
- ApplicationController.any_instance.stubs(:authenticate_user).returns(false)
10
-
11
- DatabaseCleaner.strategy = :truncation
12
- DatabaseCleaner.start
13
-
14
- Capybara.current_driver = :selenium
15
-
16
- ActionMailer::Base.deliveries.clear
17
-
18
- @show_page = ShowPage.new
19
- end
20
-
21
- teardown do
22
- DatabaseCleaner.clean
23
- Capybara.use_default_driver
24
- end
25
-
26
- test "should be able to create new root comment with subscription while logged in" do
27
- user = FactoryGirl.create(:user)
28
- sign_in user
29
-
30
- post = FactoryGirl.create(:published_post)
31
-
32
- visit proclaim.post_path(post)
33
-
34
- within('#new_comment') do
35
- fill_in 'Author', with: "Comment Author"
36
- fill_in 'Body', with: "Comment Body"
37
- fill_in 'What is', with: @show_page.antispam_solution
38
- check 'Notify me of other comments on this post'
39
- fill_in 'Email', with: "example@example.com"
40
- end
41
-
42
- # Verify that email field is shown
43
- assert page.has_text?('Email')
44
-
45
- assert_difference('Proclaim::Subscription.count', 1, "A new subscription should have been added!") do
46
- @show_page.new_comment_submit_button.click
47
- wait_for_ajax
48
- end
49
-
50
- # Now email field should be hidden
51
- assert page.has_no_text?('Email'),
52
- "Email field should be hidden again when form is successful"
53
-
54
- # Make sure a welcome email was sent
55
- assert_equal ["example@example.com"], ActionMailer::Base.deliveries.last.to
56
-
57
- post.reload # Refresh post to pull in new associations
58
-
59
- assert 1, post.subscriptions.count
60
- assert_equal "example@example.com", post.subscriptions.first.email
61
- end
62
-
63
- test "should be able to create new root comment with subscription while not logged in" do
64
- post = FactoryGirl.create(:published_post)
65
-
66
- visit proclaim.post_path(post)
67
-
68
- within('#new_comment') do
69
- fill_in 'Author', with: "Comment Author"
70
- fill_in 'Body', with: "Comment Body"
71
- fill_in 'What is', with: @show_page.antispam_solution
72
- check 'Notify me of other comments on this post'
73
- fill_in 'Email', with: "example@example.com"
74
- end
75
-
76
- assert_difference('Proclaim::Subscription.count', 1, "A new subscription should have been added!") do
77
- @show_page.new_comment_submit_button.click
78
- wait_for_ajax
79
- end
80
-
81
- # Make sure a welcome email was sent
82
- assert_equal ["example@example.com"], ActionMailer::Base.deliveries.last.to
83
-
84
- post.reload # Refresh post to pull in new associations
85
-
86
- assert 1, post.subscriptions.count
87
- assert_equal "example@example.com", post.subscriptions.first.email
88
- end
89
-
90
- test "should be able to create new reply with subscription while logged in" do
91
- user = FactoryGirl.create(:user)
92
- sign_in user
93
-
94
- comment = FactoryGirl.create(:published_comment)
95
-
96
- visit proclaim.post_path(comment.post)
97
-
98
- click_link "Reply"
99
- within("#reply_to_#{comment.id}_new_comment") do
100
- fill_in 'Author', with: "Reply Author"
101
- fill_in 'Body', with: "Reply Body"
102
- fill_in 'What is', with: @show_page.antispam_solution(comment)
103
- check 'Notify me of other comments on this post'
104
- fill_in 'Email', with: "example@example.com"
105
- end
106
-
107
- assert_difference('Proclaim::Subscription.count', 1, "A new subscription should have been added!") do
108
- @show_page.new_comment_submit_button(comment).click
109
- wait_for_ajax
110
- end
111
-
112
- # Make sure a welcome email was sent
113
- assert_equal ["example@example.com"], ActionMailer::Base.deliveries.last.to
114
- comment.reload # Refresh comment to pull in new associations
115
-
116
- assert 1, comment.post.subscriptions.count
117
- assert_equal "example@example.com", comment.post.subscriptions.first.email
118
- end
119
-
120
- test "should be able to create new reply with subscription while not logged in" do
121
- comment = FactoryGirl.create(:published_comment)
122
-
123
- visit proclaim.post_path(comment.post)
124
-
125
- click_link "Reply"
126
- within("#reply_to_#{comment.id}_new_comment") do
127
- fill_in 'Author', with: "Reply Author"
128
- fill_in 'Body', with: "Reply Body"
129
- fill_in 'What is', with: @show_page.antispam_solution(comment)
130
- check 'Notify me of other comments on this post'
131
- fill_in 'Email', with: "example@example.com"
132
- end
133
-
134
- assert_difference('Proclaim::Subscription.count', 1, "A new subscription should have been added!") do
135
- @show_page.new_comment_submit_button(comment).click
136
- wait_for_ajax
137
- end
138
-
139
- # Make sure a welcome email was sent
140
- assert_equal ["example@example.com"], ActionMailer::Base.deliveries.last.to
141
-
142
- comment.reload # Refresh comment to pull in new associations
143
-
144
- assert 1, comment.post.subscriptions.count
145
- assert_equal "example@example.com", comment.post.subscriptions.first.email
146
- end
147
-
148
- test "should not send new comment notification email containing own comment" do
149
- post = FactoryGirl.create(:published_post)
150
-
151
- visit proclaim.post_path(post)
152
-
153
- within('#new_comment') do
154
- fill_in 'Author', with: "Comment Author"
155
- fill_in 'Body', with: "Comment Body"
156
- fill_in 'What is', with: @show_page.antispam_solution
157
- check 'Notify me of other comments on this post'
158
- fill_in 'Email', with: "example@example.com"
159
- end
160
-
161
- assert_difference('Proclaim::Subscription.count', 1, "A new subscription should have been added!") do
162
- @show_page.new_comment_submit_button.click
163
- wait_for_ajax
164
- end
165
-
166
- # Make sure only a single email was sent
167
- assert_equal 1, ActionMailer::Base.deliveries.count,
168
- "Only a welcome email should have been sent!"
169
- assert_match "Welcome", ActionMailer::Base.deliveries.last.subject
170
- end
171
-
172
- test "should not create new root comment with subscription if spammy" do
173
- comment = FactoryGirl.create(:published_comment)
174
-
175
- visit proclaim.post_path(comment.post)
176
-
177
- within('#new_comment') do
178
- fill_in 'Author', with: "Comment Author"
179
- fill_in 'Body', with: "Comment Body"
180
- fill_in 'What is', with: "wrong answer"
181
- check 'Notify me of other comments on this post'
182
- fill_in 'Email', with: "example@example.com"
183
- end
184
-
185
- assert_no_difference('Proclaim::Comment.count',
186
- "A new comment should not have been added!") do
187
- assert_no_difference('Proclaim::Subscription.count',
188
- "A new subscription should not have been added!") do
189
- @show_page.new_comment_submit_button.click
190
- assert page.has_css?('div.error'), "Failed antispam question-- errors should show!"
191
- wait_for_ajax
192
- end
193
- end
194
-
195
- # Make sure no email was sent
196
- assert_empty ActionMailer::Base.deliveries
197
- end
198
-
199
- test "should not create new reply with subscription if spammy" do
200
- comment = FactoryGirl.create(:published_comment)
201
-
202
- visit proclaim.post_path(comment.post)
203
-
204
- click_link "Reply"
205
- within("#reply_to_#{comment.id}_new_comment") do
206
- fill_in 'Author', with: "Reply Author"
207
- fill_in 'Body', with: "Reply Body"
208
- fill_in 'What is', with: "wrong answer"
209
- check 'Notify me of other comments on this post'
210
- fill_in 'Email', with: "example@example.com"
211
- end
212
-
213
- assert_no_difference('Proclaim::Comment.count',
214
- "A new comment should not have been added!") do
215
- assert_no_difference('Proclaim::Subscription.count',
216
- "A new subscription should not have been added!") do
217
- @show_page.new_comment_submit_button(comment).click
218
- assert page.has_css?('div.error'), "Failed antispam question-- errors should show!"
219
- wait_for_ajax
220
- end
221
- end
222
-
223
- # Make sure no email was sent
224
- assert_empty ActionMailer::Base.deliveries
225
- end
226
-
227
- test "catch lack of email address" do
228
- post = FactoryGirl.create(:published_post)
229
- visit proclaim.post_path(post)
230
-
231
- # Create a new comment and say "notify me," but don't provide email
232
- within('#new_comment') do
233
- fill_in 'Author', with: "Comment Author"
234
- fill_in 'Body', with: "Comment Body"
235
- fill_in 'What is', with: @show_page.antispam_solution
236
- check 'Notify me of other comments on this post'
237
- end
238
-
239
- assert_no_difference('Proclaim::Comment.count',
240
- "A new comment should not have been added!") do
241
- assert_no_difference('Proclaim::Subscription.count',
242
- "A new subscription should not have been added!") do
243
- @show_page.new_comment_submit_button.click
244
- assert page.has_css?('div.error')
245
- wait_for_ajax
246
- end
247
- end
248
-
249
- # Make sure no email was sent
250
- assert_empty ActionMailer::Base.deliveries
251
- end
252
-
253
- test "catch bad email address" do
254
- post = FactoryGirl.create(:published_post)
255
-
256
- visit proclaim.post_path(post)
257
-
258
- # Create a new comment and say "notify me," but provide invalid email
259
- within('#new_comment') do
260
- fill_in 'Author', with: "Comment Author"
261
- fill_in 'Body', with: "Comment Body"
262
- fill_in 'What is', with: @show_page.antispam_solution
263
- check 'Notify me of other comments on this post'
264
- fill_in 'Email', with: "bad_email"
265
- end
266
-
267
- assert_no_difference('Proclaim::Comment.count',
268
- "A new comment should not have been added!") do
269
- assert_no_difference('Proclaim::Subscription.count',
270
- "A new subscription should not have been added!") do
271
- @show_page.new_comment_submit_button.click
272
- assert page.has_css?('div.error')
273
- wait_for_ajax
274
- end
275
- end
276
-
277
- # Make sure no email was sent
278
- assert_empty ActionMailer::Base.deliveries
279
- end
280
-
281
- test "cancel button should remove email field" do
282
- post = FactoryGirl.create(:published_post)
283
-
284
- visit proclaim.post_path(post)
285
-
286
- within('#new_comment') do
287
- fill_in 'Author', with: "Comment Author"
288
- fill_in 'Body', with: "Comment Body"
289
- fill_in 'What is', with: @show_page.antispam_solution
290
- check 'Notify me of other comments on this post'
291
- end
292
-
293
- # Verify email field is shown
294
- assert page.has_text?('Email')
295
-
296
- # Now click cancel
297
- @show_page.new_comment_cancel_button.click
298
-
299
- # Now email field should be hidden
300
- assert page.has_no_text?('Email')
301
- end
302
- end