From 2df0e2e01e495d9cf067511e5c9c50cfc4921c5e Mon Sep 17 00:00:00 2001 From: irrationalpie7 Date: Thu, 16 Feb 2023 00:12:59 -0800 Subject: [PATCH 1/7] AO3-5053 Update bookmarker name when pseud/login name changes --- app/models/pseud.rb | 9 +- app/models/user.rb | 2 + features/other_a/pseuds.feature | 770 ++++++++++++++++++----------- features/users/user_rename.feature | 57 ++- spec/models/pseud_spec.rb | 12 + spec/models/user_spec.rb | 13 + 6 files changed, 554 insertions(+), 309 deletions(-) diff --git a/app/models/pseud.rb b/app/models/pseud.rb index 91940f84131..82ac09743c8 100644 --- a/app/models/pseud.rb +++ b/app/models/pseud.rb @@ -397,10 +397,11 @@ def check_default_pseud end def expire_caches - if saved_change_to_name? - works.touch_all - series.each(&:expire_byline_cache) - end + return unless saved_change_to_name? + + bookmarks.touch_all + works.touch_all + series.each(&:expire_byline_cache) end def touch_comments diff --git a/app/models/user.rb b/app/models/user.rb index 791f2bc0580..609886fab94 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -160,7 +160,9 @@ class User < ApplicationRecord def expire_caches return unless saved_change_to_login? + series.each(&:expire_byline_cache) + self.bookmarks.touch_all self.works.each do |work| work.touch work.expire_caches diff --git a/features/other_a/pseuds.feature b/features/other_a/pseuds.feature index 077c1407e00..b8551fadd9d 100644 --- a/features/other_a/pseuds.feature +++ b/features/other_a/pseuds.feature @@ -1,289 +1,489 @@ @users Feature: Pseuds -Scenario: pseud creation and playing with the default pseud - - Given I am logged in as "myself" - And I go to myself's pseuds page - - # Check that you can't edit your default pseud. - Then I should see "Default Pseud" - When I follow "Edit" - Then I should see "You cannot change the pseud that matches your user name." - And the "Make this name default" checkbox should be checked and disabled - - # Make a new default pseud called "Me." - When I follow "Back To Pseuds" - And I follow "New Pseud" - And I fill in "Name" with "Me" - And I check "Make this name default" - And I fill in "Description" with "Something's cute" - And I press "Create" - Then I should see "Pseud was successfully created." - And I should be on myself's "Me" pseud page - - # Make sure the new "Me" pseud is the default. - When I follow "Edit Pseud" - Then I should see "Me" - And the "Make this name default" checkbox should not be disabled - And the "Make this name default" checkbox should be checked - - # Make sure the old "myself" pseud is no longer the default. - When I follow "Back To Pseuds" - And I follow "edit_myself" - Then the "Make this name default" checkbox should not be checked - And the "Make this name default" checkbox should not be disabled - - # Edit "Me" to remove it as your default pseud. - When I follow "Back To Pseuds" - And I follow "Me" - Then I should be on myself's "Me" pseud page - When I follow "Edit Pseud" - And I uncheck "Make this name default" - And I press "Update" - Then I should see "Pseud was successfully updated." - And I should be on myself's "Me" pseud page - - # Make sure "Me" is no longer the default pseud, but "myself" is. - When I follow "Edit Pseud" - Then the "Make this name default" checkbox should not be checked - When I follow "Back To Pseuds" - And I follow "edit_myself" - Then the "Make this name default" checkbox should be checked and disabled - - # Test the pseud update path by making Me the default pseud once again. - When I follow "Back To Pseuds" - And I follow "Me" - And I follow "Edit Pseud" - And I check "Make this name default" - And I press "Update" - Then I should see "Pseud was successfully updated." - And I should be on myself's "Me" pseud page - When I follow "Edit Pseud" - Then the "Make this name default" checkbox should be checked - -Scenario: Manage pseuds - add, edit - - Given I am logged in as "editpseuds" - - # Check the Manage My Pseuds link in the profile works. - When I go to editpseuds's user page - And I follow "Profile" - And I follow "Manage My Pseuds" - Then I should see "Pseuds for editpseuds" - - # Make a new pseud. - When I follow "New Pseud" - And I fill in "Name" with "My new name" - And I fill in "Description" with "I wanted to add another name" - And I press "Create" - Then I should be on editpseuds's "My new name" pseud page - And I should see "Pseud was successfully created." - And I should see "My new name" - And I should see "You don't have anything posted under this name yet." - - # Check that all pseuds are listed on user's pseuds page. - When I follow "Back To Pseuds" - Then I should see "editpseuds (editpseuds)" - And I should see "My new name (editpseuds)" - And I should see "I wanted to add another name" - And I should see "Default Pseud" - - # Try to create another pseud with the same name you already used. - When I follow "New Pseud" - Then I should see "New pseud" - When I fill in "Name" with "My new name" - And I press "Create" - Then I should see "You already have a pseud with that name." - - # Recheck various links. - When I follow "Back To Pseuds" - And I follow "editpseuds" - And I follow "Profile" - And I follow "Manage My Pseuds" - Then I should see "Edit My new name" - - # Edit your new pseud's name and description. - When I follow "edit_my_new_name" - And I fill in "Description" with "I wanted to add another fancy name" - And I fill in "Name" with "My new fancy name" - And I press "Update" - Then I should see "Pseud was successfully updated." - And I should be on editpseuds's "My new fancy name" pseud page - - # Check that the changes to your pseud show up on your pseuds page. - When I follow "Back To Pseuds" - Then I should see "editpseuds (editpseuds)" - And I should see "My new fancy name (editpseuds)" - And I should see "I wanted to add another fancy name" - And I should not see "My new name (editpseuds)" - -Scenario: Pseud descriptions do not display images - - Given I am logged in as "myself" - And I go to my pseuds page + Scenario: pseud creation and playing with the default pseud + + Given I am logged in as "myself" + And I go to myself's pseuds page + + # Check that you can't edit your default pseud. + Then I should see "Default Pseud" + When I follow "Edit" + Then I should see "You cannot change the pseud that matches your user name." + And the "Make this name default" checkbox should be checked and disabled + + # Make a new default pseud called "Me." + When I follow "Back To Pseuds" + And I follow "New Pseud" + And I fill in "Name" with "Me" + And I check "Make this name default" + And I fill in "Description" with "Something's cute" + And I press "Create" + Then I should see "Pseud was successfully created." + And I should be on myself's "Me" pseud page + + # Make sure the new "Me" pseud is the default. + When I follow "Edit Pseud" + Then I should see "Me" + And the "Make this name default" checkbox should not be disabled + And the "Make this name default" checkbox should be checked + + # Make sure the old "myself" pseud is no longer the default. + When I follow "Back To Pseuds" + And I follow "edit_myself" + Then the "Make this name default" checkbox should not be checked + And the "Make this name default" checkbox should not be disabled + + # Edit "Me" to remove it as your default pseud. + When I follow "Back To Pseuds" + And I follow "Me" + Then I should be on myself's "Me" pseud page + When I follow "Edit Pseud" + And I uncheck "Make this name default" + And I press "Update" + Then I should see "Pseud was successfully updated." + And I should be on myself's "Me" pseud page + + # Make sure "Me" is no longer the default pseud, but "myself" is. + When I follow "Edit Pseud" + Then the "Make this name default" checkbox should not be checked + When I follow "Back To Pseuds" + And I follow "edit_myself" + Then the "Make this name default" checkbox should be checked and disabled + + # Test the pseud update path by making Me the default pseud once again. + When I follow "Back To Pseuds" + And I follow "Me" + And I follow "Edit Pseud" + And I check "Make this name default" + And I press "Update" + Then I should see "Pseud was successfully updated." + And I should be on myself's "Me" pseud page + When I follow "Edit Pseud" + Then the "Make this name default" checkbox should be checked + + Scenario: Manage pseuds - add, edit + + Given I am logged in as "editpseuds" + + # Check the Manage My Pseuds link in the profile works. + When I go to editpseuds's user page + And I follow "Profile" + And I follow "Manage My Pseuds" + Then I should see "Pseuds for editpseuds" + + # Make a new pseud. + When I follow "New Pseud" + And I fill in "Name" with "My new name" + And I fill in "Description" with "I wanted to add another name" + And I press "Create" + Then I should be on editpseuds's "My new name" pseud page + And I should see "Pseud was successfully created." + And I should see "My new name" + And I should see "You don't have anything posted under this name yet." + + # Check that all pseuds are listed on user's pseuds page. + When I follow "Back To Pseuds" + Then I should see "editpseuds (editpseuds)" + And I should see "My new name (editpseuds)" + And I should see "I wanted to add another name" + And I should see "Default Pseud" + + # Try to create another pseud with the same name you already used. + When I follow "New Pseud" + Then I should see "New pseud" + When I fill in "Name" with "My new name" + And I press "Create" + Then I should see "You already have a pseud with that name." + + # Recheck various links. + When I follow "Back To Pseuds" + And I follow "editpseuds" + And I follow "Profile" + And I follow "Manage My Pseuds" + Then I should see "Edit My new name" + + # Edit your new pseud's name and description. + When I follow "edit_my_new_name" + And I fill in "Description" with "I wanted to add another fancy name" + And I fill in "Name" with "My new fancy name" + And I press "Update" + Then I should see "Pseud was successfully updated." + And I should be on editpseuds's "My new fancy name" pseud page + + # Check that the changes to your pseud show up on your pseuds page. + When I follow "Back To Pseuds" + Then I should see "editpseuds (editpseuds)" + And I should see "My new fancy name (editpseuds)" + And I should see "I wanted to add another fancy name" + And I should not see "My new name (editpseuds)" + + Scenario: Bookmarks reflect pseud changes immediately + + Given the work "Interesting" + And I am logged in as "myself" + And I add the pseud "before" + And I bookmark the work "Interesting" as "before" + And I go to myself's bookmarks page + Then I should see "Bookmarked by before (myself)" + + When it is currently 1 second from now + And I change the pseud "before" to "after" + And I go to myself's bookmarks page + Then I should see "Bookmarked by after (myself)" + And I should not see "Bookmarked by before (myself)" + + Scenario: Pseud descriptions do not display images + + Given I am logged in as "myself" + And I go to my pseuds page + When I follow "Edit" + And I fill in "Description" with "Fantastic!" + And I press "Update" + Then I should see "Pseud was successfully updated." + When I follow "Back To Pseuds" + Then I should not see the image "src" text "http://example.com/icon.svg" + And I should see "Fantastic!" + + Scenario: Comments reflect pseud changes immediately + + Given the work "Interesting" + And I am logged in as "myself" + And I add the pseud "before" + When I set up the comment "Wow!" on the work "Interesting" + And I select "before" from "comment[pseud_id]" + And I press "Comment" + And I view the work "Interesting" with comments + Then I should see "before (myself)" within ".comment h4.byline" + + When it is currently 1 second from now + And I change the pseud "before" to "after" + And I view the work "Interesting" with comments + Then I should see "after (myself)" within ".comment h4.byline" + And I should not see "before (myself)" + + Scenario: Collections reflect pseud changes of the owner after the cache expires + + When I am logged in as "myself" + And I add the pseud "before" + And I set up the collection "My Collection Thing" + And I select "before" from "Owner pseud(s)" + And I unselect "myself" from "Owner pseud(s)" + And I press "Submit" + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + + When I change the pseud "before" to "after" + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + When the collection blurb cache has expired + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "after (myself)" within "#main" + And I should not see "before (myself)" within "#main" + + Scenario: Collections reflect pseud changes of moderators after the cache expires + + Given "myself" has the pseud "before" + When I have the collection "My Collection Thing" + And I am logged in as the owner of "My Collection Thing" + And I am on the "My Collection Thing" participants page + And I fill in "participants_to_invite" with "before (myself)" + And I press "Submit" + Then I should see "New members invited: before (myself)" + When I select "Moderator" from "myself_role" + And I submit with the 3rd button + Then I should see "Updated before." + When I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + + When I am logged in as "myself" + And I change the pseud "before" to "after" + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + When the collection blurb cache has expired + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "after (myself)" within "#main" + And I should not see "before (myself)" within "#main" + + Scenario: Many pseuds + + Given there are 3 pseuds per page + And "Zaphod" has the pseud "Slartibartfast" + And "Zaphod" has the pseud "Agrajag" + And "Zaphod" has the pseud "Betelgeuse" + And I am logged in as "Zaphod" + + When I view my profile + Then I should see "Zaphod" within "dl.meta" + And I should see "Agrajag" within "dl.meta" + And I should see "Betelgeuse" within "dl.meta" + And I should not see "Slartibartfast" within "dl.meta" + And I should see "1 more pseud" within "dl.meta" + + When I go to my user page + Then I should see "Zaphod" within "ul.expandable" + And I should see "Agrajag" within "ul.expandable" + And I should see "Betelgeuse" within "ul.expandable" + And I should not see "Slartibartfast" within "ul.expandable" + And I should see "All Pseuds (4)" within "ul.expandable" + + When I go to my "Slartibartfast" pseud page + Then I should see "Pseuds" within "li.pseud > a" + And I should see "Slartibartfast" within "ul.expandable" + + When I go to my pseuds page + Then I should not see "Zaphod (Zaphod)" within "ul.pseud.index" + But I should see "Agrajag (Zaphod)" within "ul.pseud.index" + And I should see "Betelgeuse (Zaphod)" within "ul.pseud.index" + And I should see "Slartibartfast (Zaphod)" within "ul.pseud.index" + And I should see "Next" within ".pagination" + When I follow "Next" within ".pagination" + Then I should see "Zaphod (Zaphod)" within "ul.pseud.index" + + When there are 10 pseuds per page + And I view my profile + Then I should see "Zaphod, Agrajag, Betelgeuse, and Slartibartfast" within "dl.meta" + + Scenario: Edit pseud updates series blurbs + + Given I am logged in as "Myself" + And I add the work "Great Work" to series "Best Series" as "Me2" + When I go to the dashboard page for user "Myself" with pseud "Me2" + And I follow "Series" + Then I should see "Best Series by Me2 (Myself)" + + When I go to my profile page + And I follow "Manage My Pseuds" + And I follow "Edit Me2" + And I fill in "Name" with "Me3" + And I press "Update" + Then I should see "Pseud was successfully updated." + + When I follow "Series" + Then I should see "Best Series by Me3 (Myself)" + + Scenario: Change details as an admin + + Given "someone" has the pseud "alt" + And I am logged in as a "policy_and_abuse" admin + And an abuse ticket ID exists + When I go to someone's pseuds page + And I follow "Edit alt" + And I fill in "Description" with "I'd probably be removing text." + And I fill in "Ticket ID" with "no 💜" + And I press "Update" + Then I should see "Ticket ID is not a number" + And the field labeled "Ticket ID" should contain "no 💜" + When I fill in "Ticket ID" with "47" + And I press "Update" + Then I should see "Pseud was successfully updated." + When I go to someone's pseuds page + Then I should see "I'd probably be removing text." + When I follow "Activities" within ".admin.primary.navigation" + Then I should see "Pseud alt (someone)" + When I follow "Pseud alt (someone)" + Then I should be on someone's pseuds page + When I visit the last activities item + Then I should see "Pseud alt (someone)" + And I should see "edit pseud" + And I should see a link "Ticket #47" + + # Skip logging admin activity if no change was actually made. + When I go to someone's pseuds page + And I follow "Edit alt" + And I fill in "Ticket ID" with "47" + And I press "Update" + Then I should see "Pseud was successfully updated." + When I go to the admin-activities page + Then I should see 1 admin activity log entry + + Scenario: Pseud descriptions do not display images + + Given I am logged in as "myself" + And I go to my pseuds page When I follow "Edit" - And I fill in "Description" with "Fantastic!" - And I press "Update" - Then I should see "Pseud was successfully updated." - When I follow "Back To Pseuds" - Then I should not see the image "src" text "http://example.com/icon.svg" - And I should see "Fantastic!" - -Scenario: Comments reflect pseud changes immediately - - Given the work "Interesting" - And I am logged in as "myself" - And I add the pseud "before" - When I set up the comment "Wow!" on the work "Interesting" - And I select "before" from "comment[pseud_id]" - And I press "Comment" - And I view the work "Interesting" with comments - Then I should see "before (myself)" within ".comment h4.byline" - - When it is currently 1 second from now - And I change the pseud "before" to "after" - And I view the work "Interesting" with comments - Then I should see "after (myself)" within ".comment h4.byline" - And I should not see "before (myself)" - -Scenario: Collections reflect pseud changes of the owner after the cache expires - - When I am logged in as "myself" - And I add the pseud "before" - And I set up the collection "My Collection Thing" - And I select "before" from "Owner pseud(s)" - And I unselect "myself" from "Owner pseud(s)" - And I press "Submit" - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - - When I change the pseud "before" to "after" - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - When the collection blurb cache has expired - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "after (myself)" within "#main" - And I should not see "before (myself)" within "#main" - -Scenario: Collections reflect pseud changes of moderators after the cache expires - - Given "myself" has the pseud "before" - When I have the collection "My Collection Thing" - And I am logged in as the owner of "My Collection Thing" - And I am on the "My Collection Thing" participants page - And I fill in "participants_to_invite" with "before (myself)" - And I press "Submit" - Then I should see "New members invited: before (myself)" - When I select "Moderator" from "myself_role" - And I submit with the 3rd button - Then I should see "Updated before." - When I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - - When I am logged in as "myself" - And I change the pseud "before" to "after" - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - When the collection blurb cache has expired - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "after (myself)" within "#main" - And I should not see "before (myself)" within "#main" - -Scenario: Many pseuds - - Given there are 3 pseuds per page - And "Zaphod" has the pseud "Slartibartfast" - And "Zaphod" has the pseud "Agrajag" - And "Zaphod" has the pseud "Betelgeuse" - And I am logged in as "Zaphod" - - When I view my profile - Then I should see "Zaphod" within "dl.meta" - And I should see "Agrajag" within "dl.meta" - And I should see "Betelgeuse" within "dl.meta" - And I should not see "Slartibartfast" within "dl.meta" - And I should see "1 more pseud" within "dl.meta" - - When I go to my user page - Then I should see "Zaphod" within "ul.expandable" - And I should see "Agrajag" within "ul.expandable" - And I should see "Betelgeuse" within "ul.expandable" - And I should not see "Slartibartfast" within "ul.expandable" - And I should see "All Pseuds (4)" within "ul.expandable" - - When I go to my "Slartibartfast" pseud page - Then I should see "Pseuds" within "li.pseud > a" - And I should see "Slartibartfast" within "ul.expandable" - - When I go to my pseuds page - Then I should not see "Zaphod (Zaphod)" within "ul.pseud.index" - But I should see "Agrajag (Zaphod)" within "ul.pseud.index" - And I should see "Betelgeuse (Zaphod)" within "ul.pseud.index" - And I should see "Slartibartfast (Zaphod)" within "ul.pseud.index" - And I should see "Next" within ".pagination" - When I follow "Next" within ".pagination" - Then I should see "Zaphod (Zaphod)" within "ul.pseud.index" - - When there are 10 pseuds per page - And I view my profile - Then I should see "Zaphod, Agrajag, Betelgeuse, and Slartibartfast" within "dl.meta" - -Scenario: Edit pseud updates series blurbs - - Given I am logged in as "Myself" - And I add the work "Great Work" to series "Best Series" as "Me2" - When I go to the dashboard page for user "Myself" with pseud "Me2" - And I follow "Series" - Then I should see "Best Series by Me2 (Myself)" - - When I go to my profile page - And I follow "Manage My Pseuds" - And I follow "Edit Me2" - And I fill in "Name" with "Me3" - And I press "Update" - Then I should see "Pseud was successfully updated." - - When I follow "Series" - Then I should see "Best Series by Me3 (Myself)" - -Scenario: Change details as an admin - - Given "someone" has the pseud "alt" - And I am logged in as a "policy_and_abuse" admin - And an abuse ticket ID exists - When I go to someone's pseuds page - And I follow "Edit alt" - And I fill in "Description" with "I'd probably be removing text." - And I fill in "Ticket ID" with "no 💜" - And I press "Update" - Then I should see "Ticket ID is not a number" - And the field labeled "Ticket ID" should contain "no 💜" - When I fill in "Ticket ID" with "47" - And I press "Update" - Then I should see "Pseud was successfully updated." - When I go to someone's pseuds page - Then I should see "I'd probably be removing text." - When I follow "Activities" within ".admin.primary.navigation" - Then I should see "Pseud alt (someone)" - When I follow "Pseud alt (someone)" - Then I should be on someone's pseuds page - When I visit the last activities item - Then I should see "Pseud alt (someone)" - And I should see "edit pseud" - And I should see a link "Ticket #47" - - # Skip logging admin activity if no change was actually made. - When I go to someone's pseuds page - And I follow "Edit alt" - And I fill in "Ticket ID" with "47" - And I press "Update" - Then I should see "Pseud was successfully updated." - When I go to the admin-activities page - Then I should see 1 admin activity log entry + And I fill in "Description" with "Fantastic!" + And I press "Update" + Then I should see "Pseud was successfully updated." + When I follow "Back To Pseuds" + Then I should not see the image "src" text "http://example.com/icon.svg" + And I should see "Fantastic!" + + Scenario: Comments reflect pseud changes immediately + + Given the work "Interesting" + And I am logged in as "myself" + And I add the pseud "before" + When I set up the comment "Wow!" on the work "Interesting" + And I select "before" from "comment[pseud_id]" + And I press "Comment" + And I view the work "Interesting" with comments + Then I should see "before (myself)" within ".comment h4.byline" + + When it is currently 1 second from now + And I change the pseud "before" to "after" + And I view the work "Interesting" with comments + Then I should see "after (myself)" within ".comment h4.byline" + And I should not see "before (myself)" + + Scenario: Collections reflect pseud changes of the owner after the cache expires + + When I am logged in as "myself" + And I add the pseud "before" + And I set up the collection "My Collection Thing" + And I select "before" from "Owner pseud(s)" + And I unselect "myself" from "Owner pseud(s)" + And I press "Submit" + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + + When I change the pseud "before" to "after" + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + When the collection blurb cache has expired + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "after (myself)" within "#main" + And I should not see "before (myself)" within "#main" + + Scenario: Collections reflect pseud changes of moderators after the cache expires + + Given "myself" has the pseud "before" + When I have the collection "My Collection Thing" + And I am logged in as the owner of "My Collection Thing" + And I am on the "My Collection Thing" participants page + And I fill in "participants_to_invite" with "before (myself)" + And I press "Submit" + Then I should see "New members invited: before (myself)" + When I select "Moderator" from "myself_role" + And I submit with the 3rd button + Then I should see "Updated before." + When I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + + When I am logged in as "myself" + And I change the pseud "before" to "after" + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + When the collection blurb cache has expired + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "after (myself)" within "#main" + And I should not see "before (myself)" within "#main" + + Scenario: Many pseuds + + Given there are 3 pseuds per page + And "Zaphod" has the pseud "Slartibartfast" + And "Zaphod" has the pseud "Agrajag" + And "Zaphod" has the pseud "Betelgeuse" + And I am logged in as "Zaphod" + + When I view my profile + Then I should see "Zaphod" within "dl.meta" + And I should see "Agrajag" within "dl.meta" + And I should see "Betelgeuse" within "dl.meta" + And I should not see "Slartibartfast" within "dl.meta" + And I should see "1 more pseud" within "dl.meta" + + When I go to my user page + Then I should see "Zaphod" within "ul.expandable" + And I should see "Agrajag" within "ul.expandable" + And I should see "Betelgeuse" within "ul.expandable" + And I should not see "Slartibartfast" within "ul.expandable" + And I should see "All Pseuds (4)" within "ul.expandable" + + When I go to my "Slartibartfast" pseud page + Then I should see "Pseuds" within "li.pseud > a" + And I should see "Slartibartfast" within "ul.expandable" + + When I go to my pseuds page + Then I should not see "Zaphod (Zaphod)" within "ul.pseud.index" + But I should see "Agrajag (Zaphod)" within "ul.pseud.index" + And I should see "Betelgeuse (Zaphod)" within "ul.pseud.index" + And I should see "Slartibartfast (Zaphod)" within "ul.pseud.index" + And I should see "Next" within ".pagination" + When I follow "Next" within ".pagination" + Then I should see "Zaphod (Zaphod)" within "ul.pseud.index" + + When there are 10 pseuds per page + And I view my profile + Then I should see "Zaphod, Agrajag, Betelgeuse, and Slartibartfast" within "dl.meta" + + Scenario: Edit pseud updates series blurbs + + Given I am logged in as "Myself" + And I add the work "Great Work" to series "Best Series" as "Me2" + When I go to the dashboard page for user "Myself" with pseud "Me2" + And I follow "Series" + Then I should see "Best Series by Me2 (Myself)" + + When I go to my profile page + And I follow "Manage My Pseuds" + And I follow "Edit Me2" + And I fill in "Name" with "Me3" + And I press "Update" + Then I should see "Pseud was successfully updated." + + When I follow "Series" + Then I should see "Best Series by Me3 (Myself)" + + Scenario: Change details as an admin + + Given "someone" has the pseud "alt" + And I am logged in as a "policy_and_abuse" admin + And an abuse ticket ID exists + When I go to someone's pseuds page + And I follow "Edit alt" + And I fill in "Description" with "I'd probably be removing text." + And I fill in "Ticket ID" with "no 💜" + And I press "Update" + Then I should see "Ticket ID is not a number" + And the field labeled "Ticket ID" should contain "no 💜" + When I fill in "Ticket ID" with "47" + And I press "Update" + Then I should see "Pseud was successfully updated." + When I go to someone's pseuds page + Then I should see "I'd probably be removing text." + When I follow "Activities" within ".admin.primary.navigation" + Then I should see "Pseud alt (someone)" + When I follow "Pseud alt (someone)" + Then I should be on someone's pseuds page + When I visit the last activities item + Then I should see "Pseud alt (someone)" + And I should see "edit pseud" + And I should see a link "Ticket #47" + + # Skip logging admin activity if no change was actually made. + When I go to someone's pseuds page + And I follow "Edit alt" + And I fill in "Ticket ID" with "47" + And I press "Update" + Then I should see "Pseud was successfully updated." + When I go to the admin-activities page + Then I should see 1 admin activity log entry + + Scenario: Bookmarks reflect pseud changes immediately + + Given the work "Interesting" + And I am logged in as "myself" + And I add the pseud "before" + And I bookmark the work "Interesting" as "before" + And I go to myself's bookmarks page + Then I should see "Bookmarked by before (myself)" + + When it is currently 1 second from now + And I change the pseud "before" to "after" + And I go to myself's bookmarks page + Then I should see "Bookmarked by after (myself)" + And I should not see "Bookmarked by before (myself)" \ No newline at end of file diff --git a/features/users/user_rename.feature b/features/users/user_rename.feature index 1d36b9e4543..899b9a7b561 100644 --- a/features/users/user_rename.feature +++ b/features/users/user_rename.feature @@ -7,7 +7,7 @@ Feature: Scenario: The user should not be able to change username without a password Given I am logged in as "testuser" with password "password" When I visit the change username page for testuser - And I fill in "New user name" with "anothertestuser" + And I fill in "New user name" with "anothertestuser" And I press "Change User Name" # TODO - better written error message Then I should see "Your password was incorrect" @@ -30,7 +30,7 @@ Feature: And I fill in "New user name" with "otheruser" And I fill in "Password" with "password" When I press "Change" - Then I should see "User name has already been taken" + Then I should see "User name has already been taken" Scenario: The user should not be able to change their username to another user's name even if the capitalization is different Given I have no users @@ -72,7 +72,7 @@ Feature: Then I should get confirmation that I changed my username And I should see "Hi, newusername" When I go to my pseuds page - Then I should not see "oldusername" + Then I should not see "oldusername" When I follow "Edit" Then I should see "You cannot change the pseud that matches your user name" Then the "pseud_is_default" checkbox should be checked and disabled @@ -87,7 +87,7 @@ Feature: Then I should get confirmation that I changed my username And I should see "Hi, Uppercrust" When I go to my pseuds page - Then I should not see "uppercrust" + Then I should not see "uppercrust" When I follow "Edit" Then I should see "You cannot change the pseud that matches your user name" Then the "pseud_is_default" checkbox should be checked and disabled @@ -95,8 +95,8 @@ Feature: Scenario: Changing my user name with two pseuds, one same as new, doesn't change old Given I have no users And the following activated user exists - | login | password | id | - | oldusername | secret | 1 | + | login | password | id | + | oldusername | secret | 1 | And a pseud exists with name: "newusername", user_id: 1 And I am logged in as "oldusername" with password "secret" When I visit the change username page for oldusername @@ -106,7 +106,7 @@ Feature: Then I should get confirmation that I changed my username And I should see "Hi, newusername" When I follow "Pseuds (2)" - Then I should see "Edit oldusername" + Then I should see "Edit oldusername" And I should see "Edit newusername" Scenario: Changing username updates search results (bug AO3-3468) @@ -198,16 +198,33 @@ Feature: When I follow "Series" Then I should see "Best Series by newusername" - Scenario: Changing the username from a forbidden name to non-forbidden - Given I have no users - And the following activated user exists - | login | password | - | forbidden | secret | - And the user name "forbidden" is on the forbidden list - When I am logged in as "forbidden" with password "secret" - And I visit the change username page for forbidden - And I fill in "New user name" with "notforbidden" - And I fill in "Password" with "secret" - And I press "Change User Name" - Then I should get confirmation that I changed my username - And I should see "Hi, notforbidden" + Scenario: Changing the username from a forbidden name to non-forbidden + Given I have no users + And the following activated user exists + | login | password | + | forbidden | secret | + And the user name "forbidden" is on the forbidden list + When I am logged in as "forbidden" with password "secret" + And I visit the change username page for forbidden + And I fill in "New user name" with "notforbidden" + And I fill in "Password" with "secret" + And I press "Change User Name" + Then I should get confirmation that I changed my username + And I should see "Hi, notforbidden" + + Scenario: Bookmarker's bookmark blurbs reflect username changes immediately + Given the work "Interesting" + And I am logged in as "before" with password "password" + And I add the pseud "mine" + And I bookmark the work "Interesting" as "mine" + And I go to before's bookmarks page + Then I should see "Bookmarked by mine (before)" + + When it is currently 1 second from now + And I visit the change username page for before + And I fill in "New user name" with "after" + And I fill in "Password" with "password" + And I press "Change User Name" + And I go to after's bookmarks page + Then I should see "Bookmarked by mine (after)" + And I should not see "Bookmarked by mine (before)" \ No newline at end of file diff --git a/spec/models/pseud_spec.rb b/spec/models/pseud_spec.rb index e18cb964426..dfe0a53e95d 100644 --- a/spec/models/pseud_spec.rb +++ b/spec/models/pseud_spec.rb @@ -52,6 +52,18 @@ end end + describe "changing pseud name" do + let(:pseud) { create(:pseud) } + let!(:bookmark) { create(:bookmark, pseud: pseud) } + + it "modifies the updated_at of associated bookmarks" do + travel(1.second) + expect do + pseud.update(name: "New Name") + end.to change { bookmark.reload.updated_at } + end + end + describe "touch_comments" do let(:pseud) { create(:pseud) } let!(:comment) { create(:comment, pseud: pseud) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 5296fc01611..901093ea182 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -294,6 +294,19 @@ end end + describe "changing login name" do + let(:user) { build(:user) } + let(:pseud) { create(:pseud, user: user) } + let!(:bookmark) { create(:bookmark, pseud: pseud) } + + it "modifies the updated_at of associated bookmarks" do + travel(1.second) + expect do + user.update(login: "New") + end.to change { bookmark.reload.updated_at } + end + end + describe ".search_multiple_by_email" do let(:user_bundle) { create_list(:user, 5) } From 4048cb67ed8a42549d4d73eebae1219381d1e29a Mon Sep 17 00:00:00 2001 From: irrationalpie7 Date: Thu, 28 Mar 2024 18:54:23 -0700 Subject: [PATCH 2/7] AO3-5053 revert test file formatting --- features/other_a/pseuds.feature | 786 +++++++++++------------------ features/users/user_rename.feature | 40 +- 2 files changed, 321 insertions(+), 505 deletions(-) diff --git a/features/other_a/pseuds.feature b/features/other_a/pseuds.feature index b8551fadd9d..dc8377ec16c 100644 --- a/features/other_a/pseuds.feature +++ b/features/other_a/pseuds.feature @@ -1,489 +1,305 @@ @users Feature: Pseuds - Scenario: pseud creation and playing with the default pseud - - Given I am logged in as "myself" - And I go to myself's pseuds page - - # Check that you can't edit your default pseud. - Then I should see "Default Pseud" - When I follow "Edit" - Then I should see "You cannot change the pseud that matches your user name." - And the "Make this name default" checkbox should be checked and disabled - - # Make a new default pseud called "Me." - When I follow "Back To Pseuds" - And I follow "New Pseud" - And I fill in "Name" with "Me" - And I check "Make this name default" - And I fill in "Description" with "Something's cute" - And I press "Create" - Then I should see "Pseud was successfully created." - And I should be on myself's "Me" pseud page - - # Make sure the new "Me" pseud is the default. - When I follow "Edit Pseud" - Then I should see "Me" - And the "Make this name default" checkbox should not be disabled - And the "Make this name default" checkbox should be checked - - # Make sure the old "myself" pseud is no longer the default. - When I follow "Back To Pseuds" - And I follow "edit_myself" - Then the "Make this name default" checkbox should not be checked - And the "Make this name default" checkbox should not be disabled - - # Edit "Me" to remove it as your default pseud. - When I follow "Back To Pseuds" - And I follow "Me" - Then I should be on myself's "Me" pseud page - When I follow "Edit Pseud" - And I uncheck "Make this name default" - And I press "Update" - Then I should see "Pseud was successfully updated." - And I should be on myself's "Me" pseud page - - # Make sure "Me" is no longer the default pseud, but "myself" is. - When I follow "Edit Pseud" - Then the "Make this name default" checkbox should not be checked - When I follow "Back To Pseuds" - And I follow "edit_myself" - Then the "Make this name default" checkbox should be checked and disabled - - # Test the pseud update path by making Me the default pseud once again. - When I follow "Back To Pseuds" - And I follow "Me" - And I follow "Edit Pseud" - And I check "Make this name default" - And I press "Update" - Then I should see "Pseud was successfully updated." - And I should be on myself's "Me" pseud page - When I follow "Edit Pseud" - Then the "Make this name default" checkbox should be checked - - Scenario: Manage pseuds - add, edit - - Given I am logged in as "editpseuds" - - # Check the Manage My Pseuds link in the profile works. - When I go to editpseuds's user page - And I follow "Profile" - And I follow "Manage My Pseuds" - Then I should see "Pseuds for editpseuds" - - # Make a new pseud. - When I follow "New Pseud" - And I fill in "Name" with "My new name" - And I fill in "Description" with "I wanted to add another name" - And I press "Create" - Then I should be on editpseuds's "My new name" pseud page - And I should see "Pseud was successfully created." - And I should see "My new name" - And I should see "You don't have anything posted under this name yet." - - # Check that all pseuds are listed on user's pseuds page. - When I follow "Back To Pseuds" - Then I should see "editpseuds (editpseuds)" - And I should see "My new name (editpseuds)" - And I should see "I wanted to add another name" - And I should see "Default Pseud" - - # Try to create another pseud with the same name you already used. - When I follow "New Pseud" - Then I should see "New pseud" - When I fill in "Name" with "My new name" - And I press "Create" - Then I should see "You already have a pseud with that name." - - # Recheck various links. - When I follow "Back To Pseuds" - And I follow "editpseuds" - And I follow "Profile" - And I follow "Manage My Pseuds" - Then I should see "Edit My new name" - - # Edit your new pseud's name and description. - When I follow "edit_my_new_name" - And I fill in "Description" with "I wanted to add another fancy name" - And I fill in "Name" with "My new fancy name" - And I press "Update" - Then I should see "Pseud was successfully updated." - And I should be on editpseuds's "My new fancy name" pseud page - - # Check that the changes to your pseud show up on your pseuds page. - When I follow "Back To Pseuds" - Then I should see "editpseuds (editpseuds)" - And I should see "My new fancy name (editpseuds)" - And I should see "I wanted to add another fancy name" - And I should not see "My new name (editpseuds)" - - Scenario: Bookmarks reflect pseud changes immediately - - Given the work "Interesting" - And I am logged in as "myself" - And I add the pseud "before" - And I bookmark the work "Interesting" as "before" - And I go to myself's bookmarks page - Then I should see "Bookmarked by before (myself)" - - When it is currently 1 second from now - And I change the pseud "before" to "after" - And I go to myself's bookmarks page - Then I should see "Bookmarked by after (myself)" - And I should not see "Bookmarked by before (myself)" - - Scenario: Pseud descriptions do not display images - - Given I am logged in as "myself" - And I go to my pseuds page - When I follow "Edit" - And I fill in "Description" with "Fantastic!" - And I press "Update" - Then I should see "Pseud was successfully updated." - When I follow "Back To Pseuds" - Then I should not see the image "src" text "http://example.com/icon.svg" - And I should see "Fantastic!" - - Scenario: Comments reflect pseud changes immediately - - Given the work "Interesting" - And I am logged in as "myself" - And I add the pseud "before" - When I set up the comment "Wow!" on the work "Interesting" - And I select "before" from "comment[pseud_id]" - And I press "Comment" - And I view the work "Interesting" with comments - Then I should see "before (myself)" within ".comment h4.byline" - - When it is currently 1 second from now - And I change the pseud "before" to "after" - And I view the work "Interesting" with comments - Then I should see "after (myself)" within ".comment h4.byline" - And I should not see "before (myself)" - - Scenario: Collections reflect pseud changes of the owner after the cache expires - - When I am logged in as "myself" - And I add the pseud "before" - And I set up the collection "My Collection Thing" - And I select "before" from "Owner pseud(s)" - And I unselect "myself" from "Owner pseud(s)" - And I press "Submit" - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - - When I change the pseud "before" to "after" - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - When the collection blurb cache has expired - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "after (myself)" within "#main" - And I should not see "before (myself)" within "#main" - - Scenario: Collections reflect pseud changes of moderators after the cache expires - - Given "myself" has the pseud "before" - When I have the collection "My Collection Thing" - And I am logged in as the owner of "My Collection Thing" - And I am on the "My Collection Thing" participants page - And I fill in "participants_to_invite" with "before (myself)" - And I press "Submit" - Then I should see "New members invited: before (myself)" - When I select "Moderator" from "myself_role" - And I submit with the 3rd button - Then I should see "Updated before." - When I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - - When I am logged in as "myself" - And I change the pseud "before" to "after" - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - When the collection blurb cache has expired - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "after (myself)" within "#main" - And I should not see "before (myself)" within "#main" - - Scenario: Many pseuds - - Given there are 3 pseuds per page - And "Zaphod" has the pseud "Slartibartfast" - And "Zaphod" has the pseud "Agrajag" - And "Zaphod" has the pseud "Betelgeuse" - And I am logged in as "Zaphod" - - When I view my profile - Then I should see "Zaphod" within "dl.meta" - And I should see "Agrajag" within "dl.meta" - And I should see "Betelgeuse" within "dl.meta" - And I should not see "Slartibartfast" within "dl.meta" - And I should see "1 more pseud" within "dl.meta" - - When I go to my user page - Then I should see "Zaphod" within "ul.expandable" - And I should see "Agrajag" within "ul.expandable" - And I should see "Betelgeuse" within "ul.expandable" - And I should not see "Slartibartfast" within "ul.expandable" - And I should see "All Pseuds (4)" within "ul.expandable" - - When I go to my "Slartibartfast" pseud page - Then I should see "Pseuds" within "li.pseud > a" - And I should see "Slartibartfast" within "ul.expandable" - - When I go to my pseuds page - Then I should not see "Zaphod (Zaphod)" within "ul.pseud.index" - But I should see "Agrajag (Zaphod)" within "ul.pseud.index" - And I should see "Betelgeuse (Zaphod)" within "ul.pseud.index" - And I should see "Slartibartfast (Zaphod)" within "ul.pseud.index" - And I should see "Next" within ".pagination" - When I follow "Next" within ".pagination" - Then I should see "Zaphod (Zaphod)" within "ul.pseud.index" - - When there are 10 pseuds per page - And I view my profile - Then I should see "Zaphod, Agrajag, Betelgeuse, and Slartibartfast" within "dl.meta" - - Scenario: Edit pseud updates series blurbs - - Given I am logged in as "Myself" - And I add the work "Great Work" to series "Best Series" as "Me2" - When I go to the dashboard page for user "Myself" with pseud "Me2" - And I follow "Series" - Then I should see "Best Series by Me2 (Myself)" - - When I go to my profile page - And I follow "Manage My Pseuds" - And I follow "Edit Me2" - And I fill in "Name" with "Me3" - And I press "Update" - Then I should see "Pseud was successfully updated." - - When I follow "Series" - Then I should see "Best Series by Me3 (Myself)" - - Scenario: Change details as an admin - - Given "someone" has the pseud "alt" - And I am logged in as a "policy_and_abuse" admin - And an abuse ticket ID exists - When I go to someone's pseuds page - And I follow "Edit alt" - And I fill in "Description" with "I'd probably be removing text." - And I fill in "Ticket ID" with "no 💜" - And I press "Update" - Then I should see "Ticket ID is not a number" - And the field labeled "Ticket ID" should contain "no 💜" - When I fill in "Ticket ID" with "47" - And I press "Update" - Then I should see "Pseud was successfully updated." - When I go to someone's pseuds page - Then I should see "I'd probably be removing text." - When I follow "Activities" within ".admin.primary.navigation" - Then I should see "Pseud alt (someone)" - When I follow "Pseud alt (someone)" - Then I should be on someone's pseuds page - When I visit the last activities item - Then I should see "Pseud alt (someone)" - And I should see "edit pseud" - And I should see a link "Ticket #47" - - # Skip logging admin activity if no change was actually made. - When I go to someone's pseuds page - And I follow "Edit alt" - And I fill in "Ticket ID" with "47" - And I press "Update" - Then I should see "Pseud was successfully updated." - When I go to the admin-activities page - Then I should see 1 admin activity log entry - - Scenario: Pseud descriptions do not display images - - Given I am logged in as "myself" - And I go to my pseuds page +Scenario: pseud creation and playing with the default pseud + + Given I am logged in as "myself" + And I go to myself's pseuds page + + # Check that you can't edit your default pseud. + Then I should see "Default Pseud" + When I follow "Edit" + Then I should see "You cannot change the pseud that matches your user name." + And the "Make this name default" checkbox should be checked and disabled + + # Make a new default pseud called "Me." + When I follow "Back To Pseuds" + And I follow "New Pseud" + And I fill in "Name" with "Me" + And I check "Make this name default" + And I fill in "Description" with "Something's cute" + And I press "Create" + Then I should see "Pseud was successfully created." + And I should be on myself's "Me" pseud page + + # Make sure the new "Me" pseud is the default. + When I follow "Edit Pseud" + Then I should see "Me" + And the "Make this name default" checkbox should not be disabled + And the "Make this name default" checkbox should be checked + + # Make sure the old "myself" pseud is no longer the default. + When I follow "Back To Pseuds" + And I follow "edit_myself" + Then the "Make this name default" checkbox should not be checked + And the "Make this name default" checkbox should not be disabled + + # Edit "Me" to remove it as your default pseud. + When I follow "Back To Pseuds" + And I follow "Me" + Then I should be on myself's "Me" pseud page + When I follow "Edit Pseud" + And I uncheck "Make this name default" + And I press "Update" + Then I should see "Pseud was successfully updated." + And I should be on myself's "Me" pseud page + + # Make sure "Me" is no longer the default pseud, but "myself" is. + When I follow "Edit Pseud" + Then the "Make this name default" checkbox should not be checked + When I follow "Back To Pseuds" + And I follow "edit_myself" + Then the "Make this name default" checkbox should be checked and disabled + + # Test the pseud update path by making Me the default pseud once again. + When I follow "Back To Pseuds" + And I follow "Me" + And I follow "Edit Pseud" + And I check "Make this name default" + And I press "Update" + Then I should see "Pseud was successfully updated." + And I should be on myself's "Me" pseud page + When I follow "Edit Pseud" + Then the "Make this name default" checkbox should be checked + +Scenario: Manage pseuds - add, edit + + Given I am logged in as "editpseuds" + + # Check the Manage My Pseuds link in the profile works. + When I go to editpseuds's user page + And I follow "Profile" + And I follow "Manage My Pseuds" + Then I should see "Pseuds for editpseuds" + + # Make a new pseud. + When I follow "New Pseud" + And I fill in "Name" with "My new name" + And I fill in "Description" with "I wanted to add another name" + And I press "Create" + Then I should be on editpseuds's "My new name" pseud page + And I should see "Pseud was successfully created." + And I should see "My new name" + And I should see "You don't have anything posted under this name yet." + + # Check that all pseuds are listed on user's pseuds page. + When I follow "Back To Pseuds" + Then I should see "editpseuds (editpseuds)" + And I should see "My new name (editpseuds)" + And I should see "I wanted to add another name" + And I should see "Default Pseud" + + # Try to create another pseud with the same name you already used. + When I follow "New Pseud" + Then I should see "New pseud" + When I fill in "Name" with "My new name" + And I press "Create" + Then I should see "You already have a pseud with that name." + + # Recheck various links. + When I follow "Back To Pseuds" + And I follow "editpseuds" + And I follow "Profile" + And I follow "Manage My Pseuds" + Then I should see "Edit My new name" + + # Edit your new pseud's name and description. + When I follow "edit_my_new_name" + And I fill in "Description" with "I wanted to add another fancy name" + And I fill in "Name" with "My new fancy name" + And I press "Update" + Then I should see "Pseud was successfully updated." + And I should be on editpseuds's "My new fancy name" pseud page + + # Check that the changes to your pseud show up on your pseuds page. + When I follow "Back To Pseuds" + Then I should see "editpseuds (editpseuds)" + And I should see "My new fancy name (editpseuds)" + And I should see "I wanted to add another fancy name" + And I should not see "My new name (editpseuds)" + +Scenario: Pseud descriptions do not display images + + Given I am logged in as "myself" + And I go to my pseuds page When I follow "Edit" - And I fill in "Description" with "Fantastic!" - And I press "Update" - Then I should see "Pseud was successfully updated." - When I follow "Back To Pseuds" - Then I should not see the image "src" text "http://example.com/icon.svg" - And I should see "Fantastic!" - - Scenario: Comments reflect pseud changes immediately - - Given the work "Interesting" - And I am logged in as "myself" - And I add the pseud "before" - When I set up the comment "Wow!" on the work "Interesting" - And I select "before" from "comment[pseud_id]" - And I press "Comment" - And I view the work "Interesting" with comments - Then I should see "before (myself)" within ".comment h4.byline" - - When it is currently 1 second from now - And I change the pseud "before" to "after" - And I view the work "Interesting" with comments - Then I should see "after (myself)" within ".comment h4.byline" - And I should not see "before (myself)" - - Scenario: Collections reflect pseud changes of the owner after the cache expires - - When I am logged in as "myself" - And I add the pseud "before" - And I set up the collection "My Collection Thing" - And I select "before" from "Owner pseud(s)" - And I unselect "myself" from "Owner pseud(s)" - And I press "Submit" - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - - When I change the pseud "before" to "after" - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - When the collection blurb cache has expired - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "after (myself)" within "#main" - And I should not see "before (myself)" within "#main" - - Scenario: Collections reflect pseud changes of moderators after the cache expires - - Given "myself" has the pseud "before" - When I have the collection "My Collection Thing" - And I am logged in as the owner of "My Collection Thing" - And I am on the "My Collection Thing" participants page - And I fill in "participants_to_invite" with "before (myself)" - And I press "Submit" - Then I should see "New members invited: before (myself)" - When I select "Moderator" from "myself_role" - And I submit with the 3rd button - Then I should see "Updated before." - When I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - - When I am logged in as "myself" - And I change the pseud "before" to "after" - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "before (myself)" within "#main" - When the collection blurb cache has expired - And I go to the collections page - Then I should see "My Collection Thing" - And I should see "after (myself)" within "#main" - And I should not see "before (myself)" within "#main" - - Scenario: Many pseuds - - Given there are 3 pseuds per page - And "Zaphod" has the pseud "Slartibartfast" - And "Zaphod" has the pseud "Agrajag" - And "Zaphod" has the pseud "Betelgeuse" - And I am logged in as "Zaphod" - - When I view my profile - Then I should see "Zaphod" within "dl.meta" - And I should see "Agrajag" within "dl.meta" - And I should see "Betelgeuse" within "dl.meta" - And I should not see "Slartibartfast" within "dl.meta" - And I should see "1 more pseud" within "dl.meta" - - When I go to my user page - Then I should see "Zaphod" within "ul.expandable" - And I should see "Agrajag" within "ul.expandable" - And I should see "Betelgeuse" within "ul.expandable" - And I should not see "Slartibartfast" within "ul.expandable" - And I should see "All Pseuds (4)" within "ul.expandable" - - When I go to my "Slartibartfast" pseud page - Then I should see "Pseuds" within "li.pseud > a" - And I should see "Slartibartfast" within "ul.expandable" - - When I go to my pseuds page - Then I should not see "Zaphod (Zaphod)" within "ul.pseud.index" - But I should see "Agrajag (Zaphod)" within "ul.pseud.index" - And I should see "Betelgeuse (Zaphod)" within "ul.pseud.index" - And I should see "Slartibartfast (Zaphod)" within "ul.pseud.index" - And I should see "Next" within ".pagination" - When I follow "Next" within ".pagination" - Then I should see "Zaphod (Zaphod)" within "ul.pseud.index" - - When there are 10 pseuds per page - And I view my profile - Then I should see "Zaphod, Agrajag, Betelgeuse, and Slartibartfast" within "dl.meta" - - Scenario: Edit pseud updates series blurbs - - Given I am logged in as "Myself" - And I add the work "Great Work" to series "Best Series" as "Me2" - When I go to the dashboard page for user "Myself" with pseud "Me2" - And I follow "Series" - Then I should see "Best Series by Me2 (Myself)" - - When I go to my profile page - And I follow "Manage My Pseuds" - And I follow "Edit Me2" - And I fill in "Name" with "Me3" - And I press "Update" - Then I should see "Pseud was successfully updated." - - When I follow "Series" - Then I should see "Best Series by Me3 (Myself)" - - Scenario: Change details as an admin - - Given "someone" has the pseud "alt" - And I am logged in as a "policy_and_abuse" admin - And an abuse ticket ID exists - When I go to someone's pseuds page - And I follow "Edit alt" - And I fill in "Description" with "I'd probably be removing text." - And I fill in "Ticket ID" with "no 💜" - And I press "Update" - Then I should see "Ticket ID is not a number" - And the field labeled "Ticket ID" should contain "no 💜" - When I fill in "Ticket ID" with "47" - And I press "Update" - Then I should see "Pseud was successfully updated." - When I go to someone's pseuds page - Then I should see "I'd probably be removing text." - When I follow "Activities" within ".admin.primary.navigation" - Then I should see "Pseud alt (someone)" - When I follow "Pseud alt (someone)" - Then I should be on someone's pseuds page - When I visit the last activities item - Then I should see "Pseud alt (someone)" - And I should see "edit pseud" - And I should see a link "Ticket #47" - - # Skip logging admin activity if no change was actually made. - When I go to someone's pseuds page - And I follow "Edit alt" - And I fill in "Ticket ID" with "47" - And I press "Update" - Then I should see "Pseud was successfully updated." - When I go to the admin-activities page - Then I should see 1 admin activity log entry - - Scenario: Bookmarks reflect pseud changes immediately - - Given the work "Interesting" - And I am logged in as "myself" - And I add the pseud "before" - And I bookmark the work "Interesting" as "before" - And I go to myself's bookmarks page - Then I should see "Bookmarked by before (myself)" - - When it is currently 1 second from now - And I change the pseud "before" to "after" - And I go to myself's bookmarks page - Then I should see "Bookmarked by after (myself)" - And I should not see "Bookmarked by before (myself)" \ No newline at end of file + And I fill in "Description" with "Fantastic!" + And I press "Update" + Then I should see "Pseud was successfully updated." + When I follow "Back To Pseuds" + Then I should not see the image "src" text "http://example.com/icon.svg" + And I should see "Fantastic!" + +Scenario: Comments reflect pseud changes immediately + + Given the work "Interesting" + And I am logged in as "myself" + And I add the pseud "before" + When I set up the comment "Wow!" on the work "Interesting" + And I select "before" from "comment[pseud_id]" + And I press "Comment" + And I view the work "Interesting" with comments + Then I should see "before (myself)" within ".comment h4.byline" + + When it is currently 1 second from now + And I change the pseud "before" to "after" + And I view the work "Interesting" with comments + Then I should see "after (myself)" within ".comment h4.byline" + And I should not see "before (myself)" + +Scenario: Collections reflect pseud changes of the owner after the cache expires + + When I am logged in as "myself" + And I add the pseud "before" + And I set up the collection "My Collection Thing" + And I select "before" from "Owner pseud(s)" + And I unselect "myself" from "Owner pseud(s)" + And I press "Submit" + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + + When I change the pseud "before" to "after" + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + When the collection blurb cache has expired + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "after (myself)" within "#main" + And I should not see "before (myself)" within "#main" + +Scenario: Collections reflect pseud changes of moderators after the cache expires + + Given "myself" has the pseud "before" + When I have the collection "My Collection Thing" + And I am logged in as the owner of "My Collection Thing" + And I am on the "My Collection Thing" participants page + And I fill in "participants_to_invite" with "before (myself)" + And I press "Submit" + Then I should see "New members invited: before (myself)" + When I select "Moderator" from "myself_role" + And I submit with the 3rd button + Then I should see "Updated before." + When I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + + When I am logged in as "myself" + And I change the pseud "before" to "after" + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "before (myself)" within "#main" + When the collection blurb cache has expired + And I go to the collections page + Then I should see "My Collection Thing" + And I should see "after (myself)" within "#main" + And I should not see "before (myself)" within "#main" + +Scenario: Many pseuds + + Given there are 3 pseuds per page + And "Zaphod" has the pseud "Slartibartfast" + And "Zaphod" has the pseud "Agrajag" + And "Zaphod" has the pseud "Betelgeuse" + And I am logged in as "Zaphod" + + When I view my profile + Then I should see "Zaphod" within "dl.meta" + And I should see "Agrajag" within "dl.meta" + And I should see "Betelgeuse" within "dl.meta" + And I should not see "Slartibartfast" within "dl.meta" + And I should see "1 more pseud" within "dl.meta" + + When I go to my user page + Then I should see "Zaphod" within "ul.expandable" + And I should see "Agrajag" within "ul.expandable" + And I should see "Betelgeuse" within "ul.expandable" + And I should not see "Slartibartfast" within "ul.expandable" + And I should see "All Pseuds (4)" within "ul.expandable" + + When I go to my "Slartibartfast" pseud page + Then I should see "Pseuds" within "li.pseud > a" + And I should see "Slartibartfast" within "ul.expandable" + + When I go to my pseuds page + Then I should not see "Zaphod (Zaphod)" within "ul.pseud.index" + But I should see "Agrajag (Zaphod)" within "ul.pseud.index" + And I should see "Betelgeuse (Zaphod)" within "ul.pseud.index" + And I should see "Slartibartfast (Zaphod)" within "ul.pseud.index" + And I should see "Next" within ".pagination" + When I follow "Next" within ".pagination" + Then I should see "Zaphod (Zaphod)" within "ul.pseud.index" + + When there are 10 pseuds per page + And I view my profile + Then I should see "Zaphod, Agrajag, Betelgeuse, and Slartibartfast" within "dl.meta" + +Scenario: Edit pseud updates series blurbs + + Given I am logged in as "Myself" + And I add the work "Great Work" to series "Best Series" as "Me2" + When I go to the dashboard page for user "Myself" with pseud "Me2" + And I follow "Series" + Then I should see "Best Series by Me2 (Myself)" + + When I go to my profile page + And I follow "Manage My Pseuds" + And I follow "Edit Me2" + And I fill in "Name" with "Me3" + And I press "Update" + Then I should see "Pseud was successfully updated." + + When I follow "Series" + Then I should see "Best Series by Me3 (Myself)" + +Scenario: Change details as an admin + + Given "someone" has the pseud "alt" + And I am logged in as a "policy_and_abuse" admin + And an abuse ticket ID exists + When I go to someone's pseuds page + And I follow "Edit alt" + And I fill in "Description" with "I'd probably be removing text." + And I fill in "Ticket ID" with "no 💜" + And I press "Update" + Then I should see "Ticket ID is not a number" + And the field labeled "Ticket ID" should contain "no 💜" + When I fill in "Ticket ID" with "47" + And I press "Update" + Then I should see "Pseud was successfully updated." + When I go to someone's pseuds page + Then I should see "I'd probably be removing text." + When I follow "Activities" within ".admin.primary.navigation" + Then I should see "Pseud alt (someone)" + When I follow "Pseud alt (someone)" + Then I should be on someone's pseuds page + When I visit the last activities item + Then I should see "Pseud alt (someone)" + And I should see "edit pseud" + And I should see a link "Ticket #47" + + # Skip logging admin activity if no change was actually made. + When I go to someone's pseuds page + And I follow "Edit alt" + And I fill in "Ticket ID" with "47" + And I press "Update" + Then I should see "Pseud was successfully updated." + When I go to the admin-activities page + Then I should see 1 admin activity log entry + + +Scenario: Bookmarks reflect pseud changes immediately + + Given the work "Interesting" + And I am logged in as "myself" + And I add the pseud "before" + And I bookmark the work "Interesting" as "before" + And I go to myself's bookmarks page + Then I should see "Bookmarked by before (myself)" + + When it is currently 1 second from now + And I change the pseud "before" to "after" + And I go to myself's bookmarks page + Then I should see "Bookmarked by after (myself)" + And I should not see "Bookmarked by before (myself)" \ No newline at end of file diff --git a/features/users/user_rename.feature b/features/users/user_rename.feature index 899b9a7b561..f64266bdd49 100644 --- a/features/users/user_rename.feature +++ b/features/users/user_rename.feature @@ -7,7 +7,7 @@ Feature: Scenario: The user should not be able to change username without a password Given I am logged in as "testuser" with password "password" When I visit the change username page for testuser - And I fill in "New user name" with "anothertestuser" + And I fill in "New user name" with "anothertestuser" And I press "Change User Name" # TODO - better written error message Then I should see "Your password was incorrect" @@ -30,7 +30,7 @@ Feature: And I fill in "New user name" with "otheruser" And I fill in "Password" with "password" When I press "Change" - Then I should see "User name has already been taken" + Then I should see "User name has already been taken" Scenario: The user should not be able to change their username to another user's name even if the capitalization is different Given I have no users @@ -72,7 +72,7 @@ Feature: Then I should get confirmation that I changed my username And I should see "Hi, newusername" When I go to my pseuds page - Then I should not see "oldusername" + Then I should not see "oldusername" When I follow "Edit" Then I should see "You cannot change the pseud that matches your user name" Then the "pseud_is_default" checkbox should be checked and disabled @@ -87,7 +87,7 @@ Feature: Then I should get confirmation that I changed my username And I should see "Hi, Uppercrust" When I go to my pseuds page - Then I should not see "uppercrust" + Then I should not see "uppercrust" When I follow "Edit" Then I should see "You cannot change the pseud that matches your user name" Then the "pseud_is_default" checkbox should be checked and disabled @@ -95,8 +95,8 @@ Feature: Scenario: Changing my user name with two pseuds, one same as new, doesn't change old Given I have no users And the following activated user exists - | login | password | id | - | oldusername | secret | 1 | + | login | password | id | + | oldusername | secret | 1 | And a pseud exists with name: "newusername", user_id: 1 And I am logged in as "oldusername" with password "secret" When I visit the change username page for oldusername @@ -106,7 +106,7 @@ Feature: Then I should get confirmation that I changed my username And I should see "Hi, newusername" When I follow "Pseuds (2)" - Then I should see "Edit oldusername" + Then I should see "Edit oldusername" And I should see "Edit newusername" Scenario: Changing username updates search results (bug AO3-3468) @@ -198,19 +198,19 @@ Feature: When I follow "Series" Then I should see "Best Series by newusername" - Scenario: Changing the username from a forbidden name to non-forbidden - Given I have no users - And the following activated user exists - | login | password | - | forbidden | secret | - And the user name "forbidden" is on the forbidden list - When I am logged in as "forbidden" with password "secret" - And I visit the change username page for forbidden - And I fill in "New user name" with "notforbidden" - And I fill in "Password" with "secret" - And I press "Change User Name" - Then I should get confirmation that I changed my username - And I should see "Hi, notforbidden" + Scenario: Changing the username from a forbidden name to non-forbidden + Given I have no users + And the following activated user exists + | login | password | + | forbidden | secret | + And the user name "forbidden" is on the forbidden list + When I am logged in as "forbidden" with password "secret" + And I visit the change username page for forbidden + And I fill in "New user name" with "notforbidden" + And I fill in "Password" with "secret" + And I press "Change User Name" + Then I should get confirmation that I changed my username + And I should see "Hi, notforbidden" Scenario: Bookmarker's bookmark blurbs reflect username changes immediately Given the work "Interesting" From ad766d5d8d2574d90aa5bdb4c62f4dc83309a930 Mon Sep 17 00:00:00 2001 From: irrationalpie7 Date: Sat, 30 Mar 2024 12:56:01 -0700 Subject: [PATCH 3/7] AO3-5053 Remove byline from cache instead of touching all bookmarks --- app/models/bookmark.rb | 2 +- app/models/pseud.rb | 9 ++++----- app/models/user.rb | 2 -- app/views/bookmarks/_bookmark_user_module.html.erb | 11 ++++++----- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index 1a5c57eaba5..81e3af952ed 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -102,7 +102,7 @@ def check_new_external_work scope :latest, -> { is_public.limit(ArchiveConfig.ITEMS_PER_PAGE).join_work } - scope :for_blurb, -> { includes(:bookmarkable, :pseud, :tags, :collections) } + scope :for_blurb, -> { includes(:bookmarkable, :pseud, :tags, :collections, :user) } # a complicated dynamic scope here: # if the user is an Admin, we use the "visible_to_admin" scope diff --git a/app/models/pseud.rb b/app/models/pseud.rb index 82ac09743c8..91940f84131 100644 --- a/app/models/pseud.rb +++ b/app/models/pseud.rb @@ -397,11 +397,10 @@ def check_default_pseud end def expire_caches - return unless saved_change_to_name? - - bookmarks.touch_all - works.touch_all - series.each(&:expire_byline_cache) + if saved_change_to_name? + works.touch_all + series.each(&:expire_byline_cache) + end end def touch_comments diff --git a/app/models/user.rb b/app/models/user.rb index 609886fab94..791f2bc0580 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -160,9 +160,7 @@ class User < ApplicationRecord def expire_caches return unless saved_change_to_login? - series.each(&:expire_byline_cache) - self.bookmarks.touch_all self.works.each do |work| work.touch work.expire_caches diff --git a/app/views/bookmarks/_bookmark_user_module.html.erb b/app/views/bookmarks/_bookmark_user_module.html.erb index 60330591694..e31ca272249 100644 --- a/app/views/bookmarks/_bookmark_user_module.html.erb +++ b/app/views/bookmarks/_bookmark_user_module.html.erb @@ -1,11 +1,12 @@ <% # expects "bookmark" %>
- <% blurb_cache_key = (is_author_of?(bookmark) ? "bookmark-owner-blurb-#{bookmark.cache_key}-v2" : "bookmark-blurb-#{bookmark.cache_key}-v2") %> + + + <% blurb_cache_key = (is_author_of?(bookmark) ? "bookmark-owner-blurb-#{bookmark.cache_key}-v3" : "bookmark-blurb-#{bookmark.cache_key}-v3") %> <% cache(blurb_cache_key, skip_digest: true) do %> - - +

<%= set_format_for_date(bookmark.created_at) %>

<% # information added by the bookmark owner %> From 0c84baf7ef4d7bed3853d8091508be63f6da0895 Mon Sep 17 00:00:00 2001 From: irrationalpie7 Date: Sat, 30 Mar 2024 17:43:55 -0700 Subject: [PATCH 4/7] AO3-5053 Fix typos --- app/models/bookmark.rb | 2 +- app/views/bookmarks/_bookmark_user_module.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index 81e3af952ed..0f516f8a4ff 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -102,7 +102,7 @@ def check_new_external_work scope :latest, -> { is_public.limit(ArchiveConfig.ITEMS_PER_PAGE).join_work } - scope :for_blurb, -> { includes(:bookmarkable, :pseud, :tags, :collections, :user) } + scope :for_blurb, -> { includes(:bookmarkable, :tags, :collections, :pseud [:user]) } # a complicated dynamic scope here: # if the user is an Admin, we use the "visible_to_admin" scope diff --git a/app/views/bookmarks/_bookmark_user_module.html.erb b/app/views/bookmarks/_bookmark_user_module.html.erb index e31ca272249..10437b1133d 100644 --- a/app/views/bookmarks/_bookmark_user_module.html.erb +++ b/app/views/bookmarks/_bookmark_user_module.html.erb @@ -2,7 +2,7 @@
<% blurb_cache_key = (is_author_of?(bookmark) ? "bookmark-owner-blurb-#{bookmark.cache_key}-v3" : "bookmark-blurb-#{bookmark.cache_key}-v3") %> <% cache(blurb_cache_key, skip_digest: true) do %> From 1b799325cf5dc607dee18e7043c772a7ee314f71 Mon Sep 17 00:00:00 2001 From: irrationalpie7 Date: Sat, 30 Mar 2024 17:52:54 -0700 Subject: [PATCH 5/7] AO3-5053 Fix typo again --- app/models/bookmark.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index 0f516f8a4ff..413cdf952f5 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -102,7 +102,7 @@ def check_new_external_work scope :latest, -> { is_public.limit(ArchiveConfig.ITEMS_PER_PAGE).join_work } - scope :for_blurb, -> { includes(:bookmarkable, :tags, :collections, :pseud [:user]) } + scope :for_blurb, -> { includes(:bookmarkable, :tags, :collections, pseud: [:user]) } # a complicated dynamic scope here: # if the user is an Admin, we use the "visible_to_admin" scope From 673ae22d3758685401c53e1744a87d30fd2e213c Mon Sep 17 00:00:00 2001 From: irrationalpie7 Date: Tue, 2 Apr 2024 14:11:50 -0700 Subject: [PATCH 6/7] AO3-5053 removed unnecessary spec tests --- spec/models/pseud_spec.rb | 12 ------------ spec/models/user_spec.rb | 13 ------------- 2 files changed, 25 deletions(-) diff --git a/spec/models/pseud_spec.rb b/spec/models/pseud_spec.rb index dfe0a53e95d..e18cb964426 100644 --- a/spec/models/pseud_spec.rb +++ b/spec/models/pseud_spec.rb @@ -52,18 +52,6 @@ end end - describe "changing pseud name" do - let(:pseud) { create(:pseud) } - let!(:bookmark) { create(:bookmark, pseud: pseud) } - - it "modifies the updated_at of associated bookmarks" do - travel(1.second) - expect do - pseud.update(name: "New Name") - end.to change { bookmark.reload.updated_at } - end - end - describe "touch_comments" do let(:pseud) { create(:pseud) } let!(:comment) { create(:comment, pseud: pseud) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 901093ea182..5296fc01611 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -294,19 +294,6 @@ end end - describe "changing login name" do - let(:user) { build(:user) } - let(:pseud) { create(:pseud, user: user) } - let!(:bookmark) { create(:bookmark, pseud: pseud) } - - it "modifies the updated_at of associated bookmarks" do - travel(1.second) - expect do - user.update(login: "New") - end.to change { bookmark.reload.updated_at } - end - end - describe ".search_multiple_by_email" do let(:user_bundle) { create_list(:user, 5) } From 68c3cb665cc683210de0c8b4331fb7446c0878b9 Mon Sep 17 00:00:00 2001 From: irrationalpie7 Date: Tue, 2 Apr 2024 14:17:25 -0700 Subject: [PATCH 7/7] AO3-5053 fix linter warning --- app/views/bookmarks/_bookmark_user_module.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/bookmarks/_bookmark_user_module.html.erb b/app/views/bookmarks/_bookmark_user_module.html.erb index 10437b1133d..5e5fffa56c2 100644 --- a/app/views/bookmarks/_bookmark_user_module.html.erb +++ b/app/views/bookmarks/_bookmark_user_module.html.erb @@ -2,7 +2,7 @@
<% blurb_cache_key = (is_author_of?(bookmark) ? "bookmark-owner-blurb-#{bookmark.cache_key}-v3" : "bookmark-blurb-#{bookmark.cache_key}-v3") %> <% cache(blurb_cache_key, skip_digest: true) do %>