+ public function test_content_not_listed_on_404_for_public_users()
+ {
+ $page = Page::query()->first();
+ $page->fill(['name' => 'my testing random unique page name'])->save();
+ $this->asAdmin()->get($page->getUrl()); // Fake visit to show on recents
+ $resp = $this->get('/cats/dogs/hippos');
+ $resp->assertStatus(404);
+ $resp->assertSee($page->name);
+ View::share('pageTitle', '');
+
+ Auth::logout();
+ $resp = $this->get('/cats/dogs/hippos');
+ $resp->assertStatus(404);
+ $resp->assertDontSee($page->name);
+ }
+
+ public function test_robots_effected_by_public_status()
+ {
+ $this->get('/robots.txt')->assertSee("User-agent: *\nDisallow: /");
+
+ $this->setSettings(['app-public' => 'true']);
+
+ $resp = $this->get('/robots.txt');
+ $resp->assertSee("User-agent: *\nDisallow:");
+ $resp->assertDontSee('Disallow: /');
+ }
+
+ public function test_robots_effected_by_setting()
+ {
+ $this->get('/robots.txt')->assertSee("User-agent: *\nDisallow: /");
+
+ config()->set('app.allow_robots', true);
+
+ $resp = $this->get('/robots.txt');
+ $resp->assertSee("User-agent: *\nDisallow:");
+ $resp->assertDontSee('Disallow: /');
+
+ // Check config overrides app-public setting
+ config()->set('app.allow_robots', false);
+ $this->setSettings(['app-public' => 'true']);
+ $this->get('/robots.txt')->assertSee("User-agent: *\nDisallow: /");
+ }
+
+ public function test_public_view_then_login_redirects_to_previous_content()
+ {
+ $this->setSettings(['app-public' => 'true']);
+ /** @var Book $book */
+ $book = Book::query()->first();
+ $resp = $this->get($book->getUrl());
+ $resp->assertSee($book->name);
+
+ $this->get('/login');
+ $resp = $this->post('/login', ['email' => '
[email protected]', 'password' => 'password']);
+ $resp->assertRedirect($book->getUrl());
+ }
+
+ public function test_access_hidden_content_then_login_redirects_to_intended_content()
+ {
+ $this->setSettings(['app-public' => 'true']);
+ /** @var Book $book */
+ $book = Book::query()->first();
+ $this->setEntityRestrictions($book);
+
+ $resp = $this->get($book->getUrl());
+ $resp->assertSee('Book not found');
+
+ $this->get('/login');
+ $resp = $this->post('/login', ['email' => '
[email protected]', 'password' => 'password']);
+ $resp->assertRedirect($book->getUrl());
+ $this->followRedirects($resp)->assertSee($book->name);
+ }
+}