AO3-7324 List user creations by date, not by pseud#5738
AO3-7324 List user creations by date, not by pseud#5738kekley wants to merge 4 commits intootwcode:masterfrom
Conversation
|
Hi, kekley! Thank you so much for this pull request. Someone will be along to review it soon. If you'd like the ability to comment on, assign, and transition issues in the future, you're welcome to create a Jira account! It makes things a bit easier for us on the organizational side if the Full Name on your Jira account either closely matches the name you'd like us to credit in the release notes or includes it in parentheses, e.g. "Nickname (CREDIT NAME)." Once you've done that (or if you've already done it -- Jira has been unreliable about showing us new accounts in the admin panel lately), you can either reply here or send an email to otw-coders@transformativeworks.org with your account name and email address and we'll set up the permissions for you. Thanks again for contributing! If you have any questions, you can contact us at the same email address listed above. |
brianjaustin
left a comment
There was a problem hiding this comment.
Just 1 comment, otherwise looking good already!
| let!(:user_work) { create(:work, authors: [user.default_pseud]) } | ||
| let!(:other_work) { create(:work) } | ||
| let!(:other_pseud) { create(:pseud, user: user) } | ||
| let!(:older_comment) { create(:comment, pseud: other_pseud) } |
There was a problem hiding this comment.
Rather than setting the created_at columns below, how about using the travel_to helper when creating the comments? For example:
| let!(:older_comment) { create(:comment, pseud: other_pseud) } | |
| let!(:older_comment) do | |
| travel_to(2.days.ago) do | |
| create(:comment, pseud: other_pseud) | |
| end | |
| end |
There was a problem hiding this comment.
and since this won't work after my suggestion: you can create records with a set id with create, just pick something not super low so there is less risk of overlap with things from other tests. E.g.:
otwarchive/spec/models/abuse_report_spec.rb
Lines 737 to 738 in 4a17584
| @works = @user.works.reorder(created_at: :asc, id: :asc).paginate(page: params[:works_page]) | ||
| @comments = @user.comments.reorder(created_at: :asc, id: :asc).paginate(page: params[:comments_page]) |
There was a problem hiding this comment.
These two additions can be simplified to order(id: :asc)
reorder is only needed if there was previously a different order set on the query, which is not the case here. The issue specifies that the creations should be ordered by id, and since that's unique (so a stable sorting criterion), it can be the only order we specify
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.
Issue
https://otwarchive.atlassian.net/browse/AO3-7324
Purpose
List user creations on the spamban page in order from oldest to newest by creation date and then ID, rather than by pseud.
Credit
kekley (they/them)