Commit Graph

2442 Commits

Author SHA1 Message Date
Emily Stark
d3ec00c3ef Fix collection driver upsert callbacks.
Run a bunch of upsert tests on the direct collections (LocalCollection and
MongoConnection). Revealed a weirdness with MongoConnection.upsert(); if there
is no id from the selector or modifier, then mongo ends up generating one and we
don't return it.
2013-10-02 23:00:23 -07:00
Emily Stark
c20db8d328 Remove $'s in selector when upserting new minimongo doc.
Plus test for it.
2013-10-02 21:21:10 -07:00
Slava Kim
0e2d56d382 Glasser's comments on restrictCreationByEmailDomain in Accounts 2013-10-02 20:28:07 -07:00
Emily Stark
7f64c726f7 Merge branch 'mongo-upsert' into devel 2013-10-02 13:23:22 -07:00
Emily Stark
86492eecec Fix simulateUpsert call indentation 2013-10-02 12:47:50 -07:00
Naomi Seyfer
67046601ea Merge branch 'cannonical' into devel 2013-10-02 12:11:37 -07:00
Naomi Seyfer
c3fb7741f6 Infinity and NaN in EJSON 2013-10-02 12:01:24 -07:00
Naomi Seyfer
0d8bfbae8a fix tests, rename option, more style fixes 2013-10-02 12:01:21 -07:00
Andrew Wilcox
da6bc1d835 EJSON.stringify objects in sorted key order.
Thus if two objects are EJSON.equals, their serialization strings will
be equal also.

(This should mean that reactive-dict could now allow objects to be
used as the key for `equal`).

Note this change does not affect livedata because livedata uses the
EJSON adjust functions to convert between JSON and EJSON (not
stringify).

Adds a couple options to EJSON.stringify:

* keyOrderSensitive: in parallel with EJSON.equals, outputs objects in
  native key order (the old behavior).

* indent: pretty-prints the output.

The serialization code is based json2, which makes it easy to preserve
the indentation functionality provided by JSON.stringify.  Only enough
code is included to serialize arrays and objects; serializing
primitive values such as strings is delegated to the native
JSON.stringify to reduce code and in case the native implementation is
more efficient.

Include underscore as an explicit dependency in package.js.

Document options to EJSON.equals and EJSON.stringify.
2013-10-02 11:43:44 -07:00
Emily Stark
e6e4c8a94e Minor token deletion cleanup and comments 2013-10-02 11:37:27 -07:00
Emily Stark
7782d7c95f Make token expiration backwards compatible with numeric when. 2013-10-02 11:36:25 -07:00
Emily Stark
d123e731cc Get rid of connectionCloseDelaySecs 2013-10-02 11:36:25 -07:00
Emily Stark
be8ac4387f Rename _logoutAllOthers to logoutOtherClients 2013-10-02 11:35:51 -07:00
Emily Stark
e69cb036d0 Add fields to user/token deletion observe 2013-10-02 11:35:51 -07:00
Emily Stark
5c08d1c70e Rename and remove some token deletion config flags. 2013-10-02 11:35:51 -07:00
Emily Stark
e8c8252b2a Remove unnecessary bindEnvironmentForWrite 2013-10-02 11:15:00 -07:00
Emily Stark
d0af2d8c91 Add comment about lack of allow/deny rules for upserts 2013-10-02 11:07:41 -07:00
Emily Stark
b29a31746f Rearrange simulateUpsertWithInsertedId() for readability 2013-10-02 10:55:12 -07:00
Emily Stark
44d399456e Clean up some comments and names for upsert. 2013-10-02 10:51:14 -07:00
Emily Stark
47b6af30a5 Factor out the bindEnvironment part of writeCallback.
Get rid of numberAffectedCallback; instead, choose the right return value at
every place where we were using numberAffectedCallback and then pass through
bindEnvironmentForWrite. This cleans up a couple places where we were going
through numberAffectedCallback to wrap a result in an object, and then sometimes
getting the numberAffected out of that object and just returning that. Also
ensures that all callbacks for write get passed through Meteor.bindEnvironment
with the same onException function.
2013-10-02 10:31:30 -07:00
Emily Stark
f9fda934ec Add some comments to minimongo upsert code 2013-10-01 22:16:32 -07:00
Emily Stark
6ae90f4d67 Rename onInsert to isInsert 2013-10-01 19:02:05 -07:00
Emily Stark
cfd5861c8d Make update() the canonical form for upserts on the wire.
update(..., { upsert: true }) returns the number of affected docs, and
update(..., { upsert: true, _returnObject: true }) returns the whole object that
is used by upsert(). Also includes a rename of returnObject -> _returnObject.
2013-10-01 18:26:41 -07:00
Slava Kim
bd77b172bd Rename Accounts option 'restrictCreationByEmail' to 'restrictCreationByEmailDomain' 2013-10-01 17:14:30 -07:00
Slava Kim
53756bd80b Allow passing function predicate for domain checks
Escape regexp construction
Don't use &= with Booleans
2013-10-01 17:10:04 -07:00
Slava Kim
b9d8fffddf Sockjs: accept relative base urls
(transform them to absolue urls)
2013-10-01 15:14:09 -07:00
Emily Stark
1002650fcd Update Collection comments to reflect new return values. 2013-10-01 11:48:45 -07:00
Emily Stark
dc8e948cb1 Test and fixes for returning upsert results immediately inside stubs.
Added a test for upsert return values. Factored out some more upsert test
helpers.

Could still use a test for update/remove return values inside a method stub.
2013-10-01 11:39:46 -07:00
Emily Stark
bad2102c06 Return results from collection methods on livedata connection.
This allows us to immediately return local collection return values inside
stubs.
2013-10-01 10:12:02 -07:00
Emily Stark
f397295b8a Suppress invalid modifier log message in upsert test 2013-09-30 15:47:40 -07:00
David Greenspan
e1dd2b40f8 return un-mongo-converted insertedId
… instead of converting to mongo form and back
2013-09-30 15:41:47 -07:00
Emily Stark
ea63ea560f Merge branch 'devel' into mongo-upsert 2013-09-30 15:07:09 -07:00
Emily Stark
1bbb34e602 Take the async out of tests that don't need it 2013-09-30 11:21:11 -07:00
Emily Stark
dd44f6b165 Fix compareResults everywhere and factor it out. 2013-09-30 11:06:16 -07:00
Emily Stark
7cba2923f5 Add a test for update/remove return values over the network. 2013-09-28 23:14:37 -07:00
Emily Stark
f7d33c734d Plumb mutation method return values through to callbacks.
Also:
* Fix some bugs: compareResults wasn't working so well; insertedId return values
  weren't being passed through replaceTypes; a few places where options objects
  weren't being treated as optional.
* Duplicate upsert tests for async upserts (with some changes to account for the
  fact that updates and removes can only be by id). Maybe this can be cleaned up
  to be less duplicate-y.
* Still need tests for async update/remove return values.
2013-09-28 23:03:47 -07:00
Emily Stark
9d1e3dbd56 Enable CSP differently for tests.
Avoids sending header and using meteor_runtime_config.js on tests. Also tweak
wording on browser-policy docs.
2013-09-28 18:44:31 -07:00
Emily Stark
a102872a96 Rework browser-policy to make API more intuitive.
- Remove starter-browser-policy and replace it with
  BrowserPolicy.enableContentSecurityPolicy(), which gives you the starter
  policy and allows you to use the other BrowserPolicy functions to configure
  it. This is motivated by the fact that the API isn't very intuitive without a
  well-defined starting policy. ex: if the package starts off without a policy,
  and then the user calls allowAllContentSameOrigin(), that will result in
  turning off inline scripts, which is probably not what they wanted.
- AllContent functions do more of what you'd expect now;
  i.e. BrowserPolicy.disallowAllContent() actually disallows all content,
  instead of setting default-src to 'none', which will allow other types of
  content that have previously had srcs set for them.
- Add some tests
2013-09-28 18:44:04 -07:00
Emily Stark
e6300461b1 Reorganize browser-policy docs a bit.
Addressing Nick's suggestions. Haven't decided yet about combining
browser-policy and starter-browser-policy docs.
2013-09-28 18:44:04 -07:00
Emily Stark
4893fe048c Package for security-related http headers. 2013-09-28 18:44:04 -07:00
David Greenspan
6329cedc51 upsert method -- let upsert go over the network
Only works in insecure mode.  (Not supported by allow/deny.)
2013-09-27 19:41:24 -07:00
David Greenspan
22d3a56b81 remove duplicate function 2013-09-27 19:13:42 -07:00
David Greenspan
2724bd0d84 upsert bugfixes and tests
* mongo_driver native upsert returns insertedId
* minimongo doesn't use query _id on upsert/replace
* minimongo supports insertedId option
* tests for all this
2013-09-27 19:10:09 -07:00
David Greenspan
3e87c8f9d5 finish optimistic retry code detect collision 2013-09-27 18:54:50 -07:00
Emily Stark
6494ec563f Put .upsert() on LocalCollection and mongo driver.
This way LocalCollection and Meteor.Collection have the same API.
2013-09-27 18:50:39 -07:00
David Glasser
3e1afb7850 Tests for extra forEach/map arguments. 2013-09-27 19:00:22 -05:00
David Glasser
d4d7ebb783 Implements ES5-style callbacks for cursor forEach and map.
Fixes #63.

Based on iwoj's PR.

Needs tests and docs.
2013-09-27 19:00:22 -05:00
Emily Stark
2b4d4974fa Update minimongo tests to new api.
All tests pass now, but we've got the unfortunate situation that the
LocalCollection return values don't match the Meteor.Collection return values,
which is problematic because the minimongo tests use LocalCollection
directly. Hmm.
2013-09-27 16:07:55 -07:00
Emily Stark
e56428dceb Make sure we provide the right return value for callbacks also.
Also, don't mutate `name` to "update" from "upsert"; the function closes over it
so all subsequent calls will start with name "update".
2013-09-27 16:06:28 -07:00
David Greenspan
2b082db1a8 adjust tests for API 2013-09-27 15:10:34 -07:00