mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 11:13:22 +08:00
Adds acceptance test for user preferences
This commit is contained in:
parent
d90e0fe66b
commit
ea51095ef9
|
@ -1,6 +1,7 @@
|
||||||
// A base route that allows us to redirect when access is restricted
|
import DiscourseRoute from 'discourse/routes/discourse';
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
// A base route that allows us to redirect when access is restricted
|
||||||
|
export default DiscourseRoute.extend({
|
||||||
|
|
||||||
afterModel() {
|
afterModel() {
|
||||||
if (!this.modelFor('user').get('can_edit')) {
|
if (!this.modelFor('user').get('can_edit')) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<section class='user-content'>
|
<section class='user-content user-preferences'>
|
||||||
|
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@
|
||||||
<div class="control-group pref-location">
|
<div class="control-group pref-location">
|
||||||
<label class="control-label">{{i18n 'user.location'}}</label>
|
<label class="control-label">{{i18n 'user.location'}}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
{{input type="text" value=location class="input-xxlarge"}}
|
{{input type="text" value=location class="input-xxlarge" id='edit-location'}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
<button {{action "save"}} {{bind-attr disabled="saving"}} class="btn btn-primary">{{saveButtonText}}</button>
|
<button {{action "save"}} {{bind-attr disabled="saving"}} class="btn btn-primary save-user">{{saveButtonText}}</button>
|
||||||
{{#if saved}}{{i18n 'saved'}}{{/if}}
|
{{#if saved}}
|
||||||
|
<span class='saved-user'>{{i18n 'saved'}}</span>
|
||||||
|
{{/if}}
|
||||||
|
|
|
@ -39,3 +39,11 @@ test("Filters", () => {
|
||||||
visit("/users/eviltrout/activity/edits");
|
visit("/users/eviltrout/activity/edits");
|
||||||
hasStream();
|
hasStream();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Restricted Routes", () => {
|
||||||
|
visit("/users/eviltrout/preferences");
|
||||||
|
|
||||||
|
andThen(() => {
|
||||||
|
equal(currentURL(), '/users/eviltrout/activity', "it redirects from preferences");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
19
test/javascripts/acceptance/user-preferences-test.js.es6
Normal file
19
test/javascripts/acceptance/user-preferences-test.js.es6
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
|
acceptance("User Preferences", { loggedIn: true });
|
||||||
|
|
||||||
|
test("update some fields", () => {
|
||||||
|
visit("/users/eviltrout/preferences");
|
||||||
|
|
||||||
|
andThen(() => {
|
||||||
|
equal(currentURL(), '/users/eviltrout/preferences', "it doesn't redirect");
|
||||||
|
ok(exists('.user-preferences'), 'it shows the preferences');
|
||||||
|
});
|
||||||
|
|
||||||
|
fillIn("#edit-location", "Westeros");
|
||||||
|
|
||||||
|
click('.save-user');
|
||||||
|
ok(!exists('.saved-user'), "it hasn't been saved yet");
|
||||||
|
andThen(() => {
|
||||||
|
ok(exists('.saved-user'), 'it displays the saved message');
|
||||||
|
});
|
||||||
|
});
|
File diff suppressed because one or more lines are too long
|
@ -87,6 +87,18 @@ export default function() {
|
||||||
return response(json);
|
return response(json);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.get('/users/eviltrout.json', () => {
|
||||||
|
const json = fixturesByUrl['/users/eviltrout.json'];
|
||||||
|
if (loggedIn()) {
|
||||||
|
json.user.can_edit = true;
|
||||||
|
}
|
||||||
|
return response(json);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.put('/users/eviltrout', () => {
|
||||||
|
return response({ user: {} });
|
||||||
|
});
|
||||||
|
|
||||||
this.get("/t/280.json", function() {
|
this.get("/t/280.json", function() {
|
||||||
return response(fixturesByUrl['/t/280/1.json']);
|
return response(fixturesByUrl['/t/280/1.json']);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user