Skip to content

Commit

Permalink
fix: lang is not required
Browse files Browse the repository at this point in the history
  • Loading branch information
dariogmori committed Mar 11, 2024
1 parent 2ccc0b3 commit adacaa7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/questions")
@RequiredArgsConstructor
Expand All @@ -23,7 +21,7 @@ private ResponseEntity<AnswerCheckResponseDto> answerQuestion(@PathVariable @Pos
}

@GetMapping("/new")
private ResponseEntity<QuestionResponseDto> generateQuestion(@RequestParam String lang){
private ResponseEntity<QuestionResponseDto> generateQuestion(@RequestParam(required = false) String lang){
return ResponseEntity.ok(questionService.getRandomQuestion(lang));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ void newQuestionShouldReturn200() throws Exception{
.andExpect(status().isOk());
}

@Test
void newQuestionNoLangShouldReturn200() throws Exception{
mockMvc.perform(get("/questions/new")
.with(user("test").roles("user"))
.contentType("application/json")
.with(csrf()))
.andExpect(status().isOk());
}

@Test
void questionByIdShouldReturn403() throws Exception{
mockMvc.perform(get("/questions/1")
Expand Down

0 comments on commit adacaa7

Please sign in to comment.