diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/search_controller_test.rb | 8 | ||||
-rw-r--r-- | test/unit/search_test.rb | 49 |
2 files changed, 37 insertions, 20 deletions
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 1c505620b..ce06ec298 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -32,9 +32,17 @@ class SearchControllerTest < Test::Unit::TestCase get :index, :q => 'recipe subproject commit', :submit => 'Search' assert_response :success assert_template 'index' + assert assigns(:results).include?(Issue.find(2)) assert assigns(:results).include?(Issue.find(5)) assert assigns(:results).include?(Changeset.find(101)) + assert_tag :dt, :attributes => { :class => /issue/ }, + :child => { :tag => 'a', :content => /Add ingredients categories/ }, + :sibling => { :tag => 'dd', :content => /should be classified by categories/ } + + assert assigns(:results_by_type).is_a?(Hash) + assert_equal 4, assigns(:results_by_type)['changesets'] + assert_tag :a, :content => 'Changesets (4)' end def test_search_project_and_subprojects 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) |