proclaim 0.5.6 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,114 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BlogSubscriptionTest < ActionDispatch::IntegrationTest
|
4
|
-
setup do
|
5
|
-
ApplicationController.any_instance.stubs(:current_user).returns(nil)
|
6
|
-
ApplicationController.any_instance.stubs(:authenticate_user).returns(false)
|
7
|
-
|
8
|
-
ActionMailer::Base.deliveries.clear
|
9
|
-
end
|
10
|
-
|
11
|
-
test "should be able to create new blog subscription while logged in" do
|
12
|
-
user = FactoryGirl.create(:user)
|
13
|
-
sign_in user
|
14
|
-
|
15
|
-
visit proclaim.new_subscription_path
|
16
|
-
|
17
|
-
within('#new_subscription') do
|
18
|
-
fill_in 'Name', with: "example"
|
19
|
-
fill_in 'Email', with: "example@example.com"
|
20
|
-
fill_in 'What is', with: antispam_solution
|
21
|
-
end
|
22
|
-
|
23
|
-
assert_difference('Proclaim::Subscription.count', 1,
|
24
|
-
"Should have successfully created subscription!") do
|
25
|
-
find('#new_subscription input[type=submit]').click
|
26
|
-
end
|
27
|
-
|
28
|
-
assert page.has_text?("example"),
|
29
|
-
"Should be shown subscription name"
|
30
|
-
assert page.has_no_text?("example@example.com"),
|
31
|
-
"Should not be shown email address, in case link is compromised"
|
32
|
-
end
|
33
|
-
|
34
|
-
test "should be able to create new blog subscription while not logged in" do
|
35
|
-
visit proclaim.new_subscription_path
|
36
|
-
|
37
|
-
within('#new_subscription') do
|
38
|
-
fill_in 'Name', with: "example"
|
39
|
-
fill_in 'Email', with: "example@example.com"
|
40
|
-
fill_in 'What is', with: antispam_solution
|
41
|
-
end
|
42
|
-
|
43
|
-
assert_difference('Proclaim::Subscription.count', 1,
|
44
|
-
"Should have successfully created subscription!") do
|
45
|
-
find('#new_subscription input[type=submit]').click
|
46
|
-
end
|
47
|
-
|
48
|
-
assert page.has_text?("example"),
|
49
|
-
"Should be shown subscription name"
|
50
|
-
assert page.has_no_text?("example@example.com"),
|
51
|
-
"Should not be shown email address, in case link is compromised"
|
52
|
-
end
|
53
|
-
|
54
|
-
test "should not be able to create new blog subscription if spammy" do
|
55
|
-
user = FactoryGirl.create(:user)
|
56
|
-
sign_in user
|
57
|
-
|
58
|
-
visit proclaim.new_subscription_path
|
59
|
-
|
60
|
-
within('#new_subscription') do
|
61
|
-
fill_in 'Name', with: "example"
|
62
|
-
fill_in 'Email', with: "example@example.com"
|
63
|
-
fill_in 'What is', with: "wrong answer"
|
64
|
-
end
|
65
|
-
|
66
|
-
assert_no_difference('Proclaim::Subscription.count',
|
67
|
-
"Should have failed antispam questions!") do
|
68
|
-
find('#new_subscription input[type=submit]').click
|
69
|
-
end
|
70
|
-
|
71
|
-
assert page.has_css?('div#error_explanation'),
|
72
|
-
"Should be shown errors since the antispam questions failed!"
|
73
|
-
end
|
74
|
-
|
75
|
-
test "catch missing name" do
|
76
|
-
visit proclaim.new_subscription_path
|
77
|
-
|
78
|
-
within('#new_subscription') do
|
79
|
-
# Don't fill in name
|
80
|
-
fill_in 'Email', with: "example@example.com"
|
81
|
-
fill_in 'What is', with: antispam_solution
|
82
|
-
end
|
83
|
-
|
84
|
-
assert_no_difference('Proclaim::Subscription.count',
|
85
|
-
"Should have caught missing name!") do
|
86
|
-
find('#new_subscription input[type=submit]').click
|
87
|
-
end
|
88
|
-
|
89
|
-
assert page.has_css?('div#error_explanation')
|
90
|
-
end
|
91
|
-
|
92
|
-
test "catch bad email address" do
|
93
|
-
visit proclaim.new_subscription_path
|
94
|
-
|
95
|
-
within('#new_subscription') do
|
96
|
-
fill_in 'Name', with: "example"
|
97
|
-
fill_in 'Email', with: "bad_email_address"
|
98
|
-
fill_in 'What is', with: antispam_solution
|
99
|
-
end
|
100
|
-
|
101
|
-
assert_no_difference('Proclaim::Subscription.count',
|
102
|
-
"Should have caught bad email address!") do
|
103
|
-
find('#new_subscription input[type=submit]').click
|
104
|
-
end
|
105
|
-
|
106
|
-
assert page.has_css?('div#error_explanation')
|
107
|
-
end
|
108
|
-
|
109
|
-
private
|
110
|
-
|
111
|
-
def antispam_solution
|
112
|
-
find('input#antispam_solution', visible: false).value
|
113
|
-
end
|
114
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ManageSubscriptionTest < ActionDispatch::IntegrationTest
|
4
|
-
setup do
|
5
|
-
ApplicationController.any_instance.stubs(:current_user).returns(nil)
|
6
|
-
ApplicationController.any_instance.stubs(:authenticate_user).returns(false)
|
7
|
-
|
8
|
-
ActionMailer::Base.deliveries.clear
|
9
|
-
end
|
10
|
-
|
11
|
-
test "should be able to see subscribers index if logged in" do
|
12
|
-
user = FactoryGirl.create(:user)
|
13
|
-
sign_in user
|
14
|
-
|
15
|
-
blog_subscription = FactoryGirl.create(:subscription)
|
16
|
-
post_subscription = FactoryGirl.create(:published_post_subscription)
|
17
|
-
|
18
|
-
visit proclaim.subscriptions_path
|
19
|
-
|
20
|
-
# Verify that the blog subscription is shown
|
21
|
-
assert page.has_text?(blog_subscription.name),
|
22
|
-
"Blog subscription name should be on the index"
|
23
|
-
assert page.has_text?(blog_subscription.email),
|
24
|
-
"Blog subscription email should be on the index"
|
25
|
-
|
26
|
-
# Verify that the title of the post to which the post subscription belongs
|
27
|
-
# is shown as well
|
28
|
-
assert page.has_text?(post_subscription.post.title),
|
29
|
-
"Post subscription's post's title should be on the index"
|
30
|
-
|
31
|
-
# Finally, verify that the post subscription is shown
|
32
|
-
assert page.has_text?(post_subscription.name),
|
33
|
-
"Post subscription name should be on the index"
|
34
|
-
assert page.has_text?(post_subscription.email),
|
35
|
-
"Post subscription email should be on the index"
|
36
|
-
end
|
37
|
-
end
|
@@ -1,234 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class PostTest < ActionDispatch::IntegrationTest
|
4
|
-
setup do
|
5
|
-
ApplicationController.any_instance.stubs(:current_user).returns(nil)
|
6
|
-
ApplicationController.any_instance.stubs(:authenticate_user).returns(false)
|
7
|
-
|
8
|
-
@edit_page = EditPage.new
|
9
|
-
end
|
10
|
-
|
11
|
-
test "index should give option to create new post if logged in" do
|
12
|
-
user = FactoryGirl.create(:user)
|
13
|
-
sign_in user
|
14
|
-
|
15
|
-
visit proclaim.posts_path
|
16
|
-
|
17
|
-
assert page.has_css? "a", text: "New Post"
|
18
|
-
end
|
19
|
-
|
20
|
-
test "index should not give option to create new post if not logged in" do
|
21
|
-
visit proclaim.posts_path
|
22
|
-
|
23
|
-
assert page.has_no_css? "a", text: "New Post"
|
24
|
-
end
|
25
|
-
|
26
|
-
test "index should give option to edit post if logged in" do
|
27
|
-
user = FactoryGirl.create(:user)
|
28
|
-
sign_in user
|
29
|
-
|
30
|
-
post = FactoryGirl.create(:published_post)
|
31
|
-
|
32
|
-
visit proclaim.posts_path
|
33
|
-
|
34
|
-
assert page.has_css? "a", text: "Edit"
|
35
|
-
end
|
36
|
-
|
37
|
-
test "index should not give option to edit post if not logged in" do
|
38
|
-
post = FactoryGirl.create(:published_post)
|
39
|
-
|
40
|
-
visit proclaim.posts_path
|
41
|
-
|
42
|
-
assert page.has_no_css? "a", text: "Edit"
|
43
|
-
end
|
44
|
-
|
45
|
-
test "index should give option to delete post if logged in" do
|
46
|
-
user = FactoryGirl.create(:user)
|
47
|
-
sign_in user
|
48
|
-
|
49
|
-
post = FactoryGirl.create(:published_post)
|
50
|
-
|
51
|
-
visit proclaim.posts_path
|
52
|
-
|
53
|
-
assert page.has_css? "a", text: "Delete"
|
54
|
-
end
|
55
|
-
|
56
|
-
test "index should not give option to delete post if not logged in" do
|
57
|
-
post = FactoryGirl.create(:published_post)
|
58
|
-
|
59
|
-
visit proclaim.posts_path
|
60
|
-
|
61
|
-
assert page.has_no_css? "a", text: "Delete"
|
62
|
-
end
|
63
|
-
|
64
|
-
test "index should show post titles" do
|
65
|
-
post1 = FactoryGirl.create(:published_post)
|
66
|
-
post2 = FactoryGirl.create(:published_post)
|
67
|
-
|
68
|
-
visit proclaim.posts_path
|
69
|
-
|
70
|
-
assert page.has_text? post1.title
|
71
|
-
assert page.has_text? post2.title
|
72
|
-
end
|
73
|
-
|
74
|
-
test "index should show authors" do
|
75
|
-
post1 = FactoryGirl.create(:published_post)
|
76
|
-
post2 = FactoryGirl.create(:published_post)
|
77
|
-
|
78
|
-
visit proclaim.posts_path
|
79
|
-
|
80
|
-
assert page.has_text? post1.author.send(Proclaim.author_name_method)
|
81
|
-
assert page.has_text? post2.author.send(Proclaim.author_name_method)
|
82
|
-
end
|
83
|
-
|
84
|
-
test "index should show excerpts" do
|
85
|
-
post1Body = Faker::Lorem.paragraph(50)
|
86
|
-
|
87
|
-
post1 = FactoryGirl.create(:published_post,
|
88
|
-
body: post1Body)
|
89
|
-
post2 = FactoryGirl.create(:published_post,
|
90
|
-
body: "foo")
|
91
|
-
|
92
|
-
visit proclaim.posts_path
|
93
|
-
|
94
|
-
post1RenderedBody = page.find("#post_#{post1.id} span.excerpt")
|
95
|
-
post2RenderedBody = page.find("#post_#{post2.id} span.excerpt")
|
96
|
-
|
97
|
-
# Make sure the render text from the post is only the excerpt-- no more
|
98
|
-
assert_equal post1.excerpt, post1RenderedBody.text
|
99
|
-
assert_equal post2.body, post2RenderedBody.text
|
100
|
-
end
|
101
|
-
|
102
|
-
test "index should show more link" do
|
103
|
-
post1Body = Faker::Lorem.paragraph(50)
|
104
|
-
|
105
|
-
post1 = FactoryGirl.create(:published_post,
|
106
|
-
body: post1Body)
|
107
|
-
post2 = FactoryGirl.create(:published_post,
|
108
|
-
body: "foo")
|
109
|
-
|
110
|
-
visit proclaim.posts_path
|
111
|
-
|
112
|
-
assert page.has_css?("#post_#{post1.id} a", text: "(more)"),
|
113
|
-
"Post 1 should contain a link to view more"
|
114
|
-
assert page.has_no_css?("#post_#{post2.id} a", text: "(more)"),
|
115
|
-
"Post 2 should not contain a link to see more"
|
116
|
-
end
|
117
|
-
|
118
|
-
test "index should show posts ordered by publication date" do
|
119
|
-
post1 = FactoryGirl.create(:published_post)
|
120
|
-
post2 = FactoryGirl.create(:published_post)
|
121
|
-
|
122
|
-
visit proclaim.posts_path
|
123
|
-
|
124
|
-
assert page.body.index(post2.title) < page.body.index(post1.title),
|
125
|
-
"Post 2 should be shown before post 1!"
|
126
|
-
end
|
127
|
-
|
128
|
-
test "index should show drafts ordered by modification date" do
|
129
|
-
user = FactoryGirl.create(:user)
|
130
|
-
sign_in user
|
131
|
-
|
132
|
-
post1 = FactoryGirl.create(:post)
|
133
|
-
post2 = FactoryGirl.create(:post)
|
134
|
-
post3 = FactoryGirl.create(:post)
|
135
|
-
|
136
|
-
# Update post1 so its updated_at is newest
|
137
|
-
post2.body = "Updated Body"
|
138
|
-
post2.save
|
139
|
-
|
140
|
-
visit proclaim.posts_path
|
141
|
-
|
142
|
-
assert page.body.index(post2.title) < page.body.index(post3.title),
|
143
|
-
"Post 2 draft should be shown before post 3 draft!"
|
144
|
-
assert page.body.index(post3.title) < page.body.index(post1.title),
|
145
|
-
"Post 3 draft should be shown before post 1 draft!"
|
146
|
-
end
|
147
|
-
|
148
|
-
test "index should not show comment count for drafts" do
|
149
|
-
user = FactoryGirl.create(:user)
|
150
|
-
sign_in user
|
151
|
-
|
152
|
-
comment = FactoryGirl.create(:comment)
|
153
|
-
|
154
|
-
visit proclaim.posts_path
|
155
|
-
|
156
|
-
assert page.has_no_text? "1 comment"
|
157
|
-
end
|
158
|
-
|
159
|
-
test "index should show comment count for published post" do
|
160
|
-
user = FactoryGirl.create(:user)
|
161
|
-
sign_in user
|
162
|
-
|
163
|
-
# Verify no comments
|
164
|
-
post = FactoryGirl.create(:published_post)
|
165
|
-
visit proclaim.posts_path
|
166
|
-
assert page.has_text?("No comments"),
|
167
|
-
"Comment count should indicate no comments"
|
168
|
-
|
169
|
-
# Verify that single comment count shows up.
|
170
|
-
comment = FactoryGirl.create(:published_comment, post: post)
|
171
|
-
visit proclaim.posts_path
|
172
|
-
assert page.has_text?("1 comment"), "Comment count should be shown"
|
173
|
-
|
174
|
-
# Also verify that the comment count is properly pluralized.
|
175
|
-
comment = FactoryGirl.create(:published_comment, post: comment.post)
|
176
|
-
visit proclaim.posts_path
|
177
|
-
assert page.has_text?("2 comments"),
|
178
|
-
"Comment count should be shown and pluralized"
|
179
|
-
end
|
180
|
-
|
181
|
-
test "show should include author name" do
|
182
|
-
post = FactoryGirl.create(:published_post)
|
183
|
-
|
184
|
-
visit proclaim.post_path(post)
|
185
|
-
|
186
|
-
assert page.has_text? post.author.send(Proclaim.author_name_method)
|
187
|
-
end
|
188
|
-
|
189
|
-
test "show should work via id" do
|
190
|
-
post = FactoryGirl.create(:published_post)
|
191
|
-
|
192
|
-
visit proclaim.post_path(post.id)
|
193
|
-
assert page.has_text? post.title
|
194
|
-
assert_equal proclaim.post_path(post.friendly_id), current_path,
|
195
|
-
"Post show via ID should redirect to more friendly URL"
|
196
|
-
end
|
197
|
-
|
198
|
-
test "show should work via slug" do
|
199
|
-
post = FactoryGirl.create(:published_post)
|
200
|
-
|
201
|
-
visit proclaim.post_path(post.friendly_id)
|
202
|
-
assert page.has_text? post.title
|
203
|
-
end
|
204
|
-
|
205
|
-
test "show should work via old slugs for published posts" do
|
206
|
-
post = FactoryGirl.create(:published_post, title: "New Post")
|
207
|
-
old_slug = post.friendly_id
|
208
|
-
|
209
|
-
# Change slug
|
210
|
-
post.title = "New Post Modified"
|
211
|
-
post.save
|
212
|
-
|
213
|
-
visit proclaim.post_path(old_slug)
|
214
|
-
assert page.has_text? post.title
|
215
|
-
assert_equal proclaim.post_path(post.friendly_id), current_path,
|
216
|
-
"Post show via ID should redirect to more friendly URL"
|
217
|
-
end
|
218
|
-
|
219
|
-
test "image should have relative source path" do
|
220
|
-
user = FactoryGirl.create(:user)
|
221
|
-
sign_in user
|
222
|
-
|
223
|
-
image = FactoryGirl.create(:image)
|
224
|
-
image.post.body = @edit_page.medium_inserted_image_html(image)
|
225
|
-
image.post.save
|
226
|
-
|
227
|
-
image_tags = Nokogiri::HTML.fragment(image.post.body).css("img")
|
228
|
-
|
229
|
-
assert_equal 1, image_tags.length,
|
230
|
-
"Post body should contain one image tag"
|
231
|
-
refute_match root_url, image_tags[0].attribute("src"),
|
232
|
-
"Images should have relative paths"
|
233
|
-
end
|
234
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SubscriptionEmailTest < ActionDispatch::IntegrationTest
|
4
|
-
setup do
|
5
|
-
ApplicationController.any_instance.stubs(:current_user).returns(nil)
|
6
|
-
ApplicationController.any_instance.stubs(:authenticate_user).returns(false)
|
7
|
-
|
8
|
-
ActionMailer::Base.deliveries.clear
|
9
|
-
end
|
10
|
-
|
11
|
-
test "should email welcome to post subscriber upon subscription" do
|
12
|
-
post = FactoryGirl.create(:published_post)
|
13
|
-
subscription = FactoryGirl.create(:subscription, post: post)
|
14
|
-
|
15
|
-
# Make sure subscriber was sent a welcome email
|
16
|
-
assert_equal [subscription.email], ActionMailer::Base.deliveries.last.to
|
17
|
-
assert_match "Welcome", ActionMailer::Base.deliveries.last.subject
|
18
|
-
end
|
19
|
-
|
20
|
-
test "should email notification to post subscriber when new comment is made" do
|
21
|
-
post = FactoryGirl.create(:published_post)
|
22
|
-
subscription = FactoryGirl.create(:subscription, post: post)
|
23
|
-
|
24
|
-
# Clear out emails-- new subscription probably sent a welcome email
|
25
|
-
ActionMailer::Base.deliveries.clear
|
26
|
-
|
27
|
-
comment = FactoryGirl.create(:comment, post: post)
|
28
|
-
|
29
|
-
# Make sure subscriber was notified of new comment
|
30
|
-
assert_equal [subscription.email], ActionMailer::Base.deliveries.last.to
|
31
|
-
assert_equal "New Comment On \"#{post.title}\"", ActionMailer::Base.deliveries.last.subject
|
32
|
-
end
|
33
|
-
|
34
|
-
test "should not email post subscriber when old comment is edited" do
|
35
|
-
post = FactoryGirl.create(:published_post)
|
36
|
-
subscription = FactoryGirl.create(:subscription, post: post)
|
37
|
-
comment = FactoryGirl.create(:comment, post: post)
|
38
|
-
|
39
|
-
# Clear out emails that were just sent
|
40
|
-
ActionMailer::Base.deliveries.clear
|
41
|
-
|
42
|
-
comment.author = "Edit Author"
|
43
|
-
comment.body = "Edit Body"
|
44
|
-
comment.save
|
45
|
-
|
46
|
-
# Make sure no email was sent after update
|
47
|
-
assert_empty ActionMailer::Base.deliveries
|
48
|
-
end
|
49
|
-
|
50
|
-
test "should email notification to blog subscriber when post is published" do
|
51
|
-
subscription = FactoryGirl.create(:subscription)
|
52
|
-
|
53
|
-
# Clear out emails-- new subscription probably sent a welcome email
|
54
|
-
ActionMailer::Base.deliveries.clear
|
55
|
-
|
56
|
-
post = FactoryGirl.create(:published_post)
|
57
|
-
|
58
|
-
# Make sure subscriber was notified of new post
|
59
|
-
assert_equal [subscription.email], ActionMailer::Base.deliveries.last.to
|
60
|
-
assert_equal "New Post: #{post.title}", ActionMailer::Base.deliveries.last.subject
|
61
|
-
end
|
62
|
-
|
63
|
-
test "should not email notification to blog subscriber when post is updated" do
|
64
|
-
subscription = FactoryGirl.create(:subscription)
|
65
|
-
post = FactoryGirl.create(:published_post)
|
66
|
-
|
67
|
-
# Clear out all emails
|
68
|
-
ActionMailer::Base.deliveries.clear
|
69
|
-
|
70
|
-
post.title = "Edit Title"
|
71
|
-
post.body = "Edit Body"
|
72
|
-
|
73
|
-
# Make sure no email was sent after update
|
74
|
-
assert_empty ActionMailer::Base.deliveries
|
75
|
-
end
|
76
|
-
|
77
|
-
test "should not email notification to blog subscriber if post is not published" do
|
78
|
-
subscription = FactoryGirl.create(:subscription)
|
79
|
-
|
80
|
-
# Clear out emails-- new subscription probably sent a welcome email
|
81
|
-
ActionMailer::Base.deliveries.clear
|
82
|
-
|
83
|
-
post = FactoryGirl.create(:post)
|
84
|
-
|
85
|
-
# Make sure no email was sent after update
|
86
|
-
assert_empty ActionMailer::Base.deliveries
|
87
|
-
|
88
|
-
post.publish
|
89
|
-
assert post.save
|
90
|
-
|
91
|
-
# Make sure subscriber was notified of newly published post
|
92
|
-
assert_equal [subscription.email], ActionMailer::Base.deliveries.last.to
|
93
|
-
assert_equal "New Post: #{post.title}", ActionMailer::Base.deliveries.last.subject
|
94
|
-
end
|
95
|
-
end
|