has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
# Groups and active users
- named_scope :active, :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status = 1)"
+ named_scope :active, :conditions => "#{Principal.table_name}.status = 1"
named_scope :like, lambda {|q|
s = "%#{q.to_s.strip.downcase}%"
class PrincipalTest < ActiveSupport::TestCase
+ def test_active_scope_should_return_groups_and_active_users
+ result = Principal.active.all
+ assert_include Group.first, result
+ assert_not_nil result.detect {|p| p.is_a?(User)}
+ assert_nil result.detect {|p| p.is_a?(User) && !p.active?}
+ assert_nil result.detect {|p| p.is_a?(AnonymousUser)}
+ end
+
context "#like" do
setup do
Principal.generate!(:login => 'login')