mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-25 16:04:22 -05:00
For performance reasons, use delete_all
when removing a user's email logs
This commit is contained in:
parent
37a3e956b6
commit
cb0e7a5724
2 changed files with 12 additions and 1 deletions
|
@ -25,7 +25,7 @@ class User < ActiveRecord::Base
|
||||||
has_many :post_actions, dependent: :destroy
|
has_many :post_actions, dependent: :destroy
|
||||||
has_many :user_badges, -> {where('user_badges.badge_id IN (SELECT id FROM badges where enabled)')}, dependent: :destroy
|
has_many :user_badges, -> {where('user_badges.badge_id IN (SELECT id FROM badges where enabled)')}, dependent: :destroy
|
||||||
has_many :badges, through: :user_badges
|
has_many :badges, through: :user_badges
|
||||||
has_many :email_logs, dependent: :destroy
|
has_many :email_logs, dependent: :delete_all
|
||||||
has_many :post_timings
|
has_many :post_timings
|
||||||
has_many :topic_allowed_users, dependent: :destroy
|
has_many :topic_allowed_users, dependent: :destroy
|
||||||
has_many :topics_allowed, through: :topic_allowed_users, source: :topic
|
has_many :topics_allowed, through: :topic_allowed_users, source: :topic
|
||||||
|
|
|
@ -283,6 +283,17 @@ describe UserDestroyer do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'user got an email' do
|
||||||
|
let(:user) { Fabricate(:user) }
|
||||||
|
let!(:email_log) { Fabricate(:email_log, user: user) }
|
||||||
|
|
||||||
|
it "deletes the email log" do
|
||||||
|
expect {
|
||||||
|
UserDestroyer.new(@admin).destroy(user, {delete_posts: true})
|
||||||
|
}.to change { EmailLog.count }.by(-1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'user liked things' do
|
context 'user liked things' do
|
||||||
before do
|
before do
|
||||||
@topic = Fabricate(:topic, user: Fabricate(:user))
|
@topic = Fabricate(:topic, user: Fabricate(:user))
|
||||||
|
|
Loading…
Reference in a new issue