Dan Brown

Merge branch 'master' into release

...@@ -49,6 +49,7 @@ class RegeneratePermissions extends Command ...@@ -49,6 +49,7 @@ class RegeneratePermissions extends Command
49 $connection = \DB::getDefaultConnection(); 49 $connection = \DB::getDefaultConnection();
50 if ($this->option('database') !== null) { 50 if ($this->option('database') !== null) {
51 \DB::setDefaultConnection($this->option('database')); 51 \DB::setDefaultConnection($this->option('database'));
52 + $this->permissionService->setConnection(\DB::connection($this->option('database')));
52 } 53 }
53 54
54 $this->permissionService->buildJointPermissions(); 55 $this->permissionService->buildJointPermissions();
......
...@@ -44,6 +44,7 @@ class RegenerateSearch extends Command ...@@ -44,6 +44,7 @@ class RegenerateSearch extends Command
44 $connection = \DB::getDefaultConnection(); 44 $connection = \DB::getDefaultConnection();
45 if ($this->option('database') !== null) { 45 if ($this->option('database') !== null) {
46 \DB::setDefaultConnection($this->option('database')); 46 \DB::setDefaultConnection($this->option('database'));
47 + $this->searchService->setConnection(\DB::connection($this->option('database')));
47 } 48 }
48 49
49 $this->searchService->indexAllEntities(); 50 $this->searchService->indexAllEntities();
......
...@@ -95,17 +95,6 @@ class Entity extends Ownable ...@@ -95,17 +95,6 @@ class Entity extends Ownable
95 } 95 }
96 96
97 /** 97 /**
98 - * Check if this entity has live (active) restrictions in place.
99 - * @param $role_id
100 - * @param $action
101 - * @return bool
102 - */
103 - public function hasActiveRestriction($role_id, $action)
104 - {
105 - return $this->getRawAttribute('restricted') && $this->hasRestriction($role_id, $action);
106 - }
107 -
108 - /**
109 * Get the entity jointPermissions this is connected to. 98 * Get the entity jointPermissions this is connected to.
110 * @return \Illuminate\Database\Eloquent\Relations\MorphMany 99 * @return \Illuminate\Database\Eloquent\Relations\MorphMany
111 */ 100 */
...@@ -176,5 +165,11 @@ class Entity extends Ownable ...@@ -176,5 +165,11 @@ class Entity extends Ownable
176 */ 165 */
177 public function entityRawQuery(){return '';} 166 public function entityRawQuery(){return '';}
178 167
168 + /**
169 + * Get the url of this entity
170 + * @param $path
171 + * @return string
172 + */
173 + public function getUrl($path){return '/';}
179 174
180 } 175 }
......
1 <?php namespace BookStack\Http\Controllers; 1 <?php namespace BookStack\Http\Controllers;
2 2
3 use Activity; 3 use Activity;
4 +use BookStack\Book;
4 use BookStack\Repos\EntityRepo; 5 use BookStack\Repos\EntityRepo;
5 use BookStack\Repos\UserRepo; 6 use BookStack\Repos\UserRepo;
6 use BookStack\Services\ExportService; 7 use BookStack\Services\ExportService;
...@@ -207,13 +208,12 @@ class BookController extends Controller ...@@ -207,13 +208,12 @@ class BookController extends Controller
207 208
208 // Add activity for books 209 // Add activity for books
209 foreach ($sortedBooks as $bookId) { 210 foreach ($sortedBooks as $bookId) {
211 + /** @var Book $updatedBook */
210 $updatedBook = $this->entityRepo->getById('book', $bookId); 212 $updatedBook = $this->entityRepo->getById('book', $bookId);
213 + $this->entityRepo->buildJointPermissionsForBook($updatedBook);
211 Activity::add($updatedBook, 'book_sort', $updatedBook->id); 214 Activity::add($updatedBook, 'book_sort', $updatedBook->id);
212 } 215 }
213 216
214 - // Update permissions on changed models
215 - if (count($updatedModels) === 0) $this->entityRepo->buildJointPermissions($updatedModels);
216 -
217 return redirect($book->getUrl()); 217 return redirect($book->getUrl());
218 } 218 }
219 219
......
...@@ -46,7 +46,7 @@ class HomeController extends Controller ...@@ -46,7 +46,7 @@ class HomeController extends Controller
46 * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response 46 * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
47 */ 47 */
48 public function getTranslations() { 48 public function getTranslations() {
49 - $locale = trans()->getLocale(); 49 + $locale = app()->getLocale();
50 $cacheKey = 'GLOBAL_TRANSLATIONS_' . $locale; 50 $cacheKey = 'GLOBAL_TRANSLATIONS_' . $locale;
51 if (cache()->has($cacheKey) && config('app.env') !== 'development') { 51 if (cache()->has($cacheKey) && config('app.env') !== 'development') {
52 $resp = cache($cacheKey); 52 $resp = cache($cacheKey);
......
...@@ -15,7 +15,17 @@ class Localization ...@@ -15,7 +15,17 @@ class Localization
15 public function handle($request, Closure $next) 15 public function handle($request, Closure $next)
16 { 16 {
17 $defaultLang = config('app.locale'); 17 $defaultLang = config('app.locale');
18 + if (user()->isDefault()) {
19 + $locale = $defaultLang;
20 + $availableLocales = config('app.locales');
21 + foreach ($request->getLanguages() as $lang) {
22 + if (!in_array($lang, $availableLocales)) continue;
23 + $locale = $lang;
24 + break;
25 + }
26 + } else {
18 $locale = setting()->getUser(user(), 'language', $defaultLang); 27 $locale = setting()->getUser(user(), 'language', $defaultLang);
28 + }
19 app()->setLocale($locale); 29 app()->setLocale($locale);
20 Carbon::setLocale($locale); 30 Carbon::setLocale($locale);
21 return $next($request); 31 return $next($request);
......
...@@ -533,11 +533,11 @@ class EntityRepo ...@@ -533,11 +533,11 @@ class EntityRepo
533 533
534 /** 534 /**
535 * Alias method to update the book jointPermissions in the PermissionService. 535 * Alias method to update the book jointPermissions in the PermissionService.
536 - * @param Collection $collection collection on entities 536 + * @param Book $book
537 */ 537 */
538 - public function buildJointPermissions(Collection $collection) 538 + public function buildJointPermissionsForBook(Book $book)
539 { 539 {
540 - $this->permissionService->buildJointPermissionsForEntities($collection); 540 + $this->permissionService->buildJointPermissionsForEntity($book);
541 } 541 }
542 542
543 /** 543 /**
...@@ -730,6 +730,7 @@ class EntityRepo ...@@ -730,6 +730,7 @@ class EntityRepo
730 if ($chapter) $page->chapter_id = $chapter->id; 730 if ($chapter) $page->chapter_id = $chapter->id;
731 731
732 $book->pages()->save($page); 732 $book->pages()->save($page);
733 + $page = $this->page->find($page->id);
733 $this->permissionService->buildJointPermissionsForEntity($page); 734 $this->permissionService->buildJointPermissionsForEntity($page);
734 return $page; 735 return $page;
735 } 736 }
......
...@@ -51,6 +51,15 @@ class SearchService ...@@ -51,6 +51,15 @@ class SearchService
51 } 51 }
52 52
53 /** 53 /**
54 + * Set the database connection
55 + * @param Connection $connection
56 + */
57 + public function setConnection(Connection $connection)
58 + {
59 + $this->db = $connection;
60 + }
61 +
62 + /**
54 * Search all entities in the system. 63 * Search all entities in the system.
55 * @param string $searchString 64 * @param string $searchString
56 * @param string $entityType 65 * @param string $entityType
......
...@@ -58,6 +58,7 @@ return [ ...@@ -58,6 +58,7 @@ return [
58 */ 58 */
59 59
60 'locale' => env('APP_LANG', 'en'), 60 'locale' => env('APP_LANG', 'en'),
61 + 'locales' => ['en', 'de', 'es', 'fr', 'nl', 'pt_BR', 'sk'],
61 62
62 /* 63 /*
63 |-------------------------------------------------------------------------- 64 |--------------------------------------------------------------------------
......
...@@ -28,6 +28,12 @@ class DummyContentSeeder extends Seeder ...@@ -28,6 +28,12 @@ class DummyContentSeeder extends Seeder
28 $book->pages()->saveMany($pages); 28 $book->pages()->saveMany($pages);
29 }); 29 });
30 30
31 + $largeBook = factory(\BookStack\Book::class)->create(['name' => 'Large book' . str_random(10), 'created_by' => $user->id, 'updated_by' => $user->id]);
32 + $pages = factory(\BookStack\Page::class, 200)->make(['created_by' => $user->id, 'updated_by' => $user->id]);
33 + $chapters = factory(\BookStack\Chapter::class, 50)->make(['created_by' => $user->id, 'updated_by' => $user->id]);
34 + $largeBook->pages()->saveMany($pages);
35 + $largeBook->chapters()->saveMany($chapters);
36 +
31 app(\BookStack\Services\PermissionService::class)->buildJointPermissions(); 37 app(\BookStack\Services\PermissionService::class)->buildJointPermissions();
32 app(\BookStack\Services\SearchService::class)->indexAllEntities(); 38 app(\BookStack\Services\SearchService::class)->indexAllEntities();
33 } 39 }
......
...@@ -44,6 +44,8 @@ Once done you can run `phpunit` in the application root directory to run all tes ...@@ -44,6 +44,8 @@ Once done you can run `phpunit` in the application root directory to run all tes
44 44
45 As part of BookStack v0.14 support for translations has been built in. All text strings can be found in the `resources/lang` folder where each language option has its own folder. To add a new language you should copy the `en` folder to an new folder (eg. `fr` for french) then go through and translate all text strings in those files, leaving the keys and file-names intact. If a language string is missing then the `en` translation will be used. To show the language option in the user preferences language drop-down you will need to add your language to the options found at the bottom of the `resources/lang/en/settings.php` file. A system-wide language can also be set in the `.env` file like so: `APP_LANG=en`. 45 As part of BookStack v0.14 support for translations has been built in. All text strings can be found in the `resources/lang` folder where each language option has its own folder. To add a new language you should copy the `en` folder to an new folder (eg. `fr` for french) then go through and translate all text strings in those files, leaving the keys and file-names intact. If a language string is missing then the `en` translation will be used. To show the language option in the user preferences language drop-down you will need to add your language to the options found at the bottom of the `resources/lang/en/settings.php` file. A system-wide language can also be set in the `.env` file like so: `APP_LANG=en`.
46 46
47 +You will also need to add the language to the `locales` array in the `config/app.php` file.
48 +
47 Some strings have colon-prefixed variables in such as `:userName`. Leave these values as they are as they will be replaced at run-time. 49 Some strings have colon-prefixed variables in such as `:userName`. Leave these values as they are as they will be replaced at run-time.
48 50
49 ## Contributing 51 ## Contributing
......
...@@ -215,7 +215,7 @@ module.exports = function (ngApp, events) { ...@@ -215,7 +215,7 @@ module.exports = function (ngApp, events) {
215 } 215 }
216 }]); 216 }]);
217 217
218 - const md = new MarkdownIt(); 218 + const md = new MarkdownIt({html: true});
219 md.use(mdTasksLists, {label: true}); 219 md.use(mdTasksLists, {label: true});
220 220
221 /** 221 /**
......
...@@ -166,7 +166,7 @@ return [ ...@@ -166,7 +166,7 @@ return [
166 'start_a' => ':count usuarios han comenzado a editar esta página', 166 'start_a' => ':count usuarios han comenzado a editar esta página',
167 'start_b' => ':userName ha comenzado a editar esta página', 167 'start_b' => ':userName ha comenzado a editar esta página',
168 'time_a' => 'desde que las página fue actualizada', 168 'time_a' => 'desde que las página fue actualizada',
169 - 'time_b' => 'en los Ãltimos :minCount minutos', 169 + 'time_b' => 'en los últimos :minCount minutos',
170 'message' => ':start :time. Ten cuidado de no sobreescribir los cambios del otro usuario', 170 'message' => ':start :time. Ten cuidado de no sobreescribir los cambios del otro usuario',
171 ], 171 ],
172 'pages_draft_discarded' => 'Borrador descartado, el editor ha sido actualizado con el contenido de la página actual', 172 'pages_draft_discarded' => 'Borrador descartado, el editor ha sido actualizado con el contenido de la página actual',
...@@ -189,7 +189,7 @@ return [ ...@@ -189,7 +189,7 @@ return [
189 'attachments_set_link' => 'Setear Link', 189 'attachments_set_link' => 'Setear Link',
190 'attachments_delete_confirm' => 'Haga click en borrar nuevamente para confirmar que quiere borrar este adjunto.', 190 'attachments_delete_confirm' => 'Haga click en borrar nuevamente para confirmar que quiere borrar este adjunto.',
191 'attachments_dropzone' => 'Arrastre ficheros aquío haga click aquípara adjuntar un fichero', 191 'attachments_dropzone' => 'Arrastre ficheros aquío haga click aquípara adjuntar un fichero',
192 - 'attachments_no_files' => 'NingÃn fichero ha sido adjuntado', 192 + 'attachments_no_files' => 'Ningún fichero ha sido adjuntado',
193 'attachments_explain_link' => 'Ud. puede agregar un link o si lo prefiere puede agregar un fichero. Esto puede ser un link a otra página o un link a un fichero en la nube.', 193 'attachments_explain_link' => 'Ud. puede agregar un link o si lo prefiere puede agregar un fichero. Esto puede ser un link a otra página o un link a un fichero en la nube.',
194 'attachments_link_name' => 'Nombre de Link', 194 'attachments_link_name' => 'Nombre de Link',
195 'attachment_link' => 'Link adjunto', 195 'attachment_link' => 'Link adjunto',
......
1 <?php namespace Tests; 1 <?php namespace Tests;
2 2
3 use BookStack\Role; 3 use BookStack\Role;
4 +use BookStack\Services\PermissionService;
4 use Illuminate\Contracts\Console\Kernel; 5 use Illuminate\Contracts\Console\Kernel;
5 use Illuminate\Foundation\Testing\DatabaseTransactions; 6 use Illuminate\Foundation\Testing\DatabaseTransactions;
6 use Laravel\BrowserKitTesting\TestCase; 7 use Laravel\BrowserKitTesting\TestCase;
...@@ -105,11 +106,9 @@ abstract class BrowserKitTest extends TestCase ...@@ -105,11 +106,9 @@ abstract class BrowserKitTest extends TestCase
105 { 106 {
106 if ($updaterUser === false) $updaterUser = $creatorUser; 107 if ($updaterUser === false) $updaterUser = $creatorUser;
107 $book = factory(\BookStack\Book::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id]); 108 $book = factory(\BookStack\Book::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id]);
108 - $chapter = factory(\BookStack\Chapter::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id]); 109 + $chapter = factory(\BookStack\Chapter::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id]);
109 - $page = factory(\BookStack\Page::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id]); 110 + $page = factory(\BookStack\Page::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id, 'chapter_id' => $chapter->id]);
110 - $book->chapters()->saveMany([$chapter]); 111 + $restrictionService = $this->app[PermissionService::class];
111 - $chapter->pages()->saveMany([$page]);
112 - $restrictionService = $this->app[\BookStack\Services\PermissionService::class];
113 $restrictionService->buildJointPermissionsForEntity($book); 112 $restrictionService->buildJointPermissionsForEntity($book);
114 return [ 113 return [
115 'book' => $book, 114 'book' => $book,
......
...@@ -42,7 +42,7 @@ class EntitySearchTest extends TestCase ...@@ -42,7 +42,7 @@ class EntitySearchTest extends TestCase
42 42
43 public function test_book_search() 43 public function test_book_search()
44 { 44 {
45 - $book = \BookStack\Book::all()->first(); 45 + $book = \BookStack\Book::first();
46 $page = $book->pages->last(); 46 $page = $book->pages->last();
47 $chapter = $book->chapters->last(); 47 $chapter = $book->chapters->last();
48 48
......
1 <?php namespace Tests; 1 <?php namespace Tests;
2 2
3 +use BookStack\Role;
3 use BookStack\Tag; 4 use BookStack\Tag;
4 use BookStack\Page; 5 use BookStack\Page;
5 use BookStack\Services\PermissionService; 6 use BookStack\Services\PermissionService;
......
...@@ -14,6 +14,23 @@ class LanguageTest extends TestCase ...@@ -14,6 +14,23 @@ class LanguageTest extends TestCase
14 $this->langs = array_diff(scandir(resource_path('lang')), ['..', '.']); 14 $this->langs = array_diff(scandir(resource_path('lang')), ['..', '.']);
15 } 15 }
16 16
17 + public function test_locales_config_key_set_properly()
18 + {
19 + $configLocales = config('app.locales');
20 + sort($configLocales);
21 + sort($this->langs);
22 + $this->assertTrue(implode(':', $this->langs) === implode(':', $configLocales), 'app.locales configuration variable matches found lang files');
23 + }
24 +
25 + public function test_correct_language_if_not_logged_in()
26 + {
27 + $loginReq = $this->get('/login');
28 + $loginReq->assertSee('Log In');
29 +
30 + $loginPageFrenchReq = $this->get('/login', ['Accept-Language' => 'fr']);
31 + $loginPageFrenchReq->assertSee('Se Connecter');
32 + }
33 +
17 public function test_js_endpoint_for_each_language() 34 public function test_js_endpoint_for_each_language()
18 { 35 {
19 36
......
...@@ -226,6 +226,7 @@ class RestrictionsTest extends BrowserKitTest ...@@ -226,6 +226,7 @@ class RestrictionsTest extends BrowserKitTest
226 ->type('test content', 'html') 226 ->type('test content', 'html')
227 ->press('Save Page') 227 ->press('Save Page')
228 ->seePageIs($chapter->book->getUrl() . '/page/test-page'); 228 ->seePageIs($chapter->book->getUrl() . '/page/test-page');
229 +
229 $this->visit($chapterUrl)->seeInElement('.action-buttons', 'New Page'); 230 $this->visit($chapterUrl)->seeInElement('.action-buttons', 'New Page');
230 } 231 }
231 232
......
1 <?php namespace Tests; 1 <?php namespace Tests;
2 2
3 +use BookStack\Repos\PermissionsRepo;
4 +use BookStack\Role;
5 +
3 class RolesTest extends BrowserKitTest 6 class RolesTest extends BrowserKitTest
4 { 7 {
5 protected $user; 8 protected $user;
...@@ -34,11 +37,11 @@ class RolesTest extends BrowserKitTest ...@@ -34,11 +37,11 @@ class RolesTest extends BrowserKitTest
34 /** 37 /**
35 * Create a new basic role for testing purposes. 38 * Create a new basic role for testing purposes.
36 * @param array $permissions 39 * @param array $permissions
37 - * @return static 40 + * @return Role
38 */ 41 */
39 protected function createNewRole($permissions = []) 42 protected function createNewRole($permissions = [])
40 { 43 {
41 - $permissionRepo = app('BookStack\Repos\PermissionsRepo'); 44 + $permissionRepo = app(PermissionsRepo::class);
42 $roleData = factory(\BookStack\Role::class)->make()->toArray(); 45 $roleData = factory(\BookStack\Role::class)->make()->toArray();
43 $roleData['permissions'] = array_flip($permissions); 46 $roleData['permissions'] = array_flip($permissions);
44 return $permissionRepo->saveNewRole($roleData); 47 return $permissionRepo->saveNewRole($roleData);
...@@ -107,16 +110,16 @@ class RolesTest extends BrowserKitTest ...@@ -107,16 +110,16 @@ class RolesTest extends BrowserKitTest
107 110
108 public function test_manage_user_permission() 111 public function test_manage_user_permission()
109 { 112 {
110 - $this->actingAs($this->user)->visit('/')->visit('/settings/users') 113 + $this->actingAs($this->user)->visit('/settings/users')
111 ->seePageIs('/'); 114 ->seePageIs('/');
112 $this->giveUserPermissions($this->user, ['users-manage']); 115 $this->giveUserPermissions($this->user, ['users-manage']);
113 - $this->actingAs($this->user)->visit('/')->visit('/settings/users') 116 + $this->actingAs($this->user)->visit('/settings/users')
114 ->seePageIs('/settings/users'); 117 ->seePageIs('/settings/users');
115 } 118 }
116 119
117 public function test_user_roles_manage_permission() 120 public function test_user_roles_manage_permission()
118 { 121 {
119 - $this->actingAs($this->user)->visit('/')->visit('/settings/roles') 122 + $this->actingAs($this->user)->visit('/settings/roles')
120 ->seePageIs('/')->visit('/settings/roles/1')->seePageIs('/'); 123 ->seePageIs('/')->visit('/settings/roles/1')->seePageIs('/');
121 $this->giveUserPermissions($this->user, ['user-roles-manage']); 124 $this->giveUserPermissions($this->user, ['user-roles-manage']);
122 $this->actingAs($this->user)->visit('/settings/roles') 125 $this->actingAs($this->user)->visit('/settings/roles')
...@@ -126,10 +129,10 @@ class RolesTest extends BrowserKitTest ...@@ -126,10 +129,10 @@ class RolesTest extends BrowserKitTest
126 129
127 public function test_settings_manage_permission() 130 public function test_settings_manage_permission()
128 { 131 {
129 - $this->actingAs($this->user)->visit('/')->visit('/settings') 132 + $this->actingAs($this->user)->visit('/settings')
130 ->seePageIs('/'); 133 ->seePageIs('/');
131 $this->giveUserPermissions($this->user, ['settings-manage']); 134 $this->giveUserPermissions($this->user, ['settings-manage']);
132 - $this->actingAs($this->user)->visit('/')->visit('/settings') 135 + $this->actingAs($this->user)->visit('/settings')
133 ->seePageIs('/settings')->press('Save Settings')->see('Settings Saved'); 136 ->seePageIs('/settings')->press('Save Settings')->see('Settings Saved');
134 } 137 }
135 138
...@@ -181,27 +184,26 @@ class RolesTest extends BrowserKitTest ...@@ -181,27 +184,26 @@ class RolesTest extends BrowserKitTest
181 * @param string $permission 184 * @param string $permission
182 * @param array $accessUrls Urls that are only accessible after having the permission 185 * @param array $accessUrls Urls that are only accessible after having the permission
183 * @param array $visibles Check this text, In the buttons toolbar, is only visible with the permission 186 * @param array $visibles Check this text, In the buttons toolbar, is only visible with the permission
184 - * @param null $callback
185 */ 187 */
186 private function checkAccessPermission($permission, $accessUrls = [], $visibles = []) 188 private function checkAccessPermission($permission, $accessUrls = [], $visibles = [])
187 { 189 {
188 foreach ($accessUrls as $url) { 190 foreach ($accessUrls as $url) {
189 - $this->actingAs($this->user)->visit('/')->visit($url) 191 + $this->actingAs($this->user)->visit($url)
190 ->seePageIs('/'); 192 ->seePageIs('/');
191 } 193 }
192 foreach ($visibles as $url => $text) { 194 foreach ($visibles as $url => $text) {
193 - $this->actingAs($this->user)->visit('/')->visit($url) 195 + $this->actingAs($this->user)->visit($url)
194 ->dontSeeInElement('.action-buttons',$text); 196 ->dontSeeInElement('.action-buttons',$text);
195 } 197 }
196 198
197 $this->giveUserPermissions($this->user, [$permission]); 199 $this->giveUserPermissions($this->user, [$permission]);
198 200
199 foreach ($accessUrls as $url) { 201 foreach ($accessUrls as $url) {
200 - $this->actingAs($this->user)->visit('/')->visit($url) 202 + $this->actingAs($this->user)->visit($url)
201 ->seePageIs($url); 203 ->seePageIs($url);
202 } 204 }
203 foreach ($visibles as $url => $text) { 205 foreach ($visibles as $url => $text) {
204 - $this->actingAs($this->user)->visit('/')->visit($url) 206 + $this->actingAs($this->user)->visit($url)
205 ->see($text); 207 ->see($text);
206 } 208 }
207 } 209 }
...@@ -391,8 +393,8 @@ class RolesTest extends BrowserKitTest ...@@ -391,8 +393,8 @@ class RolesTest extends BrowserKitTest
391 393
392 public function test_page_create_own_permissions() 394 public function test_page_create_own_permissions()
393 { 395 {
394 - $book = \BookStack\Book::take(1)->get()->first(); 396 + $book = \BookStack\Book::first();
395 - $chapter = \BookStack\Chapter::take(1)->get()->first(); 397 + $chapter = \BookStack\Chapter::first();
396 398
397 $entities = $this->createEntityChainBelongingToUser($this->user); 399 $entities = $this->createEntityChainBelongingToUser($this->user);
398 $ownBook = $entities['book']; 400 $ownBook = $entities['book'];
...@@ -405,7 +407,7 @@ class RolesTest extends BrowserKitTest ...@@ -405,7 +407,7 @@ class RolesTest extends BrowserKitTest
405 $accessUrls = [$createUrl, $createUrlChapter]; 407 $accessUrls = [$createUrl, $createUrlChapter];
406 408
407 foreach ($accessUrls as $url) { 409 foreach ($accessUrls as $url) {
408 - $this->actingAs($this->user)->visit('/')->visit($url) 410 + $this->actingAs($this->user)->visit($url)
409 ->seePageIs('/'); 411 ->seePageIs('/');
410 } 412 }
411 413
...@@ -417,7 +419,7 @@ class RolesTest extends BrowserKitTest ...@@ -417,7 +419,7 @@ class RolesTest extends BrowserKitTest
417 $this->giveUserPermissions($this->user, ['page-create-own']); 419 $this->giveUserPermissions($this->user, ['page-create-own']);
418 420
419 foreach ($accessUrls as $index => $url) { 421 foreach ($accessUrls as $index => $url) {
420 - $this->actingAs($this->user)->visit('/')->visit($url); 422 + $this->actingAs($this->user)->visit($url);
421 $expectedUrl = \BookStack\Page::where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl(); 423 $expectedUrl = \BookStack\Page::where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl();
422 $this->seePageIs($expectedUrl); 424 $this->seePageIs($expectedUrl);
423 } 425 }
...@@ -449,7 +451,7 @@ class RolesTest extends BrowserKitTest ...@@ -449,7 +451,7 @@ class RolesTest extends BrowserKitTest
449 $accessUrls = [$createUrl, $createUrlChapter]; 451 $accessUrls = [$createUrl, $createUrlChapter];
450 452
451 foreach ($accessUrls as $url) { 453 foreach ($accessUrls as $url) {
452 - $this->actingAs($this->user)->visit('/')->visit($url) 454 + $this->actingAs($this->user)->visit($url)
453 ->seePageIs('/'); 455 ->seePageIs('/');
454 } 456 }
455 457
...@@ -461,7 +463,7 @@ class RolesTest extends BrowserKitTest ...@@ -461,7 +463,7 @@ class RolesTest extends BrowserKitTest
461 $this->giveUserPermissions($this->user, ['page-create-all']); 463 $this->giveUserPermissions($this->user, ['page-create-all']);
462 464
463 foreach ($accessUrls as $index => $url) { 465 foreach ($accessUrls as $index => $url) {
464 - $this->actingAs($this->user)->visit('/')->visit($url); 466 + $this->actingAs($this->user)->visit($url);
465 $expectedUrl = \BookStack\Page::where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl(); 467 $expectedUrl = \BookStack\Page::where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl();
466 $this->seePageIs($expectedUrl); 468 $this->seePageIs($expectedUrl);
467 } 469 }
......