diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-11-28 09:31:56 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-11-28 09:31:56 +0000 |
commit | 4d2688e7a8b95a28c12f61b7d4ce8db6551283e8 (patch) | |
tree | d348eed57fb3bd7ace7796e4ed1a51165c420372 /test | |
parent | 86d8acb3446321a7d891b83bf73ecce27c20f849 (diff) | |
download | redmine-4d2688e7a8b95a28c12f61b7d4ce8db6551283e8.tar.gz redmine-4d2688e7a8b95a28c12f61b7d4ce8db6551283e8.zip |
Group filters in the filter select list (#13849).
git-svn-id: http://svn.redmine.org/redmine/trunk@13662 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/helpers/queries_helper_test.rb | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/test/unit/helpers/queries_helper_test.rb b/test/unit/helpers/queries_helper_test.rb index db492be6e..37aa5fd4f 100644 --- a/test/unit/helpers/queries_helper_test.rb +++ b/test/unit/helpers/queries_helper_test.rb @@ -29,12 +29,55 @@ class QueriesHelperTest < ActionView::TestCase :projects_trackers, :custom_fields_trackers - def test_filters_options_has_empty_item - query = IssueQuery.new - filter_count = query.available_filters.size - fo = filters_options(query) - assert_equal filter_count + 1, fo.size - assert_equal [], fo[0] + def test_filters_options_for_select_should_have_a_blank_option + options = filters_options_for_select(IssueQuery.new) + assert_select_in options, 'option[value=""]' + end + + def test_filters_options_for_select_should_not_group_regular_filters + with_locale 'en' do + options = filters_options_for_select(IssueQuery.new) + assert_select_in options, 'option[value=status_id]:root' + assert_select_in options, 'option[value=status_id]', :text => 'Status' + end + end + + def test_filters_options_for_select_should_group_date_filters + with_locale 'en' do + options = filters_options_for_select(IssueQuery.new) + assert_select_in options, 'optgroup[label=?]', 'Date', 1 + assert_select_in options, 'optgroup > option[value=due_date]', :text => 'Due date' + end + end + + def test_filters_options_for_select_should_not_group_only_one_date_filter + with_locale 'en' do + options = filters_options_for_select(TimeEntryQuery.new) + assert_select_in options, 'optgroup[label=?]', 'Date', 0 + assert_select_in options, 'option[value=spent_on]:root', :text => 'Date' + end + end + + def test_filters_options_for_select_should_group_relations_filters + with_locale 'en' do + options = filters_options_for_select(IssueQuery.new) + assert_select_in options, 'optgroup[label=?]', 'Related issues', 1 + assert_select_in options, 'optgroup[label=?] > option', 'Related issues', 9 + assert_select_in options, 'optgroup > option[value=relates]', :text => 'Related to' + end + end + + def test_filters_options_for_select_should_group_associations_filters + CustomField.delete_all + cf1 = ProjectCustomField.create!(:name => 'Foo', :field_format => 'string', :is_filter => true) + cf2 = ProjectCustomField.create!(:name => 'Bar', :field_format => 'string', :is_filter => true) + + with_locale 'en' do + options = filters_options_for_select(IssueQuery.new) + assert_select_in options, 'optgroup[label=?]', 'Project', 1 + assert_select_in options, 'optgroup[label=?] > option', 'Project', 2 + assert_select_in options, 'optgroup > option[value=?]', "project.cf_#{cf1.id}", :text => "Project's Foo" + end end def test_query_to_csv_should_translate_boolean_custom_field_values |