Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Comptoir
Comptoir-srv
Commits
13e17b15
Commit
13e17b15
authored
Apr 04, 2021
by
Fabrice Gangler
🎨
Browse files
FIX(tags): redirect view method when is HTML format
Refs:
#954
parent
edf51ca2
Pipeline
#13560
passed with stage
in 6 minutes and 40 seconds
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
src/Controller/Api/V1/TagsController.php
View file @
13e17b15
...
...
@@ -160,7 +160,11 @@ class TagsController extends AppController
}
/**
* View method of a given tag
* API view method of a given tag
*
* URL : API /$lang/tags/$idTag.json
* Webapp /$lang/tags/$idTag ---> redirect 301 to /$lang/tags/$idTag/software
* /$lang/tags/$idTag/ ---> redirect 301 to /$lang/tags/$idTag/software
*
* @param string|null $id Tag id.
* @return Response|null
...
...
@@ -168,17 +172,23 @@ class TagsController extends AppController
*/
public
function
view
(
$id
=
null
)
{
if
(
$this
->
request
->
is
(
'json'
))
{
$tag
=
$this
->
Tags
->
get
(
$id
,
[
'contain'
=>
[
'Softwares'
]]
);
$tag
=
$this
->
Tags
->
get
(
$
id
,
[
'contain'
=>
[
'Softwares'
]]
);
$this
->
set
(
'tag'
,
$t
ag
)
;
$this
->
set
(
'_serialize'
,
[
'tag'
]
);
return
null
;
$this
->
set
(
'tag'
,
$tag
);
$
this
->
set
(
'_serialize'
,
[
'tag'
]);
return
null
;
}
else
{
$idTag
=
(
int
)
$id
;
$lang
=
$this
->
selectedLangu
ag
e
;
return
$this
->
redirect
(
"/
$lang
/tags/
$idTag
/software"
,
301
);
}
}
/**
* Returns a list of software associated to a given tag
*
...
...
tests/TestCase/Controller/Api/V1/TagsControllerTest.php
View file @
13e17b15
...
...
@@ -198,7 +198,36 @@ class TagsControllerTest extends ApiIntegrationTestCase
}
/**
* Test view method of Tags controller. Show us all data of one tag, here is tested tag id=4.
* Test view method of Tags controller for HTML format
* must redirect to new tag URL
*
* URL : Webapp /$lang/tags/$idTag ---> redirect 301 to /$lang/tags/$idTag/software
* /$lang/tags/$idTag/ ---> redirect 301 to /$lang/tags/$idTag/software
*
* @group public
* @group tag
* @group tag_public
* @group tag_method_view
*
* @return void
*/
public
function
testViewMethodForHtmlFormat
()
{
$this
->
get
(
'/tags/4'
);
$this
->
currentResponseIsRedirectionToAnotherUrl
(
'/en/tags/4/software'
,
301
);
$this
->
get
(
'/fr/tags/4'
);
$this
->
currentResponseIsRedirectionToAnotherUrl
(
'/fr/tags/4/software'
,
301
);
$this
->
get
(
'/fr/tags/4/'
);
$this
->
currentResponseIsRedirectionToAnotherUrl
(
'/fr/tags/4/software'
,
301
);
}
/**
* Test API view method of Tags controller for JSON format.
* Show us all data of one tag, here is tested tag id=4.
*
* URL : API /$lang/tags/$idTag.json
*
* @group public
* @group tag
...
...
@@ -207,7 +236,7 @@ class TagsControllerTest extends ApiIntegrationTestCase
*
* @return void
*/
public
function
testView
()
public
function
testView
MethodForJsonFormat
()
{
$this
->
get
(
'/api/v1/tags/4.json'
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment