Skip to content

Commit

Permalink
Fix tests after adding default volunteer
Browse files Browse the repository at this point in the history
  • Loading branch information
rogargon committed May 9, 2024
1 parent 9c8269a commit feb00e7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public void thereIsAShelterVolunteerWithUsernameInTheShelter(String username, St
volunteer.setPassword(password);
volunteer.encodePassword();
shelterVolunteerRepository.save(volunteer);
} else {
shelterVolunteerRepository.findById(username).ifPresent(shelterVolunteer -> {
shelterVolunteer.setUserShelter(shelterRepository.findByName(shelterName).get(0));
shelterVolunteerRepository.save(shelterVolunteer);
});

}

}
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/features/AddShelterCertificate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ Feature: Add Shelter Certificate

Background: Exists a shelter with name "test" and a shelter volunteer
Given A shelter with name "test"
And There is a registered user with username "volunteer" and password "123456789" and email "[email protected]"
And There is a registered user with username "volunteer" and password "password" and email "[email protected]"

Scenario: Adding a Shelter Certificate as a Shelter Volunteer
Given I can login with username "volunteer" and password "123456789"
Given I can login with username "volunteer" and password "password"
When I add a Shelter Certificate with valid expiration date to the shelter with name "test"
Then The response code is 201

Scenario: Adding a Shelter Certificate as a non Shelter Volunteer
Given I cannot login with username "test" and password "wrongPassword"
When I add a Shelter Certificate with valid expiration date to the shelter with name "test"
Then The response code is 401
Then The response code is 401
4 changes: 2 additions & 2 deletions src/test/resources/features/EditShelter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: Edit Shelter
Background:
Given There is a registered user with username "user" and password "existing" and email "[email protected]"
Given There is a registered already admin with username "admin" and password "admin" and email "[email protected]"
Given There is a registered volunteer with username "volunteer" and password "volunteer"
Given There is a registered volunteer with username "volunteer" and password "password"
And There is already a shelter with name "Shelter 1" email "[email protected]" and mobile "999999999"

Scenario: Edit shelter without being logged in
Expand All @@ -28,7 +28,7 @@ Feature: Edit Shelter
Then The response code is 200

Scenario: Edit shelter with volunteer
Given I login as "volunteer" with password "volunteer"
Given I login as "volunteer" with password "password"
When I update the shelter with name "Shelter 1" to name "Another Shelter" email "[email protected]" and mobile "123123123"
And I get the shelter with name "Another Shelter"
Then The response code is 200
Expand Down
20 changes: 10 additions & 10 deletions src/test/resources/features/KickUserFromShelter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ Feature: Kick ShelterVolunteer from Shelter
I want to be able to kick a volunteer from my shelter but not able to kick volunteers from other shelters

Background:
Given There is a registered user with username "user" and password "pass" and email "[email protected]"
Given There is a registered user with username "user" and password "password" and email "[email protected]"
And There is already a shelter with name "shelter1" email "[email protected]" and mobile "12345678"
And There is a shelter volunteer with username "volunteer" and password "pass" in the shelter "shelter1"
And There is a shelter volunteer with username "volunteer1" and password "pass" in the shelter "shelter1"
And There is a shelter volunteer with username "volunteer" and password "password" in the shelter "shelter1"
And There is a shelter volunteer with username "volunteer1" and password "password" in the shelter "shelter1"
And There is already a shelter with name "shelter2" email "[email protected]" and mobile "12345679"
And There is a shelter volunteer with username "volunteer2" and password "pass" in the shelter "shelter2"
And There is a shelter volunteer with username "volunteer2" and password "password" in the shelter "shelter2"

Scenario: Kick volunteer from shelter
Given I can login with username "volunteer" and password "pass"
Given I can login with username "volunteer" and password "password"
When I kick user "volunteer1" from shelter "shelter"
Then The response code is 200
And I cannot login with username "volunteer1" and password "pass"
And I cannot login with username "volunteer1" and password "password"

Scenario: Kick volunteer from shelter as user
And I can login with username "user" and password "pass"
And I can login with username "user" and password "password"
When I kick user "volunteer1" from shelter "shelter"
Then The response code is 403
And I can login with username "volunteer1" and password "pass"
And I can login with username "volunteer1" and password "password"

Scenario: Kick volunteer from shelter as volunteer in another shelter
Given I can login with username "volunteer" and password "pass"
Given I can login with username "volunteer" and password "password"
When I kick user "volunteer2" from shelter "shelter"
Then The response code is 412
And I can login with username "volunteer2" and password "pass"
And I can login with username "volunteer2" and password "password"

0 comments on commit feb00e7

Please sign in to comment.