Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Déconnecter les agents et usagers après un temps d'inactivité (#4241)
* Ne plus utiliser le module :rememberable de Devise * Déconnecter les agents soient 14 jours après la dernière visite * Prendre des exemples de test plus explicites * Déconnecter les usagers 30 minutes après la dernière visite * Utiliser un critère plus précis pour déterminer qu'on est déconnecté * Move spec to the right directory * Move specs to account/ subdirectory * Déplacer la méthode `timeout_in` près de `devise` * Correction d'un titre de spec où j'anticipais trop
- Loading branch information
1 parent
9ff8e47
commit 7ff66c3
Showing
15 changed files
with
75 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,3 @@ fr: | |
new: | ||
email: Email | ||
password: Mot de passe | ||
sessions: | ||
new: | ||
remember_me: Se souvenir de moi |
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
spec/features/agents/account/agent_session_expires_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
RSpec.describe "Agent session expiration" do | ||
let(:password) { Faker::Internet.password(min_length: 12) } | ||
let!(:agent) { create(:agent, password: password, password_confirmation: password) } | ||
|
||
def expect_to_be_logged_in | ||
visit agents_preferences_path | ||
expect(page).to have_content("Préférences de notifications") | ||
end | ||
|
||
def expect_to_be_logged_out | ||
visit agents_preferences_path | ||
expect(page).to have_content("Entrez votre email et votre mot de passe") | ||
end | ||
|
||
it "is done 14 days after last visit" do | ||
login_time = Time.zone.parse("2024-01-01 12:00") | ||
travel_to(login_time) | ||
visit new_agent_session_path | ||
fill_in "Email", with: agent.email | ||
fill_in "password", with: password | ||
click_on "Se connecter" | ||
expect_to_be_logged_in | ||
|
||
travel_to(Time.zone.parse("2024-01-10 12:00")) # 10 days after last visit | ||
expect_to_be_logged_in | ||
|
||
travel_to(Time.zone.parse("2024-01-24 11:55")) # almost 14 days after last visit | ||
expect_to_be_logged_in | ||
|
||
travel_to(Time.zone.parse("2024-02-07 12:00")) # 14 days and 5 minutes after last visit | ||
expect_to_be_logged_out | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
RSpec.describe "Agent session expiration" do | ||
let(:password) { Faker::Internet.password(min_length: 12) } | ||
let!(:user) { create(:user, password: password, password_confirmation: password) } | ||
|
||
def expect_to_be_logged_in | ||
visit users_informations_path | ||
expect(page).to have_content("Mes informations") | ||
end | ||
|
||
def expect_to_be_logged_out | ||
visit users_informations_path | ||
expect(page).to have_content("Entrez votre email et votre mot de passe") | ||
end | ||
|
||
it "is done 30 minutes after last visit" do | ||
visit new_user_session_path | ||
fill_in "Email", with: user.email | ||
fill_in "password", with: password | ||
click_on "Se connecter" | ||
expect_to_be_logged_in | ||
|
||
travel_to(28.minutes.from_now) | ||
expect_to_be_logged_in | ||
|
||
travel_to(31.minutes.from_now) | ||
expect_to_be_logged_out | ||
end | ||
end |
File renamed without changes.