diff --git a/app/models/pseud.rb b/app/models/pseud.rb index 6d2e137896f..550ed3dc963 100644 --- a/app/models/pseud.rb +++ b/app/models/pseud.rb @@ -399,7 +399,8 @@ def check_default_pseud def expire_caches if saved_change_to_name? - self.works.each{ |work| work.touch } + works.touch_all + series.touch_all end end diff --git a/app/models/user.rb b/app/models/user.rb index 1798931b048..f33abd06949 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -158,6 +158,7 @@ class User < ApplicationRecord def expire_caches return unless saved_change_to_login? + series.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 b35f9414982..23b3cb5f131 100644 --- a/features/other_a/pseuds.feature +++ b/features/other_a/pseuds.feature @@ -173,3 +173,21 @@ Scenario: Many pseuds 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)" diff --git a/features/users/user_rename.feature b/features/users/user_rename.feature index a5b2f4f13ad..3a292d2f870 100644 --- a/features/users/user_rename.feature +++ b/features/users/user_rename.feature @@ -147,3 +147,19 @@ Feature: And I view the work "Interesting" with comments Then I should see "after" within ".comment h4.byline" And I should not see "mine (before)" + + Scenario: Changing username updates series blurbs + Given I have no users + And I am logged in as "oldusername" with password "password" + And I add the work "Great Work" to series "Best Series" + When I go to the dashboard page for user "oldusername" with pseud "oldusername" + And I follow "Series" + Then I should see "Best Series by oldusername" + When I visit the change username page for oldusername + And I fill in "New user name" with "newusername" + And I fill in "Password" with "password" + And I press "Change User Name" + Then I should get confirmation that I changed my username + And I should see "Hi, newusername" + When I follow "Series" + Then I should see "Best Series by newusername" diff --git a/spec/models/pseud_spec.rb b/spec/models/pseud_spec.rb index eac4a07b777..c8b5ade0d80 100644 --- a/spec/models/pseud_spec.rb +++ b/spec/models/pseud_spec.rb @@ -66,6 +66,20 @@ end end + describe "expire_caches" do + let(:pseud) { create(:pseud) } + let(:series) { create(:series, authors: [pseud]) } + + it "modifies the updated_at of associated series" do + pseud.reload + series.reload + travel(1.day) + expect do + pseud.update(name: "New Name") + end.to change { series.reload.updated_at } + end + end + describe ".default_alphabetical" do let(:user) { create(:user, login: "Zaphod") } let(:subject) { user.pseuds.default_alphabetical }