-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Phoning] Set unique team name by zone (#7356)
- Loading branch information
1 parent
4ca8c4d
commit e80efc6
Showing
3 changed files
with
105 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -496,6 +496,82 @@ Feature: | |
""" | ||
Then the response status code should be 401 | ||
|
||
Scenario: As a user granted with national scope, I cannot create a national team with the same name | ||
Given I am logged with "[email protected]" via OAuth client "JeMengage Web" | ||
When I add "Content-Type" header equal to "application/json" | ||
And I send a "POST" request to "/api/v3/teams?scope=phoning_national_manager" with body: | ||
""" | ||
{ | ||
"name": "Première équipe de phoning" | ||
} | ||
""" | ||
Then the response status code should be 400 | ||
And the response should be in JSON | ||
And the JSON should be equal to: | ||
""" | ||
{ | ||
"type": "https://tools.ietf.org/html/rfc2616#section-10", | ||
"title": "An error occurred", | ||
"detail": "name: Une équipe porte déjà le même nom.", | ||
"violations": [ | ||
{ | ||
"propertyPath": "name", | ||
"message": "Une équipe porte déjà le même nom." | ||
} | ||
] | ||
} | ||
""" | ||
|
||
When I add "Content-Type" header equal to "application/json" | ||
And I send a "POST" request to "/api/v3/teams?scope=phoning_national_manager" with body: | ||
""" | ||
{ | ||
"name": "Équipe locale du département 92" | ||
} | ||
""" | ||
Then the response status code should be 201 | ||
|
||
Scenario Outline: As a user granted with local scope, I cannot create a team with the same name and zone | ||
When I am logged with "[email protected]" via OAuth client "JeMengage Web" | ||
And I add "Content-Type" header equal to "application/json" | ||
And I send a "POST" request to "/api/v3/teams?scope=referent" with body: | ||
""" | ||
{ | ||
"name": "Équipe locale du département 92", | ||
"zone": "e3efe6fd-906e-11eb-a875-0242ac150002" | ||
} | ||
""" | ||
Then the response status code should be 400 | ||
And the response should be in JSON | ||
And the JSON should be equal to: | ||
""" | ||
{ | ||
"type": "https://tools.ietf.org/html/rfc2616#section-10", | ||
"title": "An error occurred", | ||
"detail": "name: Une équipe porte déjà le même nom.", | ||
"violations": [ | ||
{ | ||
"propertyPath": "name", | ||
"message": "Une équipe porte déjà le même nom." | ||
} | ||
] | ||
} | ||
""" | ||
|
||
When I add "Content-Type" header equal to "application/json" | ||
And I send a "POST" request to "/api/v3/teams?scope=referent" with body: | ||
""" | ||
{ | ||
"name": "Première équipe de phoning", | ||
"zone": "e3efe6fd-906e-11eb-a875-0242ac150002" | ||
} | ||
""" | ||
Then the response status code should be 201 | ||
Examples: | ||
| user | scope | | ||
| referent@en-marche-dev.fr | referent | | ||
| senateur@en-marche-dev.fr | delegated_08f40730-d807-4975-8773-69d8fae1da74 | | ||
|
||
Scenario: As a user granted with team feature, I can add a member to a team | ||
Given I am logged with "[email protected]" via OAuth client "JeMengage Web" | ||
When I send a "GET" request to "/api/v3/teams/6434f2ac-edd0-412a-9c4b-99ab4b039146?scope=phoning_national_manager" | ||
|
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,21 @@ | ||
<?php | ||
|
||
namespace Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20220616140609 extends AbstractMigration | ||
{ | ||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('DROP INDEX UNIQ_C4E0A61F5E237E06 ON team'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_C4E0A61F5E237E069F2C3FAB ON team (name, zone_id)'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('DROP INDEX UNIQ_C4E0A61F5E237E069F2C3FAB ON team'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_C4E0A61F5E237E06 ON team (name)'); | ||
} | ||
} |
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