Skip to content

Commit

Permalink
Collaborators.vue: make invitation as guest possible
Browse files Browse the repository at this point in the history
Issue: #1415
  • Loading branch information
BacLuc committed May 14, 2021
1 parent dd4e54b commit d1cae1b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
->addValidatorInArray([
CampCollaboration::ROLE_MEMBER,
CampCollaboration::ROLE_MANAGER,
CampCollaboration::ROLE_GUEST,
])
)
->buildConfig()
Expand Down
11 changes: 9 additions & 2 deletions backend/module/eCampApi/test/Rest/CampCollaborationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,13 @@ public function testCreateSuccess(): void {
$this->assertEquals(CampCollaboration::STATUS_INVITED, $this->getResponseContent()->status);
}

public function testCreateOnlyWithEmail(): void {
/**
* @dataProvider getRoles
*/
public function testCreateOnlyWithEmail(string $role): void {
$inviteEmail = 'my.mail@fantasy.com';
$this->setRequestContent([
'role' => CampCollaboration::ROLE_MEMBER,
'role' => $role,
'campId' => $this->campCollaboration1->getCamp()->getId(),
'inviteEmail' => $inviteEmail,
'userId' => null,
Expand All @@ -244,6 +247,10 @@ public function testCreateOnlyWithEmail(): void {
$this->assertThat($this->getResponseContent()->_embedded, self::logicalNot(self::classHasAttribute('user')));
}

public static function getRoles(): array {
return [[CampCollaboration::ROLE_GUEST], [CampCollaboration::ROLE_MANAGER], [CampCollaboration::ROLE_MEMBER]];
}

public function testCreateWithEmailOfExistingUser() {
$inviteEmail = 'my.mail@fantasy.com';
$user2 = new User();
Expand Down
3 changes: 2 additions & 1 deletion common/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"collaborators": {
"invite": "Invite",
"manager": "Manager",
"member": "Member"
"member": "Member",
"guest": "Guest"
},
"fields": {
"addressCity": "City",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/camp/CollaboratorListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
:items="[
{ key: 'member', translation: $tc('entity.camp.collaborators.member') },
{ key: 'manager', translation: $tc('entity.camp.collaborators.manager') },
{ key: 'guest', translation: $tc('entity.camp.collaborators.guest') },
]"
item-value="key"
item-text="translation"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/views/camp/Collaborators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Displays collaborators of a single camp.
:items="[
{ key: 'member', translation: $tc('entity.camp.collaborators.member') },
{ key: 'manager', translation: $tc('entity.camp.collaborators.manager') },
{ key: 'guest', translation: $tc('entity.camp.collaborators.guest') },
]"
item-value="key"
item-text="translation"
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/views/camp/__tests__/Admin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,25 @@ describe('Admin view', () => {
expect(queryByText('components.camp.campDangerzone.title')).not.toBeInTheDocument()
expect(queryByText('components.camp.campDangerzone.deleteCamp.title')).not.toBeInTheDocument()
})

it('doesn\'t show the danger zone when the user has the guest role', async () => {
const { queryByText } = renderWithVuetify(Admin, {
props: {
camp: () => ({
role: 'guest',
materialLists: () => {},
_meta: { loading: false }
})
},
routes: [],
mocks: {
api: { reload: () => Promise.resolve() },
$tc: key => key
},
stubs: ['camp-settings', 'camp-address', 'camp-periods', 'camp-categories', 'camp-material-lists']
})

expect(queryByText('components.camp.campDangerzone.title')).not.toBeInTheDocument()
expect(queryByText('components.camp.campDangerzone.deleteCamp.title')).not.toBeInTheDocument()
})
})

0 comments on commit d1cae1b

Please sign in to comment.