diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-04-06 18:54:57 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-04-06 18:54:57 +0000 |
commit | bef1aca8837f2306ecbd8ff70deb2204bf1da539 (patch) | |
tree | 8b8e1e2edaca871756f98bfa991aeff0a69bb106 /spec/models/user_spec.rb | |
parent | 9205caa3361fb38233588c8a18d27288b1e076ee (diff) | |
parent | 1c42505b026d922df50c59d5f9e85073b5f5345f (diff) | |
download | gitlab-ce-bef1aca8837f2306ecbd8ff70deb2204bf1da539.tar.gz |
Merge branch '28695-move-all-associated-records-to-ghost-user' into 'master'
Resolve "Deleting a user shouldn't delete associated records"
Closes #28695 and #30514
See merge request !10467
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r-- | spec/models/user_spec.rb | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 3977af55176..6f7b9c2388a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -28,7 +28,6 @@ describe User, models: true do it { is_expected.to have_many(:merge_requests).dependent(:destroy) } it { is_expected.to have_many(:assigned_merge_requests).dependent(:nullify) } it { is_expected.to have_many(:identities).dependent(:destroy) } - it { is_expected.to have_one(:abuse_report) } it { is_expected.to have_many(:spam_logs).dependent(:destroy) } it { is_expected.to have_many(:todos).dependent(:destroy) } it { is_expected.to have_many(:award_emoji).dependent(:destroy) } @@ -37,6 +36,34 @@ describe User, models: true do it { is_expected.to have_many(:pipelines).dependent(:nullify) } it { is_expected.to have_many(:chat_names).dependent(:destroy) } it { is_expected.to have_many(:uploads).dependent(:destroy) } + it { is_expected.to have_many(:reported_abuse_reports).dependent(:destroy).class_name('AbuseReport') } + + describe "#abuse_report" do + let(:current_user) { create(:user) } + let(:other_user) { create(:user) } + + it { is_expected.to have_one(:abuse_report) } + + it "refers to the abuse report whose user_id is the current user" do + abuse_report = create(:abuse_report, reporter: other_user, user: current_user) + + expect(current_user.abuse_report).to eq(abuse_report) + end + + it "does not refer to the abuse report whose reporter_id is the current user" do + create(:abuse_report, reporter: current_user, user: other_user) + + expect(current_user.abuse_report).to be_nil + end + + it "does not update the user_id of an abuse report when the user is updated" do + abuse_report = create(:abuse_report, reporter: current_user, user: other_user) + + current_user.block + + expect(abuse_report.reload.user).to eq(other_user) + end + end describe '#group_members' do it 'does not include group memberships for which user is a requester' do |