Adds acceptance test for user preferences

This commit is contained in:
Robin Ward
2015-05-13 10:42:36 -04:00
parent d90e0fe66b
commit ea51095ef9
7 changed files with 50 additions and 8 deletions

View File

@@ -39,3 +39,11 @@ test("Filters", () => {
visit("/users/eviltrout/activity/edits");
hasStream();
});
test("Restricted Routes", () => {
visit("/users/eviltrout/preferences");
andThen(() => {
equal(currentURL(), '/users/eviltrout/activity', "it redirects from preferences");
});
});

View 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

View File

@@ -87,6 +87,18 @@ export default function() {
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() {
return response(fixturesByUrl['/t/280/1.json']);
});