@@ -1,103 +1,103 | |||||
1 | --- |
|
1 | --- | |
2 | custom_values_006: |
|
2 | custom_values_006: | |
3 | customized_type: Issue |
|
3 | customized_type: Issue | |
4 | custom_field_id: 2 |
|
4 | custom_field_id: 2 | |
5 | customized_id: 3 |
|
5 | customized_id: 3 | |
6 | id: 6 |
|
6 | id: 6 | |
7 | value: "125" |
|
7 | value: "125" | |
8 | custom_values_007: |
|
8 | custom_values_007: | |
9 | customized_type: Project |
|
9 | customized_type: Project | |
10 | custom_field_id: 3 |
|
10 | custom_field_id: 3 | |
11 | customized_id: 1 |
|
11 | customized_id: 1 | |
12 | id: 7 |
|
12 | id: 7 | |
13 | value: Stable |
|
13 | value: Stable | |
14 | custom_values_001: |
|
14 | custom_values_001: | |
15 | customized_type: Principal |
|
15 | customized_type: Principal | |
16 | custom_field_id: 4 |
|
16 | custom_field_id: 4 | |
17 | customized_id: 3 |
|
17 | customized_id: 3 | |
18 | id: 1 |
|
18 | id: 1 | |
19 | value: "" |
|
19 | value: "" | |
20 | custom_values_002: |
|
20 | custom_values_002: | |
21 | customized_type: Principal |
|
21 | customized_type: Principal | |
22 | custom_field_id: 4 |
|
22 | custom_field_id: 4 | |
23 | customized_id: 4 |
|
23 | customized_id: 4 | |
24 | id: 2 |
|
24 | id: 2 | |
25 | value: 01 23 45 67 89 |
|
25 | value: 01 23 45 67 89 | |
26 | custom_values_003: |
|
26 | custom_values_003: | |
27 | customized_type: Principal |
|
27 | customized_type: Principal | |
28 | custom_field_id: 4 |
|
28 | custom_field_id: 4 | |
29 | customized_id: 2 |
|
29 | customized_id: 2 | |
30 | id: 3 |
|
30 | id: 3 | |
31 | value: "01 42 50 00 00" |
|
31 | value: "01 42 50 00 00" | |
32 | custom_values_004: |
|
32 | custom_values_004: | |
33 | customized_type: Issue |
|
33 | customized_type: Issue | |
34 | custom_field_id: 2 |
|
34 | custom_field_id: 2 | |
35 | customized_id: 1 |
|
35 | customized_id: 1 | |
36 | id: 4 |
|
36 | id: 4 | |
37 | value: "125" |
|
37 | value: "125" | |
38 | custom_values_005: |
|
38 | custom_values_005: | |
39 | customized_type: Issue |
|
39 | customized_type: Issue | |
40 | custom_field_id: 2 |
|
40 | custom_field_id: 2 | |
41 | customized_id: 2 |
|
41 | customized_id: 2 | |
42 | id: 5 |
|
42 | id: 5 | |
43 | value: "" |
|
43 | value: "" | |
44 | custom_values_008: |
|
44 | custom_values_008: | |
45 | customized_type: Issue |
|
45 | customized_type: Issue | |
46 | custom_field_id: 1 |
|
46 | custom_field_id: 1 | |
47 | customized_id: 3 |
|
47 | customized_id: 3 | |
48 | id: 8 |
|
48 | id: 8 | |
49 | value: "MySQL" |
|
49 | value: "MySQL" | |
50 | custom_values_009: |
|
50 | custom_values_009: | |
51 | customized_type: Issue |
|
51 | customized_type: Issue | |
52 | custom_field_id: 2 |
|
52 | custom_field_id: 2 | |
53 |
customized_id: |
|
53 | customized_id: 7 | |
54 | id: 9 |
|
54 | id: 9 | |
55 | value: "this is a stringforcustomfield search" |
|
55 | value: "this is a stringforcustomfield search" | |
56 | custom_values_010: |
|
56 | custom_values_010: | |
57 | customized_type: Issue |
|
57 | customized_type: Issue | |
58 | custom_field_id: 6 |
|
58 | custom_field_id: 6 | |
59 | customized_id: 1 |
|
59 | customized_id: 1 | |
60 | id: 10 |
|
60 | id: 10 | |
61 | value: "2.1" |
|
61 | value: "2.1" | |
62 | custom_values_011: |
|
62 | custom_values_011: | |
63 | customized_type: Issue |
|
63 | customized_type: Issue | |
64 | custom_field_id: 6 |
|
64 | custom_field_id: 6 | |
65 | customized_id: 2 |
|
65 | customized_id: 2 | |
66 | id: 11 |
|
66 | id: 11 | |
67 | value: "2.05" |
|
67 | value: "2.05" | |
68 | custom_values_012: |
|
68 | custom_values_012: | |
69 | customized_type: Issue |
|
69 | customized_type: Issue | |
70 | custom_field_id: 6 |
|
70 | custom_field_id: 6 | |
71 | customized_id: 3 |
|
71 | customized_id: 3 | |
72 | id: 12 |
|
72 | id: 12 | |
73 | value: "11.65" |
|
73 | value: "11.65" | |
74 | custom_values_013: |
|
74 | custom_values_013: | |
75 | customized_type: Issue |
|
75 | customized_type: Issue | |
76 | custom_field_id: 6 |
|
76 | custom_field_id: 6 | |
77 | customized_id: 7 |
|
77 | customized_id: 7 | |
78 | id: 13 |
|
78 | id: 13 | |
79 | value: "" |
|
79 | value: "" | |
80 | custom_values_014: |
|
80 | custom_values_014: | |
81 | customized_type: Issue |
|
81 | customized_type: Issue | |
82 | custom_field_id: 6 |
|
82 | custom_field_id: 6 | |
83 | customized_id: 5 |
|
83 | customized_id: 5 | |
84 | id: 14 |
|
84 | id: 14 | |
85 | value: "-7.6" |
|
85 | value: "-7.6" | |
86 | custom_values_015: |
|
86 | custom_values_015: | |
87 | customized_type: Enumeration |
|
87 | customized_type: Enumeration | |
88 | custom_field_id: 7 |
|
88 | custom_field_id: 7 | |
89 | customized_id: 10 |
|
89 | customized_id: 10 | |
90 | id: 15 |
|
90 | id: 15 | |
91 | value: true |
|
91 | value: true | |
92 | custom_values_016: |
|
92 | custom_values_016: | |
93 | customized_type: Enumeration |
|
93 | customized_type: Enumeration | |
94 | custom_field_id: 7 |
|
94 | custom_field_id: 7 | |
95 | customized_id: 11 |
|
95 | customized_id: 11 | |
96 | id: 16 |
|
96 | id: 16 | |
97 | value: '1' |
|
97 | value: '1' | |
98 | custom_values_017: |
|
98 | custom_values_017: | |
99 | customized_type: Issue |
|
99 | customized_type: Issue | |
100 | custom_field_id: 8 |
|
100 | custom_field_id: 8 | |
101 | customized_id: 1 |
|
101 | customized_id: 1 | |
102 | id: 17 |
|
102 | id: 17 | |
103 | value: '2009-12-01' |
|
103 | value: '2009-12-01' |
@@ -1,147 +1,147 | |||||
1 | require File.dirname(__FILE__) + '/../test_helper' |
|
1 | require File.dirname(__FILE__) + '/../test_helper' | |
2 | require 'search_controller' |
|
2 | require 'search_controller' | |
3 |
|
3 | |||
4 | # Re-raise errors caught by the controller. |
|
4 | # Re-raise errors caught by the controller. | |
5 | class SearchController; def rescue_action(e) raise e end; end |
|
5 | class SearchController; def rescue_action(e) raise e end; end | |
6 |
|
6 | |||
7 | class SearchControllerTest < ActionController::TestCase |
|
7 | class SearchControllerTest < ActionController::TestCase | |
8 | fixtures :projects, :enabled_modules, :roles, :users, :members, :member_roles, |
|
8 | fixtures :projects, :enabled_modules, :roles, :users, :members, :member_roles, | |
9 | :issues, :trackers, :issue_statuses, |
|
9 | :issues, :trackers, :issue_statuses, | |
10 | :custom_fields, :custom_values, |
|
10 | :custom_fields, :custom_values, | |
11 | :repositories, :changesets |
|
11 | :repositories, :changesets | |
12 |
|
12 | |||
13 | def setup |
|
13 | def setup | |
14 | @controller = SearchController.new |
|
14 | @controller = SearchController.new | |
15 | @request = ActionController::TestRequest.new |
|
15 | @request = ActionController::TestRequest.new | |
16 | @response = ActionController::TestResponse.new |
|
16 | @response = ActionController::TestResponse.new | |
17 | User.current = nil |
|
17 | User.current = nil | |
18 | end |
|
18 | end | |
19 |
|
19 | |||
20 | def test_search_for_projects |
|
20 | def test_search_for_projects | |
21 | get :index |
|
21 | get :index | |
22 | assert_response :success |
|
22 | assert_response :success | |
23 | assert_template 'index' |
|
23 | assert_template 'index' | |
24 |
|
24 | |||
25 | get :index, :q => "cook" |
|
25 | get :index, :q => "cook" | |
26 | assert_response :success |
|
26 | assert_response :success | |
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', :submit => 'Search' | |
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)) | |
38 | assert assigns(:results).include?(Changeset.find(101)) |
|
38 | assert assigns(:results).include?(Changeset.find(101)) | |
39 | assert_tag :dt, :attributes => { :class => /issue/ }, |
|
39 | assert_tag :dt, :attributes => { :class => /issue/ }, | |
40 | :child => { :tag => 'a', :content => /Add ingredients categories/ }, |
|
40 | :child => { :tag => 'a', :content => /Add ingredients categories/ }, | |
41 | :sibling => { :tag => 'dd', :content => /should be classified by categories/ } |
|
41 | :sibling => { :tag => 'dd', :content => /should be classified by categories/ } | |
42 |
|
42 | |||
43 | assert assigns(:results_by_type).is_a?(Hash) |
|
43 | assert assigns(:results_by_type).is_a?(Hash) | |
44 | assert_equal 5, assigns(:results_by_type)['changesets'] |
|
44 | assert_equal 5, assigns(:results_by_type)['changesets'] | |
45 | assert_tag :a, :content => 'Changesets (5)' |
|
45 | assert_tag :a, :content => 'Changesets (5)' | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
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 assigns(:results).include?(Issue.find(8)) |
|
53 | assert assigns(:results).include?(Issue.find(8)) | |
54 | assert assigns(:results).include?(Issue.find(5)) |
|
54 | assert assigns(:results).include?(Issue.find(5)) | |
55 | assert_tag :dt, :attributes => { :class => /issue closed/ }, |
|
55 | assert_tag :dt, :attributes => { :class => /issue closed/ }, | |
56 | :child => { :tag => 'a', :content => /Closed/ } |
|
56 | :child => { :tag => 'a', :content => /Closed/ } | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
59 | def test_search_project_and_subprojects |
|
59 | def test_search_project_and_subprojects | |
60 | get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :submit => 'Search' |
|
60 | get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :submit => 'Search' | |
61 | assert_response :success |
|
61 | assert_response :success | |
62 | assert_template 'index' |
|
62 | assert_template 'index' | |
63 | assert assigns(:results).include?(Issue.find(1)) |
|
63 | assert assigns(:results).include?(Issue.find(1)) | |
64 | assert assigns(:results).include?(Issue.find(5)) |
|
64 | assert assigns(:results).include?(Issue.find(5)) | |
65 | end |
|
65 | end | |
66 |
|
66 | |||
67 | def test_search_without_searchable_custom_fields |
|
67 | def test_search_without_searchable_custom_fields | |
68 | CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}" |
|
68 | CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}" | |
69 |
|
69 | |||
70 | get :index, :id => 1 |
|
70 | get :index, :id => 1 | |
71 | assert_response :success |
|
71 | assert_response :success | |
72 | assert_template 'index' |
|
72 | assert_template 'index' | |
73 | assert_not_nil assigns(:project) |
|
73 | assert_not_nil assigns(:project) | |
74 |
|
74 | |||
75 | get :index, :id => 1, :q => "can" |
|
75 | get :index, :id => 1, :q => "can" | |
76 | assert_response :success |
|
76 | assert_response :success | |
77 | assert_template 'index' |
|
77 | assert_template 'index' | |
78 | end |
|
78 | end | |
79 |
|
79 | |||
80 | def test_search_with_searchable_custom_fields |
|
80 | def test_search_with_searchable_custom_fields | |
81 | get :index, :id => 1, :q => "stringforcustomfield" |
|
81 | get :index, :id => 1, :q => "stringforcustomfield" | |
82 | assert_response :success |
|
82 | assert_response :success | |
83 | results = assigns(:results) |
|
83 | results = assigns(:results) | |
84 | assert_not_nil results |
|
84 | assert_not_nil results | |
85 | assert_equal 1, results.size |
|
85 | assert_equal 1, results.size | |
86 |
assert results.include?(Issue.find( |
|
86 | assert results.include?(Issue.find(7)) | |
87 | end |
|
87 | end | |
88 |
|
88 | |||
89 | def test_search_all_words |
|
89 | def test_search_all_words | |
90 | # 'all words' is on by default |
|
90 | # 'all words' is on by default | |
91 | get :index, :id => 1, :q => 'recipe updating saving' |
|
91 | get :index, :id => 1, :q => 'recipe updating saving' | |
92 | results = assigns(:results) |
|
92 | results = assigns(:results) | |
93 | assert_not_nil results |
|
93 | assert_not_nil results | |
94 | assert_equal 1, results.size |
|
94 | assert_equal 1, results.size | |
95 | assert results.include?(Issue.find(3)) |
|
95 | assert results.include?(Issue.find(3)) | |
96 | end |
|
96 | end | |
97 |
|
97 | |||
98 | def test_search_one_of_the_words |
|
98 | def test_search_one_of_the_words | |
99 | get :index, :id => 1, :q => 'recipe updating saving', :submit => 'Search' |
|
99 | get :index, :id => 1, :q => 'recipe updating saving', :submit => 'Search' | |
100 | results = assigns(:results) |
|
100 | results = assigns(:results) | |
101 | assert_not_nil results |
|
101 | assert_not_nil results | |
102 | assert_equal 3, results.size |
|
102 | assert_equal 3, results.size | |
103 | assert results.include?(Issue.find(3)) |
|
103 | assert results.include?(Issue.find(3)) | |
104 | end |
|
104 | end | |
105 |
|
105 | |||
106 | def test_search_titles_only_without_result |
|
106 | def test_search_titles_only_without_result | |
107 | get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1', :titles_only => '1', :submit => 'Search' |
|
107 | get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1', :titles_only => '1', :submit => 'Search' | |
108 | results = assigns(:results) |
|
108 | results = assigns(:results) | |
109 | assert_not_nil results |
|
109 | assert_not_nil results | |
110 | assert_equal 0, results.size |
|
110 | assert_equal 0, results.size | |
111 | end |
|
111 | end | |
112 |
|
112 | |||
113 | def test_search_titles_only |
|
113 | def test_search_titles_only | |
114 | get :index, :id => 1, :q => 'recipe', :titles_only => '1', :submit => 'Search' |
|
114 | get :index, :id => 1, :q => 'recipe', :titles_only => '1', :submit => 'Search' | |
115 | results = assigns(:results) |
|
115 | results = assigns(:results) | |
116 | assert_not_nil results |
|
116 | assert_not_nil results | |
117 | assert_equal 2, results.size |
|
117 | assert_equal 2, results.size | |
118 | end |
|
118 | end | |
119 |
|
119 | |||
120 | def test_search_with_invalid_project_id |
|
120 | def test_search_with_invalid_project_id | |
121 | get :index, :id => 195, :q => 'recipe' |
|
121 | get :index, :id => 195, :q => 'recipe' | |
122 | assert_response 404 |
|
122 | assert_response 404 | |
123 | assert_nil assigns(:results) |
|
123 | assert_nil assigns(:results) | |
124 | end |
|
124 | end | |
125 |
|
125 | |||
126 | def test_quick_jump_to_issue |
|
126 | def test_quick_jump_to_issue | |
127 | # issue of a public project |
|
127 | # issue of a public project | |
128 | get :index, :q => "3" |
|
128 | get :index, :q => "3" | |
129 | assert_redirected_to '/issues/3' |
|
129 | assert_redirected_to '/issues/3' | |
130 |
|
130 | |||
131 | # issue of a private project |
|
131 | # issue of a private project | |
132 | get :index, :q => "4" |
|
132 | get :index, :q => "4" | |
133 | assert_response :success |
|
133 | assert_response :success | |
134 | assert_template 'index' |
|
134 | assert_template 'index' | |
135 | end |
|
135 | end | |
136 |
|
136 | |||
137 | def test_large_integer |
|
137 | def test_large_integer | |
138 | get :index, :q => '4615713488' |
|
138 | get :index, :q => '4615713488' | |
139 | assert_response :success |
|
139 | assert_response :success | |
140 | assert_template 'index' |
|
140 | assert_template 'index' | |
141 | end |
|
141 | end | |
142 |
|
142 | |||
143 | def test_tokens_with_quotes |
|
143 | def test_tokens_with_quotes | |
144 | get :index, :id => 1, :q => '"good bye" hello "bye bye"' |
|
144 | get :index, :id => 1, :q => '"good bye" hello "bye bye"' | |
145 | assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens) |
|
145 | assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens) | |
146 | end |
|
146 | end | |
147 | end |
|
147 | end |
General Comments 0
You need to be logged in to leave comments.
Login now