From 002d065fe823523b49cd595699d01b24706ac426 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Tue, 30 Apr 2019 03:29:50 +0000 Subject: [PATCH] Merged r18103 from trunk to 4.0-stable (#31276). git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@18104 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 552b9faad..03e2d363b 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -401,6 +401,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 5e2a7ea41..b1a7002db 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -2229,4 +2229,19 @@ class QueryTest < ActiveSupport::TestCase assert_equal [["active", "1"], ["closed", "5"]], project_status_filter[:values] 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