Skip to content

Commit d55040f

Browse files
committed
display link to owners only
1 parent fc9234f commit d55040f

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

app/controllers/crate/version.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export default Controller.extend({
2525
keywords: computed.alias('crate.keywords'),
2626
categories: computed.alias('crate.categories'),
2727
badges: computed.alias('crate.badges'),
28+
isOwner: computed('crate.owner_user', function() {
29+
return this.get('crate.owner_user').findBy('login', this.session.get('currentUser.id'));
30+
}),
2831

2932
sortedVersions: computed.readOnly('crate.versions'),
3033

app/templates/crate/version.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@
169169

170170
<div id='crate-owners'>
171171
<h3>Owners</h3>
172+
{{#if isOwner}}
172173
<p>
173174
{{#link-to 'crate.owners' crate}}
174175
Manage owners
175176
{{/link-to}}
176177
</p>
178+
{{/if}}
177179
<ul class='owners'>
178180
{{#each crate.owner_team as |team|}}
179181
<li>

tests/acceptance/crate-test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test } from 'qunit';
22
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';
3+
import Ember from 'ember';
34

45
moduleForAcceptance('Acceptance | crate page');
56

@@ -125,9 +126,41 @@ test('crates license is supplied by version', async function(assert) {
125126
assert.dom('.license').hasText('MIT/Apache-2.0');
126127
});
127128

129+
test('navigating to the owners page when not logged in', async function(assert) {
130+
server.loadFixtures();
131+
132+
await visit('/crates/nanomsg');
133+
134+
assert.dom('#crate-owners p a').doesNotExist();
135+
});
136+
137+
test('navigating to the owners page when not an owner', async function(assert) {
138+
server.loadFixtures();
139+
140+
this.application.register('service:session-b', Ember.Service.extend({
141+
currentUser: {
142+
id: 'iain8'
143+
}
144+
}));
145+
146+
this.application.inject('controller', 'session', 'service:session-b');
147+
148+
await visit('/crates/nanomsg');
149+
150+
assert.dom('#crate-owners p a').doesNotExist();
151+
});
152+
128153
test('navigating to the owners page', async function(assert) {
129154
server.loadFixtures();
130155

156+
this.application.register('service:session-b', Ember.Service.extend({
157+
currentUser: {
158+
id: 'thehydroimpulse'
159+
}
160+
}));
161+
162+
this.application.inject('controller', 'session', 'service:session-b');
163+
131164
await visit('/crates/nanomsg');
132165
await click('#crate-owners p a');
133166

0 commit comments

Comments
 (0)