Skip to content

Commit

Permalink
Improved site:team:add for users on sites w/o the change_management f…
Browse files Browse the repository at this point in the history
…eature (#1750)

I don't know why it is making me do this after @ronan approved.
  • Loading branch information
TeslaDethray authored Aug 14, 2017
1 parent a20082e commit c0bedac
Show file tree
Hide file tree
Showing 6 changed files with 346 additions and 63 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. This projec
- Updated the name of the `longname` field output by `upstream:info` to `label`. (#1747)
- Upstreams of types `core` and `custom` are the only ones which appear by default when using `upstream:list`. (#1747)
- The `--org` option of the `site:list` command now defaults to `"all"` instead of `null`, but its behavior is unchanged. (#1747)
- The `role` parameter of the `site:team:add` command defaults to `team_member`. (#1750)

### Added
- Added a `machine_name` field to the output of `upstream:list`. (#1747)
Expand All @@ -24,6 +25,7 @@ All notable changes to this project will be documented in this file. This projec

### Fixed
- The `org` option of `site:create` now works with machine names and labels as well as UUIDs. (#1747)
- If the `change_management` feature is not enabled on a site, no warning is displayed only if the `role` has been supplied and is not `team_member`. (#1750)

## 1.4.1 - 2017-07-17
### Fixed
Expand Down
5 changes: 3 additions & 2 deletions src/Commands/Site/Team/AddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ class AddCommand extends TerminusCommand implements SiteAwareInterface
* @param string $member Email of user
* @param string $role [developer|team_member] Role
*
* @usage <site> <user> Adds <user> as a team_member to <site>'s team.
* @usage <site> <user> <role> Adds <user> as a <role> to <site>'s team.
*/
public function add($site_id, $member, $role)
public function add($site_id, $member, $role = 'team_member')
{
$site = $this->getSite($site_id);
$team = $site->getUserMemberships();

if (!(boolean)$site->getFeature('change_management')) {
if (($role !== 'team_member') && !(boolean)$site->getFeature('change_management')) {
$role = 'team_member';
$this->log()->warning(
'Site does not have change management enabled, defaulting to user role {role}.',
Expand Down
24 changes: 19 additions & 5 deletions tests/features/site-team.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,26 @@ Feature: Managing a site's team

@vcr site-team-add.yml
Scenario: Adding a team member
When I run "terminus site:team:add [[test_site_name]] [[other_user]] --role=team_member"
When I run "terminus site:team:add [[test_site_name]] [[other_user]] developer"
And I list the team members on "[[test_site_name]]"
Then I should get:
"""
[[other_user]]
"""
Then I should get: "----------- ----------- ----------------------- ------------- --------------------------------------"
And I should get: "First name Last name Email Role User ID"
And I should get: "------------ ----------- ----------------------- ------------- --------------------------------------"
And I should get: "Dev User [email protected] team_member 11111111-1111-1111-1111-111111111111"
And I should get: "Dev User [email protected] developer 3a1d2042-cca3-432e-94c4-12a8f2b6a950"
And I should get: "------------ ----------- ----------------------- ------------- --------------------------------------"

@vcr site-team-add-no-change-mgmt.yml
Scenario: Adding a team member without change management enabled
When I run "terminus site:team:add [[test_site_name]] [[other_user]] developer"
Then I should see a warning message: Site does not have change management enabled, defaulting to user role team_member.
And I list the team members on "[[test_site_name]]"
Then I should get: "------------ ----------- ----------------------- ------------- --------------------------------------"
And I should get: "First name Last name Email Role User ID"
And I should get: "------------ ----------- ----------------------- ------------- --------------------------------------"
And I should get: "Dev User [email protected] team_member 11111111-1111-1111-1111-111111111111"
And I should get: "Dev User [email protected] team_member 3a1d2042-cca3-432e-94c4-12a8f2b6a950"
And I should get: "------------ ----------- ----------------------- ------------- --------------------------------------"

@vcr site-team-role.yml
Scenario: Changing a team member's role
Expand Down
Loading

0 comments on commit c0bedac

Please sign in to comment.