]> source.dussan.org Git - redmine.git/commitdiff
Fixed: unchecking status filter on the issue list has no effect (#6844).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 7 Nov 2010 15:38:51 +0000 (15:38 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 7 Nov 2010 15:38:51 +0000 (15:38 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4387 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/queries_helper.rb
app/models/query.rb
app/views/queries/_filters.rhtml
test/functional/issues_controller_test.rb

index 26be63693ec04d52b7efc14a36e6b3ef7f6c0f1b..e9ab3769f7785815bb6748321525865303dd99e2 100644 (file)
@@ -78,10 +78,9 @@ module QueriesHelper
         # Give it a name, required to be valid
         @query = Query.new(:name => "_")
         @query.project = @project
-        if params[:fields] and params[:fields].is_a? Array
-          params[:fields].each do |field|
-            @query.add_filter(field, params[:operators][field], params[:values][field])
-          end
+        if params[:fields]
+          @query.filters = {}
+          @query.add_filters(params[:fields], params[:operators], params[:values])
         else
           @query.available_filters.keys.each do |field|
             @query.add_short_filter(field, params[field]) if params[field]
index 638cc82264f5eb74568b11d1175dac400347a30f..7c246f9aec7e508eef4c2890097993e7b39edb46 100644 (file)
@@ -258,8 +258,10 @@ class Query < ActiveRecord::Base
 
   # Add multiple filters using +add_filter+
   def add_filters(fields, operators, values)
-    fields.each do |field|
-      add_filter(field, operators[field], values[field])
+    if fields.is_a?(Array) && operators.is_a?(Hash) && values.is_a?(Hash)
+      fields.each do |field|
+        add_filter(field, operators[field], values[field])
+      end
     end
   end
   
index 20640eb8de2fd3052e642c541f003181a16d3a32..29f916eb794ad1fea4e2d608ec304e76854035f5 100644 (file)
@@ -114,3 +114,4 @@ Event.observe(document,"dom:loaded", apply_filters_observer);
 </td>
 </tr>
 </table>
+<%= hidden_field_tag 'fields[]', '' %>
index 1fdff9214d4f640bfe2f8fd16417d17ce651f24a..e81556d5f44d4ca609c12b4a6d628df09c6d8de7 100644 (file)
@@ -125,11 +125,42 @@ class IssuesControllerTest < ActionController::TestCase
     assert_tag :tag => 'a', :content => /Issue of a private subproject/
   end
   
-  def test_index_with_project_and_filter
+  def test_index_with_project_and_default_filter
     get :index, :project_id => 1, :set_filter => 1
     assert_response :success
     assert_template 'index.rhtml'
     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
   
   def test_index_with_query