-
Notifications
You must be signed in to change notification settings - Fork 132
Conversation
…rivial due to phpenv
…server causes whatever/10.00/group path a 404, it does not reach Drupal. Instead of patching Drush, rewrote the test to check similar, but a bit different scenario
The other failing assertion is because somehow plugins/entityreference/behavior/OgBehaviorHandler.class.php /
Is not effective anymore. |
@AronNovak Can you invest 2h in this please |
Sure. |
…r has group admin permission, we should not set new membership to pending. But if he is not an admin, we exit early from the membership Crud. Adapted the test to test admin permission check of the Crud itself
I highly refactored that particular test, 1b32b2c - the commit message has the explanation, waiting for the green from Travis. |
…result of simpletest
Very good, we have the Travis green. To make sure the opposite direction works, by intention, now i break a test, then let's see if we have red again, then going to revert that change. |
@@ -122,11 +122,7 @@ public function OgMembershipCrud($entity_type, $entity, $field, $instance, $lang | |||
foreach ($items as $item) { | |||
$gid = $item['target_id']; | |||
|
|||
// Must provide correct state in the event that approval is required. | |||
if (empty($item['state']) && $entity_type == 'user' && !og_user_access($group_type, $gid, 'subscribe without approval', $entity) && !og_user_access($group_type, $gid, 'administer group')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this seems wrong. I guess you tested a specific case of adding members via UI, but this is about creating membership via the field API.
I believe the existing code should be reverted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this is unreachable code, due to og_user_access($group_type, $gid, 'administer group')
, versus https://github.com/Gizra/og/blob/7.x-2.x/plugins/entityreference/behavior/OgBehaviorHandler.class.php#L98 , that's why I removed. As far as i see, now it became impossible to trigger that branch.
If the user has group admin permission, we should not set new membership to pending. But if he is not an admin, we exit early from the membership Crud. Adapted the test to test admin permission check of the Crud itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I think #120 - this issue justifies the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please test this scenario:
- Create a private group (that is with
og_access
module enabled and configured) - Allow in the OG permissions, to subscribe to group
- As a non-admin user visit directly the subscribe URL
- Try to subscribe
What is the OgMembership->state you get?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I used the same environment as we use in Travis, same PHP built-in webserver, same setup, and I was on this branch, not the main one.
OG Access configured:
Non-member regular Drupal user wants to join:
After join, he sees this:
And in the database, the state is:
And state 2 is Pending: https://github.com/Gizra/og/blob/7.x-2.x/og.module#L26 , so it still works as expected.
// Numeric values that are not consist of decimal characters are forbidden. | ||
// 0x1 for instance is equivalent to 1 | ||
// http://php.net/manual/en/language.types.integer.php | ||
$this->drupalGet('entity_test/0x' . $this->entity->pid . '/group'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could also just do $this->drupalGet('entity_test/666/group');
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, just added.
$membership = og_get_membership('node', $this->group->nid, 'user', $this->user->uid); | ||
$this->assertEqual($membership->state, OG_STATE_PENDING, t('User membership is pending.')); | ||
$this->assertFalse(is_object($membership), t('Non-admins cannot add members to private groups.')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the assertion isn't the same as the original one. It's not about interaction with admins, it's about a user trying to subscribe to a private group -- they should be pending
by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it isn't the same, but after https://github.com/Gizra/og/pull/124/files , it's not possible to test it this way, based on my current understanding.
…etection" This reverts commit e6a6a02.
What's the status here? |
@amitaibu thanks a lot for the reminder, based on the last Travis output, i pushed one more commit, it's supposed to provide green status, we're very close (or ready) on this PR to achieve the goal. |
ready for (a final) review |
Finally, travis is green. Thank you! |
Status:
Todo:
#133