[featured] fix feature button
This commit is contained in:
parent
4a5d30e0bf
commit
4807064a65
2 changed files with 5 additions and 6 deletions
|
@ -18,8 +18,8 @@ class Featured extends Extension
|
||||||
public function onPageRequest(PageRequestEvent $event): void
|
public function onPageRequest(PageRequestEvent $event): void
|
||||||
{
|
{
|
||||||
global $config, $page, $user;
|
global $config, $page, $user;
|
||||||
if ($event->page_matches("featured_image/set", method: "POST", permission: Permissions::EDIT_FEATURE)) {
|
if ($event->page_matches("featured_image/set/{image_id}", method: "POST", permission: Permissions::EDIT_FEATURE)) {
|
||||||
$id = int_escape($event->req_POST('image_id'));
|
$id = $event->get_iarg('image_id');
|
||||||
$config->set_int("featured_id", $id);
|
$config->set_int("featured_id", $id);
|
||||||
log_info("featured", "Featured post set to >>$id", "Featured post set");
|
log_info("featured", "Featured post set to >>$id", "Featured post set");
|
||||||
$page->set_mode(PageMode::REDIRECT);
|
$page->set_mode(PageMode::REDIRECT);
|
||||||
|
|
|
@ -17,10 +17,9 @@ class FeaturedTest extends ShimmiePHPUnitTestCase
|
||||||
# FIXME: test that regular users can't feature things
|
# FIXME: test that regular users can't feature things
|
||||||
|
|
||||||
// Admin can feature things
|
// Admin can feature things
|
||||||
// FIXME: use Event rather than modifying database
|
$this->log_in_as_admin();
|
||||||
// $this->log_in_as_admin();
|
$page = $this->post_page("featured_image/set/$image_id");
|
||||||
// send_event(new SetFeaturedEvent($image_id));
|
$this->assertEquals(302, $page->code);
|
||||||
$config->set_int("featured_id", $image_id);
|
|
||||||
|
|
||||||
$this->get_page("post/list");
|
$this->get_page("post/list");
|
||||||
$this->assert_text("Featured Post");
|
$this->assert_text("Featured Post");
|
||||||
|
|
Reference in a new issue