From 6fc62d393cc49986408aa4ef22ddb5f8eb7b34e2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 25 Aug 2008 11:55:40 +0000 Subject: [PATCH] Fixed: invalid SQL query on User#destroy (#1781). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1755 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/user.rb | 3 ++- test/unit/user_test.rb | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index cabce3005..05a75e1ad 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -33,7 +33,8 @@ class User < ActiveRecord::Base :username => '#{login}' } - has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :conditions => "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}", :order => "#{Project.table_name}.name", :dependent => :delete_all + has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :conditions => "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}", :order => "#{Project.table_name}.name" + has_many :members, :dependent => :delete_all has_many :projects, :through => :memberships has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 3209f261a..80011f4bf 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -57,6 +57,12 @@ class UserTest < Test::Unit::TestCase assert_equal "john", @admin.login end + def test_destroy + User.find(2).destroy + assert_nil User.find_by_id(2) + assert Member.find_all_by_user_id(2).empty? + end + def test_validate @admin.login = "" assert !@admin.save -- 2.39.5