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