Skip to content

Conversation

@not-varram
Copy link

@not-varram not-varram commented Jan 14, 2026

Pull Request Checklist

Issue

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

Purpose

Fixes incorrect reference to current_user.preference.locale_for_mails in the preferences view. The view was using current_user.preference instead of the already-loaded @preference instance variable, which could potentially cause errors and was inconsistent with the rest of the form.

Changes:

  • Updated line 76 in app/views/preferences/index.html.erb to use @preference.locale_for_mails instead of current_user.preference.locale_for_mails
  • This makes it consistent with other references in the same view (e.g., @preference.preferred_locale on line 78)
  • Follows the same pattern used in app/views/help/preferences_locale.html.erb

Testing Instructions

  1. Login as policy_and_abuse, support or superadmin admin
  2. Navigate to a user’s preferences page
    a. Browse > Works
    b. Follow the link to an author’s pseud
    c. Click on preferences in the user sidebar
  3. Now just ensure the page loads and you dont see any errors

Credit

varram (he/him)

Copy link
Member

@marcus8448 marcus8448 left a comment

Choose a reason for hiding this comment

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

Hi varram,

Thanks for the pull request! It would be great if you could also add a test for this issue. (You might find preferences_edit.feature helpful when doing so)

@not-varram
Copy link
Author

hey! @marcus8448 I've made the changes you requested. Let me know if this is fine? (I'm pretty new to contributing to ao3 so any feedback is appreciated :))

Copy link
Member

@marcus8448 marcus8448 left a comment

Choose a reason for hiding this comment

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

Implementation looks good! Just two notes for the tests.

Comment on lines +51 to +69

context "when locale preferences are enabled for the viewed user" do
before do
allow($rollout).to receive(:active?).with(:set_locale_preference, user).and_return(true)
end

read_roles.each do |role|
it "allows #{role} to view preferences without errors" do
admin = create(:admin, roles: [role])
fake_login_admin(admin)

get :index, params: { user_id: user.login }

expect(assigns(:user)).to eq(user)
expect(assigns(:preference)).to eq(user.preference)
expect(response).to be_successful
end
end
end
Copy link
Member

Choose a reason for hiding this comment

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

RSpec doesn't render views by default, so this doesn't actually hit the problematic code in the view.
I think the Cucumber test should be sufficient to cover this issue anyways, so this can just be removed.

When I go to testuser's preferences page
Then I should see "Set My Preferences"
And I should see "Your locale"
And I should not see "We're sorry, but something went wrong"
Copy link
Member

Choose a reason for hiding this comment

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

When the error is raised, the test automatically fails so we don't need to check for the error page text.

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.

2 participants