summaryrefslogtreecommitdiffstats
path: root/test/unit/issue_priority_test.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-01-21 04:10:11 +0000
committerGo MAEDA <maeda@farend.jp>2020-01-21 04:10:11 +0000
commitd438c89b1a986176bf9fa6e5bb4dab6a1f4ee8e1 (patch)
tree0bd690b42a0d7722b99e5fdfa61d06aad1731502 /test/unit/issue_priority_test.rb
parent006b686499a469fcafbf34bd910332f246c75b48 (diff)
downloadredmine-d438c89b1a986176bf9fa6e5bb4dab6a1f4ee8e1.tar.gz
redmine-d438c89b1a986176bf9fa6e5bb4dab6a1f4ee8e1.zip
Add IssuePriority#high? and #low? helpers (#32628).
Patch by Jan Schulz-Hofen. git-svn-id: http://svn.redmine.org/redmine/trunk@19448 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/issue_priority_test.rb')
-rw-r--r--test/unit/issue_priority_test.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/unit/issue_priority_test.rb b/test/unit/issue_priority_test.rb
index 2fb863ace..592d18f04 100644
--- a/test/unit/issue_priority_test.rb
+++ b/test/unit/issue_priority_test.rb
@@ -90,6 +90,43 @@ class IssuePriorityTest < ActiveSupport::TestCase
assert_equal %w(lowest low2 default high2 highest), IssuePriority.active.to_a.sort.map(&:position_name)
end
+ def test_low_high_helpers
+ IssuePriority.delete_all
+
+ priorities = [1, 2, 3, 4, 5, 6].map {|i| IssuePriority.create!(:name => "P#{i}")}
+
+ middle = IssuePriority.find_by_position(3)
+
+ [1, 2].each do |p|
+ assert IssuePriority.find_by_position(p).low?
+ assert !IssuePriority.find_by_position(p).high?
+ end
+
+ assert !middle.high?
+ assert !middle.low?
+
+ [4, 5, 6].each do |p|
+ assert IssuePriority.find_by_position(p).high?
+ assert !IssuePriority.find_by_position(p).low?
+ end
+
+ default = IssuePriority.find_by_position(5)
+ default.update_attributes is_default: true
+
+ [1, 2, 3, 4].each do |p|
+ assert IssuePriority.find_by_position(p).low?
+ assert !IssuePriority.find_by_position(p).high?
+ end
+
+ assert !default.high?
+ assert !default.low?
+
+ [6].each do |p|
+ assert IssuePriority.find_by_position(p).high?
+ assert !IssuePriority.find_by_position(p).low?
+ end
+ end
+
def test_adding_a_priority_should_update_position_names
priority = IssuePriority.create!(:name => 'New')
assert_equal %w(lowest default high4 high3 high2 highest), IssuePriority.active.to_a.sort.map(&:position_name)