A03-7219 keep users with 'show the whole work by default' enabled in chapter by chapter mode when commenting #5524
+14
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
as the first thing in your pull request title (e.g.
AO3-1234 Fix thing)until they are reviewed and merged before creating new pull requests.
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 totrueif it is set.But even if
params[:view_full_work] == "false", if the user had their preference set toview_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
Ensure other behavior did not change
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
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.