docbrown/app/controllers
Daniel Uber 14caad86a7
handle deleted article's comments page with a 404 response (#15351)
* Add a failing test for comments index of deleted article

After https://github.com/forem/forem/pull/15052 removed the (also
broken) deleted commentable template and the redirect, requests for
comments from deleted articles raise no method errors (initially
trying to set the page title to "Comments for commentable.title" but
the assumption that @commentable is non-nil is present in several
other places.

This test currently fails (by design). Either we want to update the
controller so that comments from deleted articles are no longer
viewable (returning not found, as we did prior to
https://github.com/forem/forem/pull/5199 or making the view safe for
the case where @commentable is nil and no @root_comment is present.

These requests are happening quite frequently (@maestromac and I
suspect the sitemap may contain these pages and crawlers are visiting
the site from a published link), as evidenced by
https://app.honeybadger.io/projects/66984/faults/81994265

* Add request spec for deleted article scenario

Additionally, relabel the legacy spec (updated during #15052) to
clarify we do not render the deleted_commentable_comment view (this is
testing the comment.path, rather than the article.path/comments index

The scenario with comment.path sets `@root_comment` in the controller,
so does not trigger errors on the `@commentable` method calls.

* Update view

pass 1: get the errors to stop (need to check the rendered page is
also usable, the comment tree is not shown when commentable is nil and
this might be a huge usability/correctness issue).

* extract logic from comments index to methods and update tests

We no longer expect deleted article's comments index to render (should
return 404), only direct links to comments of deleted articles.

Only assign @article in the index for the view if it is in fact an
article (not a podcast episode, it's possible `@root_comment` was for
a podcast episode).

* remove unneeded (and soon to be incorrect spec)

No longer want or need to test for the case where root comment is nil
and so is commentable. This was an exploratory spec (scaffolding) and
can be removed.

* Undo nil safety changes to comments index

and fix typo in comments spec
2021-11-11 12:56:14 -06:00
..
admin Provide "Help" on the Creator Onboarding Setup Page (#15308) 2021-11-11 08:42:56 -07:00
api/v0 Auto register Forems on Discover (#14962) 2021-10-06 10:51:15 -04:00
concerns Zappat0n/add rate limit model everywhere 11500 (#14609) 2021-09-23 10:49:19 +01:00
incoming_webhooks Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
notifications Rubocop: fix additional violations in todo file (#9218) 2020-07-09 10:25:44 -04:00
oauth Change Webhook::DestroyJob to Wehook::DestroyWorker and move to sidekiq (#5424) [deploy] 2020-01-13 12:38:10 -06:00
stories Refactoring to extract common interface (#15229) 2021-11-02 13:16:09 -04:00
users Use constants for controller allowed params (#14815) 2021-09-28 16:30:56 +02:00
api_secrets_controller.rb Removing Settings::General.email_addresses (#13958) 2021-06-11 12:34:34 +03:00
application_controller.rb Try env var from request for Nginx ip address (#15201) 2021-10-27 16:00:20 -04:00
application_metal_controller.rb Add ApplicationMetalController to relevant controllers (#4937) 2019-11-26 16:29:07 -05:00
article_approvals_controller.rb Allow tag mods to approve posts even if they mod just one tag (#6525) [deploy] 2020-03-08 15:42:38 -04:00
articles_controller.rb Clean up feed-related code (#14707) 2021-09-17 09:23:32 +07:00
async_info_controller.rb Creator Onboarding: Creator Setup View (#14728) 2021-11-01 15:50:08 -04:00
badges_controller.rb Add badges index page. (#4236) 2019-10-06 17:34:52 -04:00
chat_channel_memberships_controller.rb Fix "possible unprotected redirect" warning (#10511) 2020-12-29 14:54:34 -05:00
chat_channels_controller.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
collections_controller.rb Fix Bug: Series index page showing series with 0 articles -#9658 (#11227) 2020-11-03 09:10:46 +01:00
comments_controller.rb handle deleted article's comments page with a 404 response (#15351) 2021-11-11 12:56:14 -06:00
confirmations_controller.rb Redirect to creator settings page where necessary (#15298) 2021-11-11 14:44:49 +02:00
credits_controller.rb Refactor credit purchasing (#13955) 2021-06-15 09:04:51 +07:00
dashboards_controller.rb In dashboard show api eager load collection with articles (#14677) 2021-09-09 11:11:03 +01:00
deep_links_controller.rb Add exclusion to AASA supported paths (#14593) 2021-08-26 10:17:39 -06:00
devices_controller.rb Have specs run without Redis and refactor ConsumerApp and Device (#13647) 2021-05-07 08:03:16 +02:00
discussion_locks_controller.rb Update DiscussionLocksController (#14351) 2021-07-27 14:42:14 +02:00
display_ad_events_controller.rb [15-minute fix] Add ThrottledCall to DisplayAdEventsController (#12924) 2021-03-09 09:06:11 +07:00
email_authorizations_controller.rb Standardize ActiveRecord order clauses (#9395) 2020-07-20 10:00:51 -04:00
email_subscriptions_controller.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
feedback_messages_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
followings_controller.rb Rubocop: move dot in multi-line calls to leading position (#9262) 2020-07-16 15:51:11 +02:00
follows_controller.rb Bug Fix: Following an organization from article's sidebar creates an incorrect follow record (#15093) 2021-11-05 12:40:20 -04:00
ga_events_controller.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
github_repos_controller.rb Fix Ruby 2.7 kwargs' warnings & misc spec warnings (#13256) 2021-04-06 16:57:59 -04:00
html_variant_successes_controller.rb Move HtmlVariantSuccessesCreate from job to inline (#5879) [deploy] 2020-02-04 10:24:39 -08:00
html_variant_trials_controller.rb Move HtmlVariantTrial#create inline (#5901) [deploy] 2020-02-04 17:29:46 -08:00
image_uploads_controller.rb [deploy] Store Article's main_image path unprocessed (#10867) 2020-10-16 14:46:37 -04:00
invitations_controller.rb Part One: Fix Users Stuck in a "Created" but "Unregistered" State (#10882) 2020-10-19 16:51:31 -04:00
liquid_embeds_controller.rb Modify headers to allow embed (#3935) 2019-09-03 16:38:04 -04:00
liquid_tags_controller.rb Remove redundant freeze calls (#14596) 2021-08-26 10:01:08 -04:00
listings_controller.rb Zappat0n/add rate limit model everywhere 11500 (#14609) 2021-09-23 10:49:19 +01:00
messages_controller.rb [deploy] Include APP_NAME in Pusher channels (#10001) 2020-08-31 08:28:46 -04:00
moderations_controller.rb Bug Fix:Remove Score Filter From Tag Mod Index (#11599) 2020-11-24 14:18:14 -06:00
notification_subscriptions_controller.rb Rename unidiomatic methods (#13328) 2021-04-09 10:59:56 -05:00
notifications_controller.rb Enable Rubocop 0.89 cops and fix Lint/ violations (#9709) 2020-08-10 16:57:12 +02:00
omniauth_callbacks_controller.rb Rename banned and comment_banned roles (#12270) 2021-04-06 10:12:14 -05:00
onboardings_controller.rb Cache onboarding at edge (#6966) 2020-03-31 16:12:14 +02:00
open_search_controller.rb [deploy] Remove need for ENV vars during asset precompile (#10349) 2020-09-16 13:57:05 -04:00
organizations_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
page_views_controller.rb Extract page view updates into workers (#12686) 2021-02-17 09:24:05 +07:00
pages_controller.rb RFC #74, Pt. 2: Private Forem Landing Page (#13819) 2021-06-10 11:46:24 -06:00
passwords_controller.rb Add a notification on password reset (#14968) 2021-10-07 14:48:01 -04:00
podcast_episodes_controller.rb Fix and clean up podcast pages (#15004) 2021-10-15 17:38:57 -04:00
podcasts_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
poll_skips_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
poll_votes_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
pro_accounts_controller.rb Add basic pro accounts lander test (#3433) 2019-07-09 22:10:50 -04:00
profile_field_groups_controller.rb Add ProfileFieldGroupsController to API (#10124) 2020-09-03 10:12:53 +07:00
profile_pins_controller.rb Create DiscussionLocks (#13905) 2021-06-10 11:04:33 -04:00
profile_preview_cards_controller.rb Add JSON representation of Profile Preview Card info (#14296) 2021-07-21 16:23:54 +01:00
profiles_controller.rb Profile generalization: cleanup (#12947) 2021-08-20 16:36:02 +02:00
pusher_controller.rb [deploy] Include APP_NAME in Pusher channels (#10001) 2020-08-31 08:28:46 -04:00
rating_votes_controller.rb [deploy] Rubocop: fix violations of Layout/LineLength (#9197) 2020-07-08 08:36:36 -05:00
reactions_controller.rb Don't try to create invalid RatingVote (#14706) 2021-09-14 09:41:59 +07:00
reading_list_items_controller.rb [deploy] Fix Reading List Counter Without last_reacted_at Default (#10933) 2020-10-19 13:26:19 -05:00
registrations_controller.rb Redirect to creator settings page where necessary (#15298) 2021-11-11 14:44:49 +02:00
response_templates_controller.rb Add ApplicationRecord#errors_as_sentence (#8265) 2020-06-04 16:02:41 +02:00
search_controller.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
service_worker_controller.rb Revert "Revert "Removed service worker (#12974)" (#13014)" (#13015) 2021-03-17 10:57:56 -04:00
sidebars_controller.rb Split Settings::Campaign from SiteConfig (#13238) 2021-04-19 10:01:03 +07:00
sitemaps_controller.rb I18n copy on Tags index page (#14891) 2021-10-08 10:21:06 +07:00
social_previews_controller.rb Rubocop: enable and fix new Rails cops (#9537) 2020-07-29 11:14:19 +02:00
stories_controller.rb Low Stakes Refactor of Feed class (#15180) 2021-10-26 09:57:33 -04:00
stripe_active_cards_controller.rb Use constants for Permitted params in controller (#14895) 2021-10-05 09:00:14 -04:00
tag_adjustments_controller.rb Fix new Rubocop violations (#10808) 2020-10-20 09:28:53 -04:00
tags_controller.rb Update TagsController#index query (#15202) 2021-10-27 08:17:53 -04:00
user_blocks_controller.rb Add ApplicationRecord#errors_as_sentence (#8265) 2020-06-04 16:02:41 +02:00
user_subscriptions_controller.rb UserSubscription backend refactor (#9060) 2020-07-02 12:08:37 -04:00
users_controller.rb Tokenize settings menu and add French translations (#14905) 2021-10-06 17:53:58 +02:00
video_states_controller.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
videos_controller.rb Rubocop: Enable and fix Style/StringConcatenation (#9844) 2020-08-18 14:50:15 +02:00