"Fossies" - the Fresh Open Source Software Archive

Member "redmine-4.1.1/test/unit/project_query_test.rb" (6 Apr 2020, 2175 Bytes) of package /linux/www/redmine-4.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "project_query_test.rb": 4.1.0_vs_4.1.1.

    1 # frozen_string_literal: true
    2 
    3 # Redmine - project management software
    4 # Copyright (C) 2006-2017  Jean-Philippe Lang
    5 #
    6 # This program is free software; you can redistribute it and/or
    7 # modify it under the terms of the GNU General Public License
    8 # as published by the Free Software Foundation; either version 2
    9 # of the License, or (at your option) any later version.
   10 #
   11 # This program is distributed in the hope that it will be useful,
   12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14 # GNU General Public License for more details.
   15 #
   16 # You should have received a copy of the GNU General Public License
   17 # along with this program; if not, write to the Free Software
   18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   19 
   20 require File.expand_path('../../test_helper', __FILE__)
   21 
   22 class ProjectQueryTest < ActiveSupport::TestCase
   23   fixtures :projects, :users,
   24            :members, :roles, :member_roles,
   25            :issue_categories, :enumerations,
   26            :groups_users,
   27            :enabled_modules,
   28            :custom_fields, :custom_values
   29 
   30   include Redmine::I18n
   31 
   32   def test_filter_values_be_arrays
   33     q = ProjectQuery.new
   34     assert_nil q.project
   35 
   36     q.available_filters.each do |name, filter|
   37       values = filter.values
   38       assert (values.nil? || values.is_a?(Array)),
   39              "#values for #{name} filter returned a #{values.class.name}"
   40     end
   41   end
   42 
   43   def test_project_statuses_filter_should_return_project_statuses
   44     set_language_if_valid 'en'
   45     query = ProjectQuery.new(:name => '_')
   46     query.filters = {'status' => {:operator => '=', :values => []}}
   47     values = query.available_filters['status'][:values]
   48     assert_equal ['active', 'closed'], values.map(&:first)
   49     assert_equal ['1', '5'], values.map(&:second)
   50   end
   51 
   52   def test_default_columns
   53     q = ProjectQuery.new
   54     assert q.columns.any?
   55     assert q.inline_columns.any?
   56     assert q.block_columns.empty?
   57   end
   58 
   59   def test_available_columns_should_include_project_custom_fields
   60     query = ProjectQuery.new
   61     assert_include :cf_3, query.available_columns.map(&:name)
   62   end
   63 end