Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/31/2017 08:31:10 PM (9 years ago)
Author:
r-a-y
Message:

Groups: Fix AJAX pagination when on a group type directory page.

This commit moves group type directory detection from the
'template_redirect' hook to our groups component class to ensure
detection is available for AJAX purposes.

Commit also changes invalid group type directory requests to 404 instead
of redirecting back to the main Groups directory.

Props r-a-y, dcavins.

Fixes #7423.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/routing/groups.php

    r9819 r11405  
    2828        $this->assertTrue( bp_is_user_groups() && bp_is_current_action( 'invites' ) );
    2929    }
     30
     31    /**
     32     * @group group_types
     33     */
     34    public function test_group_directory_with_type() {
     35        bp_groups_register_group_type( 'foo' );
     36        $this->go_to( bp_get_groups_directory_permalink() . 'type/foo/' );
     37        $this->assertTrue( bp_is_groups_component() && ! bp_is_group() && bp_is_current_action( bp_get_groups_group_type_base() ) && bp_is_action_variable( 'foo', 0 ) );
     38    }
     39
     40    /**
     41     * @group group_types
     42     */
     43    public function test_group_directory_with_type_that_has_custom_directory_slug() {
     44        bp_groups_register_group_type( 'foo', array( 'has_directory' => 'foos' ) );
     45        $this->go_to( bp_get_groups_directory_permalink() . 'type/foos/' );
     46        $this->assertTrue( bp_is_groups_component() && ! bp_is_group() && bp_is_current_action( bp_get_groups_group_type_base() ) && bp_is_action_variable( 'foos', 0 ) );
     47    }
     48
     49    /**
     50     * @group group_types
     51     */
     52    public function test_group_directory_should_404_for_group_types_that_have_no_directory() {
     53        bp_register_member_type( 'foo', array( 'has_directory' => false ) );
     54        $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
     55        $this->assertTrue( is_404() );
     56    }
     57
     58    /**
     59     * @group group_types
     60     */
     61    public function test_group_directory_should_404_for_invalid_group_types() {
     62        $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
     63        $this->assertTrue( is_404() );
     64    }
    3065}
Note: See TracChangeset for help on using the changeset viewer.