Commit 63866407 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Fixed: unchecking status filter on the issue list has no effect (#6844).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4387 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 2ca9bb3c
...@@ -78,10 +78,9 @@ module QueriesHelper ...@@ -78,10 +78,9 @@ module QueriesHelper
# Give it a name, required to be valid # Give it a name, required to be valid
@query = Query.new(:name => "_") @query = Query.new(:name => "_")
@query.project = @project @query.project = @project
if params[:fields] and params[:fields].is_a? Array if params[:fields]
params[:fields].each do |field| @query.filters = {}
@query.add_filter(field, params[:operators][field], params[:values][field]) @query.add_filters(params[:fields], params[:operators], params[:values])
end
else else
@query.available_filters.keys.each do |field| @query.available_filters.keys.each do |field|
@query.add_short_filter(field, params[field]) if params[field] @query.add_short_filter(field, params[field]) if params[field]
......
...@@ -258,8 +258,10 @@ class Query < ActiveRecord::Base ...@@ -258,8 +258,10 @@ class Query < ActiveRecord::Base
# Add multiple filters using +add_filter+ # Add multiple filters using +add_filter+
def add_filters(fields, operators, values) def add_filters(fields, operators, values)
fields.each do |field| if fields.is_a?(Array) && operators.is_a?(Hash) && values.is_a?(Hash)
add_filter(field, operators[field], values[field]) fields.each do |field|
add_filter(field, operators[field], values[field])
end
end end
end end
......
...@@ -114,3 +114,4 @@ Event.observe(document,"dom:loaded", apply_filters_observer); ...@@ -114,3 +114,4 @@ Event.observe(document,"dom:loaded", apply_filters_observer);
</td> </td>
</tr> </tr>
</table> </table>
<%= hidden_field_tag 'fields[]', '' %>
...@@ -125,11 +125,42 @@ class IssuesControllerTest < ActionController::TestCase ...@@ -125,11 +125,42 @@ class IssuesControllerTest < ActionController::TestCase
assert_tag :tag => 'a', :content => /Issue of a private subproject/ assert_tag :tag => 'a', :content => /Issue of a private subproject/
end end
def test_index_with_project_and_filter def test_index_with_project_and_default_filter
get :index, :project_id => 1, :set_filter => 1 get :index, :project_id => 1, :set_filter => 1
assert_response :success assert_response :success
assert_template 'index.rhtml' assert_template 'index.rhtml'
assert_not_nil assigns(:issues) assert_not_nil assigns(:issues)
query = assigns(:query)
assert_not_nil query
# default filter
assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters)
end
def test_index_with_project_and_filter
get :index, :project_id => 1, :set_filter => 1,
:fields => ['tracker_id'],
:operators => {'tracker_id' => '='},
:values => {'tracker_id' => ['1']}
assert_response :success
assert_template 'index.rhtml'
assert_not_nil assigns(:issues)
query = assigns(:query)
assert_not_nil query
assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters)
end
def test_index_with_project_and_empty_filters
get :index, :project_id => 1, :set_filter => 1, :fields => ['']
assert_response :success
assert_template 'index.rhtml'
assert_not_nil assigns(:issues)
query = assigns(:query)
assert_not_nil query
# no filter
assert_equal({}, query.filters)
end end
def test_index_with_query def test_index_with_query
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment