-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from PaulKreft/edit-username
Edit username
- Loading branch information
Showing
32 changed files
with
383 additions
and
185 deletions.
There are no files selected for viewing
15 changes: 0 additions & 15 deletions
15
backend/src/main/java/de/neuefische/paulkreft/backend/exception/GlobalExceptionHandler.java
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
39 changes: 39 additions & 0 deletions
39
backend/src/main/java/de/neuefische/paulkreft/backend/fallback/Fallback.java
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,39 @@ | ||
package de.neuefische.paulkreft.backend.fallback; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
import org.springframework.web.servlet.resource.PathResourceResolver; | ||
|
||
import java.io.IOException; | ||
|
||
@Configuration | ||
public class Fallback implements WebMvcConfigurer { | ||
|
||
public static final String DEFAULT_STARTING_PAGE = "static/index.html"; | ||
|
||
static class ReactRoutingPathResourceResolver extends PathResourceResolver { | ||
@Override | ||
protected Resource getResource(String resourcePath, Resource location) throws IOException { | ||
var requestedResource = location.createRelative(resourcePath); | ||
|
||
// Is this a request to a real file? | ||
if (requestedResource.exists() && requestedResource.isReadable()) { | ||
return requestedResource; | ||
} | ||
|
||
// It seems to be only a frontend-routing request (Single-Page-Application). | ||
return new ClassPathResource(DEFAULT_STARTING_PAGE); | ||
} | ||
} | ||
|
||
@Override | ||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
registry.addResourceHandler("/**") | ||
.addResourceLocations("classpath:/static/") | ||
.resourceChain(true) | ||
.addResolver(new ReactRoutingPathResourceResolver()); | ||
} | ||
} |
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
46 changes: 0 additions & 46 deletions
46
...d/src/test/java/de/neuefische/paulkreft/backend/exception/GlobalExceptionHandlerTest.java
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
backend/src/test/java/de/neuefische/paulkreft/backend/fallback/FallbackTest.java
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,53 @@ | ||
package de.neuefische.paulkreft.backend.fallback; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.core.io.Resource; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class FallbackTest { | ||
|
||
@Test | ||
void expectRelativeResource_ifItExists() throws IOException { | ||
|
||
// GIVEN | ||
var resolver = new Fallback.ReactRoutingPathResourceResolver(); | ||
var location = mock(Resource.class); | ||
var relativeLocation = mock(Resource.class); | ||
var resourcePath = "index.html"; | ||
when(location.createRelative(resourcePath)).thenReturn(relativeLocation); | ||
when(relativeLocation.exists()).thenReturn(true); | ||
when(relativeLocation.isReadable()).thenReturn(true); | ||
|
||
// WHEN | ||
var actual = resolver.getResource(resourcePath, location); | ||
|
||
// THEN | ||
Assertions.assertEquals(relativeLocation, actual); | ||
} | ||
|
||
@Test | ||
void expectIndexHtml_ifRequestedResourceDoesNotExist() throws IOException { | ||
|
||
// GIVEN | ||
var resolver = new Fallback.ReactRoutingPathResourceResolver(); | ||
var location = mock(Resource.class); | ||
var relativeLocation = mock(Resource.class); | ||
var resourcePath = "index.html"; | ||
when(location.createRelative(resourcePath)).thenReturn(relativeLocation); | ||
when(relativeLocation.exists()).thenReturn(false); | ||
|
||
// WHEN | ||
var actual = resolver.getResource(resourcePath, location); | ||
|
||
// THEN | ||
ClassPathResource expected = new ClassPathResource("static/index.html"); | ||
Assertions.assertEquals(expected, actual); | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -50,7 +50,7 @@ class UserControllerIntegrationTest { | |
@BeforeEach | ||
public void instantiateTestUser() { | ||
Instant now = Instant.parse("2016-06-09T00:00:00.00Z"); | ||
testUser = new User("123", "Paul", "[email protected]", "", now, now); | ||
testUser = new User("123", "Paule", "[email protected]", "", now, now); | ||
} | ||
|
||
@Test | ||
|
@@ -81,7 +81,7 @@ void testGetUser_whenReturningUserIsLoggedIn_returnReturningUser() throws Except | |
{ | ||
"id":"123", | ||
"email":"[email protected]", | ||
"name":"Paul", | ||
"name":"Paule", | ||
"lastActive": "2016-06-09T00:00:00Z", | ||
"createdAt": "2016-06-09T00:00:00Z" | ||
} | ||
|
@@ -178,7 +178,7 @@ void testGetUser_whenReturningEmailUserIsLoggedIn_returnReturningUser() throws E | |
.andExpect(content().json( | ||
""" | ||
{"id":"123", | ||
"name":"Paul", | ||
"name":"Paule", | ||
"email":"[email protected]", | ||
"lastActive":"2016-06-09T00:00:00Z", | ||
"createdAt":"2016-06-09T00:00:00Z" | ||
|
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
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 |
---|---|---|
@@ -1,3 +1,15 @@ | ||
input:focus { | ||
outline: none; | ||
} | ||
|
||
/* Chrome, Safari, Edge, Opera */ | ||
input::-webkit-outer-spin-button, | ||
input::-webkit-inner-spin-button { | ||
-webkit-appearance: none; | ||
margin: 0; | ||
} | ||
|
||
/* Firefox */ | ||
input[type=number] { | ||
-moz-appearance: textfield; | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Oops, something went wrong.