Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2015-12-01 21:14:39 +0000
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
5e21ecc5261bef9b7632b503359702c823a2815f
5e21ecc5
1 parent
99696987
Fixed crash on public entitiy viewing
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
app/Services/ViewService.php
tests/PublicViewTest.php
app/Services/ViewService.php
View file @
5e21ecc
...
...
@@ -27,6 +27,7 @@ class ViewService
*/
public
function
add
(
Entity
$entity
)
{
if
(
$this
->
user
===
null
)
return
0
;
$view
=
$entity
->
views
()
->
where
(
'user_id'
,
'='
,
$this
->
user
->
id
)
->
first
();
// Add view if model exists
if
(
$view
)
{
...
...
@@ -52,6 +53,7 @@ class ViewService
*/
public
function
getUserRecentlyViewed
(
$count
=
10
,
$page
=
0
,
$filterModel
=
false
)
{
if
(
$this
->
user
===
null
)
return
collect
();
$skipCount
=
$count
*
$page
;
$query
=
$this
->
view
->
where
(
'user_id'
,
'='
,
auth
()
->
user
()
->
id
);
...
...
tests/PublicViewTest.php
0 → 100644
View file @
5e21ecc
<?php
class
PublicViewTest
extends
TestCase
{
public
function
testBooksViewable
()
{
$this
->
setSettings
([
'app-public'
=>
'true'
]);
$books
=
\BookStack\Book
::
orderBy
(
'name'
,
'asc'
)
->
take
(
10
)
->
get
();
$bookToVisit
=
$books
[
1
];
// Check books index page is showing
$this
->
visit
(
'/books'
)
->
seeStatusCode
(
200
)
->
see
(
$books
[
0
]
->
name
)
// Check indavidual book page is showing and it's child contents are visible.
->
click
(
$bookToVisit
->
name
)
->
seePageIs
(
$bookToVisit
->
getUrl
())
->
see
(
$bookToVisit
->
name
)
->
see
(
$bookToVisit
->
chapters
()
->
first
()
->
name
);
}
public
function
testChaptersViewable
()
{
$this
->
setSettings
([
'app-public'
=>
'true'
]);
$chapterToVisit
=
\BookStack\Chapter
::
first
();
$pageToVisit
=
$chapterToVisit
->
pages
()
->
first
();
// Check chapters index page is showing
$this
->
visit
(
$chapterToVisit
->
getUrl
())
->
seeStatusCode
(
200
)
->
see
(
$chapterToVisit
->
name
)
// Check indavidual chapter page is showing and it's child contents are visible.
->
see
(
$pageToVisit
->
name
)
->
click
(
$pageToVisit
->
name
)
->
see
(
$chapterToVisit
->
book
->
name
)
->
see
(
$chapterToVisit
->
name
)
->
seePageIs
(
$pageToVisit
->
getUrl
());
}
}
\ No newline at end of file
Please
register
or
sign in
to post a comment