Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

.travis.yml fix for 7.x #255

Merged
merged 23 commits into from
Jun 23, 2017
Merged

.travis.yml fix for 7.x #255

merged 23 commits into from
Jun 23, 2017

Conversation

AronNovak
Copy link
Member

@AronNovak AronNovak commented Apr 18, 2017

Status:

  • rewritten YML file with upgraded PHP

Todo:

  • make Travis green
  • optionally include PHP7 in the build matrix

#133

@AronNovak
Copy link
Member Author

Travis now realistically shows that the tests do not pass, we have identical result on local execution:
local

AronNovak added 2 commits May 12, 2017 17:09
…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
@AronNovak
Copy link
Member Author

The other failing assertion is because somehow plugins/entityreference/behavior/OgBehaviorHandler.class.php / OgMembershipCrud has an issue:

      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')) {
        $item['state'] = OG_STATE_PENDING;
      } 

Is not effective anymore.

@amitaibu
Copy link
Member

@AronNovak Can you invest 2h in this please

@AronNovak
Copy link
Member Author

Sure.
So this particular assertion became broken after the merge of #120 , which totally make sense. Now thinking about what to test meaningfully to avoid to remove it completely.

…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
@AronNovak
Copy link
Member Author

I highly refactored that particular test, 1b32b2c - the commit message has the explanation, waiting for the green from Travis.

@AronNovak
Copy link
Member Author

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')) {
Copy link
Member

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

Copy link
Member Author

@AronNovak AronNovak May 17, 2017

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.

Copy link
Member Author

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.

Copy link
Member

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:

  1. Create a private group (that is with og_access module enabled and configured)
  2. Allow in the OG permissions, to subscribe to group
  3. As a non-admin user visit directly the subscribe URL
  4. Try to subscribe

What is the OgMembership->state you get?

Copy link
Member Author

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:
perm-table
Non-member regular Drupal user wants to join:
join
After join, he sees this:
unsub
And in the database, the state is:
state-2
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');
Copy link
Member

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

Copy link
Member Author

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.'));
Copy link
Member

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

Copy link
Member Author

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.

@amitaibu
Copy link
Member

What's the status here?

@AronNovak
Copy link
Member Author

@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.

@AronNovak AronNovak changed the title WIP: .travis.yml fix for 7.x .travis.yml fix for 7.x Jun 23, 2017
@AronNovak
Copy link
Member Author

ready for (a final) review

@amitaibu
Copy link
Member

Finally, travis is green. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants