Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-5052 Update series byline on username or pseud update #4605

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/pseud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions features/other_a/pseuds.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
16 changes: 16 additions & 0 deletions features/users/user_rename.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 14 additions & 0 deletions spec/models/pseud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down