annotate test/unit/.svn/text-base/principal_test.rb.svn-base @ 904:0a8317a50fa0 redmine-1.1

Close obsolete branch redmine-1.1
author Chris Cannam
date Fri, 14 Jan 2011 12:53:21 +0000
parents af80e5618e9b
children
rev   line source
Chris@0 1 # redMine - project management software
Chris@0 2 # Copyright (C) 2009 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@0 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@0 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@117 18 require File.expand_path('../../test_helper', __FILE__)
Chris@0 19
Chris@0 20 class PrincipalTest < ActiveSupport::TestCase
Chris@0 21
Chris@0 22 context "#like" do
Chris@0 23 setup do
Chris@0 24 Principal.generate!(:login => 'login')
Chris@0 25 Principal.generate!(:login => 'login2')
Chris@0 26
Chris@0 27 Principal.generate!(:firstname => 'firstname')
Chris@0 28 Principal.generate!(:firstname => 'firstname2')
Chris@0 29
Chris@0 30 Principal.generate!(:lastname => 'lastname')
Chris@0 31 Principal.generate!(:lastname => 'lastname2')
Chris@0 32
Chris@0 33 Principal.generate!(:mail => 'mail@example.com')
Chris@0 34 Principal.generate!(:mail => 'mail2@example.com')
Chris@0 35 end
Chris@0 36
Chris@0 37 should "search login" do
Chris@0 38 results = Principal.like('login')
Chris@0 39
Chris@0 40 assert_equal 2, results.count
Chris@0 41 assert results.all? {|u| u.login.match(/login/) }
Chris@0 42 end
Chris@0 43
Chris@0 44 should "search firstname" do
Chris@0 45 results = Principal.like('firstname')
Chris@0 46
Chris@0 47 assert_equal 2, results.count
Chris@0 48 assert results.all? {|u| u.firstname.match(/firstname/) }
Chris@0 49 end
Chris@0 50
Chris@0 51 should "search lastname" do
Chris@0 52 results = Principal.like('lastname')
Chris@0 53
Chris@0 54 assert_equal 2, results.count
Chris@0 55 assert results.all? {|u| u.lastname.match(/lastname/) }
Chris@0 56 end
Chris@0 57
Chris@0 58 should "search mail" do
Chris@0 59 results = Principal.like('mail')
Chris@0 60
Chris@0 61 assert_equal 2, results.count
Chris@0 62 assert results.all? {|u| u.mail.match(/mail/) }
Chris@0 63 end
Chris@0 64 end
Chris@0 65
Chris@0 66 end