summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2024-08-21 08:05:59 +0000
committerGo MAEDA <maeda@farend.jp>2024-08-21 08:05:59 +0000
commit9cc3542fa1277b190a006323a77e22bd7474371c (patch)
treee52ff576fb4335eb565227a3109dee3cdbfc54b4
parent643b4ebb088ce5ed57b6cc959677627a660004cc (diff)
downloadredmine-9cc3542fa1277b190a006323a77e22bd7474371c.tar.gz
redmine-9cc3542fa1277b190a006323a77e22bd7474371c.zip
Introduce `active?` method to Group via Principal model (#27510).
Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@22976 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/principal.rb4
-rw-r--r--app/models/user.rb4
-rw-r--r--test/unit/group_test.rb1
3 files changed, 5 insertions, 4 deletions
diff --git a/app/models/principal.rb b/app/models/principal.rb
index 56da6d9c7..6ea19e60d 100644
--- a/app/models/principal.rb
+++ b/app/models/principal.rb
@@ -136,6 +136,10 @@ class Principal < ApplicationRecord
nil
end
+ def active?
+ self.status == STATUS_ACTIVE
+ end
+
def visible?(user=User.current)
Principal.visible(user).find_by(:id => id) == self
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 0294e7d21..c3f183fc7 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -273,10 +273,6 @@ class User < Principal
end
end
- def active?
- self.status == STATUS_ACTIVE
- end
-
def registered?
self.status == STATUS_REGISTERED
end
diff --git a/test/unit/group_test.rb b/test/unit/group_test.rb
index 0e5288f1b..59923927c 100644
--- a/test/unit/group_test.rb
+++ b/test/unit/group_test.rb
@@ -38,6 +38,7 @@ class GroupTest < ActiveSupport::TestCase
assert g.save
g.reload
assert_equal 'New group', g.name
+ assert_equal true, g.active?
end
def test_name_should_accept_255_characters