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,77 +0,0 @@
|
|
|
1
|
-
# == Schema Information
|
|
2
|
-
#
|
|
3
|
-
# Table name: proclaim_subscriptions
|
|
4
|
-
#
|
|
5
|
-
# id :integer not null, primary key
|
|
6
|
-
# post_id :integer
|
|
7
|
-
# email :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 SubscriptionTest < ActiveSupport::TestCase
|
|
16
|
-
test "subscriptions should be unique" do
|
|
17
|
-
FactoryGirl.create(:subscription, email: "foo@bar.com")
|
|
18
|
-
subscription = FactoryGirl.build(:subscription, email: "foo@bar.com")
|
|
19
|
-
refute subscription.save,
|
|
20
|
-
"Blog subscriptions should have unique emails!"
|
|
21
|
-
|
|
22
|
-
subscription = FactoryGirl.create(:post_subscription, email: "foo@bar.com")
|
|
23
|
-
subscription = FactoryGirl.build(:post_subscription,
|
|
24
|
-
post: subscription.post,
|
|
25
|
-
email: subscription.email)
|
|
26
|
-
refute subscription.save,
|
|
27
|
-
"Post subscriptions should have unique emails!"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
test "should require a name" do
|
|
31
|
-
subscription = FactoryGirl.build(:subscription, name: nil)
|
|
32
|
-
refute subscription.save, "Subscription should require a name!"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
test "should not save without valid email address" do
|
|
36
|
-
subscription = FactoryGirl.build(:subscription, email: nil)
|
|
37
|
-
refute subscription.save,
|
|
38
|
-
"Subscription should require an email address!"
|
|
39
|
-
|
|
40
|
-
subscription = FactoryGirl.build(:subscription, email: "blah")
|
|
41
|
-
refute subscription.save,
|
|
42
|
-
"Subscription should require a valid email address!"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
test "token should be able to identify subscriptions" do
|
|
46
|
-
subscription1 = FactoryGirl.create(:subscription)
|
|
47
|
-
subscription2 = FactoryGirl.create(:subscription)
|
|
48
|
-
|
|
49
|
-
token1 = subscription1.token
|
|
50
|
-
token2 = subscription2.token
|
|
51
|
-
|
|
52
|
-
assert_equal subscription1, Subscription.from_token(token1)
|
|
53
|
-
assert_equal subscription2, Subscription.from_token(token2)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
test "an invalid token should raise a NotFound" do
|
|
57
|
-
assert_raises ActiveRecord::RecordNotFound do
|
|
58
|
-
Subscription.from_token("123456")
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
test "should require valid post or none at all" do
|
|
63
|
-
# Post 12345 doesn't exist
|
|
64
|
-
subscription = FactoryGirl.build(:subscription, post_id: 12345)
|
|
65
|
-
refute subscription.save,
|
|
66
|
-
"Subscription should require a valid post!"
|
|
67
|
-
|
|
68
|
-
subscription = FactoryGirl.build(:subscription,
|
|
69
|
-
post: FactoryGirl.create(:published_post))
|
|
70
|
-
assert subscription.save
|
|
71
|
-
|
|
72
|
-
subscription = FactoryGirl.build(:subscription, post: nil)
|
|
73
|
-
assert subscription.save,
|
|
74
|
-
"Subscription shouldn't require a post!"
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class ApplicationPolicyTest < ActiveSupport::TestCase
|
|
4
|
-
test "application index" do
|
|
5
|
-
user = FactoryGirl.create(:user)
|
|
6
|
-
|
|
7
|
-
# Verify that a user cannot visit the index by default
|
|
8
|
-
policy = ApplicationPolicy.new(user, nil)
|
|
9
|
-
refute policy.index?, "A user should be not able to visit the index by default"
|
|
10
|
-
|
|
11
|
-
# Verify that a guest cannot visit the index by default
|
|
12
|
-
policy = ApplicationPolicy.new(nil, nil)
|
|
13
|
-
refute policy.index?, "A guest should not be able to visit the index by default"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
test "application show" do
|
|
17
|
-
user = FactoryGirl.create(:user)
|
|
18
|
-
|
|
19
|
-
# Verify that a user cannot view an object by default
|
|
20
|
-
policy = ApplicationPolicy.new(user, nil)
|
|
21
|
-
refute policy.show?, "A user should be not able to view an object by default"
|
|
22
|
-
|
|
23
|
-
# Verify that a guest cannot view an object by default
|
|
24
|
-
policy = ApplicationPolicy.new(nil, nil)
|
|
25
|
-
refute policy.show?, "A guest should not be able to view an object by default"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
test "application create" do
|
|
29
|
-
user = FactoryGirl.create(:user)
|
|
30
|
-
|
|
31
|
-
# Verify that a user cannot create an object by default
|
|
32
|
-
policy = ApplicationPolicy.new(user, nil)
|
|
33
|
-
refute policy.create?, "A user should be not able to create an object by default"
|
|
34
|
-
|
|
35
|
-
# Verify that a guest cannot create an object by default
|
|
36
|
-
policy = ApplicationPolicy.new(nil, nil)
|
|
37
|
-
refute policy.create?, "A guest should not be able to create an object by default"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
test "application new" do
|
|
41
|
-
user = FactoryGirl.create(:user)
|
|
42
|
-
|
|
43
|
-
# Verify that a user cannot visit the new action by default
|
|
44
|
-
policy = ApplicationPolicy.new(user, nil)
|
|
45
|
-
refute policy.new?, "A user should be not able to visit the new action by default"
|
|
46
|
-
|
|
47
|
-
# Verify that a guest cannot visit the new action by default
|
|
48
|
-
policy = ApplicationPolicy.new(nil, nil)
|
|
49
|
-
refute policy.new?, "A guest should not be able to visit the new action by default"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
test "application update" do
|
|
53
|
-
user = FactoryGirl.create(:user)
|
|
54
|
-
|
|
55
|
-
# Verify that a user cannot update an object by default
|
|
56
|
-
policy = ApplicationPolicy.new(user, nil)
|
|
57
|
-
refute policy.update?, "A user should be not able to update an object by default"
|
|
58
|
-
|
|
59
|
-
# Verify that a guest cannot update an object by default
|
|
60
|
-
policy = ApplicationPolicy.new(nil, nil)
|
|
61
|
-
refute policy.update?, "A guest should not be able to update an object by default"
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
test "application edit" do
|
|
65
|
-
user = FactoryGirl.create(:user)
|
|
66
|
-
|
|
67
|
-
# Verify that a user cannot visit the edit action by default
|
|
68
|
-
policy = ApplicationPolicy.new(user, nil)
|
|
69
|
-
refute policy.edit?, "A user should be not able to visit the edit action by default"
|
|
70
|
-
|
|
71
|
-
# Verify that a guest cannot visit the edit action by default
|
|
72
|
-
policy = ApplicationPolicy.new(nil, nil)
|
|
73
|
-
refute policy.edit?, "A guest should not be able to visit the edit action by default"
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
test "application destroy" do
|
|
77
|
-
user = FactoryGirl.create(:user)
|
|
78
|
-
|
|
79
|
-
# Verify that a user cannot destroy an object by default
|
|
80
|
-
policy = ApplicationPolicy.new(user, nil)
|
|
81
|
-
refute policy.destroy?, "A user should be not able to destroy an object by default"
|
|
82
|
-
|
|
83
|
-
# Verify that a guest cannot destroy an object by default
|
|
84
|
-
policy = ApplicationPolicy.new(nil, nil)
|
|
85
|
-
refute policy.destroy?, "A guest should not be able to destroy an object by default"
|
|
86
|
-
end
|
|
87
|
-
end
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class CommentPolicyTest < ActiveSupport::TestCase
|
|
4
|
-
test "comment scope" do
|
|
5
|
-
user = FactoryGirl.create(:user)
|
|
6
|
-
comment1 = FactoryGirl.create(:comment)
|
|
7
|
-
comment2 = FactoryGirl.create(:comment)
|
|
8
|
-
|
|
9
|
-
# Verify that a user can view both comments
|
|
10
|
-
comments = Pundit.policy_scope(user, Proclaim::Comment)
|
|
11
|
-
assert_includes comments, comment1
|
|
12
|
-
assert_includes comments, comment2
|
|
13
|
-
|
|
14
|
-
# Verify that even without a user, both comments can still be viewed
|
|
15
|
-
comments = Pundit.policy_scope(nil, Proclaim::Comment)
|
|
16
|
-
assert_includes comments, comment1
|
|
17
|
-
assert_includes comments, comment2
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
test "comment creation" do
|
|
21
|
-
user = FactoryGirl.create(:user)
|
|
22
|
-
publishedComment = FactoryGirl.build(:published_comment)
|
|
23
|
-
unpublishedComment = FactoryGirl.build(:comment)
|
|
24
|
-
|
|
25
|
-
# Verify that a user can create a comment on a published post
|
|
26
|
-
policy = Proclaim::CommentPolicy.new(user, publishedComment)
|
|
27
|
-
assert policy.create?,
|
|
28
|
-
"A user should be able to create comments on published posts!"
|
|
29
|
-
|
|
30
|
-
# Verify that a user can create a comment on an unpublished post
|
|
31
|
-
policy = Proclaim::CommentPolicy.new(user, unpublishedComment)
|
|
32
|
-
assert policy.create?,
|
|
33
|
-
"A user should be able to create comments on unpublished posts!"
|
|
34
|
-
|
|
35
|
-
# Verify that a guest can create a comment on a published post
|
|
36
|
-
policy = Proclaim::CommentPolicy.new(nil, publishedComment)
|
|
37
|
-
assert policy.create?,
|
|
38
|
-
"A guest should be able to create comments on published posts!"
|
|
39
|
-
|
|
40
|
-
# Verify that a guest cannot create a comment on an unpublished post
|
|
41
|
-
policy = Proclaim::CommentPolicy.new(nil, unpublishedComment)
|
|
42
|
-
refute policy.create?,
|
|
43
|
-
"A guest should not be able to create comments on unpublished posts!"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
test "comment update" do
|
|
47
|
-
user = FactoryGirl.create(:user)
|
|
48
|
-
comment = FactoryGirl.create(:comment)
|
|
49
|
-
|
|
50
|
-
# Verify that a user can update a comment
|
|
51
|
-
policy = Proclaim::CommentPolicy.new(user, comment)
|
|
52
|
-
assert policy.update?, "A user should be able to update comments!"
|
|
53
|
-
|
|
54
|
-
# Verify that a guest cannot update a comment
|
|
55
|
-
policy = Proclaim::CommentPolicy.new(nil, comment)
|
|
56
|
-
refute policy.update?, "A guest should not be able to update comments!"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
test "comment destroy" do
|
|
60
|
-
user = FactoryGirl.create(:user)
|
|
61
|
-
comment = FactoryGirl.create(:comment)
|
|
62
|
-
|
|
63
|
-
# Verify that a user can destroy a comment
|
|
64
|
-
policy = Proclaim::CommentPolicy.new(user, comment)
|
|
65
|
-
assert policy.destroy?, "A user should be able to destroy comments!"
|
|
66
|
-
|
|
67
|
-
# Verify that a guest cannot destroy a comment
|
|
68
|
-
policy = Proclaim::CommentPolicy.new(nil, comment)
|
|
69
|
-
refute policy.destroy?, "A guest should not be able to destroy comments!"
|
|
70
|
-
end
|
|
71
|
-
end
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class ImagePolicyTest < ActiveSupport::TestCase
|
|
4
|
-
teardown do
|
|
5
|
-
image = Proclaim::Image.new
|
|
6
|
-
FileUtils.rm_rf(File.join(Rails.public_path, image.image.cache_dir))
|
|
7
|
-
FileUtils.rm_rf(File.join(Rails.public_path, image.image.store_dir))
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
test "image scope" do
|
|
11
|
-
user = FactoryGirl.create(:user)
|
|
12
|
-
image = FactoryGirl.create(:image)
|
|
13
|
-
|
|
14
|
-
# Verify that a user can view the image
|
|
15
|
-
images = Pundit.policy_scope(user, Proclaim::Image)
|
|
16
|
-
assert_includes images, image
|
|
17
|
-
|
|
18
|
-
# Verify that a guest cannot see any images
|
|
19
|
-
images = Pundit.policy_scope(nil, Proclaim::Image)
|
|
20
|
-
assert_empty images
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
test "image caching" do
|
|
24
|
-
user = FactoryGirl.create(:user)
|
|
25
|
-
image = FactoryGirl.build(:image)
|
|
26
|
-
|
|
27
|
-
# Verify that a user can cache an image
|
|
28
|
-
policy = Proclaim::ImagePolicy.new(user, image)
|
|
29
|
-
assert policy.cache?, "A user should be able to cache images"
|
|
30
|
-
|
|
31
|
-
# Verify that a guest cannot cache an image
|
|
32
|
-
policy = Proclaim::ImagePolicy.new(nil, image)
|
|
33
|
-
refute policy.cache?, "A guest should not be able to cache images"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
test "image creation" do
|
|
37
|
-
user = FactoryGirl.create(:user)
|
|
38
|
-
image = FactoryGirl.build(:image)
|
|
39
|
-
|
|
40
|
-
# Verify that a user can create an image
|
|
41
|
-
policy = Proclaim::ImagePolicy.new(user, image)
|
|
42
|
-
assert policy.create?, "A user should be able to create images"
|
|
43
|
-
|
|
44
|
-
# Verify that a guest cannot create an image
|
|
45
|
-
policy = Proclaim::ImagePolicy.new(nil, image)
|
|
46
|
-
refute policy.create?, "A guest should not be able to create images"
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
test "image discard" do
|
|
50
|
-
user = FactoryGirl.create(:user)
|
|
51
|
-
cached_image = FactoryGirl.build(:image)
|
|
52
|
-
saved_image = FactoryGirl.create(:image)
|
|
53
|
-
|
|
54
|
-
# Verify that a user can discard a cached image
|
|
55
|
-
policy = Proclaim::ImagePolicy.new(user, cached_image)
|
|
56
|
-
assert policy.discard?, "A user should be able to discard a cached image"
|
|
57
|
-
|
|
58
|
-
# Verify that a user can discard a saved image
|
|
59
|
-
policy = Proclaim::ImagePolicy.new(user, saved_image)
|
|
60
|
-
assert policy.discard?, "A user should be able to discard a saved image"
|
|
61
|
-
|
|
62
|
-
# Verify that a guest cannot discard a cached image
|
|
63
|
-
policy = Proclaim::ImagePolicy.new(nil, cached_image)
|
|
64
|
-
refute policy.discard?, "A guest should not be able to discard a cached image"
|
|
65
|
-
|
|
66
|
-
# Verify that a guest cannot discard a saved image
|
|
67
|
-
policy = Proclaim::ImagePolicy.new(nil, saved_image)
|
|
68
|
-
refute policy.discard?, "A guest should not be able to discard a saved image"
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
test "image destroy" do
|
|
72
|
-
user = FactoryGirl.create(:user)
|
|
73
|
-
image = FactoryGirl.create(:image)
|
|
74
|
-
|
|
75
|
-
# Verify that a user can destroy an image
|
|
76
|
-
policy = Proclaim::ImagePolicy.new(user, image)
|
|
77
|
-
assert policy.destroy?, "A user should be able to destroy image"
|
|
78
|
-
|
|
79
|
-
# Verify that a guest cannot destroy an image
|
|
80
|
-
policy = Proclaim::ImagePolicy.new(nil, image)
|
|
81
|
-
refute policy.destroy?, "A guest should not be able to destroy image"
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class PostPolicyTest < ActiveSupport::TestCase
|
|
4
|
-
test "post scope" do
|
|
5
|
-
user = FactoryGirl.create(:user)
|
|
6
|
-
post1 = FactoryGirl.create(:post)
|
|
7
|
-
post2 = FactoryGirl.create(:published_post)
|
|
8
|
-
|
|
9
|
-
# Verify that a user can see all posts
|
|
10
|
-
posts = Pundit.policy_scope(user, Proclaim::Post)
|
|
11
|
-
assert_includes posts, post1
|
|
12
|
-
assert_includes posts, post2
|
|
13
|
-
|
|
14
|
-
# Verify that guests can only see published posts
|
|
15
|
-
posts = Pundit.policy_scope(nil, Proclaim::Post)
|
|
16
|
-
assert_not_includes posts, post1
|
|
17
|
-
assert_includes posts, post2
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
test "post index" do
|
|
21
|
-
user = FactoryGirl.create(:user)
|
|
22
|
-
|
|
23
|
-
# Verify that a user can visit the index
|
|
24
|
-
policy = Proclaim::PostPolicy.new(user, Proclaim::Post)
|
|
25
|
-
assert policy.index?, "A user should be able to visit the index"
|
|
26
|
-
|
|
27
|
-
# Verify that a guest can also visit the index
|
|
28
|
-
policy = Proclaim::PostPolicy.new(nil, Proclaim::Post)
|
|
29
|
-
assert policy.index?, "A guest should be able to visit the index"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
test "post create" do
|
|
33
|
-
user = FactoryGirl.create(:user)
|
|
34
|
-
post = FactoryGirl.create(:post)
|
|
35
|
-
|
|
36
|
-
# Verify that a user can create posts
|
|
37
|
-
policy = Proclaim::PostPolicy.new(user, post)
|
|
38
|
-
assert policy.create?
|
|
39
|
-
|
|
40
|
-
# Verify that guests can't create posts
|
|
41
|
-
policy = Proclaim::PostPolicy.new(nil, post)
|
|
42
|
-
refute policy.create?
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
test "post show" do
|
|
46
|
-
user = FactoryGirl.create(:user)
|
|
47
|
-
post1 = FactoryGirl.create(:post)
|
|
48
|
-
post2 = FactoryGirl.create(:published_post)
|
|
49
|
-
|
|
50
|
-
# Verify that a user can see both posts
|
|
51
|
-
policy = Proclaim::PostPolicy.new(user, post1)
|
|
52
|
-
assert policy.show?
|
|
53
|
-
policy = Proclaim::PostPolicy.new(user, post2)
|
|
54
|
-
assert policy.show?
|
|
55
|
-
|
|
56
|
-
# Verify that a guest can only see published post
|
|
57
|
-
policy = Proclaim::PostPolicy.new(nil, post1)
|
|
58
|
-
refute policy.show?
|
|
59
|
-
policy = Proclaim::PostPolicy.new(nil, post2)
|
|
60
|
-
assert policy.show?
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
test "post update" do
|
|
64
|
-
user = FactoryGirl.create(:user)
|
|
65
|
-
post1 = FactoryGirl.create(:post)
|
|
66
|
-
post2 = FactoryGirl.create(:published_post)
|
|
67
|
-
|
|
68
|
-
# Verify that a user can update any post
|
|
69
|
-
policy = Proclaim::PostPolicy.new(user, post1)
|
|
70
|
-
assert policy.update?
|
|
71
|
-
policy = Proclaim::PostPolicy.new(user, post2)
|
|
72
|
-
assert policy.update?
|
|
73
|
-
|
|
74
|
-
# Verify that guests can't update post
|
|
75
|
-
policy = Proclaim::PostPolicy.new(nil, post1)
|
|
76
|
-
refute policy.update?
|
|
77
|
-
policy = Proclaim::PostPolicy.new(nil, post2)
|
|
78
|
-
refute policy.update?
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
test "post destroy" do
|
|
82
|
-
user = FactoryGirl.create(:user)
|
|
83
|
-
post1 = FactoryGirl.create(:post)
|
|
84
|
-
post2 = FactoryGirl.create(:published_post)
|
|
85
|
-
|
|
86
|
-
# Verify that a user can destroy any post
|
|
87
|
-
policy = Proclaim::PostPolicy.new(user, post1)
|
|
88
|
-
assert policy.destroy?
|
|
89
|
-
policy = Proclaim::PostPolicy.new(user, post2)
|
|
90
|
-
assert policy.destroy?
|
|
91
|
-
|
|
92
|
-
# Verify that guests can't destroy post
|
|
93
|
-
policy = Proclaim::PostPolicy.new(nil, post1)
|
|
94
|
-
refute policy.destroy?
|
|
95
|
-
policy = Proclaim::PostPolicy.new(nil, post2)
|
|
96
|
-
refute policy.destroy?
|
|
97
|
-
end
|
|
98
|
-
end
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class SubscriptionPolicyTest < ActiveSupport::TestCase
|
|
4
|
-
test "subscription scope" do
|
|
5
|
-
user = FactoryGirl.create(:user)
|
|
6
|
-
subscription1 = FactoryGirl.create(:subscription)
|
|
7
|
-
subscription2 = FactoryGirl.create(:subscription)
|
|
8
|
-
|
|
9
|
-
# Verify that a user can view both subscriptions
|
|
10
|
-
subscriptions = Pundit.policy_scope(user, Proclaim::Subscription)
|
|
11
|
-
assert_includes subscriptions, subscription1
|
|
12
|
-
assert_includes subscriptions, subscription2
|
|
13
|
-
|
|
14
|
-
# Verify that without a user, no subscription can be seen
|
|
15
|
-
subscriptions = Pundit.policy_scope(nil, Proclaim::Subscription)
|
|
16
|
-
assert_empty subscriptions
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
test "subscription index" do
|
|
20
|
-
user = FactoryGirl.create(:user)
|
|
21
|
-
|
|
22
|
-
# Verify that a user can visit the index
|
|
23
|
-
policy = Proclaim::SubscriptionPolicy.new(user, Proclaim::Subscription)
|
|
24
|
-
assert policy.index?, "A user should be able to visit the index"
|
|
25
|
-
|
|
26
|
-
# Verify that a guest cannot visit the index
|
|
27
|
-
policy = Proclaim::SubscriptionPolicy.new(nil, Proclaim::Subscription)
|
|
28
|
-
refute policy.index?, "A guest should not be able to visit the index"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
test "subscription show" do
|
|
32
|
-
user = FactoryGirl.create(:user)
|
|
33
|
-
subscription = FactoryGirl.create(:subscription)
|
|
34
|
-
|
|
35
|
-
# Verify that a user can view a subscription
|
|
36
|
-
policy = Proclaim::SubscriptionPolicy.new(user, subscription)
|
|
37
|
-
assert policy.show?, "A user should be able to view a subscription"
|
|
38
|
-
|
|
39
|
-
# Verify that a guest can also view a subscription
|
|
40
|
-
policy = Proclaim::SubscriptionPolicy.new(nil, subscription)
|
|
41
|
-
assert policy.show?, "A guest should be able to view a subscription"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
test "subscription creation" do
|
|
45
|
-
user = FactoryGirl.create(:user)
|
|
46
|
-
|
|
47
|
-
# Verify that a user can create a subscription to the blog
|
|
48
|
-
subscription = FactoryGirl.build(:subscription)
|
|
49
|
-
policy = Proclaim::SubscriptionPolicy.new(user, subscription)
|
|
50
|
-
assert policy.create?, "A user should be able to create subscriptions to the blog"
|
|
51
|
-
|
|
52
|
-
# Verify that a user can create a subscription to an unpublished post
|
|
53
|
-
subscription = FactoryGirl.build(:post_subscription)
|
|
54
|
-
policy = Proclaim::SubscriptionPolicy.new(user, subscription)
|
|
55
|
-
assert policy.create?, "A user should be able to create subscriptions to unpublished posts"
|
|
56
|
-
|
|
57
|
-
# Verify that a user can create a subscription to a published post
|
|
58
|
-
subscription = FactoryGirl.build(:published_post_subscription)
|
|
59
|
-
policy = Proclaim::SubscriptionPolicy.new(user, subscription)
|
|
60
|
-
assert policy.create?, "A user should be able to create subscriptions to published posts"
|
|
61
|
-
|
|
62
|
-
# Verify that a guest can create a subscription to the blog
|
|
63
|
-
subscription = FactoryGirl.build(:subscription)
|
|
64
|
-
policy = Proclaim::SubscriptionPolicy.new(nil, subscription)
|
|
65
|
-
assert policy.create?, "A guest should be able to create subscriptions to the blog"
|
|
66
|
-
|
|
67
|
-
# Verify that a guest cannot create a subscription to an unpublished post
|
|
68
|
-
subscription = FactoryGirl.build(:post_subscription)
|
|
69
|
-
policy = Proclaim::SubscriptionPolicy.new(nil, subscription)
|
|
70
|
-
refute policy.create?, "A guest should not be able to create subscriptions to unpublished posts"
|
|
71
|
-
|
|
72
|
-
# Verify that a guest can create a subscription to a published post
|
|
73
|
-
subscription = FactoryGirl.build(:published_post_subscription)
|
|
74
|
-
policy = Proclaim::SubscriptionPolicy.new(nil, subscription)
|
|
75
|
-
assert policy.create?, "A guest should be able to create subscriptions to published posts"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
test "subscription update" do
|
|
79
|
-
user = FactoryGirl.create(:user)
|
|
80
|
-
subscription = FactoryGirl.create(:subscription)
|
|
81
|
-
|
|
82
|
-
# Verify that a even a user can't update a subscription
|
|
83
|
-
policy = Proclaim::SubscriptionPolicy.new(user, subscription)
|
|
84
|
-
refute policy.update?, "A user should not be able to update subscriptions!"
|
|
85
|
-
|
|
86
|
-
# Verify that a guest cannot update a subscription
|
|
87
|
-
policy = Proclaim::SubscriptionPolicy.new(nil, subscription)
|
|
88
|
-
refute policy.update?, "A guest should not be able to update subscription!"
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
test "subscription destroy" do
|
|
92
|
-
user = FactoryGirl.create(:user)
|
|
93
|
-
subscription = FactoryGirl.create(:subscription)
|
|
94
|
-
|
|
95
|
-
# Verify that a user can destroy a subscription
|
|
96
|
-
policy = Proclaim::SubscriptionPolicy.new(user, subscription)
|
|
97
|
-
assert policy.destroy?, "A user should be able to destroy subscriptions!"
|
|
98
|
-
|
|
99
|
-
# Verify that a guest can also destroy a subscription
|
|
100
|
-
policy = Proclaim::SubscriptionPolicy.new(nil, subscription)
|
|
101
|
-
assert policy.destroy?, "A guest should be able to destroy subscriptions!"
|
|
102
|
-
end
|
|
103
|
-
end
|