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
|
||||
|
||||
before_destroy do
|
||||
raise "Never destroy users!"
|
||||
end
|
||||
|
||||
def self.all_sharing_with_person(person)
|
||||
User.joins(:contacts).where(:contacts => {:person_id => person.id})
|
||||
end
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ describe PostsController, type: :controller do
|
|||
msg = alice.post(:status_message, text: "Mention @{User ; #{user.diaspora_handle}}", public: true)
|
||||
|
||||
expect(msg.mentioned_people.count).to eq(1)
|
||||
user.destroy
|
||||
user.close_account!
|
||||
|
||||
get :show, params: {id: msg.id}
|
||||
expect(response).to be_success
|
||||
|
|
|
|||
|
|
@ -565,16 +565,11 @@ describe User, :type => :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'account deletion' do
|
||||
describe '#destroy' do
|
||||
it 'removes all service connections' do
|
||||
Services::Facebook.create(:access_token => 'what', :user_id => alice.id)
|
||||
expect {
|
||||
alice.destroy
|
||||
}.to change {
|
||||
alice.services.count
|
||||
}.by(-1)
|
||||
end
|
||||
describe "#destroy" do
|
||||
it "raises error" do
|
||||
expect {
|
||||
alice.destroy
|
||||
}.to raise_error "Never destroy users!"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue