From 54909632237a9868475c0c46b8b9fd8aac766c46 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Tue, 30 Apr 2019 03:33:17 +0000 Subject: [PATCH] Merged r18103 from trunk to 3.4-stable (#31276). git-svn-id: http://svn.redmine.org/redmine/branches/3.4-stable@18105 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/query.rb | 2 ++ test/unit/query_test.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/models/query.rb b/app/models/query.rb index c8fc7789c..bfa010de6 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -399,6 +399,8 @@ class Query < ActiveRecord::Base params[:v][field] = options[:values] end params[:c] = column_names + params[:group_by] = group_by.to_s if group_by.present? + params[:t] = totalable_names.map(&:to_s) if totalable_names.any? params[:sort] = sort_criteria.to_param params[:set_filter] = 1 params diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index c7c8e97f7..508922ff3 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -2162,4 +2162,19 @@ class QueryTest < ActiveSupport::TestCase assert_equal ['1','2','3','4','5','6'], query.available_filters['status_id'][:values].map(&:second) end + + def test_as_params_should_serialize_query + query = IssueQuery.new(name: "_") + query.add_filter('subject', '!~', ['asdf']) + query.group_by = 'tracker' + query.totalable_names = %w(estimated_hours) + query.column_names = %w(id subject estimated_hours) + assert hsh = query.as_params + + new_query = IssueQuery.build_from_params(hsh) + assert_equal query.filters, new_query.filters + assert_equal query.group_by, new_query.group_by + assert_equal query.column_names, new_query.column_names + assert_equal query.totalable_names, new_query.totalable_names + end end -- 2.39.5