]> source.dussan.org Git - redmine.git/commitdiff
Query display types should accept only known types (#37925).
authorMarius Balteanu <marius.balteanu@zitec.com>
Mon, 28 Nov 2022 22:41:53 +0000 (22:41 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Mon, 28 Nov 2022 22:41:53 +0000 (22:41 +0000)
Patch by Alexander Meindl.

git-svn-id: https://svn.redmine.org/redmine/trunk@21965 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/query.rb
test/unit/query_test.rb

index e18b06805b02fe7885f6ae5fa43699da297fa2c3..3313248c4b45003c6d37d618b22bea64688bb650 100644 (file)
@@ -1065,7 +1065,7 @@ class Query < ActiveRecord::Base
   end
 
   def display_type=(type)
-    unless type || self.available_display_types.include?(type)
+    unless type && self.available_display_types.include?(type)
       type = self.available_display_types.first
     end
     options[:display_type] = type
index 1591e985efd5f0adba2847589a34be7d9bbbf675..e4ac5bd6fce0877322f39c527702259b3d344f46 100644 (file)
@@ -2880,4 +2880,18 @@ class QueryTest < ActiveSupport::TestCase
 
     assert_equal 1, query.issue_count
   end
+
+  def test_display_type_should_accept_known_types
+    query = ProjectQuery.new(:name => '_')
+    query.display_type = 'list'
+
+    assert_equal 'list', query.display_type
+  end
+
+  def test_display_type_should_not_accept_unknown_types
+    query = ProjectQuery.new(:name => '_')
+    query.display_type = 'invalid'
+
+    assert_equal 'board', query.display_type
+  end
 end