Mercurial > hg > soundsoftware-site
comparison test/functional/search_controller_test.rb @ 507:0c939c159af4 redmine-1.2
Update to Redmine 1.2.1 on 1.2-stable branch (Redmine SVN rev 6270)
author | Chris Cannam |
---|---|
date | Thu, 14 Jul 2011 10:32:19 +0100 |
parents | cbce1fd3b1b7 |
children | cbb26bc654de |
comparison
equal
deleted
inserted
replaced
441:cbce1fd3b1b7 | 507:0c939c159af4 |
---|---|
27 assert_template 'index' | 27 assert_template 'index' |
28 assert assigns(:results).include?(Project.find(1)) | 28 assert assigns(:results).include?(Project.find(1)) |
29 end | 29 end |
30 | 30 |
31 def test_search_all_projects | 31 def test_search_all_projects |
32 get :index, :q => 'recipe subproject commit', :submit => 'Search' | 32 get :index, :q => 'recipe subproject commit', :all_words => '' |
33 assert_response :success | 33 assert_response :success |
34 assert_template 'index' | 34 assert_template 'index' |
35 | 35 |
36 assert assigns(:results).include?(Issue.find(2)) | 36 assert assigns(:results).include?(Issue.find(2)) |
37 assert assigns(:results).include?(Issue.find(5)) | 37 assert assigns(:results).include?(Issue.find(5)) |
48 def test_search_issues | 48 def test_search_issues |
49 get :index, :q => 'issue', :issues => 1 | 49 get :index, :q => 'issue', :issues => 1 |
50 assert_response :success | 50 assert_response :success |
51 assert_template 'index' | 51 assert_template 'index' |
52 | 52 |
53 assert_equal true, assigns(:all_words) | |
54 assert_equal false, assigns(:titles_only) | |
53 assert assigns(:results).include?(Issue.find(8)) | 55 assert assigns(:results).include?(Issue.find(8)) |
54 assert assigns(:results).include?(Issue.find(5)) | 56 assert assigns(:results).include?(Issue.find(5)) |
55 assert_tag :dt, :attributes => { :class => /issue closed/ }, | 57 assert_tag :dt, :attributes => { :class => /issue closed/ }, |
56 :child => { :tag => 'a', :content => /Closed/ } | 58 :child => { :tag => 'a', :content => /Closed/ } |
57 end | 59 end |
58 | 60 |
59 def test_search_project_and_subprojects | 61 def test_search_project_and_subprojects |
60 get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :submit => 'Search' | 62 get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => '' |
61 assert_response :success | 63 assert_response :success |
62 assert_template 'index' | 64 assert_template 'index' |
63 assert assigns(:results).include?(Issue.find(1)) | 65 assert assigns(:results).include?(Issue.find(1)) |
64 assert assigns(:results).include?(Issue.find(5)) | 66 assert assigns(:results).include?(Issue.find(5)) |
65 end | 67 end |
86 assert results.include?(Issue.find(7)) | 88 assert results.include?(Issue.find(7)) |
87 end | 89 end |
88 | 90 |
89 def test_search_all_words | 91 def test_search_all_words |
90 # 'all words' is on by default | 92 # 'all words' is on by default |
91 get :index, :id => 1, :q => 'recipe updating saving' | 93 get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1' |
94 assert_equal true, assigns(:all_words) | |
92 results = assigns(:results) | 95 results = assigns(:results) |
93 assert_not_nil results | 96 assert_not_nil results |
94 assert_equal 1, results.size | 97 assert_equal 1, results.size |
95 assert results.include?(Issue.find(3)) | 98 assert results.include?(Issue.find(3)) |
96 end | 99 end |
97 | 100 |
98 def test_search_one_of_the_words | 101 def test_search_one_of_the_words |
99 get :index, :id => 1, :q => 'recipe updating saving', :submit => 'Search' | 102 get :index, :id => 1, :q => 'recipe updating saving', :all_words => '' |
103 assert_equal false, assigns(:all_words) | |
100 results = assigns(:results) | 104 results = assigns(:results) |
101 assert_not_nil results | 105 assert_not_nil results |
102 assert_equal 3, results.size | 106 assert_equal 3, results.size |
103 assert results.include?(Issue.find(3)) | 107 assert results.include?(Issue.find(3)) |
104 end | 108 end |
105 | 109 |
106 def test_search_titles_only_without_result | 110 def test_search_titles_only_without_result |
107 get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1', :titles_only => '1', :submit => 'Search' | 111 get :index, :id => 1, :q => 'recipe updating saving', :titles_only => '1' |
108 results = assigns(:results) | 112 results = assigns(:results) |
109 assert_not_nil results | 113 assert_not_nil results |
110 assert_equal 0, results.size | 114 assert_equal 0, results.size |
111 end | 115 end |
112 | 116 |
113 def test_search_titles_only | 117 def test_search_titles_only |
114 get :index, :id => 1, :q => 'recipe', :titles_only => '1', :submit => 'Search' | 118 get :index, :id => 1, :q => 'recipe', :titles_only => '1' |
119 assert_equal true, assigns(:titles_only) | |
115 results = assigns(:results) | 120 results = assigns(:results) |
116 assert_not_nil results | 121 assert_not_nil results |
117 assert_equal 2, results.size | 122 assert_equal 2, results.size |
123 end | |
124 | |
125 def test_search_content | |
126 Issue.update_all("description = 'This is a searchkeywordinthecontent'", "id=1") | |
127 | |
128 get :index, :id => 1, :q => 'searchkeywordinthecontent', :titles_only => '' | |
129 assert_equal false, assigns(:titles_only) | |
130 results = assigns(:results) | |
131 assert_not_nil results | |
132 assert_equal 1, results.size | |
118 end | 133 end |
119 | 134 |
120 def test_search_with_invalid_project_id | 135 def test_search_with_invalid_project_id |
121 get :index, :id => 195, :q => 'recipe' | 136 get :index, :id => 195, :q => 'recipe' |
122 assert_response 404 | 137 assert_response 404 |