diff options
Diffstat (limited to 'test/models/user_test.rb')
| -rw-r--r-- | test/models/user_test.rb | 45 |
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 | ||
| 146 | protected | 191 | protected |
| 147 | def create_user(options = {}) | 192 | def create_user(options = {}) |
