correct miscellaneous issues with user login history

This commit is contained in:
Bianca Nenciu
2018-09-02 17:24:54 +10:00
committed by Sam
parent 8e70b82baa
commit f5e0356fb2
7 changed files with 73 additions and 26 deletions
+19
View File
@@ -250,6 +250,25 @@ describe UserAuthToken do
end
it "calls before_destroy" do
SiteSetting.verbose_auth_token_logging = true
user = Fabricate(:user)
token = UserAuthToken.generate!(user_id: user.id,
user_agent: "some user agent",
client_ip: "1.1.2.3")
expect(user.user_auth_token_logs.count).to eq(1)
token.destroy
expect(user.user_auth_token_logs.count).to eq(2)
expect(user.user_auth_token_logs.last.action).to eq("destroy")
expect(user.user_auth_token_logs.last.user_agent).to eq("some user agent")
expect(user.user_auth_token_logs.last.client_ip).to eq("1.1.2.3")
end
it "will not mark token unseen when prev and current are the same" do
user = Fabricate(:user)
+20
View File
@@ -3167,4 +3167,24 @@ describe UsersController do
end
end
describe '#revoke_auth_token' do
context 'while logged in' do
before do
sign_in(user)
end
it 'logs user out' do
expect(user.user_auth_tokens.count).to eq(1)
post "/u/#{user.username}/preferences/revoke-auth-token.json"
expect(response.status).to eq(200)
expect(user.user_auth_tokens.count).to eq(0)
end
end
end
end