annotate test/unit/helpers/queries_helper_test.rb @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
rev   line source
Chris@1115 1 # Redmine - project management software
Chris@1295 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
Chris@1115 3 #
Chris@1115 4 # This program is free software; you can redistribute it and/or
Chris@1115 5 # modify it under the terms of the GNU General Public License
Chris@1115 6 # as published by the Free Software Foundation; either version 2
Chris@1115 7 # of the License, or (at your option) any later version.
Chris@1115 8 #
Chris@1115 9 # This program is distributed in the hope that it will be useful,
Chris@1115 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1115 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1115 12 # GNU General Public License for more details.
Chris@1115 13 #
Chris@1115 14 # You should have received a copy of the GNU General Public License
Chris@1115 15 # along with this program; if not, write to the Free Software
Chris@1115 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1115 17
Chris@1115 18 require File.expand_path('../../../test_helper', __FILE__)
Chris@1115 19
Chris@1115 20 class QueriesHelperTest < ActionView::TestCase
Chris@1115 21 include QueriesHelper
Chris@1115 22 include Redmine::I18n
Chris@1115 23
Chris@1115 24 fixtures :projects, :enabled_modules, :users, :members,
Chris@1115 25 :member_roles, :roles, :trackers, :issue_statuses,
Chris@1115 26 :issue_categories, :enumerations, :issues,
Chris@1115 27 :watchers, :custom_fields, :custom_values, :versions,
Chris@1115 28 :queries,
Chris@1115 29 :projects_trackers,
Chris@1115 30 :custom_fields_trackers
Chris@1115 31
Chris@1295 32 def test_filters_options_should_be_ordered
Chris@1295 33 set_language_if_valid 'en'
Chris@1295 34 query = IssueQuery.new
Chris@1295 35 filter_count = query.available_filters.size
Chris@1115 36 fo = filters_options(query)
Chris@1295 37 assert_equal filter_count + 1, fo.size
Chris@1115 38 assert_equal [], fo[0]
Chris@1295 39
Chris@1295 40 expected_order = [
Chris@1295 41 "Status",
Chris@1295 42 "Project",
Chris@1295 43 "Tracker",
Chris@1295 44 "Priority"
Chris@1295 45 ]
Chris@1295 46 assert_equal expected_order, (fo.map(&:first) & expected_order)
Chris@1115 47 end
Chris@1115 48
Chris@1295 49 def test_filters_options_should_be_ordered_with_custom_fields
Chris@1115 50 set_language_if_valid 'en'
Chris@1295 51 field = UserCustomField.create!(
Chris@1115 52 :name => 'order test', :field_format => 'string',
Chris@1115 53 :is_for_all => true, :is_filter => true
Chris@1115 54 )
Chris@1295 55 query = IssueQuery.new
Chris@1295 56 filter_count = query.available_filters.size
Chris@1115 57 fo = filters_options(query)
Chris@1295 58 assert_equal filter_count + 1, fo.size
Chris@1295 59
Chris@1295 60 expected_order = [
Chris@1295 61 "Searchable field",
Chris@1295 62 "Database",
Chris@1295 63 "Project's Development status",
Chris@1295 64 "Author's order test",
Chris@1295 65 "Assignee's order test"
Chris@1295 66 ]
Chris@1295 67 assert_equal expected_order, (fo.map(&:first) & expected_order)
Chris@1115 68 end
Chris@1115 69 end