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
2017-03-23 22:19:14 +0000
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
cc0ce7c6308985e7524c36214aa965757b4c92df
cc0ce7c6
1 parent
668ce262
Fixed bug preventing page revision restore
Added regression tests to cover. Fixes #341
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletions
app/Repos/EntityRepo.php
tests/Entity/PageContentTest.php
app/Repos/EntityRepo.php
View file @
cc0ce7c
...
...
@@ -1058,7 +1058,7 @@ class EntityRepo
public
function
restorePageRevision
(
Page
$page
,
Book
$book
,
$revisionId
)
{
$this
->
savePageRevision
(
$page
);
$revision
=
$
this
->
getById
(
'page_revision'
,
$revisionId
);
$revision
=
$
page
->
revisions
()
->
where
(
'id'
,
'='
,
$revisionId
)
->
first
(
);
$page
->
fill
(
$revision
->
toArray
());
$page
->
slug
=
$this
->
findSuitableSlug
(
'page'
,
$page
->
name
,
$page
->
id
,
$book
->
id
);
$page
->
text
=
strip_tags
(
$page
->
html
);
...
...
tests/Entity/PageContentTest.php
View file @
cc0ce7c
...
...
@@ -53,4 +53,31 @@ class PageContentTest extends TestCase
$revisionView
->
assertSee
(
'new content'
);
}
public
function
test_page_revision_restore_updates_content
()
{
$this
->
asEditor
();
$entityRepo
=
$this
->
app
[
EntityRepo
::
class
];
$page
=
Page
::
first
();
$entityRepo
->
updatePage
(
$page
,
$page
->
book_id
,
[
'name'
=>
'updated page abc123'
,
'html'
=>
'<p>new contente def456</p>'
,
'summary'
=>
'initial page revision testing'
]);
$entityRepo
->
updatePage
(
$page
,
$page
->
book_id
,
[
'name'
=>
'updated page again'
,
'html'
=>
'<p>new content</p>'
,
'summary'
=>
'page revision testing'
]);
$page
=
Page
::
find
(
$page
->
id
);
$pageView
=
$this
->
get
(
$page
->
getUrl
());
$pageView
->
assertDontSee
(
'abc123'
);
$pageView
->
assertDontSee
(
'def456'
);
$revToRestore
=
$page
->
revisions
()
->
where
(
'name'
,
'like'
,
'%abc123'
)
->
first
();
$restoreReq
=
$this
->
get
(
$page
->
getUrl
()
.
'/revisions/'
.
$revToRestore
->
id
.
'/restore'
);
$page
=
Page
::
find
(
$page
->
id
);
$restoreReq
->
assertStatus
(
302
);
$restoreReq
->
assertRedirect
(
$page
->
getUrl
());
$pageView
=
$this
->
get
(
$page
->
getUrl
());
$pageView
->
assertSee
(
'abc123'
);
$pageView
->
assertSee
(
'def456'
);
}
}
...
...
Please
register
or
sign in
to post a comment