Prefer authentication token for session if present

This commit is contained in:
Sebastian Serth
2022-10-05 21:31:24 +02:00
parent 4f5f71840a
commit 42688ed1c9
2 changed files with 19 additions and 2 deletions

View File

@ -107,6 +107,23 @@ describe 'Authentication' do
visit(root_path)
end
context "with an authentication token" do
let(:request_for_comment) { create(:rfc_with_comment, user: user) }
let(:study_group) { request_for_comment.submission.study_group }
let(:commenting_user) { InternalUser.create(attributes_for(:teacher)) }
let(:mail) { UserMailer.got_new_comment(request_for_comment.comments.first, request_for_comment, commenting_user) }
let(:rfc_link) { request_for_comment_url(request_for_comment, token: token.shared_secret) }
it 'still invalidates the token on login' do
token = create(:authentication_token, user: user, study_group: study_group)
mail = UserMailer.got_new_comment(request_for_comment.comments.first, request_for_comment, commenting_user)
mail.deliver_now
visit(request_for_comment_url(request_for_comment, token: token.shared_secret))
expect(token.reload.expire_at).to be_within(10.seconds).of(Time.zone.now)
end
end
it "displays the user's displayname" do
expect(page).to have_content(user.displayname)
end