Skip to content

Redirect /owners to /settings #3428

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

Merged
merged 2 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service';

import { task } from 'ember-concurrency';

export default class CrateOwnersController extends Controller {
export default class CrateSettingsController extends Controller {
@service notifications;

crate = null;
Expand Down
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Router.map(function () {
this.route('reverse-dependencies', { path: 'reverse_dependencies' });

this.route('owners');
this.route('settings');

// Well-known routes
this.route('docs');
Expand Down
6 changes: 3 additions & 3 deletions app/routes/crate/owners.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Route from '@ember/routing/route';

export default class OwnersRoute extends Route {
setupController(controller) {
super.setupController(...arguments);
redirect() {
let crate = this.modelFor('crate');
controller.set('crate', crate);

this.transitionTo('crate.settings', crate);
}
}
9 changes: 9 additions & 0 deletions app/routes/crate/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Route from '@ember/routing/route';

export default class SettingsRoute extends Route {
setupController(controller) {
super.setupController(...arguments);
let crate = this.modelFor('crate');
controller.set('crate', crate);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{page-title 'Manage Crate Owners'}}
{{page-title 'Manage Crate Settings'}}

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

Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/crate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ module('Acceptance | crate page', function (hooks) {
assert.dom('[data-test-settings-tab]').doesNotExist();
});

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

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

assert.equal(currentURL(), '/crates/nanomsg/owners');
assert.equal(currentURL(), '/crates/nanomsg/settings');
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { click, fillIn, visit } from '@ember/test-helpers';
import { click, currentURL, fillIn, visit } from '@ember/test-helpers';
import { module, test } from 'qunit';

import percySnapshot from '@percy/ember';
Expand All @@ -8,13 +8,14 @@ import { setupApplicationTest } from 'cargo/tests/helpers';

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

module('Acceptance | /crates/:name/owners', function (hooks) {
module('Acceptance | /crates/:name/settings', function (hooks) {
setupApplicationTest(hooks);

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

await visit('/crates/nanomsg/owners');
await visit('/crates/nanomsg/settings');
assert.equal(currentURL(), '/crates/nanomsg/settings');

assert.dom('[data-test-owners] [data-test-owner-team]').exists({ count: 2 });
assert.dom('[data-test-owners] [data-test-owner-user]').exists({ count: 2 });
Expand All @@ -27,18 +28,25 @@ module('Acceptance | /crates/:name/owners', function (hooks) {
await a11yAudit(axeConfig);
});

test('attempting to add owner without username', async function (assert) {
test('/crates/:name/owners redirects to /crates/:name/settings', async function (assert) {
this.server.loadFixtures();

await visit('/crates/nanomsg/owners');
assert.equal(currentURL(), '/crates/nanomsg/settings');
});

test('attempting to add owner without username', async function (assert) {
this.server.loadFixtures();

await visit('/crates/nanomsg/settings');
await fillIn('input[name="username"]', '');
assert.dom('[data-test-save-button]').isDisabled();
});

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

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

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

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

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

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

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

this.authenticateAs(user);

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

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

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

assert
Expand All @@ -122,7 +130,7 @@ module('Acceptance | /crates/:name/owners', function (hooks) {

this.authenticateAs(user);

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

assert
Expand Down