mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FIX: when destroying uploads clear card and profile background
There is an fk to user_profile that can make destroying uploads fail if they happen to be set as user profile. This ensures we clear this information when destroying uploads. There are more relationships, but this makes some more progress.
This commit is contained in:
@ -413,4 +413,25 @@ describe Upload do
|
||||
"https://#{SiteSetting.s3_upload_bucket}.s3.amazonaws.com/original/1X/#{upload.sha1}.#{upload.extension}?acl"
|
||||
)
|
||||
end
|
||||
|
||||
context '.destroy' do
|
||||
|
||||
it "can correctly clear information when destroying an upload" do
|
||||
upload = Fabricate(:upload)
|
||||
user = Fabricate(:user)
|
||||
|
||||
user.user_profile.update!(
|
||||
card_background_upload_id: upload.id,
|
||||
profile_background_upload_id: upload.id
|
||||
)
|
||||
|
||||
upload.destroy
|
||||
|
||||
user.user_profile.reload
|
||||
|
||||
expect(user.user_profile.card_background_upload_id).to eq(nil)
|
||||
expect(user.user_profile.profile_background_upload_id).to eq(nil)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user