Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Cleanup baseViewer.hasAnnotationPermissions() and tests #685

Merged
merged 6 commits into from
Mar 26, 2018

Conversation

pramodsum
Copy link
Contributor

No description provided.

@boxcla
Copy link

boxcla commented Feb 26, 2018

Verified that @pramodsum has signed the CLA. Thanks for the pull request!

Copy link
Contributor

@jeremypress jeremypress left a comment

Choose a reason for hiding this comment

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

Is this a refactor or does it fix a specific issue?

const { can_annotate, can_view_annotations_all, can_view_annotations_self } = permissions;

// eslint-disable-next-line
return can_annotate || can_view_annotations_all || can_view_annotations_self;
Copy link
Contributor

Choose a reason for hiding this comment

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

You were forcing a boolean before with !! on line 814, is ok to return undefined now if no permissions are passed in the object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forcing it again now just to be sure :)

Copy link
Contributor

@DanDeMicco DanDeMicco left a comment

Choose a reason for hiding this comment

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

Seems like this test file is inconsistent with other files in terms of the matchers. http://chaijs.com/api/bdd/

@tonyjin
Copy link
Contributor

tonyjin commented Mar 1, 2018

This change lgtm, but I'm curious why hasAnnotationPermissions() worked before. It looked like it was returning true if you could not leave annotations and you could not view annotations, false otherwise.

This patch changes it to return true if you can either leave annotations, view your own, or view all annotations. I'd like some investigation into what this was doing before before we merge this.

@@ -382,8 +383,8 @@ describe('lib/viewers/BaseViewer', () => {
sinon.assert.failException;
})
.catch((error) => {
expect(error).equals(sinon.match.error);
expect(error.message).equals('message');
expect(error).to.equal(sinon.match.error);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you just change this line real quick to use chai? expect(error).to.be.an('error');

@pramodsum
Copy link
Contributor Author

@tonyjin looks like this was always returning true because we were passing in the file object rather than the expected permissions object. There are a lot more permissions checks within the annotations codebase which is why this may method may not have actually surfaced a bug but yea the method was never working correctly 👎

@pramodsum pramodsum merged commit daa8e86 into box:master Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants