@@ -24,7 +24,7 class Principal < ActiveRecord::Base | |||
|
24 | 24 | has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify |
|
25 | 25 | |
|
26 | 26 | # Groups and active users |
|
27 |
named_scope :active, :conditions => "#{Principal.table_name} |
|
|
27 | named_scope :active, :conditions => "#{Principal.table_name}.status = 1" | |
|
28 | 28 | |
|
29 | 29 | named_scope :like, lambda {|q| |
|
30 | 30 | s = "%#{q.to_s.strip.downcase}%" |
@@ -19,6 +19,14 require File.expand_path('../../test_helper', __FILE__) | |||
|
19 | 19 | |
|
20 | 20 | class PrincipalTest < ActiveSupport::TestCase |
|
21 | 21 | |
|
22 | def test_active_scope_should_return_groups_and_active_users | |
|
23 | result = Principal.active.all | |
|
24 | assert_include Group.first, result | |
|
25 | assert_not_nil result.detect {|p| p.is_a?(User)} | |
|
26 | assert_nil result.detect {|p| p.is_a?(User) && !p.active?} | |
|
27 | assert_nil result.detect {|p| p.is_a?(AnonymousUser)} | |
|
28 | end | |
|
29 | ||
|
22 | 30 | context "#like" do |
|
23 | 31 | setup do |
|
24 | 32 | Principal.generate!(:login => 'login') |
General Comments 0
You need to be logged in to leave comments.
Login now