do not destroy uploads when destroying a user

This commit is contained in:
Régis Hanol
2013-11-22 18:29:07 +01:00
parent 4e45c5ff3d
commit 3cf5a363f7
2 changed files with 35 additions and 17 deletions

View File

@@ -28,7 +28,7 @@ class User < ActiveRecord::Base
has_many :user_visits, dependent: :destroy has_many :user_visits, dependent: :destroy
has_many :invites, dependent: :destroy has_many :invites, dependent: :destroy
has_many :topic_links, dependent: :destroy has_many :topic_links, dependent: :destroy
has_many :uploads, dependent: :destroy has_many :uploads
has_one :facebook_user_info, dependent: :destroy has_one :facebook_user_info, dependent: :destroy
has_one :twitter_user_info, dependent: :destroy has_one :twitter_user_info, dependent: :destroy

View File

@@ -3,26 +3,44 @@ require_dependency 'user'
describe User do describe User do
it { should have_many :posts } it { should have_many(:posts) }
it { should have_many :notifications } it { should have_many(:notifications).dependent(:destroy) }
it { should have_many :topic_users } it { should have_many(:topic_users).dependent(:destroy) }
it { should have_many :post_actions } it { should have_many(:topics) }
it { should have_many :user_actions } it { should have_many(:user_open_ids).dependent(:destroy) }
it { should have_many :topics } it { should have_many(:user_actions).dependent(:destroy) }
it { should have_many :user_open_ids } it { should have_many(:post_actions).dependent(:destroy) }
it { should have_many :post_timings } it { should have_many(:email_logs).dependent(:destroy) }
it { should have_many :email_tokens } it { should have_many(:post_timings) }
it { should have_many :views } it { should have_many(:topic_allowed_users).dependent(:destroy) }
it { should have_many :user_visits } it { should have_many(:topics_allowed) }
it { should belong_to :approved_by } it { should have_many(:email_tokens).dependent(:destroy) }
it { should have_many :email_logs } it { should have_many(:views) }
it { should have_many :topic_allowed_users } it { should have_many(:user_visits).dependent(:destroy) }
it { should have_many :invites } it { should have_many(:invites).dependent(:destroy) }
it { should have_many(:topic_links).dependent(:destroy) }
it { should have_many(:uploads) }
it { should have_one(:facebook_user_info).dependent(:destroy) }
it { should have_one(:twitter_user_info).dependent(:destroy) }
it { should have_one(:github_user_info).dependent(:destroy) }
it { should have_one(:cas_user_info).dependent(:destroy) }
it { should have_one(:oauth2_user_info).dependent(:destroy) }
it { should have_one(:user_stat).dependent(:destroy) }
it { should belong_to(:approved_by) }
it { should have_many(:group_users).dependent(:destroy) }
it { should have_many(:groups) }
it { should have_many(:secure_categories) }
it { should have_one(:user_search_data).dependent(:destroy) }
it { should have_one(:api_key).dependent(:destroy) }
it { should belong_to(:uploaded_avatar).dependent(:destroy) }
it { should validate_presence_of :username } it { should validate_presence_of :username }
it { should validate_presence_of :email } it { should validate_presence_of :email }
context '.enqueue_welcome_message' do context '.enqueue_welcome_message' do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }