mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
Move identity map into the store, shouldn't have been in the adapter
This commit is contained in:
@ -99,6 +99,12 @@ export default function() {
|
||||
}
|
||||
});
|
||||
|
||||
this.put('/widgets/:widget_id', function(request) {
|
||||
const w = _widgets.findBy('id', parseInt(request.params.widget_id));
|
||||
const cloned = JSON.parse(JSON.stringify(w));
|
||||
return response({ widget: cloned });
|
||||
});
|
||||
|
||||
this.get('/widgets', function() {
|
||||
return response({ widgets: _widgets });
|
||||
});
|
||||
|
24
test/javascripts/models/rest-model-test.js.es6
Normal file
24
test/javascripts/models/rest-model-test.js.es6
Normal file
@ -0,0 +1,24 @@
|
||||
module('rest-model');
|
||||
|
||||
import createStore from 'helpers/create-store';
|
||||
|
||||
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() {
|
||||
equal(widget.get('name'), 'new name');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('destroyRecord', function() {
|
||||
const store = createStore();
|
||||
store.find('widget', 123).then(function(widget) {
|
||||
widget.destroyRecord().then(function(result) {
|
||||
ok(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -23,6 +23,13 @@ test('find', function() {
|
||||
});
|
||||
});
|
||||
|
||||
test('update', function() {
|
||||
const store = createStore();
|
||||
store.update('widget', 123, {name: 'hello'}).then(function(result) {
|
||||
ok(result);
|
||||
});
|
||||
});
|
||||
|
||||
test('findAll', function() {
|
||||
const store = createStore();
|
||||
store.findAll('widget').then(function(result) {
|
||||
@ -34,7 +41,9 @@ test('findAll', function() {
|
||||
|
||||
test('destroyRecord', function() {
|
||||
const store = createStore();
|
||||
store.destroyRecord('widget', 124).then(function(result) {
|
||||
ok(result);
|
||||
store.find('widget', 123).then(function(w) {
|
||||
store.destroyRecord('widget', w).then(function(result) {
|
||||
ok(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user