apache / apache/grails-core

Unit testing when using namespaces failing

Open
#10,125 8 comments 0 reactions 0 assignees View on GitHub
info: workaround available relates-to: grails-testing type: bug type: minor
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### Expected Behaviour

In an application using namespaces for controllers, unit testing a redirect should work fine.
### Actual Behaviour

unit testing redirects does not generate the proper url when using namespaces
### Environment Information
- **Operating System**: Mac OS X 10.11.6
- **Grails Version:** 3.1.10
- **JDK Version:** 1.8.0_92
### Example Application
- https://github.com/frangarcia/errortestapp

This is an example project to show an issue when unit testing redirect on grails controllers when using namespaces.

After starting up the grails application with the command:

```
grails run-app
```

and going to http://localhost:8080/admin/content, it redirects to http://localhost:8080/admin/content/list, which is the expected behaviour.

The problem comes with the unit test ContentControllerSpec not working as expected, so when running

```
grails test-app -unit
```

the error does not pass because the application does not do the redirection properly

Contributor guide

Open the contributing guide

Research direction

Start with the linked errortestapp and its ContentControllerSpec, then run `grails test-app -unit` to reproduce the namespace redirect failure. Compare the unit-test redirect with the behavior from `grails run-app` at `/admin/content`, where the expected destination is `/admin/content/list`; done means the test passes with the proper namespaced URL.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.