Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/25/2018 11:29:28 PM (6 years ago)
Author:
r-a-y
Message:

Groups: Fix display of "Comment" button in the activity stream.

In r11959, the banned group members check is using the wrong conditional.
This caused legitimate group members to never see the "Comment" button in
the activity stream.

This commit reverses the check and adds some unit tests (which should have
been written beforehand!).

Anti-props r-a-y.

See #4429.

Fixes #7854 (3.x branch).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/tests/phpunit/testcases/groups/activity.php

    r11737 r12131  
    224224        $this->set_current_user( $old_user );
    225225    }
     226
     227    /**
     228     * @group bp_activity_can_comment
     229     */
     230    public function test_groups_activity_can_comment() {
     231        $old_user = get_current_user_id();
     232        $u1 = self::factory()->user->create();
     233        $u2 = self::factory()->user->create();
     234
     235        $g = self::factory()->group->create();
     236
     237        // User 1 is a group member, while user 2 isn't.
     238        groups_join_group( $g, $u1 );
     239
     240        $a = self::factory()->activity->create( array(
     241            'component' => buddypress()->groups->id,
     242            'type' => 'created_group',
     243            'user_id' => $u1,
     244            'item_id' => $g,
     245        ) );
     246
     247        $this->set_current_user( $u1 );
     248        if ( bp_has_activities( array( 'in' => $a ) ) ) {
     249            while ( bp_activities() ) : bp_the_activity();
     250                // User 1 should be able to comment.
     251                $this->assertTrue( bp_activity_can_comment() );
     252            endwhile;
     253        }
     254
     255        $this->set_current_user( $u2 );
     256        if ( bp_has_activities( array( 'in' => $a ) ) ) {
     257            while ( bp_activities() ) : bp_the_activity();
     258                // User 2 should not be able to comment.
     259                $this->assertFalse( bp_activity_can_comment() );
     260            endwhile;
     261        }
     262
     263        $this->set_current_user( $old_user );
     264    }
    226265}
Note: See TracChangeset for help on using the changeset viewer.