]> source.dussan.org Git - redmine.git/commitdiff
Merge r21965 from trunk to 5.0-stable (#37925).
authorMarius Balteanu <marius.balteanu@zitec.com>
Tue, 29 Nov 2022 07:15:53 +0000 (07:15 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Tue, 29 Nov 2022 07:15:53 +0000 (07:15 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@21968 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 8f1a0cee35db2314f6f1d5e9ae90cc33214e0b17..0ece369f07ee6a589f1f4a1b40e814bb35474d78 100644 (file)
@@ -1064,7 +1064,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 4d6650ee8181da83f1c3b7d7a9fb6d9f2fc4fb21..20c7ebb755426fef2823f537b9f984d26a96a451 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