proclaim 0.1.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 +7 -0
- data/CHANGELOG +6 -0
- data/Gemfile +14 -0
- data/LICENSE +674 -0
- data/README.md +137 -0
- data/Rakefile +65 -0
- data/VERSION +1 -0
- data/app/assets/images/ajax_loader.gif +0 -0
- data/app/assets/javascripts/proclaim.js +18 -0
- data/app/assets/javascripts/proclaim/comments_handler.js.coffee +192 -0
- data/app/assets/javascripts/proclaim/editor.js.coffee +50 -0
- data/app/assets/javascripts/proclaim/images.js.coffee +3 -0
- data/app/assets/javascripts/proclaim/subscriptions.js.coffee +3 -0
- data/app/assets/stylesheets/proclaim.css.scss +28 -0
- data/app/assets/stylesheets/proclaim/comments.css.scss +14 -0
- data/app/assets/stylesheets/proclaim/images.scss +3 -0
- data/app/assets/stylesheets/proclaim/posts.css.scss +77 -0
- data/app/assets/stylesheets/proclaim/subscriptions.css.scss +3 -0
- data/app/controllers/proclaim/application_controller.rb +44 -0
- data/app/controllers/proclaim/comments_controller.rb +128 -0
- data/app/controllers/proclaim/images_controller.rb +108 -0
- data/app/controllers/proclaim/posts_controller.rb +131 -0
- data/app/controllers/proclaim/subscriptions_controller.rb +67 -0
- data/app/helpers/proclaim/application_helper.rb +34 -0
- data/app/helpers/proclaim/comments_helper.rb +4 -0
- data/app/helpers/proclaim/images_helper.rb +4 -0
- data/app/helpers/proclaim/posts_helper.rb +4 -0
- data/app/helpers/proclaim/subscriptions_helper.rb +4 -0
- data/app/mailers/proclaim/subscription_mailer.rb +43 -0
- data/app/models/proclaim/comment.rb +35 -0
- data/app/models/proclaim/image.rb +19 -0
- data/app/models/proclaim/post.rb +133 -0
- data/app/models/proclaim/subscription.rb +63 -0
- data/app/policies/application_policy.rb +53 -0
- data/app/policies/proclaim/comment_policy.rb +27 -0
- data/app/policies/proclaim/image_policy.rb +29 -0
- data/app/policies/proclaim/post_policy.rb +38 -0
- data/app/policies/proclaim/subscription_policy.rb +32 -0
- data/app/uploaders/proclaim/image_uploader.rb +82 -0
- data/app/views/layouts/proclaim/subscription_mailer.html.erb +133 -0
- data/app/views/proclaim/comments/_comment.html.erb +33 -0
- data/app/views/proclaim/comments/_form.html.erb +51 -0
- data/app/views/proclaim/posts/_form.html.erb +67 -0
- data/app/views/proclaim/posts/edit.html.erb +3 -0
- data/app/views/proclaim/posts/index.html.erb +30 -0
- data/app/views/proclaim/posts/new.html.erb +3 -0
- data/app/views/proclaim/posts/show.html.erb +46 -0
- data/app/views/proclaim/subscription_mailer/new_comment_notification_email.html.erb +11 -0
- data/app/views/proclaim/subscription_mailer/new_post_notification_email.html.erb +15 -0
- data/app/views/proclaim/subscription_mailer/welcome_email.html.erb +25 -0
- data/app/views/proclaim/subscriptions/_form.html.erb +32 -0
- data/app/views/proclaim/subscriptions/new.html.erb +8 -0
- data/app/views/proclaim/subscriptions/subscribed.html.erb +7 -0
- data/app/views/proclaim/subscriptions/unsubscribe.html.erb +7 -0
- data/app/views/proclaim/subscriptions/unsubscribed.html.erb +3 -0
- data/config/routes.rb +18 -0
- data/db/migrate/20141108222616_create_proclaim_posts.rb +15 -0
- data/db/migrate/20141114235359_create_proclaim_comments.rb +15 -0
- data/db/migrate/20141115022230_create_proclaim_comment_hierarchies.rb +26 -0
- data/db/migrate/20141210234057_create_proclaim_subscriptions.rb +17 -0
- data/db/migrate/20141222224905_create_proclaim_images.rb +12 -0
- data/lib/generators/proclaim/install_generator.rb +23 -0
- data/lib/generators/proclaim/templates/README +27 -0
- data/lib/generators/proclaim/templates/initialize_proclaim.rb +22 -0
- data/lib/generators/proclaim/views_generator.rb +24 -0
- data/lib/proclaim.rb +22 -0
- data/lib/proclaim/engine.rb +39 -0
- data/lib/proclaim/version.rb +3 -0
- data/lib/tasks/proclaim_tasks.rake +4 -0
- data/proclaim.gemspec +46 -0
- data/test/controllers/proclaim/comments_controller_test.rb +228 -0
- data/test/controllers/proclaim/images_controller_test.rb +123 -0
- data/test/controllers/proclaim/posts_controller_test.rb +303 -0
- data/test/controllers/proclaim/subscriptions_controller_test.rb +93 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +14 -0
- data/test/dummy/app/assets/stylesheets/application.css +16 -0
- data/test/dummy/app/controllers/application_controller.rb +15 -0
- data/test/dummy/app/helpers/application_helper.rb +28 -0
- data/test/dummy/app/models/user.rb +7 -0
- data/test/dummy/app/views/layouts/application.html.erb +16 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +24 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +45 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +49 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/migrate/20141117214323_create_users.rb +10 -0
- data/test/dummy/db/schema.rb +75 -0
- data/test/dummy/log/development.log +131 -0
- data/test/dummy/log/test.log +25961 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/0b69f7cc441d56def3a51688e6a7a8474dc476d1/proclaim.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/comments.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/images.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/posts.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/subscriptions.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/04adcece63bc645379e6de797e7998f8 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/06620fc450f0a9b4a482a7bc08387711 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/076dd0d567a92c34163b3b98af1d48ba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/09fc2eadf6d6062b2cc135a44e4e73db +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/09fe8c62e8ae706e01058b4b4d056c8e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/142fd040033525acb73ad2ccf1406aea +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1762aeeaf38da3b8d989a5b66b088004 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/194ac1a695334e303516614579b3926d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/197ea008934db3e7ea8045302d206b92 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/19eba2635fec0895379c3e38f81ada84 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1c2ebe72fcd7ff1379a561552ca30f85 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1f42c80faacb651f670ec2b0998e49dc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2243230e778a749ecbf0415a52e75be0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/23ad87e715c70312aa61dde4fbb4bfe1 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/245b8735db4ea90bcaa91c011a1f447e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/26a42dac0cec64483f4126d2de4b0c9e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/30151c8f6d93717f06fa12774612ddf4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3c623d200214a5334aaf170537db087f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3ec36650a50759fd4b75794cb253936f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/40431cdcc10c75ba1f275ecfe42623d3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4226218a4b06608115b21063353370ea +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/437901953eb8707af6c27ca59cf65d91 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/461885b8ad31ef6a94c9a4f2e332b7eb +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4792f46317cda92ccd5b278ec61f9ac5 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4dcb3434b91b1c62f897a1741c6d398b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5101cda93cf70f0fc0837713be587780 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/52d8c61de0703e0d7cf97d0f7b0cca7a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/57f3d19a9bd484ac68c46f962a8684b2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/587e7c1332c8d8b69746dd85164e2cef +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5934d5d0d1ac6657842708e85c73cf51 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5af081799d7da2f04ead6a516c6015ad +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/69ee5af8d9a655898a67bc538ca1c7e7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6d1c56259648b0383bc438c875a448c3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6e7de35055967df848aa490830043e51 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/70bc59560ee544af7bb2f727247db307 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/728cb566999910549092ff0a98e2853b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/72b5f0d35e9d69b744a156edad98f983 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/72ffa34d552e3fd02f28a6f845a5ac5b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7369d324e84bc872c42b3e717ff4ad6c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/749a8b0e45b11df748a256dd04ceb1f7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/77fb9f62552d9b786f9407ef11cc9a09 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/797823842565e01fc989ad8df0bd4254 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7c139afa2296ac17483520109aecd449 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7fb99e2b35af65c4f58bfb92dd4185b4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/819de31c63b704f9ddf4865587a91d41 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8604b464bf846e5223da37ef2f29b524 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/88fc815613b473e98e9307b1d423918d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8bc4341aa4060b8646e8134722cf3b11 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8cf8fd5ff8eae12211a88f971af30236 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8da3b4a9f17aafff49eb263bdb758f44 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9168e513bae02f041dbb806d6dbe94ac +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/920c1322be1212a54b7c4f2751d5e7bf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/92205679a36afd387a2ba5c585a5a62c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/940566ebcae2d4e5c56a881ab66f2cf0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/976967e07e2944a7ecc7403667f1f96b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/99bdde70cefa71745279232be575f14e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9a8e402a7e32063e46647403b43553a5 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9b09ad72f8cc33503878b01c713d92d0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a20dbdfebf37fe50e832a6273c972553 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a3c6189fad6cb9ae955f6d5a43a61d51 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/abb54e11ff057a3e22a5a97d27cc4fa3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ad18e3875541d4298b1df133d494b93f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b9b7c575c22943d49734d52381c5ee16 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ba269a52f100d3d6cffda81e82e1ed49 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bc7a0846b4881b0832d41de2b1724dba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bcb2df87f9611d3cc3ef8a5575e54fb8 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bcf33791d3286af3ba2cdf6a6756c89e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/be32d0a530ce861537d6abfa41333df9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c8270a6f07dccc5f00e6b2b43f10efd2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cd82cd410a50bffcfb6e21e3c49a85c9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ce4ccaa06bdee6426486224bc7e54187 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d0bdb8592e4eed80aa2341e37f20dbc9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d4b784b16fa1b1dfcca6590689a8c157 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d968bd38a69bbf5c0065e2df3d30cfd3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/daa4d4b8a5ce46d6c4ecf031e0c61cfe +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/dc2effd195334219a7e4acfdc7ec7974 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/de36ab6c3b1a9b62a586d98373dd569c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e3aec457d5c753090d6521f2bb2d91b6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e8d6158b1fed2f574242b55856a3953d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ea82f6aececcf81eef3e2e15a9225e66 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ed9f5c17f71ec75de10b1bb029ebd7a2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f2984adaeaa5322e3a040705c6d40622 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f62fd0cf9f5e7e077ec9c4daeccb06ae +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f78ea69bdbba5738c052e9eb04e6c208 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f864e553f706456dbdf168319970ec2e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fb0f641bfcbb0101c040da9ff736447b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fe426a44cf23cf82032091cbffff898c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ff732ea47a86c449582b2a81ef2930da +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ffc4980851addaacf12abeebfa63e07f +0 -0
- data/test/dummy/tmp/generators/config/initializers/proclaim.rb +22 -0
- data/test/factories/proclaim/comment.rb +11 -0
- data/test/factories/proclaim/image.rb +6 -0
- data/test/factories/proclaim/post.rb +14 -0
- data/test/factories/proclaim/subscription.rb +13 -0
- data/test/factories/user.rb +6 -0
- data/test/helpers/proclaim/comments_helper_test.rb +6 -0
- data/test/helpers/proclaim/posts_helper_test.rb +6 -0
- data/test/helpers/proclaim/subscriptions_helper_test.rb +6 -0
- data/test/integration/with_javascript/comment_test.rb +353 -0
- data/test/integration/with_javascript/post_form_test.rb +179 -0
- data/test/integration/with_javascript/post_subscription_test.rb +273 -0
- data/test/integration/without_javascript/blog_subscription_test.rb +87 -0
- data/test/integration/without_javascript/post_test.rb +140 -0
- data/test/integration/without_javascript/subscription_email_test.rb +95 -0
- data/test/integration/without_javascript/unsubscribe_test.rb +32 -0
- data/test/mailers/previews/proclaim/subscription_mailer_preview.rb +22 -0
- data/test/mailers/proclaim/subscription_mailer_test.rb +87 -0
- data/test/models/proclaim/comment_test.rb +41 -0
- data/test/models/proclaim/image_test.rb +70 -0
- data/test/models/proclaim/post_test.rb +127 -0
- data/test/models/proclaim/subscription_test.rb +66 -0
- data/test/policies/proclaim/comment_policy_test.rb +71 -0
- data/test/policies/proclaim/post_policy_test.rb +87 -0
- data/test/policies/proclaim/subscription_policy_test.rb +91 -0
- data/test/proclaim_test.rb +7 -0
- data/test/support/images/test.jpg +0 -0
- data/test/support/pages/posts/edit_page.rb +5 -0
- data/test/support/pages/posts/show_page.rb +47 -0
- data/test/support/wait_for_ajax.rb +11 -0
- data/test/test_helper.rb +56 -0
- 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 +197 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-embeds.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-images.js +572 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-images.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-maps.js +50 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-maps.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-plugin.js +496 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-plugin.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-tables.js +132 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-tables.min.js +10 -0
- data/vendor/assets/javascripts/medium-editor-insert-plugin.all.js +1415 -0
- data/vendor/assets/javascripts/medium-editor-insert-plugin.all.min.js +10 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin-frontend.css +55 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin-frontend.min.css +10 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin.css +277 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin.min.css +10 -0
- metadata +791 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Proclaim
|
|
4
|
+
class PostsControllerTest < ActionController::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
@routes = Engine.routes
|
|
7
|
+
|
|
8
|
+
@controller.stubs(:current_user).returns(nil)
|
|
9
|
+
@controller.stubs(:authenticate_user).returns(false)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
teardown do
|
|
13
|
+
image = Image.new
|
|
14
|
+
FileUtils.rm_rf(File.join(Rails.public_path, image.image.cache_dir))
|
|
15
|
+
FileUtils.rm_rf(File.join(Rails.public_path, image.image.store_dir))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
test "should get index if logged in" do
|
|
19
|
+
user = FactoryGirl.create(:user)
|
|
20
|
+
sign_in user
|
|
21
|
+
|
|
22
|
+
post1 = FactoryGirl.create(:post)
|
|
23
|
+
post2 = FactoryGirl.create(:published_post)
|
|
24
|
+
|
|
25
|
+
get :index
|
|
26
|
+
assert_response :success
|
|
27
|
+
assert_not_nil assigns(:posts)
|
|
28
|
+
assert_includes assigns(:posts), post1
|
|
29
|
+
assert_includes assigns(:posts), post2
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test "should get index even if not logged in" do
|
|
33
|
+
post1 = FactoryGirl.create(:post)
|
|
34
|
+
post2 = FactoryGirl.create(:published_post)
|
|
35
|
+
|
|
36
|
+
get :index
|
|
37
|
+
assert_response :success
|
|
38
|
+
assert_not_nil assigns(:posts)
|
|
39
|
+
assert_not_includes assigns(:posts), post1
|
|
40
|
+
assert_includes assigns(:posts), post2
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
test "should get new if logged in" do
|
|
44
|
+
user = FactoryGirl.create(:user)
|
|
45
|
+
sign_in user
|
|
46
|
+
|
|
47
|
+
get :new
|
|
48
|
+
assert_response :success
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
test "should not get new if not logged in" do
|
|
52
|
+
get :new
|
|
53
|
+
assert_response :redirect
|
|
54
|
+
assert_match /not authorized/, flash[:error]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
test "should create post if logged in" do
|
|
58
|
+
user = FactoryGirl.create(:user)
|
|
59
|
+
sign_in user
|
|
60
|
+
|
|
61
|
+
newPost = FactoryGirl.build(:post)
|
|
62
|
+
|
|
63
|
+
assert_difference('Post.count') do
|
|
64
|
+
post :create, post: {
|
|
65
|
+
author_id: newPost.author_id,
|
|
66
|
+
body: newPost.body,
|
|
67
|
+
title: newPost.title
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
assert_redirected_to post_path(assigns(:post))
|
|
72
|
+
assert_match /successfully created/, flash[:notice]
|
|
73
|
+
refute assigns(:post).published?
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
test "should create published post if logged in" do
|
|
77
|
+
user = FactoryGirl.create(:user)
|
|
78
|
+
sign_in user
|
|
79
|
+
|
|
80
|
+
newPost = FactoryGirl.build(:post)
|
|
81
|
+
|
|
82
|
+
assert_difference('Post.count') do
|
|
83
|
+
post :create, post: {
|
|
84
|
+
author_id: newPost.author_id,
|
|
85
|
+
body: newPost.body,
|
|
86
|
+
title: newPost.title
|
|
87
|
+
}, publish: "true"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
assert_redirected_to post_path(assigns(:post))
|
|
91
|
+
assert_match /successfully created/, flash[:notice]
|
|
92
|
+
assert assigns(:post).published?
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
test "should upload images when creating post" do
|
|
96
|
+
user = FactoryGirl.create(:user)
|
|
97
|
+
sign_in user
|
|
98
|
+
|
|
99
|
+
newPost = FactoryGirl.build(:post)
|
|
100
|
+
image = FactoryGirl.build(:image, post: newPost)
|
|
101
|
+
|
|
102
|
+
newPost.body = "<img src=\"#{image.image.url}\"></img>"
|
|
103
|
+
|
|
104
|
+
post :create, post: {
|
|
105
|
+
author_id: newPost.author_id,
|
|
106
|
+
body: newPost.body,
|
|
107
|
+
title: newPost.title
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
post = Post.first # This works since there's only one
|
|
111
|
+
assert_equal 1, post.images.count, "The post should have an image"
|
|
112
|
+
|
|
113
|
+
image = post.images.first
|
|
114
|
+
|
|
115
|
+
save_path = File.join(Rails.public_path, image.image.store_dir)
|
|
116
|
+
saved_file_path = File.join(save_path, image.image_identifier)
|
|
117
|
+
assert File.exist?(saved_file_path), "File should be saved: #{saved_file_path}"
|
|
118
|
+
|
|
119
|
+
document = Nokogiri::HTML.fragment(post.body)
|
|
120
|
+
image_tags = document.css("img")
|
|
121
|
+
assert_equal 1, image_tags.count
|
|
122
|
+
|
|
123
|
+
# Note that, now that the image is saved, this URL is different than
|
|
124
|
+
# the one submitted to :create
|
|
125
|
+
assert_equal image.image.url, image_tags.first.attributes["src"].value
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
test "should not create post if not logged in" do
|
|
129
|
+
newPost = FactoryGirl.build(:post)
|
|
130
|
+
|
|
131
|
+
assert_no_difference('Post.count') do
|
|
132
|
+
post :create, post: {
|
|
133
|
+
author_id: newPost.author_id,
|
|
134
|
+
body: newPost.body,
|
|
135
|
+
title: newPost.title
|
|
136
|
+
}
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
assert_response :redirect
|
|
140
|
+
assert_match /not authorized/, flash[:error]
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
test "should show post if logged in" do
|
|
144
|
+
user = FactoryGirl.create(:user)
|
|
145
|
+
sign_in user
|
|
146
|
+
|
|
147
|
+
# Should show published post
|
|
148
|
+
newPost = FactoryGirl.create(:published_post)
|
|
149
|
+
|
|
150
|
+
get :show, id: newPost
|
|
151
|
+
assert_response :success
|
|
152
|
+
assert_equal assigns(:post), newPost
|
|
153
|
+
|
|
154
|
+
# Should also show unpublished post
|
|
155
|
+
newPost = FactoryGirl.create(:post)
|
|
156
|
+
|
|
157
|
+
get :show, id: newPost
|
|
158
|
+
assert_response :success
|
|
159
|
+
assert_equal assigns(:post), newPost
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
test "should show post if not logged in" do
|
|
163
|
+
# Should show published post
|
|
164
|
+
newPost = FactoryGirl.create(:published_post)
|
|
165
|
+
|
|
166
|
+
get :show, id: newPost
|
|
167
|
+
assert_response :success
|
|
168
|
+
assert_equal assigns(:post), newPost
|
|
169
|
+
|
|
170
|
+
# Should not show unpublished post
|
|
171
|
+
newPost = FactoryGirl.create(:post)
|
|
172
|
+
|
|
173
|
+
# Controller should hide the "permission denied" in a "not-found"
|
|
174
|
+
assert_raises ActiveRecord::RecordNotFound do
|
|
175
|
+
get :show, id: newPost
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
test "should get edit if logged in" do
|
|
180
|
+
user = FactoryGirl.create(:user)
|
|
181
|
+
sign_in user
|
|
182
|
+
|
|
183
|
+
newPost = FactoryGirl.create(:post)
|
|
184
|
+
|
|
185
|
+
get :edit, id: newPost
|
|
186
|
+
assert_response :success
|
|
187
|
+
assert_equal assigns(:post), newPost
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
test "should not get edit if not logged in" do
|
|
191
|
+
newPost = FactoryGirl.create(:post)
|
|
192
|
+
|
|
193
|
+
get :edit, id: newPost
|
|
194
|
+
assert_response :redirect
|
|
195
|
+
assert_match /not authorized/, flash[:error]
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
test "should update post if logged in" do
|
|
199
|
+
user = FactoryGirl.create(:user)
|
|
200
|
+
sign_in user
|
|
201
|
+
|
|
202
|
+
newPost = FactoryGirl.create(:post)
|
|
203
|
+
|
|
204
|
+
patch :update, id: newPost, post: {
|
|
205
|
+
author_id: newPost.author_id,
|
|
206
|
+
body: newPost.body,
|
|
207
|
+
title: newPost.title
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
assert_redirected_to post_path(assigns(:post))
|
|
211
|
+
assert_match /successfully updated/, flash[:notice]
|
|
212
|
+
refute assigns(:post).published?
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
test "should publish post if logged in" do
|
|
216
|
+
user = FactoryGirl.create(:user)
|
|
217
|
+
sign_in user
|
|
218
|
+
|
|
219
|
+
newPost = FactoryGirl.create(:post)
|
|
220
|
+
|
|
221
|
+
patch :update, id: newPost, post: {
|
|
222
|
+
author_id: newPost.author_id,
|
|
223
|
+
body: newPost.body,
|
|
224
|
+
title: newPost.title
|
|
225
|
+
}, publish: "true"
|
|
226
|
+
|
|
227
|
+
assert_redirected_to post_path(assigns(:post))
|
|
228
|
+
assert_match /successfully updated/, flash[:notice]
|
|
229
|
+
assert assigns(:post).published?, "Post should now be published!"
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
test "should upload images when updating a post" do
|
|
233
|
+
user = FactoryGirl.create(:user)
|
|
234
|
+
sign_in user
|
|
235
|
+
|
|
236
|
+
newPost = FactoryGirl.create(:post)
|
|
237
|
+
image = FactoryGirl.build(:image, post: newPost)
|
|
238
|
+
|
|
239
|
+
newPost.body = "<img src=\"#{image.image.url}\">"
|
|
240
|
+
|
|
241
|
+
patch :update, id: newPost, post: {
|
|
242
|
+
author_id: newPost.author_id,
|
|
243
|
+
body: newPost.body,
|
|
244
|
+
title: newPost.title
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
post = Post.first # This works since there's only one
|
|
248
|
+
assert_equal 1, post.images.count, "The post should have an image"
|
|
249
|
+
|
|
250
|
+
image = post.images.first
|
|
251
|
+
|
|
252
|
+
save_path = File.join(Rails.public_path, image.image.store_dir)
|
|
253
|
+
saved_file_path = File.join(save_path, image.image_identifier)
|
|
254
|
+
assert File.exist?(saved_file_path), "File should be saved: #{saved_file_path}"
|
|
255
|
+
|
|
256
|
+
document = Nokogiri::HTML.fragment(post.body)
|
|
257
|
+
image_tags = document.css("img")
|
|
258
|
+
assert_equal 1, image_tags.count
|
|
259
|
+
|
|
260
|
+
# Note that, now that the image is saved, this URL is different than
|
|
261
|
+
# the one submitted to :create
|
|
262
|
+
assert_equal image.image.url, image_tags.first.attributes["src"].value
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
test "should not update post if not logged in" do
|
|
266
|
+
newPost = FactoryGirl.create(:post)
|
|
267
|
+
|
|
268
|
+
patch :update, id: newPost, post: {
|
|
269
|
+
author_id: newPost.author_id,
|
|
270
|
+
body: newPost.body,
|
|
271
|
+
title: newPost.title
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
assert_response :redirect
|
|
275
|
+
assert_match /not authorized/, flash[:error]
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
test "should destroy post if logged in" do
|
|
279
|
+
user = FactoryGirl.create(:user)
|
|
280
|
+
sign_in user
|
|
281
|
+
|
|
282
|
+
newPost = FactoryGirl.create(:post)
|
|
283
|
+
|
|
284
|
+
assert_difference('Post.count', -1) do
|
|
285
|
+
delete :destroy, id: newPost
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
assert_redirected_to posts_path
|
|
289
|
+
assert_match /successfully destroyed/, flash[:notice]
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
test "should not destroy post if not logged in" do
|
|
293
|
+
newPost = FactoryGirl.create(:post)
|
|
294
|
+
|
|
295
|
+
assert_no_difference('Post.count') do
|
|
296
|
+
delete :destroy, id: newPost
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
assert_response :redirect
|
|
300
|
+
assert_match /not authorized/, flash[:error]
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Proclaim
|
|
4
|
+
class SubscriptionsControllerTest < ActionController::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
@routes = Engine.routes
|
|
7
|
+
|
|
8
|
+
@controller.stubs(:current_user).returns(nil)
|
|
9
|
+
@controller.stubs(:authenticate_user).returns(false)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
test "should create subscription if logged in" do
|
|
13
|
+
user = FactoryGirl.create(:user)
|
|
14
|
+
sign_in user
|
|
15
|
+
|
|
16
|
+
newSubscription = FactoryGirl.build(:subscription)
|
|
17
|
+
|
|
18
|
+
assert_difference('Subscription.count') do
|
|
19
|
+
post :create,
|
|
20
|
+
subscription: {
|
|
21
|
+
email: newSubscription.email
|
|
22
|
+
},
|
|
23
|
+
antispam: {
|
|
24
|
+
solution: 5,
|
|
25
|
+
answer: 5
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
assert_redirected_to :subscribed
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test "should create subscription if not logged in" do
|
|
33
|
+
newSubscription = FactoryGirl.build(:subscription)
|
|
34
|
+
|
|
35
|
+
assert_difference('Subscription.count') do
|
|
36
|
+
post :create,
|
|
37
|
+
subscription: {
|
|
38
|
+
email: newSubscription.email
|
|
39
|
+
},
|
|
40
|
+
antispam: {
|
|
41
|
+
solution: 3,
|
|
42
|
+
answer: 3
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
assert_redirected_to :subscribed
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
test "should not create subscription if spammy" do
|
|
50
|
+
newSubscription = FactoryGirl.build(:subscription)
|
|
51
|
+
|
|
52
|
+
assert_no_difference('Subscription.count') do
|
|
53
|
+
post :create,
|
|
54
|
+
subscription: {
|
|
55
|
+
email: newSubscription.email
|
|
56
|
+
},
|
|
57
|
+
antispam: {
|
|
58
|
+
solution: 5,
|
|
59
|
+
answer: 3
|
|
60
|
+
}
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
test "ensure token resolves to correct subscription" do
|
|
65
|
+
subscription1 = FactoryGirl.create(:subscription)
|
|
66
|
+
subscription2 = FactoryGirl.create(:subscription)
|
|
67
|
+
|
|
68
|
+
get :unsubscribe, token: subscription1.token
|
|
69
|
+
assert_response :success
|
|
70
|
+
assert_equal subscription1, assigns(:subscription)
|
|
71
|
+
|
|
72
|
+
get :unsubscribe, token: subscription2.token
|
|
73
|
+
assert_response :success
|
|
74
|
+
assert_equal subscription2, assigns(:subscription)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
test "ensure deletion with token actually deletes correct subscription" do
|
|
78
|
+
subscription1 = FactoryGirl.create(:subscription)
|
|
79
|
+
subscription2 = FactoryGirl.create(:subscription)
|
|
80
|
+
|
|
81
|
+
assert_difference('Subscription.count', -1) do
|
|
82
|
+
delete :destroy, token: subscription1.token
|
|
83
|
+
end
|
|
84
|
+
assert_equal subscription2, Subscription.first
|
|
85
|
+
assert_redirected_to :unsubscribed
|
|
86
|
+
|
|
87
|
+
assert_difference('Subscription.count', -1) do
|
|
88
|
+
delete :destroy, token: subscription2.token
|
|
89
|
+
end
|
|
90
|
+
assert_redirected_to :unsubscribed
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require proclaim
|
|
14
|
+
//= require_tree .
|