##// END OF EJS Templates
Makes autocomplete accept issue id with hash....
Jean-Philippe Lang -
r11062:f29ced77a776
parent child
Show More
@@ -1,84 +1,91
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class AutoCompletesControllerTest < ActionController::TestCase
20 class AutoCompletesControllerTest < ActionController::TestCase
21 fixtures :projects, :issues, :issue_statuses,
21 fixtures :projects, :issues, :issue_statuses,
22 :enumerations, :users, :issue_categories,
22 :enumerations, :users, :issue_categories,
23 :trackers,
23 :trackers,
24 :projects_trackers,
24 :projects_trackers,
25 :roles,
25 :roles,
26 :member_roles,
26 :member_roles,
27 :members,
27 :members,
28 :enabled_modules,
28 :enabled_modules,
29 :workflows,
29 :workflows,
30 :journals, :journal_details
30 :journals, :journal_details
31
31
32 def test_issues_should_not_be_case_sensitive
32 def test_issues_should_not_be_case_sensitive
33 get :issues, :project_id => 'ecookbook', :q => 'ReCiPe'
33 get :issues, :project_id => 'ecookbook', :q => 'ReCiPe'
34 assert_response :success
34 assert_response :success
35 assert_not_nil assigns(:issues)
35 assert_not_nil assigns(:issues)
36 assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
36 assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
37 end
37 end
38
38
39 def test_issues_should_accept_term_param
39 def test_issues_should_accept_term_param
40 get :issues, :project_id => 'ecookbook', :term => 'ReCiPe'
40 get :issues, :project_id => 'ecookbook', :term => 'ReCiPe'
41 assert_response :success
41 assert_response :success
42 assert_not_nil assigns(:issues)
42 assert_not_nil assigns(:issues)
43 assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
43 assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
44 end
44 end
45
45
46 def test_issues_should_return_issue_with_given_id
46 def test_issues_should_return_issue_with_given_id
47 get :issues, :project_id => 'subproject1', :q => '13'
47 get :issues, :project_id => 'subproject1', :q => '13'
48 assert_response :success
48 assert_response :success
49 assert_not_nil assigns(:issues)
49 assert_not_nil assigns(:issues)
50 assert assigns(:issues).include?(Issue.find(13))
50 assert assigns(:issues).include?(Issue.find(13))
51 end
51 end
52
52
53 def test_issues_should_return_issue_with_given_id_preceded_with_hash
54 get :issues, :project_id => 'subproject1', :q => '#13'
55 assert_response :success
56 assert_not_nil assigns(:issues)
57 assert assigns(:issues).include?(Issue.find(13))
58 end
59
53 def test_auto_complete_with_scope_all_should_search_other_projects
60 def test_auto_complete_with_scope_all_should_search_other_projects
54 get :issues, :project_id => 'ecookbook', :q => '13', :scope => 'all'
61 get :issues, :project_id => 'ecookbook', :q => '13', :scope => 'all'
55 assert_response :success
62 assert_response :success
56 assert_not_nil assigns(:issues)
63 assert_not_nil assigns(:issues)
57 assert assigns(:issues).include?(Issue.find(13))
64 assert assigns(:issues).include?(Issue.find(13))
58 end
65 end
59
66
60 def test_auto_complete_without_project_should_search_all_projects
67 def test_auto_complete_without_project_should_search_all_projects
61 get :issues, :q => '13'
68 get :issues, :q => '13'
62 assert_response :success
69 assert_response :success
63 assert_not_nil assigns(:issues)
70 assert_not_nil assigns(:issues)
64 assert assigns(:issues).include?(Issue.find(13))
71 assert assigns(:issues).include?(Issue.find(13))
65 end
72 end
66
73
67 def test_auto_complete_without_scope_all_should_not_search_other_projects
74 def test_auto_complete_without_scope_all_should_not_search_other_projects
68 get :issues, :project_id => 'ecookbook', :q => '13'
75 get :issues, :project_id => 'ecookbook', :q => '13'
69 assert_response :success
76 assert_response :success
70 assert_equal [], assigns(:issues)
77 assert_equal [], assigns(:issues)
71 end
78 end
72
79
73 def test_issues_should_return_json
80 def test_issues_should_return_json
74 get :issues, :project_id => 'subproject1', :q => '13'
81 get :issues, :project_id => 'subproject1', :q => '13'
75 assert_response :success
82 assert_response :success
76 json = ActiveSupport::JSON.decode(response.body)
83 json = ActiveSupport::JSON.decode(response.body)
77 assert_kind_of Array, json
84 assert_kind_of Array, json
78 issue = json.first
85 issue = json.first
79 assert_kind_of Hash, issue
86 assert_kind_of Hash, issue
80 assert_equal 13, issue['id']
87 assert_equal 13, issue['id']
81 assert_equal 13, issue['value']
88 assert_equal 13, issue['value']
82 assert_equal 'Bug #13: Subproject issue two', issue['label']
89 assert_equal 'Bug #13: Subproject issue two', issue['label']
83 end
90 end
84 end
91 end
General Comments 0
You need to be logged in to leave comments. Login now