Skip to content

Commit e4e57e6

Browse files
committed
Closes #170.
1 parent f760f6c commit e4e57e6

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- #161 - Allow the http method of DSHttpAdapter methods to be configured
88
- #166 - Add ID Resolver
99
- #167 - Default params argument of bindAll to empty object
10+
- #170 - Global callbacks
1011
- #171 - "not in" query
1112

1213
###### Backwards compatible bug fixes

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Unlike Backbone and Ember Models, angular-data does not require the use of gette
99
Supporting relations, computed properties, model lifecycle control and a slew of other features, angular-data is the tool for giving your data the respect it deserves.
1010

1111
__Latest Release:__ [1.0.0-rc.1](http://angular-data.pseudobry.com/)
12-
__master:__ [1.0.0-rc.1](http://angular-data-next.pseudobry.com/)
12+
__master:__ [1.0.0-rc.2](http://angular-data-next.pseudobry.com/)
1313

1414
Angular-data is in a 1.0.0 Beta. The API is rather stable and angular-data is well tested.
1515

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Jason Dobry",
33
"name": "angular-data",
44
"description": "Data store for Angular.js.",
5-
"version": "1.0.0-rc.1",
5+
"version": "1.0.0-rc.2",
66
"homepage": "http://angular-data.pseudobry.com/",
77
"repository": {
88
"type": "git",

karma.start.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Setup global test variables
22
var $rootScope, $q, $log, $timeout, DSHttpAdapterProvider, DSProvider, DSLocalStorageAdapter, DS, DSUtils, DSHttpAdapter, app, $httpBackend, p1, p2, p3, p4, p5;
33

4+
var Post, User, Organization, Comment, Profile;
45
var user1, organization2, comment3, profile4;
56
var comment11, comment12, comment13, organization14, profile15, user10, user16, user17, user18, organization15, user19, user20, comment19, user22, profile21;
67

@@ -128,12 +129,12 @@ function startInjector() {
128129
DSHttpAdapter = _DSHttpAdapter_;
129130
DSLocalStorageAdapter = _DSLocalStorageAdapter_;
130131
$httpBackend = _$httpBackend_;
131-
DS.defineResource({
132+
Post = DS.defineResource({
132133
name: 'post',
133134
keepChangeHistory: true,
134135
endpoint: '/posts'
135136
});
136-
DS.defineResource({
137+
User = DS.defineResource({
137138
name: 'user',
138139
relations: {
139140
hasMany: {
@@ -158,7 +159,7 @@ function startInjector() {
158159
}
159160
});
160161

161-
DS.defineResource({
162+
Organization = DS.defineResource({
162163
name: 'organization',
163164
relations: {
164165
hasMany: {
@@ -170,7 +171,7 @@ function startInjector() {
170171
}
171172
});
172173

173-
DS.defineResource({
174+
Profile = DS.defineResource({
174175
name: 'profile',
175176
relations: {
176177
belongsTo: {
@@ -182,7 +183,7 @@ function startInjector() {
182183
}
183184
});
184185

185-
DS.defineResource({
186+
Comment = DS.defineResource({
186187
name: 'comment',
187188
relations: {
188189
belongsTo: {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-data",
33
"description": "Data store for Angular.js.",
4-
"version": "1.0.0-rc.1",
4+
"version": "1.0.0-rc.2",
55
"homepage": "http://angular-data.pseudobry.com",
66
"repository": {
77
"type": "git",

test/integration/datastore/async_methods/update.test.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,26 @@ describe('DS.update(resourceName, id, attrs[, options])', function () {
115115

116116
$httpBackend.flush();
117117

118-
$httpBackend.expectPUT('http://test.angular-cache.com/user/4/comment/6').respond(200, testComment2);
118+
$httpBackend.expectPUT('http://test.angular-cache.com/user/4/comment/6', { content: 'stuff' }).respond(200, testComment2);
119119

120-
DS.inject('comment', testComment2);
120+
var comment = DS.inject('comment', testComment2);
121121

122-
DS.update('comment', 6, {
122+
function onBeforeUpdate (resourceName, attrs) {
123+
attrs.other = 'stuff';
124+
assert.equal(resourceName, 'comment');
125+
assert.deepEqual(attrs, { content: 'stuff', other: 'stuff' });
126+
}
127+
128+
function onAfterUpdate(resourceName, attrs) {
129+
assert.equal(resourceName, 'comment');
130+
assert.deepEqual(attrs, testComment2);
131+
assert.isFalse(testComment2 === attrs);
132+
}
133+
134+
Comment.on('DS.beforeUpdate', onBeforeUpdate);
135+
Comment.on('DS.afterUpdate', onAfterUpdate);
136+
137+
Comment.update(comment, {
123138
content: 'stuff'
124139
}, {
125140
params: {

0 commit comments

Comments
 (0)