2011-10-29 16:19:11 +04:00
|
|
|
#-- encoding: UTF-8
|
2011-05-30 00:11:52 +04:00
|
|
|
#-- copyright
|
|
|
|
# ChiliProject is a project management system.
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# Copyright (C) 2010-2011 the ChiliProject Team
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# See doc/COPYRIGHT.rdoc for more details.
|
|
|
|
#++
|
|
|
|
|
2010-12-13 02:24:34 +03:00
|
|
|
require File.expand_path('../../test_helper', __FILE__)
|
2010-08-17 19:03:58 +04:00
|
|
|
|
|
|
|
class AutoCompletesControllerTest < ActionController::TestCase
|
|
|
|
fixtures :all
|
|
|
|
|
|
|
|
def test_issues_should_not_be_case_sensitive
|
|
|
|
get :issues, :project_id => 'ecookbook', :q => 'ReCiPe'
|
|
|
|
assert_response :success
|
|
|
|
assert_not_nil assigns(:issues)
|
|
|
|
assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
|
|
|
|
end
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2010-08-17 19:03:58 +04:00
|
|
|
def test_issues_should_return_issue_with_given_id
|
|
|
|
get :issues, :project_id => 'subproject1', :q => '13'
|
|
|
|
assert_response :success
|
|
|
|
assert_not_nil assigns(:issues)
|
|
|
|
assert assigns(:issues).include?(Issue.find(13))
|
|
|
|
end
|
2011-03-14 03:11:04 +03:00
|
|
|
|
|
|
|
test 'should return issues matching a given id' do
|
|
|
|
@project = Project.find('subproject1')
|
|
|
|
@issue_21 = Issue.generate_for_project!(@project, :id => 21)
|
2011-05-04 21:01:15 +04:00
|
|
|
@issue_2101 = Issue.generate_for_project!(@project, :id => 2101)
|
|
|
|
@issue_2102 = Issue.generate_for_project!(@project, :id => 2102)
|
|
|
|
@issue_with_subject = Issue.generate_for_project!(@project, :subject => 'This has 21 in the subject')
|
2011-03-14 03:11:04 +03:00
|
|
|
|
2011-05-04 21:01:15 +04:00
|
|
|
get :issues, :project_id => @project.id, :q => '21'
|
2011-03-14 03:11:04 +03:00
|
|
|
|
|
|
|
assert_response :success
|
|
|
|
assert_not_nil assigns(:issues)
|
|
|
|
assert assigns(:issues).include?(@issue_21)
|
2011-05-04 21:01:15 +04:00
|
|
|
assert assigns(:issues).include?(@issue_2101)
|
|
|
|
assert assigns(:issues).include?(@issue_2102)
|
2011-03-14 03:11:04 +03:00
|
|
|
assert assigns(:issues).include?(@issue_with_subject)
|
2011-05-04 21:01:15 +04:00
|
|
|
assert_equal assigns(:issues).size, assigns(:issues).uniq.size, "Issues list includes duplicates"
|
2011-03-14 03:11:04 +03:00
|
|
|
end
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2010-12-12 19:04:28 +03:00
|
|
|
def test_auto_complete_with_scope_all_and_cross_project_relations
|
|
|
|
Setting.cross_project_issue_relations = '1'
|
|
|
|
get :issues, :project_id => 'ecookbook', :q => '13', :scope => 'all'
|
|
|
|
assert_response :success
|
|
|
|
assert_not_nil assigns(:issues)
|
|
|
|
assert assigns(:issues).include?(Issue.find(13))
|
|
|
|
end
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2010-12-12 19:04:28 +03:00
|
|
|
def test_auto_complete_with_scope_all_without_cross_project_relations
|
|
|
|
Setting.cross_project_issue_relations = '0'
|
|
|
|
get :issues, :project_id => 'ecookbook', :q => '13', :scope => 'all'
|
|
|
|
assert_response :success
|
2010-12-12 19:06:43 +03:00
|
|
|
assert_equal [], assigns(:issues)
|
2010-12-12 19:04:28 +03:00
|
|
|
end
|
2010-08-17 19:03:58 +04:00
|
|
|
end
|