Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

PLAT-452 Update logic to include editor role #512

Merged
merged 8 commits into from
Sep 23, 2016

Conversation

bimsonz
Copy link
Contributor

@bimsonz bimsonz commented Sep 14, 2016

Fixes https://jira.comicrelief.com/browse/PLAT-452

Changes proposed in this pull request

  • Update logic to include the editor role ...
  • Missing behat test

The editing operation is covered by the standard permissions.

The editing operation is covered by the standard permissions.
@bimsonz
Copy link
Contributor Author

bimsonz commented Sep 14, 2016

@pvhee what was your bhat suggestion for this ?

@bimsonz bimsonz added this to the 1.12.0 milestone Sep 14, 2016
@pvhee
Copy link
Contributor

pvhee commented Sep 14, 2016

@bimsonz something like:

  • I log in as editor and create unpublished node
  • I log in as another editor and click edit on that page

That should only work with this fix, try commenting your code to make sure it doesn't work without your fix.

return AccessResult::allowed();
if (in_array('reviewer', $account->getRoles()) || in_array('editor', $account->getRoles())) {
if ($op == 'view') {
return AccessResult::allowed();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the op view is checked, how would this work to give edit access to other editors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned in the first comment on this thread, the edit operation seems to be covered by the built in "edit" permissions, would like this tested thoroughly though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so currently the permissions were already set up fine, and this change is simply about giving editor roles access to see unpublished content?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as im aware, yes, speaking to liv, her main requirements were reviewers are able to see any page regardless of status and editors, edit.. @pvhee please also check the test site, details provided below

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, test is working fine!

I'm just confused on this, cause this means that it could be working right now on production already, simply by adding the "reviewer" role to all the editor accounts...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reviewer only has view permissions though, they cant edit anything @pvhee

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

Copy link
Contributor

@pvhee pvhee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to work as intended, can this be demo'd also on a platform.sh env.

@bimsonz
Copy link
Contributor Author

bimsonz commented Sep 15, 2016

two users:
editor/editor
editor2/Pa55w0rd!comic

http://pr-512-tx3mbsqmxtu74.eu.platform.sh/test-editor-rights

Both are able to view and edit this unpublished post...
What are the known issues you've found so i can resolve please?

@bimsonz
Copy link
Contributor Author

bimsonz commented Sep 16, 2016

@pvhee ive added an initial test but im not sure how id go about logging in with a different editor user considering i didnt define one in the first place, sure the syntax is easy, right ?

@api
Scenario: Check two different editors both have access to edit a single page
Given I am logged in as a user with the "editor" role
And I am viewing a "page" content with "Test page" title
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bimsonz if you do vendor/bin/behat -dl you see step definitions you can use. You probably need Given an **unpublished** and repeat the Given I am logged in as a user with the "editor" role step to log in again. Have a look at how they're defined, it isn't that hard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wicked, thanks for the point in the right direction, maybe we should add that command to view the definitions to some sort of 'developing bhat test' doc?

/**
* @Given I am viewing an unpublished :arg1 with the title :arg2
*/
public function iAmViewingAnUnpublishedWithTheTitle($type, $title)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pvhee i had to add this.. dont like thats its dup code.. im still a mega bhat novice, maybe you can get it so i dont need it..?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you could reuse https://github.com/comicrelief/campaign/blob/develop/profiles/cr/tests/behat/features/bootstrap/DrupalCRFeatureContext.php#L391, no?

Then, write the behat step as Given an unpublished "page" content with the title "Unpublished page"

@pvhee
Copy link
Contributor

pvhee commented Sep 16, 2016

@bimsonz Some more feedback on Travis tests: could you run this locally as well and add @javascript to the step definition (next to @api, you should install the chrome selenium driver first then run it, there are some docs in this repo). Then you can add And I break between the different steps and you'll be able to follow the test in the browser (this is a really cool way to develop behat tests). If you're then happy with the tests (Travis seems happy but I am not sure it's actually using two different editor accounts, seeing it in the browser will give clarity), we can merge this

@Saphyel Saphyel modified the milestones: 1.13.0, 1.12.0 Sep 20, 2016
@bimsonz
Copy link
Contributor Author

bimsonz commented Sep 23, 2016

Should be ready now @pvhee

@@ -26,3 +26,10 @@ Feature: User
Given I am on "/admin/people"
Then I should get a "403" HTTP response
And I should see "You are not authorized to access this page."

@api @javascript
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bimsonz can we take off @javascript then? not needed and it'll slow down tests on Travis

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry! done! @pvhee

@pvhee
Copy link
Contributor

pvhee commented Sep 23, 2016

This also is the reason this failed btw, shouldn't now fail with @javascript taken off so will merge once Travis goes green

@pvhee pvhee merged commit 9187f7a into develop Sep 23, 2016
@pvhee pvhee deleted the feature/PLAT-452_unpublished_visible_to_editors branch September 23, 2016 10:40
@bimsonz bimsonz mentioned this pull request Sep 29, 2016
@pvhee pvhee mentioned this pull request Jan 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants