proclaim 0.5.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Rakefile +5 -38
- data/app/assets/config/proclaim_manifest.js +2 -0
- data/app/assets/images/{ajax_loader.gif → proclaim/ajax_loader.gif} +0 -0
- data/app/assets/javascripts/proclaim.js +7 -7
- data/app/assets/javascripts/proclaim/{comments_handler.js.coffee → comments_handler.coffee} +16 -10
- data/app/assets/javascripts/proclaim/editor.coffee +55 -0
- data/app/assets/stylesheets/{proclaim.css.scss → proclaim.scss} +7 -8
- data/app/assets/stylesheets/proclaim/{comments.css.scss → comments.scss} +0 -0
- data/app/assets/stylesheets/proclaim/{posts.css.scss → posts.scss} +60 -25
- data/app/assets/stylesheets/proclaim/{subscriptions.css.scss → subscriptions.scss} +0 -0
- data/app/controllers/proclaim/application_controller.rb +60 -56
- data/app/controllers/proclaim/comments_controller.rb +13 -42
- data/app/controllers/proclaim/posts_controller.rb +25 -57
- data/app/controllers/proclaim/subscriptions_controller.rb +3 -3
- data/app/jobs/proclaim/application_job.rb +4 -0
- data/app/mailers/proclaim/application_mailer.rb +5 -0
- data/app/mailers/proclaim/subscription_mailer.rb +19 -17
- data/app/models/proclaim/application_record.rb +5 -0
- data/app/models/proclaim/comment.rb +6 -1
- data/app/models/proclaim/post.rb +20 -28
- data/app/models/proclaim/subscription.rb +33 -11
- data/app/views/layouts/proclaim/subscription_mailer.html.erb +15 -36
- data/app/views/proclaim/comments/_comment.html.erb +7 -7
- data/app/views/proclaim/comments/_form.html.erb +7 -5
- data/app/views/proclaim/posts/_form.html.erb +34 -21
- data/app/views/proclaim/posts/show.html.erb +16 -3
- data/app/views/proclaim/subscription_mailer/welcome_email.html.erb +2 -6
- data/config/initializers/friendly_id.rb +20 -1
- data/config/routes.rb +1 -5
- data/db/migrate/20141108222616_create_proclaim_posts.rb +8 -1
- data/db/migrate/20141114235359_create_proclaim_comments.rb +1 -1
- data/db/migrate/20141115022230_create_proclaim_comment_hierarchies.rb +1 -1
- data/db/migrate/20141210234057_create_proclaim_subscriptions.rb +5 -4
- data/db/migrate/20150213015321_create_friendly_id_slugs.rb +1 -1
- data/lib/generators/proclaim/install_generator.rb +1 -1
- data/lib/generators/proclaim/templates/initialize_proclaim.rb +31 -29
- data/lib/generators/proclaim/views_generator.rb +1 -1
- data/lib/proclaim.rb +15 -15
- data/lib/proclaim/engine.rb +21 -19
- data/lib/proclaim/version.rb +1 -1
- data/vendor/assets/fonts/KaTeX_AMS-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_AMS-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Main-Bold.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Main-Bold.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Main-Bold.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Main-Italic.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Main-Italic.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Main-Italic.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Main-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Main-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Main-Regular.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Math-Italic.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Math-Italic.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Math-Italic.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- data/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- data/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Script-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Script-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Script-Regular.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Size1-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Size1-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Size2-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Size2-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Size3-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Size3-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Size4-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Size4-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- data/vendor/assets/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- data/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- data/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- data/vendor/assets/javascripts/contrib/auto-render.js +339 -0
- data/vendor/assets/javascripts/contrib/auto-render.min.js +1 -0
- data/vendor/assets/javascripts/contrib/auto-render.mjs +215 -0
- data/vendor/assets/javascripts/contrib/copy-tex.css +14 -0
- data/vendor/assets/javascripts/contrib/copy-tex.js +213 -0
- data/vendor/assets/javascripts/contrib/copy-tex.min.css +1 -0
- data/vendor/assets/javascripts/contrib/copy-tex.min.js +1 -0
- data/vendor/assets/javascripts/contrib/copy-tex.mjs +85 -0
- data/vendor/assets/javascripts/contrib/mathtex-script-type.js +137 -0
- data/vendor/assets/javascripts/contrib/mathtex-script-type.min.js +1 -0
- data/vendor/assets/javascripts/contrib/mathtex-script-type.mjs +24 -0
- data/vendor/assets/javascripts/contrib/mhchem.js +3241 -0
- data/vendor/assets/javascripts/contrib/mhchem.min.js +1 -0
- data/vendor/assets/javascripts/contrib/mhchem.mjs +3109 -0
- data/vendor/assets/javascripts/katex.js +16517 -0
- data/vendor/assets/javascripts/katex.min.js +1 -0
- data/vendor/assets/javascripts/katex.mjs +16122 -0
- data/vendor/assets/javascripts/quill.core.js +8522 -0
- data/vendor/assets/javascripts/quill.js +11489 -0
- data/vendor/assets/javascripts/quill.min.js +8 -0
- data/vendor/assets/javascripts/quill.min.js.map +1 -0
- data/vendor/assets/stylesheets/katex.css +1011 -0
- data/vendor/assets/stylesheets/katex.min.css +1 -0
- data/vendor/assets/stylesheets/quill.bubble.css +952 -0
- data/vendor/assets/stylesheets/quill.core.css +397 -0
- data/vendor/assets/stylesheets/quill.snow.css +945 -0
- metadata +169 -278
- data/CHANGELOG +0 -77
- data/Gemfile +0 -14
- data/VERSION +0 -1
- data/app/assets/javascripts/proclaim/editor.js.coffee +0 -52
- data/app/assets/javascripts/proclaim/images.js.coffee +0 -3
- data/app/assets/javascripts/proclaim/subscriptions.js.coffee +0 -3
- data/app/assets/stylesheets/proclaim/images.scss +0 -3
- data/app/controllers/proclaim/images_controller.rb +0 -67
- data/app/helpers/proclaim/comments_helper.rb +0 -4
- data/app/helpers/proclaim/images_helper.rb +0 -4
- data/app/helpers/proclaim/subscriptions_helper.rb +0 -4
- data/app/models/proclaim/image.rb +0 -19
- data/app/policies/proclaim/image_policy.rb +0 -29
- data/app/uploaders/proclaim/image_uploader.rb +0 -82
- data/db/migrate/20141222224905_create_proclaim_images.rb +0 -12
- data/db/migrate/20150123115226_add_name_to_subscriptions.rb +0 -7
- data/db/migrate/20150213015850_add_slug_to_posts.rb +0 -20
- data/proclaim.gemspec +0 -51
- data/test/controllers/proclaim/comments_controller_test.rb +0 -228
- data/test/controllers/proclaim/images_controller_test.rb +0 -166
- data/test/controllers/proclaim/posts_controller_test.rb +0 -465
- data/test/controllers/proclaim/subscriptions_controller_test.rb +0 -154
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.js +0 -14
- data/test/dummy/app/assets/stylesheets/application.css +0 -16
- data/test/dummy/app/controllers/application_controller.rb +0 -15
- data/test/dummy/app/helpers/application_helper.rb +0 -28
- data/test/dummy/app/models/user.rb +0 -7
- data/test/dummy/app/views/layouts/application.html.erb +0 -16
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -24
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -45
- data/test/dummy/config/environments/production.rb +0 -80
- data/test/dummy/config/environments/test.rb +0 -49
- data/test/dummy/config/initializers/assets.rb +0 -8
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -5
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/db/migrate/20141117214323_create_users.rb +0 -10
- data/test/dummy/db/schema.rb +0 -91
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/factories/proclaim/comment.rb +0 -11
- data/test/factories/proclaim/image.rb +0 -6
- data/test/factories/proclaim/post.rb +0 -14
- data/test/factories/proclaim/subscription.rb +0 -14
- data/test/factories/user.rb +0 -6
- data/test/helpers/proclaim/comments_helper_test.rb +0 -6
- data/test/helpers/proclaim/posts_helper_test.rb +0 -6
- data/test/helpers/proclaim/subscriptions_helper_test.rb +0 -6
- data/test/integration/with_javascript/comment_test.rb +0 -391
- data/test/integration/with_javascript/post_form_test.rb +0 -225
- data/test/integration/with_javascript/post_show_test.rb +0 -47
- data/test/integration/with_javascript/post_subscription_test.rb +0 -302
- data/test/integration/without_javascript/blog_subscription_test.rb +0 -114
- data/test/integration/without_javascript/manage_subscriptions_test.rb +0 -37
- data/test/integration/without_javascript/post_test.rb +0 -234
- data/test/integration/without_javascript/subscription_email_test.rb +0 -95
- data/test/integration/without_javascript/unsubscribe_test.rb +0 -32
- data/test/mailers/previews/proclaim/subscription_mailer_preview.rb +0 -22
- data/test/mailers/proclaim/subscription_mailer_test.rb +0 -91
- data/test/models/proclaim/comment_test.rb +0 -41
- data/test/models/proclaim/image_test.rb +0 -70
- data/test/models/proclaim/post_test.rb +0 -193
- data/test/models/proclaim/subscription_test.rb +0 -77
- data/test/policies/application_policy_test.rb +0 -87
- data/test/policies/proclaim/comment_policy_test.rb +0 -71
- data/test/policies/proclaim/image_policy_test.rb +0 -83
- data/test/policies/proclaim/post_policy_test.rb +0 -98
- data/test/policies/proclaim/subscription_policy_test.rb +0 -103
- data/test/proclaim_test.rb +0 -7
- data/test/support/images/test.jpg +0 -0
- data/test/support/pages/posts/edit_page.rb +0 -5
- data/test/support/pages/posts/show_page.rb +0 -47
- data/test/support/wait_for_ajax.rb +0 -11
- data/test/test_helper.rb +0 -71
- data/test/unit/proclaim/new_comment_callback_test.rb +0 -62
- data/test/unit/proclaim/new_subscription_callback_test.rb +0 -62
- data/test/unit/proclaim/post_published_callback_test.rb +0 -74
- data/vendor/assets/images/link.png +0 -0
- data/vendor/assets/images/remove.png +0 -0
- data/vendor/assets/images/resize-bigger.png +0 -0
- data/vendor/assets/images/resize-smaller.png +0 -0
- data/vendor/assets/images/unlink.png +0 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-embeds.js +0 -197
- data/vendor/assets/javascripts/addons/medium-editor-insert-images.js +0 -572
- data/vendor/assets/javascripts/addons/medium-editor-insert-maps.js +0 -50
- data/vendor/assets/javascripts/addons/medium-editor-insert-plugin.js +0 -496
- data/vendor/assets/javascripts/addons/medium-editor-insert-tables.js +0 -132
- data/vendor/assets/javascripts/medium-editor-insert-plugin.all.js +0 -1415
- data/vendor/assets/stylesheets/medium-editor-insert-plugin-frontend.css.scss +0 -55
- data/vendor/assets/stylesheets/medium-editor-insert-plugin.css.scss +0 -277
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class UnsubscribeTest < ActionDispatch::IntegrationTest
|
|
4
|
-
setup do
|
|
5
|
-
ApplicationController.any_instance.stubs(:current_user).returns(nil)
|
|
6
|
-
ApplicationController.any_instance.stubs(:authenticate_user).returns(false)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
test "should be able to unsubscribe from blog" do
|
|
10
|
-
subscription = FactoryGirl.create(:subscription)
|
|
11
|
-
|
|
12
|
-
visit proclaim.subscription_path(subscription.token)
|
|
13
|
-
|
|
14
|
-
assert_difference('Proclaim::Subscription.count', -1) do
|
|
15
|
-
click_button "Unsubscribe"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
assert_equal proclaim.posts_path, current_path
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
test "should be able to unsubscribe from post" do
|
|
22
|
-
subscription = FactoryGirl.create(:published_post_subscription)
|
|
23
|
-
|
|
24
|
-
visit proclaim.subscription_path(subscription.token)
|
|
25
|
-
|
|
26
|
-
assert_difference('Proclaim::Subscription.count', -1) do
|
|
27
|
-
click_button "Unsubscribe"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
assert_equal proclaim.posts_path, current_path
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Proclaim
|
|
2
|
-
# Preview all emails at http://localhost:3000/rails/mailers/subscription_mailer
|
|
3
|
-
class SubscriptionMailerPreview < ActionMailer::Preview
|
|
4
|
-
def welcome_email
|
|
5
|
-
subscription = Subscription.first
|
|
6
|
-
SubscriptionMailer.welcome_email(subscription)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def new_post_notification_email
|
|
10
|
-
subscription = Subscription.first
|
|
11
|
-
post = Post.first
|
|
12
|
-
SubscriptionMailer.new_post_notification_email(subscription, post)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def new_comment_notification_email
|
|
16
|
-
subscription = Subscription.where("post_id <> ''").first
|
|
17
|
-
comment = subscription.post.comments.first
|
|
18
|
-
|
|
19
|
-
SubscriptionMailer.new_comment_notification_email(subscription, comment)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
module Proclaim
|
|
4
|
-
class SubscriptionMailerTest < ActionMailer::TestCase
|
|
5
|
-
include Rails.application.routes.url_helpers
|
|
6
|
-
include Rails.application.routes.mounted_helpers
|
|
7
|
-
|
|
8
|
-
def default_url_options
|
|
9
|
-
Rails.application.config.action_mailer.default_url_options
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
setup do
|
|
13
|
-
@edit_page = EditPage.new
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
test "welcome email" do
|
|
17
|
-
subscription = FactoryGirl.create(:subscription)
|
|
18
|
-
|
|
19
|
-
mail = SubscriptionMailer.welcome_email(subscription)
|
|
20
|
-
assert_match "Welcome", mail.subject
|
|
21
|
-
assert_equal [subscription.email], mail.to
|
|
22
|
-
assert_equal ["from@example.com"], mail.from
|
|
23
|
-
assert_equal 2, mail.body.parts.length # Ensure multipart: text and HTML
|
|
24
|
-
|
|
25
|
-
# Verify the email includes a greeting
|
|
26
|
-
assert_match "Hello, #{subscription.name}", get_text_part(mail)
|
|
27
|
-
assert_match "Hello, #{subscription.name}", get_html_part(mail)
|
|
28
|
-
|
|
29
|
-
# Verify the email includes an unsubscription URL
|
|
30
|
-
assert_match proclaim.subscription_url(subscription.token), get_text_part(mail)
|
|
31
|
-
assert_match proclaim.subscription_url(subscription.token), get_html_part(mail)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
test "new comment notification email" do
|
|
35
|
-
subscription = FactoryGirl.create(:post_subscription)
|
|
36
|
-
comment = FactoryGirl.create(:comment)
|
|
37
|
-
|
|
38
|
-
mail = SubscriptionMailer.new_comment_notification_email(subscription, comment)
|
|
39
|
-
assert_equal "New Comment On \"#{comment.post.title}\"", mail.subject
|
|
40
|
-
assert_equal [subscription.email], mail.to
|
|
41
|
-
assert_equal ["from@example.com"], mail.from
|
|
42
|
-
assert_equal 2, mail.body.parts.length # Ensure multipart: text and HTML
|
|
43
|
-
|
|
44
|
-
# Verify the email includes an unsubscription URL
|
|
45
|
-
assert_match proclaim.subscription_url(subscription.token), get_text_part(mail)
|
|
46
|
-
assert_match proclaim.subscription_url(subscription.token), get_html_part(mail)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
test "new post notification email" do
|
|
50
|
-
subscription = FactoryGirl.create(:subscription)
|
|
51
|
-
post = FactoryGirl.create(:published_post)
|
|
52
|
-
|
|
53
|
-
mail = SubscriptionMailer.new_post_notification_email(subscription, post)
|
|
54
|
-
assert_equal "New Post: #{post.title}", mail.subject
|
|
55
|
-
assert_equal [subscription.email], mail.to
|
|
56
|
-
assert_equal ["from@example.com"], mail.from
|
|
57
|
-
assert_equal 2, mail.body.parts.length # Ensure multipart: text and HTML
|
|
58
|
-
|
|
59
|
-
# Verify the email includes an unsubscription URL
|
|
60
|
-
assert_match proclaim.subscription_url(subscription.token), get_text_part(mail)
|
|
61
|
-
assert_match proclaim.subscription_url(subscription.token), get_html_part(mail)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
test "images in new post notification email should have absolute URLs" do
|
|
65
|
-
subscription = FactoryGirl.create(:subscription)
|
|
66
|
-
|
|
67
|
-
image = FactoryGirl.create(:image)
|
|
68
|
-
image.post.body = @edit_page.medium_inserted_image_html(image)
|
|
69
|
-
image.post.publish
|
|
70
|
-
image.post.save
|
|
71
|
-
|
|
72
|
-
mail = SubscriptionMailer.new_post_notification_email(subscription, image.post)
|
|
73
|
-
|
|
74
|
-
image_tags = Nokogiri::HTML(get_html_part(mail)).css("img")
|
|
75
|
-
|
|
76
|
-
assert_equal 1, image_tags.length, "Email should have one image tag"
|
|
77
|
-
assert_match root_url, image_tags[0].attribute("src"),
|
|
78
|
-
"Images should have absolute URLs in emails"
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
private
|
|
82
|
-
|
|
83
|
-
def get_text_part(mail)
|
|
84
|
-
mail.body.parts.find {|p| p.content_type.match /plain/}.body.raw_source
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def get_html_part(mail)
|
|
88
|
-
mail.body.parts.find {|p| p.content_type.match /html/}.body.raw_source
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# == Schema Information
|
|
2
|
-
#
|
|
3
|
-
# Table name: proclaim_comments
|
|
4
|
-
#
|
|
5
|
-
# id :integer not null, primary key
|
|
6
|
-
# post_id :integer
|
|
7
|
-
# parent_id :integer
|
|
8
|
-
# author :string
|
|
9
|
-
# body :text
|
|
10
|
-
# created_at :datetime not null
|
|
11
|
-
# updated_at :datetime not null
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
require 'test_helper'
|
|
15
|
-
|
|
16
|
-
module Proclaim
|
|
17
|
-
class CommentTest < ActiveSupport::TestCase
|
|
18
|
-
test "ensure factory is good" do
|
|
19
|
-
comment = FactoryGirl.build(:comment)
|
|
20
|
-
|
|
21
|
-
assert comment.save, "Factory needs to be updated to save successfully"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
test "ensure body is required" do
|
|
25
|
-
comment = FactoryGirl.build(:comment, body: "")
|
|
26
|
-
|
|
27
|
-
refute comment.save, "Comment should require a body!"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
test "ensure post is required" do
|
|
31
|
-
comment = FactoryGirl.build(:comment, post_id: nil)
|
|
32
|
-
|
|
33
|
-
refute comment.save, "Comment should require a post_id!"
|
|
34
|
-
|
|
35
|
-
# Post with 12345 shouldn't exist
|
|
36
|
-
comment = FactoryGirl.build(:comment, post_id: 12345)
|
|
37
|
-
|
|
38
|
-
refute comment.save, "Comment should require a valid post!"
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# == Schema Information
|
|
2
|
-
#
|
|
3
|
-
# Table name: proclaim_images
|
|
4
|
-
#
|
|
5
|
-
# id :integer not null, primary key
|
|
6
|
-
# post_id :integer
|
|
7
|
-
# image :string
|
|
8
|
-
# created_at :datetime not null
|
|
9
|
-
# updated_at :datetime not null
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
require 'test_helper'
|
|
13
|
-
|
|
14
|
-
module Proclaim
|
|
15
|
-
class ImageTest < ActiveSupport::TestCase
|
|
16
|
-
teardown do
|
|
17
|
-
image = Image.new
|
|
18
|
-
FileUtils.rm_rf(File.join(Rails.public_path, image.image.cache_dir))
|
|
19
|
-
FileUtils.rm_rf(File.join(Rails.public_path, image.image.store_dir))
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
test "ensure factory is good" do
|
|
23
|
-
image = FactoryGirl.build(:image)
|
|
24
|
-
|
|
25
|
-
assert image.save, "Factory needs to be updated to save successfully"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
test "ensure post is required" do
|
|
29
|
-
image = FactoryGirl.build(:image, post_id: nil)
|
|
30
|
-
|
|
31
|
-
refute image.save, "Image should require a post_id!"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
test "ensure post validity is verified" do
|
|
35
|
-
# Post with 12345 shouldn't exist
|
|
36
|
-
image = FactoryGirl.build(:image, post_id: 12345)
|
|
37
|
-
|
|
38
|
-
refute image.save, "Image should require a valid post!"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
test "ensure image is required" do
|
|
42
|
-
image = FactoryGirl.build(:image, image: nil)
|
|
43
|
-
|
|
44
|
-
refute image.save, "Image should require an image to be uploaded!"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
test "ensure image is cached, saved, and removed correctly" do
|
|
48
|
-
image = FactoryGirl.build(:image)
|
|
49
|
-
|
|
50
|
-
cache_file_path = File.join(Rails.public_path, image.image.cache_dir, image.image.cache_name)
|
|
51
|
-
cache_path = File.dirname(cache_file_path)
|
|
52
|
-
|
|
53
|
-
assert File.exist?(cache_file_path), "File should have been cached: #{cache_file_path}"
|
|
54
|
-
|
|
55
|
-
assert image.save, "Image should have saved!"
|
|
56
|
-
|
|
57
|
-
save_path = File.join(Rails.public_path, image.image.store_dir)
|
|
58
|
-
saved_file_path = File.join(save_path, image.image_identifier)
|
|
59
|
-
|
|
60
|
-
assert File.exist?(saved_file_path), "File should be saved: #{saved_file_path}"
|
|
61
|
-
refute File.exist?(cache_file_path), "Should have removed cache file: #{cache_file_path}"
|
|
62
|
-
refute File.exist?(cache_path), "Should have removed cache path: #{cache_path}"
|
|
63
|
-
|
|
64
|
-
assert image.destroy
|
|
65
|
-
|
|
66
|
-
refute File.exist?(saved_file_path), "Should have removed file: #{saved_file_path}"
|
|
67
|
-
refute File.exist?(save_path), "Should have removed saved path: #{save_path}"
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
# == Schema Information
|
|
2
|
-
#
|
|
3
|
-
# Table name: proclaim_posts
|
|
4
|
-
#
|
|
5
|
-
# id :integer not null, primary key
|
|
6
|
-
# author_id :integer
|
|
7
|
-
# title :string default(""), not null
|
|
8
|
-
# body :text default(""), not null
|
|
9
|
-
# published :boolean default("f"), not null
|
|
10
|
-
# publication_date :datetime
|
|
11
|
-
# created_at :datetime not null
|
|
12
|
-
# updated_at :datetime not null
|
|
13
|
-
#
|
|
14
|
-
|
|
15
|
-
require 'test_helper'
|
|
16
|
-
|
|
17
|
-
module Proclaim
|
|
18
|
-
class PostTest < ActiveSupport::TestCase
|
|
19
|
-
test "ensure factory is good" do
|
|
20
|
-
post = FactoryGirl.build(:post)
|
|
21
|
-
|
|
22
|
-
assert post.save, "Factory needs to be updated to save successfully"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
test "ensure title is required" do
|
|
26
|
-
post = FactoryGirl.build(:post, title: "")
|
|
27
|
-
|
|
28
|
-
refute post.save, "Post should require a title!"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
test "ensure body is required" do
|
|
32
|
-
post = FactoryGirl.build(:post, body: nil)
|
|
33
|
-
refute post.save, "Post should require a body!"
|
|
34
|
-
|
|
35
|
-
post = FactoryGirl.build(:post, body: "")
|
|
36
|
-
refute post.save, "Post should require a body!"
|
|
37
|
-
|
|
38
|
-
post = FactoryGirl.build(:post, body: "<p></p>")
|
|
39
|
-
refute post.save, "Post should require a body to have text!"
|
|
40
|
-
|
|
41
|
-
post = FactoryGirl.build(:post, body: "\r\n \n \r")
|
|
42
|
-
refute post.save, "Post should require a body to have text!"
|
|
43
|
-
|
|
44
|
-
post = FactoryGirl.build(:post, body: "<p></p>\r\n<p></p>\n<p></p>\r")
|
|
45
|
-
refute post.save, "Post should require a body to have text!"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
test "ensure author is required" do
|
|
49
|
-
post = FactoryGirl.build(:post, author_id: nil)
|
|
50
|
-
|
|
51
|
-
refute post.save, "Post should require an author_id!"
|
|
52
|
-
|
|
53
|
-
# Author with 12345 shouldn't exist
|
|
54
|
-
post = FactoryGirl.build(:post, author_id: 12345)
|
|
55
|
-
|
|
56
|
-
refute post.save, "Post should require a valid author!"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
test "verify publication date requirement" do
|
|
60
|
-
post = FactoryGirl.build(:post, published_at: nil)
|
|
61
|
-
assert post.save, "Post should save without a publication date if not published!"
|
|
62
|
-
|
|
63
|
-
post = FactoryGirl.build(:post, published_at: DateTime.now)
|
|
64
|
-
refute post.save, "Post should not save with a publication date if not published!"
|
|
65
|
-
|
|
66
|
-
post = FactoryGirl.build(:published_post)
|
|
67
|
-
post.published_at = nil
|
|
68
|
-
refute post.save, "Post should not save if published without a publication date!"
|
|
69
|
-
|
|
70
|
-
post = FactoryGirl.build(:published_post)
|
|
71
|
-
assert post.save, "Post should save successfully if published with a publication date!"
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
test "ensure publication date when published" do
|
|
75
|
-
post = FactoryGirl.build(:post)
|
|
76
|
-
assert_nil post.published_at
|
|
77
|
-
|
|
78
|
-
post.publish
|
|
79
|
-
assert_not_nil post.published_at
|
|
80
|
-
|
|
81
|
-
assert post.save
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
test "verify publication can't be taken back" do
|
|
85
|
-
post = FactoryGirl.build(:published_post)
|
|
86
|
-
assert post.save
|
|
87
|
-
|
|
88
|
-
assert_raises AASM::NoDirectAssignmentError do
|
|
89
|
-
post.state = "draft"
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
test "verify excerpt" do
|
|
94
|
-
post = FactoryGirl.build(:post, body: "<div><p></p><p></p></div>")
|
|
95
|
-
|
|
96
|
-
assert_equal "", post.excerpt
|
|
97
|
-
|
|
98
|
-
post = FactoryGirl.build(:post, body: "<p>foo bar baz qux</p><p>y</p>")
|
|
99
|
-
|
|
100
|
-
assert_equal "foo bar baz qux", post.excerpt
|
|
101
|
-
|
|
102
|
-
post.excerpt_length = 10
|
|
103
|
-
assert_equal "foo bar", post.excerpt
|
|
104
|
-
|
|
105
|
-
post.excerpt_length = 11
|
|
106
|
-
assert_equal "foo bar baz", post.excerpt
|
|
107
|
-
|
|
108
|
-
post.excerpt_length = 12
|
|
109
|
-
assert_equal "foo bar baz", post.excerpt
|
|
110
|
-
|
|
111
|
-
post.excerpt_length = 15
|
|
112
|
-
assert_equal "foo bar baz qux", post.excerpt
|
|
113
|
-
|
|
114
|
-
post = FactoryGirl.build(:post,
|
|
115
|
-
body: "<p>This is <strong>emphasized</strong>. This is a <a href=\"http://example.com\">link</a>.</p><p>foo</p>")
|
|
116
|
-
assert_equal "This is emphasized. This is a link.", post.excerpt
|
|
117
|
-
|
|
118
|
-
post = FactoryGirl.build(:post,
|
|
119
|
-
body: "<p></p><div></div><p>foo</p>")
|
|
120
|
-
assert_equal "foo", post.excerpt
|
|
121
|
-
|
|
122
|
-
post = FactoryGirl.build(:post,
|
|
123
|
-
body: "This is outside.<p>This is inside.</p>")
|
|
124
|
-
assert_equal "This is outside.", post.excerpt
|
|
125
|
-
|
|
126
|
-
post = FactoryGirl.build(:post,
|
|
127
|
-
body: "<p>\r\n</p><p>foo</p>")
|
|
128
|
-
assert_equal "foo", post.excerpt
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
test "verify body sanitization" do
|
|
132
|
-
post = FactoryGirl.create(:post,
|
|
133
|
-
body: "foo <script>alert('bar');</script>")
|
|
134
|
-
|
|
135
|
-
assert_equal "foo alert('bar');", post.body
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
test "verify slug presence" do
|
|
139
|
-
post = FactoryGirl.build(:post, title: "New Post")
|
|
140
|
-
assert_nil post.slug
|
|
141
|
-
|
|
142
|
-
post.save
|
|
143
|
-
assert_equal "new-post", post.slug
|
|
144
|
-
|
|
145
|
-
assert_equal post, Post.friendly.find(post.slug)
|
|
146
|
-
assert_equal post, Post.friendly.find(post.id),
|
|
147
|
-
"Should also be able to use regular-old ID"
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
test "verify slug uniqueness" do
|
|
151
|
-
post = FactoryGirl.create(:post, title: "New Post")
|
|
152
|
-
assert_equal "new-post", post.slug
|
|
153
|
-
|
|
154
|
-
post = FactoryGirl.build(:post, title: "New Post") # Same title
|
|
155
|
-
post.valid?
|
|
156
|
-
|
|
157
|
-
assert post.save, "Title should not be required to be unique"
|
|
158
|
-
assert_not_equal "new-post", post.slug, "Slugs should be unique"
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
test "verify unpublished post slug changes but does not keep history" do
|
|
162
|
-
post = FactoryGirl.create(:post, title: "New Post")
|
|
163
|
-
assert_equal "new-post", post.slug
|
|
164
|
-
assert_equal post, Post.friendly.find(post.slug)
|
|
165
|
-
|
|
166
|
-
post.title = "New Post Modified"
|
|
167
|
-
post.save
|
|
168
|
-
assert_equal "new-post-modified", post.slug,
|
|
169
|
-
"The slug should change if the post title changes"
|
|
170
|
-
assert_equal post, Post.friendly.find(post.slug)
|
|
171
|
-
|
|
172
|
-
# Assert that we cannot use the old slug
|
|
173
|
-
refute Post.friendly.exists_by_friendly_id?("new-post"),
|
|
174
|
-
"Should not be able to use old slug on an unpublished post"
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
test "verify published post slug changes and keeps history" do
|
|
178
|
-
post = FactoryGirl.create(:published_post, title: "New Post")
|
|
179
|
-
assert_equal "new-post", post.slug
|
|
180
|
-
assert_equal post, Post.friendly.find(post.slug)
|
|
181
|
-
|
|
182
|
-
post.title = "New Post Modified"
|
|
183
|
-
post.save
|
|
184
|
-
assert_equal "new-post-modified", post.slug,
|
|
185
|
-
"The slug should change if the post title changes"
|
|
186
|
-
assert_equal post, Post.friendly.find(post.slug)
|
|
187
|
-
|
|
188
|
-
# Also assert that we can use the old slug (i.e. published links
|
|
189
|
-
# can't be broken)
|
|
190
|
-
assert_equal post, Post.friendly.find("new-post")
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
end
|