Skip to content

Commit

Permalink
JME users can become adherents
Browse files Browse the repository at this point in the history
  • Loading branch information
Remg committed Jun 3, 2022
1 parent 635556a commit 84cb883
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 5 deletions.
80 changes: 76 additions & 4 deletions features/admin/adherent.feature
Original file line number Diff line number Diff line change
@@ -1,18 +1,90 @@
@app
Feature: Manage adherent from admin panel

Background:
When I am logged as "[email protected]" admin

Scenario: Display list of adherents
Given I am logged as "[email protected]" admin
When I am on "/admin/app/adherent/list"
Then the response status code should be 200
And I should see 32 "tbody tr" elements
And I should see 14 "thead tr th" elements

Scenario: A user update must trigger an event in RabbitMQ
Given I am on "/admin/app/adherent/list"
Given I am logged as "[email protected]" admin
When I am on "/admin/app/adherent/list"
And I follow "SCHMIDT"
And I clean the "api_sync" queue
When I press "Mettre à jour"
Then the response status code should be 200

@debug
Scenario:
As an administrator, I can manually register a user from another app.
The adherent can then change his password on the platform
Given I am logged as "[email protected]" admin
When I am on "/admin/app/adherent/list"
And I fill in the following:
| filter[emailAddress][value] | je-mengage-user-1@en-marche-dev.fr |
When I press "Filtrer"
Then I should be on "/admin/app/adherent/list"
And I should see "Jules Fullstack"
And I follow "EM"
Then I should be on "/"

And I follow "Adhérer"
Then I should be on "/adhesion"
And I check "become_adherent[conditions]"
When I press "Je rejoins La République En Marche"
Then I should be on "/espace-adherent/accueil"
And I should see "Votre compte adhérent est maintenant actif."
Then I go to "/deconnexion"
Then I should be on "/"

Then I follow "Connexion"
And I fill in the following:
| _login_email | je-mengage-user-1@en-marche-dev.fr |
| _login_password | secret!12345 |
And I press "Connexion"
And I should be on "/evenements"
Then I go to "/deconnexion"
Then I should be on "/"

Then I follow "Connexion"
Then I should be on "/connexion"
And I should have 0 email
Then I follow "Mot de passe oublié ? Cliquez ici"
Then I should be on "/mot-de-passe-oublie"
And I fill in the following:
| form[email] | je-mengage-user-1@en-marche-dev.fr |
And I press "Envoyer un e-mail"
Then I should be on "/connexion"
And I should see "Si l'adresse que vous avez saisie est valide, un e-mail vous a été envoyé contenant un lien pour réinitialiser votre mot de passe."
And I should have 1 email
And I should have 1 email "AdherentResetPasswordMessage" for "[email protected]" with payload:
"""
{
"template_name": "adherent-reset-password,
"template_content": [],
"message": {
"subject": "Réinitialisation de votre mot de passe",
"from_email": "[email protected]",
"from_name": "La République En Marche !",
"global_merge_vars": [
{
"name": "first_name",
"content": "Jules"
},
{
"name": "reset_link",
"content": "http://enmarche.code/changer-mot-de-passe/@string@/@string@"
}
],
"to": [
{
"email": "[email protected]",
"type": "to",
"name": "Jules Fullstack"
}
]
}
}
"""
1 change: 1 addition & 0 deletions src/Entity/Adherent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,7 @@ public function isUser(): bool

public function join(): void
{
$this->source = null;
$this->adherent = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Membership/AdherentResetPasswordHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function reset(Adherent $adherent, AdherentResetPasswordToken $token, str

$this->manager->flush();

if (null === $adherent->getSource()) {
if (null === $adherent->getSource() || $adherent->isAdherent()) {
$this->mailer->sendMessage(AdherentResetPasswordConfirmationMessage::createFromAdherent($adherent));
} else {
if ($hasBeenActivated) {
Expand Down
4 changes: 4 additions & 0 deletions tests/Test/Geocoder/DummyGeocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class DummyGeocoder implements Geocoder
'latitude' => 48.5278939,
'longitude' => 2.6484923,
],
'2 avenue jean jaurès, 77000 melun, france' => [
'latitude' => 48.5278939,
'longitude' => 2.6484923,
],
'30 boulevard louis guichoux, 13003 marseille 3e, fr' => [
'latitude' => 43.325900,
'longitude' => 5.374680,
Expand Down

0 comments on commit 84cb883

Please sign in to comment.