Patch #31276 » 0001-changes-Query-as_params-for-more-complete-serializat.patch
app/models/query.rb | ||
---|---|---|
426 | 426 |
params[:v][field] = options[:values] |
427 | 427 |
end |
428 | 428 |
params[:c] = column_names |
429 |
params[:group_by] = group_by.to_s if group_by.present? |
|
430 |
params[:t] = totalable_names.map(&:to_s) if totalable_names.any? |
|
429 | 431 |
params[:sort] = sort_criteria.to_param |
430 | 432 |
params[:set_filter] = 1 |
431 | 433 |
params |
test/unit/query_test.rb | ||
---|---|---|
2295 | 2295 | |
2296 | 2296 |
assert_equal [["active", "1"], ["closed", "5"]], project_status_filter[:values] |
2297 | 2297 |
end |
2298 | ||
2299 |
def test_as_params_should_serialize_query |
|
2300 |
query = IssueQuery.new(name: "_") |
|
2301 |
query.add_filter('subject', '!~', ['asdf']) |
|
2302 |
query.group_by = 'tracker' |
|
2303 |
query.totalable_names = %w(estimated_hours) |
|
2304 |
query.column_names = %w(id subject estimated_hours) |
|
2305 |
assert hsh = query.as_params |
|
2306 | ||
2307 |
new_query = IssueQuery.build_from_params(hsh) |
|
2308 |
assert_equal query.filters, new_query.filters |
|
2309 |
assert_equal query.group_by, new_query.group_by |
|
2310 |
assert_equal query.column_names, new_query.column_names |
|
2311 |
assert_equal query.totalable_names, new_query.totalable_names |
|
2312 |
end |
|
2298 | 2313 |
end |