Skip to content

Commit 2675a6a

Browse files
committed
Redirect /owners to /settings
fix typo fix test: add cases test: add cases
1 parent 51ca554 commit 2675a6a

File tree

8 files changed

+41
-15
lines changed

8 files changed

+41
-15
lines changed

app/controllers/crate/owners.js renamed to app/controllers/crate/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { inject as service } from '@ember/service';
33

44
import { task } from 'ember-concurrency';
55

6-
export default class CrateOwnersController extends Controller {
6+
export default class CrateSettingsController extends Controller {
77
@service notifications;
88

99
crate = null;

app/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Router.map(function () {
2020
this.route('reverse-dependencies', { path: 'reverse_dependencies' });
2121

2222
this.route('owners');
23+
this.route('settings');
2324

2425
// Well-known routes
2526
this.route('docs');

app/routes/crate/owners.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import Route from '@ember/routing/route';
22

33
export default class OwnersRoute extends Route {
4-
setupController(controller) {
5-
super.setupController(...arguments);
4+
redirect() {
65
let crate = this.modelFor('crate');
7-
controller.set('crate', crate);
6+
7+
this.transitionTo('crate.settings', crate);
88
}
99
}

app/routes/crate/settings.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Route from '@ember/routing/route';
2+
3+
export default class SettingsRoute extends Route {
4+
setupController(controller) {
5+
super.setupController(...arguments);
6+
let crate = this.modelFor('crate');
7+
controller.set('crate', crate);
8+
}
9+
}

app/templates/crate/owners.hbs renamed to app/templates/crate/settings.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{page-title 'Manage Crate Owners'}}
1+
{{page-title 'Manage Crate Settings'}}
22

33
<CrateHeader @crate={{this.crate}} />
44

tests/acceptance/crate-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ module('Acceptance | crate page', function (hooks) {
201201
assert.dom('[data-test-settings-tab]').doesNotExist();
202202
});
203203

204-
test('navigating to the owners page', async function (assert) {
204+
test('navigating to the settings page', async function (assert) {
205205
this.server.loadFixtures();
206206

207207
let user = this.server.schema.users.findBy({ login: 'thehydroimpulse' });
@@ -210,6 +210,6 @@ module('Acceptance | crate page', function (hooks) {
210210
await visit('/crates/nanomsg');
211211
await click('[data-test-settings-tab] a');
212212

213-
assert.equal(currentURL(), '/crates/nanomsg/owners');
213+
assert.equal(currentURL(), '/crates/nanomsg/settings');
214214
});
215215
});

tests/acceptance/owners-test.js renamed to tests/acceptance/settings-test.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,28 @@ import { setupApplicationTest } from 'cargo/tests/helpers';
88

99
import axeConfig from '../axe-config';
1010

11-
module('Acceptance | /crates/:name/owners', function (hooks) {
11+
module('Acceptance | /crates/:name/settings', function (hooks) {
1212
setupApplicationTest(hooks);
1313

1414
test('listing crate owners', async function (assert) {
1515
this.server.loadFixtures();
1616

17+
await visit('/crates/nanomsg/settings');
18+
19+
assert.dom('[data-test-owners] [data-test-owner-team]').exists({ count: 2 });
20+
assert.dom('[data-test-owners] [data-test-owner-user]').exists({ count: 2 });
21+
assert.dom('a[href="/teams/github:org:thehydroimpulse"]').exists();
22+
assert.dom('a[href="/teams/github:org:blabaere"]').exists();
23+
assert.dom('a[href="/users/thehydroimpulse"]').exists();
24+
assert.dom('a[href="/users/blabaere"]').exists();
25+
26+
await percySnapshot(assert);
27+
await a11yAudit(axeConfig);
28+
});
29+
30+
test('redirecting and listing crate owners', async function (assert) {
31+
this.server.loadFixtures();
32+
1733
await visit('/crates/nanomsg/owners');
1834

1935
assert.dom('[data-test-owners] [data-test-owner-team]').exists({ count: 2 });
@@ -30,15 +46,15 @@ module('Acceptance | /crates/:name/owners', function (hooks) {
3046
test('attempting to add owner without username', async function (assert) {
3147
this.server.loadFixtures();
3248

33-
await visit('/crates/nanomsg/owners');
49+
await visit('/crates/nanomsg/settings');
3450
await fillIn('input[name="username"]', '');
3551
assert.dom('[data-test-save-button]').isDisabled();
3652
});
3753

3854
test('attempting to add non-existent owner', async function (assert) {
3955
this.server.loadFixtures();
4056

41-
await visit('/crates/nanomsg/owners');
57+
await visit('/crates/nanomsg/settings');
4258
await fillIn('input[name="username"]', 'spookyghostboo');
4359
await click('[data-test-save-button]');
4460

@@ -52,7 +68,7 @@ module('Acceptance | /crates/:name/owners', function (hooks) {
5268
test('add a new owner', async function (assert) {
5369
this.server.loadFixtures();
5470

55-
await visit('/crates/nanomsg/owners');
71+
await visit('/crates/nanomsg/settings');
5672
await fillIn('input[name="username"]', 'iain8');
5773
await click('[data-test-save-button]');
5874

@@ -64,7 +80,7 @@ module('Acceptance | /crates/:name/owners', function (hooks) {
6480
test('remove a crate owner when owner is a user', async function (assert) {
6581
this.server.loadFixtures();
6682

67-
await visit('/crates/nanomsg/owners');
83+
await visit('/crates/nanomsg/settings');
6884
await click('[data-test-owner-user="thehydroimpulse"] [data-test-remove-owner-button]');
6985

7086
assert.dom('[data-test-notification-message="success"]').hasText('User thehydroimpulse removed as crate owner');
@@ -86,7 +102,7 @@ module('Acceptance | /crates/:name/owners', function (hooks) {
86102

87103
this.authenticateAs(user);
88104

89-
await visit(`/crates/${crate.name}/owners`);
105+
await visit(`/crates/${crate.name}/settings`);
90106
await click(`[data-test-owner-user="${user2.login}"] [data-test-remove-owner-button]`);
91107

92108
assert
@@ -98,7 +114,7 @@ module('Acceptance | /crates/:name/owners', function (hooks) {
98114
test('remove a crate owner when owner is a team', async function (assert) {
99115
this.server.loadFixtures();
100116

101-
await visit('/crates/nanomsg/owners');
117+
await visit('/crates/nanomsg/settings');
102118
await click('[data-test-owner-team="github:org:thehydroimpulse"] [data-test-remove-owner-button]');
103119

104120
assert
@@ -122,7 +138,7 @@ module('Acceptance | /crates/:name/owners', function (hooks) {
122138

123139
this.authenticateAs(user);
124140

125-
await visit(`/crates/${crate.name}/owners`);
141+
await visit(`/crates/${crate.name}/settings`);
126142
await click(`[data-test-owner-team="${team.login}"] [data-test-remove-owner-button]`);
127143

128144
assert

0 commit comments

Comments
 (0)