Interface is wired up for Approving/Rejecting posts

This commit is contained in:
Robin Ward
2015-04-14 14:21:02 -04:00
parent 96d2c5069b
commit 0c233e4e25
20 changed files with 273 additions and 90 deletions
@@ -2,7 +2,7 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("View Topic");
test("Enter a Topic", () => {
visit("/t/internationalization-localization/280");
visit("/t/internationalization-localization/280/1");
andThen(() => {
ok(exists("#topic"), "The topic was rendered");
ok(exists("#topic .post-cloak"), "The topic has cloaked posts");
@@ -173,6 +173,14 @@ export default function() {
});
});
this.get('/fruits/:id', function() {
return response({
__rest_serializer: "1",
fruit: {id: 1, name: 'apple', farmer_id: 1},
farmers: [{id: 1, name: 'Evil Trout'}]
});
});
this.get('/widgets/:widget_id', function(request) {
const w = _widgets.findBy('id', parseInt(request.params.widget_id));
if (w) {
+48 -3
View File
@@ -19,23 +19,51 @@ test('munging', function() {
test('update', function() {
const store = createStore();
store.find('widget', 123).then(function(widget) {
equal(widget.get('name'), 'Trout Lure');
widget.update({ name: 'new name' }).then(function() {
ok(!widget.get('isSaving'));
const promise = widget.update({ name: 'new name' });
ok(widget.get('isSaving'));
promise.then(function() {
ok(!widget.get('isSaving'));
equal(widget.get('name'), 'new name');
});
});
});
test('updating simultaneously', function() {
expect(2);
const store = createStore();
store.find('widget', 123).then(function(widget) {
const firstPromise = widget.update({ name: 'new name' });
const secondPromise = widget.update({ name: 'new name' });
firstPromise.then(function() {
ok(true, 'the first promise succeeeds');
});
secondPromise.catch(function() {
ok(true, 'the second promise fails');
});
});
});
test('save new', function() {
const store = createStore();
const widget = store.createRecord('widget');
ok(widget.get('isNew'), 'it is a new record');
ok(!widget.get('isCreated'), 'it is not created');
ok(!widget.get('isSaving'));
widget.save({ name: 'Evil Widget' }).then(function() {
const promise = widget.save({ name: 'Evil Widget' });
ok(widget.get('isSaving'));
promise.then(function() {
ok(!widget.get('isSaving'));
ok(widget.get('id'), 'it has an id');
ok(widget.get('name'), 'Evil Widget');
ok(widget.get('isCreated'), 'it is created');
@@ -43,6 +71,23 @@ test('save new', function() {
});
});
test('creating simultaneously', function() {
expect(2);
const store = createStore();
const widget = store.createRecord('widget');
const firstPromise = widget.save({ name: 'Evil Widget' });
const secondPromise = widget.save({ name: 'Evil Widget' });
firstPromise.then(function() {
ok(true, 'the first promise succeeeds');
});
secondPromise.catch(function() {
ok(true, 'the second promise fails');
});
});
test('destroyRecord', function() {
const store = createStore();
store.find('widget', 123).then(function(widget) {
@@ -88,3 +88,11 @@ test('destroyRecord', function() {
});
});
});
test('find embedded', function() {
const store = createStore();
store.find('fruit', 1).then(function(f) {
ok(f.get('farmer'), 'it has the embedded object');
});
});