Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/17/2017 06:57:37 PM (8 years ago)
Author:
dcavins
Message:

Redirect group requests to new group slug.

If a user attempts to visit a group using an old slug, redirect her to
the current URI.

Fixes #6014.

File:
1 edited

Legend:

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

    r11408 r11559  
    6464        $this->assertTrue( is_404() );
    6565    }
     66
     67    /**
     68     * @group group_previous_slug
     69     */
     70    public function test_group_previous_slug_current_slug_should_resolve() {
     71        $g1 = $this->factory->group->create( array(
     72            'slug' => 'george',
     73        ) );
     74        groups_edit_base_group_details( array(
     75            'group_id' => $g1,
     76            'slug'     => 'ralph',
     77        ) );
     78
     79        $this->go_to( bp_get_groups_directory_permalink() . 'ralph' );
     80
     81        $this->assertEquals( $g1, bp_get_current_group_id() );
     82    }
     83
     84    /**
     85     * @group group_previous_slug
     86     */
     87    public function test_group_previous_slug_should_resolve() {
     88        $g1 = $this->factory->group->create( array(
     89            'slug' => 'george',
     90        ) );
     91
     92        groups_edit_base_group_details( array(
     93            'group_id'       => $g1,
     94            'slug'           => 'sam!',
     95            'notify_members' => false,
     96        ) );
     97        $this->go_to( bp_get_groups_directory_permalink() . 'george' );
     98
     99        $this->assertEquals( $g1, bp_get_current_group_id() );
     100    }
     101
     102    /**
     103     * @group group_previous_slug
     104     */
     105    public function test_group_previous_slug_most_recent_takes_precedence() {
     106        $g1 = $this->factory->group->create( array(
     107            'slug' => 'george',
     108        ) );
     109        groups_edit_base_group_details( array(
     110            'group_id'       => $g1,
     111            'slug'           => 'ralph',
     112            'notify_members' => false,
     113        ) );
     114        $g2 = $this->factory->group->create( array(
     115            'slug' => 'george',
     116        ) );
     117        groups_edit_base_group_details( array(
     118            'group_id'       => $g2,
     119            'slug'           => 'sam',
     120            'notify_members' => false,
     121        ) );
     122
     123        $this->go_to( bp_get_groups_directory_permalink() . 'george' );
     124        $this->assertEquals( $g2, bp_get_current_group_id() );
     125    }
     126
    66127}
Note: See TracChangeset for help on using the changeset viewer.