Skip to content

Conversation

@Dame-Zoom-A-Lot
Copy link
Contributor

@Dame-Zoom-A-Lot Dame-Zoom-A-Lot commented Dec 27, 2025

Pull Request Checklist

Note on tests:

I decided not to add tests since comments_controller_spec did not have any tests for the create endpoint, nor tests that would verify redirect_to_all_comments behaviors. works_controller_spec likewise only had tests for #navigate.

I'm assuming this was a conscious decision to avoid bogging down CI since there's a robust QA team.

I'm happy to put in some extra work to add net new tests for these endpoints if the testing gap was due to lack of resources, but that would increase the scope of this PR.

Issue

https://otwarchive.atlassian.net/browse/AO3-7219

Purpose

Fix the bug where users who had "show the whole work by default" enabled were getting redirected to the full work view after commenting.

This was happening because we were showing the whole work

if params[:view_full_work] || (logged_in? && current_user.preference.try(:view_full_works))

Since params[:view_full_work] is either "true" or "false" this always evaluates to true if it is set.
But even if params[:view_full_work] == "false", if the user had their preference set to view_full_works, we would have shown the full work view and not the chapter by chapter view.

There was also a routing error in the comments_controller where
if commentable.is_a?(Chapter) && (options[:view_full_work] || current_user.try(:preference).try(:view_full_works)) we set the chapter commentable to a work commentable, which also routed to the entire work view.

I added the same logic here that I added in the works controller

Testing Instructions

Reported bug

  1. Log in
  2. Have the "Show the whole work by default" preference enabled
  3. Open a work in chapter by chapter mode
  4. Leave a comment or reply to a comment on a chapter
  5. Confirm users stays in chapter by chapter mode

Ensure other behavior did not change

  1. Log in
  2. Have the "Show the whole work by default" preference enabled
  3. Open a work in entire work mode
  4. Leave a comment or reply to a comment on a chapter
  5. Confirm user stays in entire work mode, and that the new comment is tied to the last chapter

Testing Notes
While testing, I found that when the new comment would be in page 2+, the user does not get redirected to the comment section. This is an unrelated issue, and potentially a bug. To test

  1. Log in
  2. Open work in whatever mode
  3. Leave a comment that would show in page 2 of the comments view
  4. User is redirected to the work view upon submitting a comment, but the stays at the top of the page and does not get navigated to the comments box

How can the Archive's QA team verify that this is working as you intended?

If you have a Jira account with access, please update or comment on the issue
with any new or missing testing instructions instead.

You can remove this section if there are already full testing instructions in the Jira issue.

Credit

What name and pronouns should we use to credit you in the Archive of Our Own's Release Notes?
Zooms, any pronoun

If you have a Jira account, please include the same name in the "Full name"
field on your Jira profile, so we can assign you the issues you're working on.

Please note that if you do not fill in this section, we will use your GitHub account name and
they/them pronouns.

@Dame-Zoom-A-Lot Dame-Zoom-A-Lot marked this pull request as draft December 28, 2025 00:05

def check_pseud_ownership
return unless params[:comment][:pseud_id]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some whitespace only rubocop auto corrects

if commentable.is_a?(Chapter) && (options[:view_full_work] || current_user.try(:preference).try(:view_full_works))
commentable = commentable.work
if commentable.is_a?(Chapter)
user_chose_to_view_full_work = current_user.try(:preference).try(:view_full_works) && options[:view_full_work] != false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to have a unified way to see when a user wanted to to view full work vs chaptered view. But all the different helper methods and endpoints had slightly different ways we would need to use to identify them.

@Dame-Zoom-A-Lot Dame-Zoom-A-Lot marked this pull request as ready for review December 28, 2025 00:37
@Dame-Zoom-A-Lot Dame-Zoom-A-Lot marked this pull request as draft December 28, 2025 00:37
@Dame-Zoom-A-Lot Dame-Zoom-A-Lot marked this pull request as ready for review December 28, 2025 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant