summaryrefslogtreecommitdiff
path: root/test/models
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-08-03 00:53:35 +0200
committererdgeist <erdgeist@erdgeist.org>2026-08-03 00:53:35 +0200
commit751261c2ffdc90e93869192555ae0d5e4070ff79 (patch)
tree5023240ca3a10653fe560a259d0e46e6c6a7240f /test/models
parentf2f2b31832ec320889f2178e7e08838723961a14 (diff)
Display stale accounts in users#index
Diffstat (limited to 'test/models')
-rw-r--r--test/models/user_test.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
index 9942385c..62552ee7 100644
--- a/test/models/user_test.rb
+++ b/test/models/user_test.rb
@@ -142,6 +142,51 @@ class UserTest < ActiveSupport::TestCase
142 assert redaktion.may_change_live?(plain) 142 assert redaktion.may_change_live?(plain)
143 assert redaktion.may_change_live?(restricted) 143 assert redaktion.may_change_live?(restricted)
144 end 144 end
145
146 test "amber needs a role to remove, red does not" do
147 now = Time.zone.parse("2026-08-03")
148 roled = users(:redella)
149 plain = users(:quentin)
150
151 [roled, plain].each { |u| u.update_column(:last_login_at, now - 4.years) }
152
153 assert_equal :amber, roled.staleness_tier(now)
154 assert_nil plain.staleness_tier(now)
155
156 [roled, plain].each { |u| u.update_column(:last_login_at, now - 11.years) }
157
158 assert_equal :red, roled.staleness_tier(now)
159 assert_equal :red, plain.staleness_tier(now), "dormant credentials are dormant whatever the roles"
160 end
161
162 test "staleness_tier boundaries" do
163 now = Time.zone.parse("2026-08-03")
164 user = users(:redella)
165
166 user.update_column(:last_login_at, now - 2.years - 11.months)
167 assert_nil user.staleness_tier(now)
168
169 user.update_column(:last_login_at, now - 3.years)
170 assert_equal :amber, user.staleness_tier(now)
171
172 user.update_column(:last_login_at, now - 9.years - 11.months)
173 assert_equal :amber, user.staleness_tier(now)
174
175 user.update_column(:last_login_at, now - 10.years)
176 assert_equal :red, user.staleness_tier(now)
177 end
178
179 test "alumni are exempt, an account that never signed in is not" do
180 now = Time.zone.parse("2026-08-03")
181
182 alufa = users(:alufa)
183 alufa.update_column(:last_login_at, now - 20.years)
184 assert_nil alufa.staleness_tier(now), "alumni are the outcome, not a candidate"
185
186 redella = users(:redella)
187 redella.update_column(:last_login_at, nil)
188 assert_equal :never, redella.staleness_tier(now)
189 end
145 190
146protected 191protected
147 def create_user(options = {}) 192 def create_user(options = {})