mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-17 23:37:54 +00:00
Fix user disabling changing activity timestamps, fix nil error (#12943)
This commit is contained in:
parent
b89e6cfe70
commit
71921f6bc3
|
@ -128,9 +128,7 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def disable!
|
def disable!
|
||||||
update!(disabled: true,
|
update!(disabled: true)
|
||||||
last_sign_in_at: current_sign_in_at,
|
|
||||||
current_sign_in_at: nil)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def enable!
|
def enable!
|
||||||
|
@ -301,7 +299,7 @@ class User < ApplicationRecord
|
||||||
arr << [current_sign_in_at, current_sign_in_ip] if current_sign_in_ip.present?
|
arr << [current_sign_in_at, current_sign_in_ip] if current_sign_in_ip.present?
|
||||||
arr << [last_sign_in_at, last_sign_in_ip] if last_sign_in_ip.present?
|
arr << [last_sign_in_at, last_sign_in_ip] if last_sign_in_ip.present?
|
||||||
|
|
||||||
arr.sort_by(&:first).uniq(&:last).reverse!
|
arr.sort_by { |pair| pair.first || Time.now.utc }.uniq(&:last).reverse!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -322,20 +322,7 @@ RSpec.describe User, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'disables user' do
|
it 'disables user' do
|
||||||
expect(user).to have_attributes(disabled: true, current_sign_in_at: nil, last_sign_in_at: current_sign_in_at)
|
expect(user).to have_attributes(disabled: true)
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#disable!' do
|
|
||||||
subject(:user) { Fabricate(:user, disabled: false, current_sign_in_at: current_sign_in_at, last_sign_in_at: nil) }
|
|
||||||
let(:current_sign_in_at) { Time.zone.now }
|
|
||||||
|
|
||||||
before do
|
|
||||||
user.disable!
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'disables user' do
|
|
||||||
expect(user).to have_attributes(disabled: true, current_sign_in_at: nil, last_sign_in_at: current_sign_in_at)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue