Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit f065857

Browse files
author
Jacob Wenger
committed
Merge pull request #367 from firebase/kato-add-fix
Fix $add to accept $priority and $value meta fields
2 parents 79411a6 + ce2dbf3 commit f065857

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

dist/angularfire.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
* angularfire 0.8.0 2014-07-29
3-
* https://github.com/firebase/angularFire
2+
* angularfire 0.8.0 2014-07-31
3+
* https://github.com/firebase/angularfire
44
* Copyright (c) 2014 Firebase, Inc.
55
* MIT LICENSE: http://firebase.mit-license.org/
66
*/
@@ -115,7 +115,7 @@
115115
*/
116116
$add: function(data) {
117117
this._assertNotDestroyed('$add');
118-
return this.$inst().$push(data);
118+
return this.$inst().$push($firebaseUtils.toJSON(data));
119119
},
120120

121121
/**

dist/angularfire.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/FirebaseArray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
*/
8484
$add: function(data) {
8585
this._assertNotDestroyed('$add');
86-
return this.$inst().$push(data);
86+
return this.$inst().$push($firebaseUtils.toJSON(data));
8787
},
8888

8989
/**

tests/lib/MockFirebase.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/**
2-
* MockFirebase: A Firebase stub/spy library for writing unit tests
1+
/*! mockfirebase - v0.2.6 - 2014-07-31
32
* https://github.com/katowulf/mockfirebase
4-
* @version 0.2.4
5-
*/
3+
* Copyright (c) 2014 Kato
4+
* MIT LICENSE */
5+
66
(function (root, factory) {
77
if (typeof define === 'function' && define.amd) {
88
// AMD. Register as an anonymous module.
@@ -422,7 +422,7 @@
422422

423423
once: function(event, callback, cancel, context) {
424424
var self = this;
425-
if( arguments.length === 3 && !angular.isFunction(cancel) ) {
425+
if( arguments.length === 3 && !_.isFunction(cancel) ) {
426426
context = cancel;
427427
cancel = function() {};
428428
}
@@ -1677,7 +1677,7 @@
16771677

16781678
MockFirebaseSimpleLogin.DEFAULT_FAIL_WHEN = function(provider, options, user) {
16791679
var res = null;
1680-
if( ['password', 'persona', 'anonymous', 'twitter', 'facebook', 'google', 'github'].indexOf(provider) === -1 ) {
1680+
if( ['password', 'anonymous', 'twitter', 'facebook', 'google', 'github'].indexOf(provider) === -1 ) {
16811681
console.error('MockFirebaseSimpleLogin:login() failed: unrecognized authentication provider '+provider);
16821682
// res = createError();
16831683
}
@@ -1691,7 +1691,7 @@
16911691
};
16921692

16931693
MockFirebaseSimpleLogin.DEFAULT_USER_DATA = {};
1694-
_.each(['password', 'persona', 'anonymous', 'facebook', 'twitter', 'google', 'github'], function(provider) {
1694+
_.each(['password', 'anonymous', 'facebook', 'twitter', 'google', 'github'], function(provider) {
16951695
var user = createDefaultUser(provider);
16961696
if( provider !== 'password' ) {
16971697
MockFirebaseSimpleLogin.DEFAULT_USER_DATA[provider] = user;

tests/unit/FirebaseArray.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ describe('$FirebaseArray', function () {
121121
expect(arr[i-1].$priority).toBe(i);
122122
}
123123
});
124+
125+
it('should observe $priority and $value meta keys if present', function() {
126+
var arr = stubArray();
127+
arr.$add({$value: 'foo', $priority: 99});
128+
expect(arr.$$$fb.$push).toHaveBeenCalledWith(jasmine.objectContaining({'.priority': 99, '.value': 'foo'}));
129+
});
124130
});
125131

126132
describe('$save', function() {

0 commit comments

Comments
 (0)