[#10799] Move api entreprise token logic in a concern

This commit is contained in:
Mathieu Magnin 2024-09-24 17:03:18 +02:00
parent 39fdb8ddbb
commit 7009eed9d7
No known key found for this signature in database
GPG key ID: 8DCAFC82D7BA654E
5 changed files with 72 additions and 20 deletions

View file

@ -24,7 +24,7 @@ RSpec.describe 'administrateurs/procedures/_api_entreprise_token_expiration_aler
end
end
context "when the token is valid it should display the expiration date" do
context "when the token expires in few days it should display the expiration date" do
let(:expiration) { 2.days.from_now }
let(:api_entreprise_token) { JWT.encode({ exp: expiration.to_i }, nil, "none") }
@ -34,4 +34,14 @@ RSpec.describe 'administrateurs/procedures/_api_entreprise_token_expiration_aler
expect(rendered).to have_content("Votre jeton API Entreprise expirera le\n#{expiration.strftime('%d/%m/%Y à %H:%M')}")
end
end
context "when the token expires in a long time" do
let(:expiration) { 2.months.from_now }
let(:api_entreprise_token) { JWT.encode({ exp: expiration.to_i }, nil, "none") }
it "does not render anything" do
subject
expect(rendered).to be_empty
end
end
end