summaryrefslogtreecommitdiffstats
path: root/test/unit/search_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-20 17:26:07 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-20 17:26:07 +0000
commitbe2b8a62f4d0d8bf413a5583fe644bd41a8ebf04 (patch)
tree95fe7f273935739e1ffa82be16cee93927a4c054 /test/unit/search_test.rb
parent83baccb71ac0e609ce72ebf322f73884548a9ba5 (diff)
downloadredmine-be2b8a62f4d0d8bf413a5583fe644bd41a8ebf04.tar.gz
redmine-be2b8a62f4d0d8bf413a5583fe644bd41a8ebf04.zip
Search engine: display total results count (#906) and count by result type.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1681 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/search_test.rb')
-rw-r--r--test/unit/search_test.rb49
1 files changed, 29 insertions, 20 deletions
diff --git a/test/unit/search_test.rb b/test/unit/search_test.rb
index 244b27a58..1b32df733 100644
--- a/test/unit/search_test.rb
+++ b/test/unit/search_test.rb
@@ -41,24 +41,24 @@ class SearchTest < Test::Unit::TestCase
def test_search_by_anonymous
User.current = nil
- r = Issue.search(@issue_keyword)
+ r = Issue.search(@issue_keyword).first
assert r.include?(@issue)
- r = Changeset.search(@changeset_keyword)
+ r = Changeset.search(@changeset_keyword).first
assert r.include?(@changeset)
# Removes the :view_changesets permission from Anonymous role
remove_permission Role.anonymous, :view_changesets
- r = Issue.search(@issue_keyword)
+ r = Issue.search(@issue_keyword).first
assert r.include?(@issue)
- r = Changeset.search(@changeset_keyword)
+ r = Changeset.search(@changeset_keyword).first
assert !r.include?(@changeset)
# Make the project private
@project.update_attribute :is_public, false
- r = Issue.search(@issue_keyword)
+ r = Issue.search(@issue_keyword).first
assert !r.include?(@issue)
- r = Changeset.search(@changeset_keyword)
+ r = Changeset.search(@changeset_keyword).first
assert !r.include?(@changeset)
end
@@ -66,24 +66,24 @@ class SearchTest < Test::Unit::TestCase
User.current = User.find_by_login('rhill')
assert User.current.memberships.empty?
- r = Issue.search(@issue_keyword)
+ r = Issue.search(@issue_keyword).first
assert r.include?(@issue)
- r = Changeset.search(@changeset_keyword)
+ r = Changeset.search(@changeset_keyword).first
assert r.include?(@changeset)
# Removes the :view_changesets permission from Non member role
remove_permission Role.non_member, :view_changesets
- r = Issue.search(@issue_keyword)
+ r = Issue.search(@issue_keyword).first
assert r.include?(@issue)
- r = Changeset.search(@changeset_keyword)
+ r = Changeset.search(@changeset_keyword).first
assert !r.include?(@changeset)
# Make the project private
@project.update_attribute :is_public, false
- r = Issue.search(@issue_keyword)
+ r = Issue.search(@issue_keyword).first
assert !r.include?(@issue)
- r = Changeset.search(@changeset_keyword)
+ r = Changeset.search(@changeset_keyword).first
assert !r.include?(@changeset)
end
@@ -91,16 +91,16 @@ class SearchTest < Test::Unit::TestCase
User.current = User.find_by_login('jsmith')
assert User.current.projects.include?(@project)
- r = Issue.search(@issue_keyword)
+ r = Issue.search(@issue_keyword).first
assert r.include?(@issue)
- r = Changeset.search(@changeset_keyword)
+ r = Changeset.search(@changeset_keyword).first
assert r.include?(@changeset)
# Make the project private
@project.update_attribute :is_public, false
- r = Issue.search(@issue_keyword)
+ r = Issue.search(@issue_keyword).first
assert r.include?(@issue)
- r = Changeset.search(@changeset_keyword)
+ r = Changeset.search(@changeset_keyword).first
assert r.include?(@changeset)
end
@@ -112,19 +112,28 @@ class SearchTest < Test::Unit::TestCase
User.current = User.find_by_login('jsmith')
assert User.current.projects.include?(@project)
- r = Issue.search(@issue_keyword)
+ r = Issue.search(@issue_keyword).first
assert r.include?(@issue)
- r = Changeset.search(@changeset_keyword)
+ r = Changeset.search(@changeset_keyword).first
assert !r.include?(@changeset)
# Make the project private
@project.update_attribute :is_public, false
- r = Issue.search(@issue_keyword)
+ r = Issue.search(@issue_keyword).first
assert r.include?(@issue)
- r = Changeset.search(@changeset_keyword)
+ r = Changeset.search(@changeset_keyword).first
assert !r.include?(@changeset)
end
+ def test_search_issue_with_multiple_hits_in_journals
+ i = Issue.find(1)
+ assert_equal 2, i.journals.count(:all, :conditions => "notes LIKE '%notes%'")
+
+ r = Issue.search('%notes%').first
+ assert_equal 1, r.size
+ assert_equal i, r.first
+ end
+
private
def remove_permission(role, permission)