Forbid user destruction
This commit is contained in:
parent
973e9d98c6
commit
ad025850ce
3 changed files with 10 additions and 11 deletions
|
|
@ -90,6 +90,10 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
after_save :remove_invalid_unconfirmed_emails
|
after_save :remove_invalid_unconfirmed_emails
|
||||||
|
|
||||||
|
before_destroy do
|
||||||
|
raise "Never destroy users!"
|
||||||
|
end
|
||||||
|
|
||||||
def self.all_sharing_with_person(person)
|
def self.all_sharing_with_person(person)
|
||||||
User.joins(:contacts).where(:contacts => {:person_id => person.id})
|
User.joins(:contacts).where(:contacts => {:person_id => person.id})
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ describe PostsController, type: :controller do
|
||||||
msg = alice.post(:status_message, text: "Mention @{User ; #{user.diaspora_handle}}", public: true)
|
msg = alice.post(:status_message, text: "Mention @{User ; #{user.diaspora_handle}}", public: true)
|
||||||
|
|
||||||
expect(msg.mentioned_people.count).to eq(1)
|
expect(msg.mentioned_people.count).to eq(1)
|
||||||
user.destroy
|
user.close_account!
|
||||||
|
|
||||||
get :show, params: {id: msg.id}
|
get :show, params: {id: msg.id}
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
|
|
|
||||||
|
|
@ -565,16 +565,11 @@ describe User, :type => :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'account deletion' do
|
describe "#destroy" do
|
||||||
describe '#destroy' do
|
it "raises error" do
|
||||||
it 'removes all service connections' do
|
|
||||||
Services::Facebook.create(:access_token => 'what', :user_id => alice.id)
|
|
||||||
expect {
|
expect {
|
||||||
alice.destroy
|
alice.destroy
|
||||||
}.to change {
|
}.to raise_error "Never destroy users!"
|
||||||
alice.services.count
|
|
||||||
}.by(-1)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue