-
Notifications
You must be signed in to change notification settings - Fork 605
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
Show right-hand column for yanked versions to crate owners. #1759
Conversation
df74424
to
c7823b4
Compare
Among other things, this makes the "Manage owners" link available even if all versions of a crate were yanked.
c7823b4
to
3bde7dd
Compare
@@ -33,6 +33,11 @@ export default Controller.extend({ | |||
isOwner: computed('crate.owner_user', 'session.currentUser.id', function() { | |||
return this.get('crate.owner_user').findBy('id', this.get('session.currentUser.id')); | |||
}), | |||
notYankedOrIsOwner: computed('model', 'crate.owner_user', 'session.currentUser.id', function() { |
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.
could we add unit tests for this computed?
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 we could, but I'm not familiar with Ember or Mirage, so I'm not sure what's the best way to do this. I've added an attempt as a new commit that tries to use Mirage to set up a new crate and a version. The test passes in its current form, but has a few problems:
- I was only able to use the Mirage factories when running the whole application with
setupApplicationTest()
. This seems unnecessary and makes the test much slower than it should be. - Testing the other cases (yanked crate, with the user being owner or not) requires also faking an active session and user accounts. I couldn't find any existing infrastructure to do so in a unit test.
We may be able to test this with an acceptance test instead, but at least for me this would involve significant effort. Maybe someone more experienced with Ember could add this test?
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.
Apologies @smarnach, I should've added a bit more direction here. Ember can generate default unit tests that should avoid needing to use mirage. The problems you point out highlight the many concerns of acceptance / integration testing I hoped to avoid by suggesting a unit test. I'll open a PR against your branch with a simple unit test.
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.
I'm doing this in my fork, but you can create test files using ember generate
commands.
ember generate controller-test crate/version
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.
I was lazy and didn't fork your copy, but here is the working example of the unit test: https://github.com/rust-lang/crates.io/compare/master...efx:unit-test-controller?expand=1#diff-a30cef8546b1174ebf3c37a550e2357f
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.
Thanks a lot, this looks a lot more reasonable than my attempt! I guess I should learn a bit more about Ember before doing any more work on the frontend. :)
I've copied your test to this branch (and force-pushed, since my attempt isn't worth being preserved in the Git history).
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.
certainly @smarnach. Eh, learning on the go seems most efficient 😄. Grand!
4656a9e
to
234a9ac
Compare
Looks good to me. |
@locks any objections to merging this? |
The text wrapping is different now if you're not an owner, but I'm fine with it. @bors: r+ |
📌 Commit 234a9ac has been approved by |
Show right-hand column for yanked versions to crate owners. Fixes #1660. Without this change, the page for a yanked version looks like this: ![image](https://user-images.githubusercontent.com/249196/58944345-ec823d00-8781-11e9-9322-019250a6fb1d.png) With this change applied, crate owners see this page instead: ![image](https://user-images.githubusercontent.com/249196/58944390-0de32900-8782-11e9-9c58-ac649c9c23c0.png)
☀️ Test successful - checks-travis |
Fixes #1660.
Without this change, the page for a yanked version looks like this:
With this change applied, crate owners see this page instead: