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:21:04 +0000
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Commit
7fa5405cb7c46f2bb9375ed327199514e8e85d02
7fa5405c
2 parents
6725ddcc
cc0ce7c6
Merge branch 'master' into release
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
2 deletions
app/Repos/EntityRepo.php
resources/views/books/form.blade.php
tests/Entity/PageContentTest.php
app/Repos/EntityRepo.php
View file @
7fa5405
...
...
@@ -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
);
...
...
resources/views/books/form.blade.php
View file @
7fa5405
...
...
@@ -11,6 +11,6 @@
</div>
<div
class=
"form-group"
>
<a
href=
"{{
back()->getTargetUrl(
) }}"
class=
"button muted"
>
{{ trans('common.cancel') }}
</a>
<a
href=
"{{
isset($book) ? $book->getUrl() : baseUrl('/books'
) }}"
class=
"button muted"
>
{{ trans('common.cancel') }}
</a>
<button
type=
"submit"
class=
"button pos"
>
{{ trans('entities.books_save') }}
</button>
</div>
\ No newline at end of file
...
...
tests/Entity/PageContentTest.php
View file @
7fa5405
...
...
@@ -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