Skip to content

Commit

Permalink
Lock mongoose version and fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ivank committed Oct 4, 2017
1 parent 100bf87 commit a6954a8
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 52 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongoose-subscriptions-braintree",
"version": "1.4.7",
"version": "1.5.0",
"description": "Braintree processor for mongoose-subscriptions",
"main": "src/index.js",
"repository": "[email protected]:enhancv/mongoose-subscriptions-braintree.git",
Expand All @@ -16,15 +16,15 @@
},
"peerDependencies": {
"braintree": "^2.0",
"mongoose-subscriptions": "^1.8"
"mongoose-subscriptions": "^1.16"
},
"devDependencies": {
"braintree": "^2.1.1",
"dotenv": "^4.0.0",
"istanbul": "^0.4.5",
"mocha": "^3.2.0",
"mongoose": "^4.8",
"mongoose-subscriptions": "^1.15.2",
"mongoose": "4.10.8",
"mongoose-subscriptions": "^1.16.0",
"prettier": "^1.4.4",
"sinon": "^2.1.0"
}
Expand Down
3 changes: 2 additions & 1 deletion src/subscriptionProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function cancel(processor, customer, subscription) {
});
}

function save(processor, customer, subscription) {
function save(processor, customer, subscription, index) {
const data = processorFields(customer, subscription);
const originalStatus =
get("snapshotOriginal.status", subscription) || get("original.status", subscription);
Expand All @@ -155,6 +155,7 @@ function save(processor, customer, subscription) {
processor.emit("event", new Event(Event.SUBSCRIPTION, Event.SAVED, result));

Object.assign(subscription, fields(customer, subscription.discounts, result.subscription));
customer.markModified(`subscriptions.${index}.discounts`);

const transactions = map(
transactionProcessor.fields(customer),
Expand Down
3 changes: 2 additions & 1 deletion test/integrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe(
numberOfBillingCycles: 2,
description: "For testing purposes",
percent: "10",
usedCount: 0,
usedCountMax: 2,
});

Expand Down Expand Up @@ -249,7 +250,7 @@ describe(
name: "Testing JKALSD",
numberOfBillingCycles: 2,
percent: 10,
usedCount: 1,
usedCount: 2,
usedCountMax: 2,
},
name: "Testing JKALSD",
Expand Down
16 changes: 8 additions & 8 deletions test/subscriptionProcessorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ describe(
this.customer.subscriptions[0].processor = { id: null, state: ProcessorItem.INITIAL };

return subscriptionProcessor
.save(processor, this.customer, this.customer.subscriptions[0])
.save(processor, this.customer, this.customer.subscriptions[0], 0)
.then(customer => {
const subscription = this.customer.subscriptions[0];

Expand Down Expand Up @@ -536,7 +536,7 @@ describe(
this.customer.subscriptions[0].status = "Canceled";

return subscriptionProcessor
.save(processor, this.customer, this.customer.subscriptions[0])
.save(processor, this.customer, this.customer.subscriptions[0], 0)
.then(customer => {
const subscription = this.customer.subscriptions[0];

Expand Down Expand Up @@ -602,7 +602,7 @@ describe(
};

return subscriptionProcessor
.save(processor, this.customer, this.customer.subscriptions[0])
.save(processor, this.customer, this.customer.subscriptions[0], 0)
.catch(error => {
sinon.assert.calledWith(
processor.emit,
Expand All @@ -628,7 +628,7 @@ describe(
};

return subscriptionProcessor
.save(processor, this.customer, this.customer.subscriptions[0])
.save(processor, this.customer, this.customer.subscriptions[0], 0)
.then(customer => {
assert.equal(customer, this.customer);
sinon.assert.neverCalledWith(
Expand All @@ -649,7 +649,7 @@ describe(
this.customer.subscriptions[0].processor.state = ProcessorItem.LOCAL;

return subscriptionProcessor
.save(processor, this.customer, this.customer.subscriptions[0])
.save(processor, this.customer, this.customer.subscriptions[0], 0)
.then(customer => {
assert.equal(customer, this.customer);
sinon.assert.neverCalledWith(
Expand All @@ -676,7 +676,7 @@ describe(
this.customer.subscriptions[0].firstBillingDate = new Date("2016-10-18");

return subscriptionProcessor
.save(processor, this.customer, this.customer.subscriptions[0])
.save(processor, this.customer, this.customer.subscriptions[0], 0)
.then(customer => {
const subscription = this.customer.subscriptions[0];

Expand Down Expand Up @@ -708,7 +708,7 @@ describe(
this.customer.subscriptions[0].processor.state = ProcessorItem.CHANGED;

return subscriptionProcessor
.save(processor, this.customer, this.customer.subscriptions[0])
.save(processor, this.customer, this.customer.subscriptions[0], 0)
.catch(error => {
sinon.assert.neverCalledWith(
processor.emit,
Expand All @@ -733,7 +733,7 @@ describe(
this.customer.subscriptions[0].processor.state = ProcessorItem.CHANGED;

return subscriptionProcessor
.save(processor, this.customer, this.customer.subscriptions[0])
.save(processor, this.customer, this.customer.subscriptions[0], 0)
.catch(error => {
sinon.assert.neverCalledWith(
processor.emit,
Expand Down
92 changes: 54 additions & 38 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ bson@~1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/bson/-/bson-1.0.4.tgz#93c10d39eaa5b58415cbc4052f3e53e562b0b72c"

buffer-shims@^1.0.0:
buffer-shims@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51"

Expand Down Expand Up @@ -116,6 +116,12 @@ [email protected]:
dependencies:
ms "0.7.1"

[email protected]:
version "2.6.8"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc"
dependencies:
ms "2.0.0"

[email protected]:
version "0.0.2"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-0.0.2.tgz#6c0dcf07e2c3f74524629b741668bd46c7b362eb"
Expand Down Expand Up @@ -297,9 +303,9 @@ [email protected]:
version "3.3.2"
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1"

kareem@1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/kareem/-/kareem-1.2.1.tgz#acdb8c8119845834abbfa58ade1cf9dea63dc752"
kareem@1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/kareem/-/kareem-1.4.1.tgz#ed76200044fa041ef32b4da8261e2553f1173531"

kind-of@^3.0.2:
version "3.1.0"
Expand Down Expand Up @@ -409,76 +415,76 @@ mocha@^3.2.0:
mkdirp "0.5.1"
supports-color "3.1.2"

[email protected].9:
version "2.1.9"
resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.9.tgz#85aa71ee4fb716196e06b787557bf139f801daf5"
[email protected].11:
version "2.1.11"
resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.11.tgz#1c38776ceb174997a99c28860eed9028da9b3e1a"
dependencies:
bson "~1.0.4"
require_optional "~1.0.0"

[email protected].25:
version "2.2.25"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-2.2.25.tgz#d3b25dad00eda2bdfcbc996210ba082ac686a6b6"
[email protected].27:
version "2.2.27"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-2.2.27.tgz#34122034db66d983bcf6ab5adb26a24a70fef6e6"
dependencies:
es6-promise "3.2.1"
mongodb-core "2.1.9"
readable-stream "2.1.5"
mongodb-core "2.1.11"
readable-stream "2.2.7"

mongoose-originals@^1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/mongoose-originals/-/mongoose-originals-1.3.2.tgz#914fa2e8125cfd2db5a645f213c8e0f3e0c09c28"
dependencies:
lodash "^4.17.4"

mongoose-subscriptions@^1.15.2:
version "1.15.2"
resolved "https://registry.yarnpkg.com/mongoose-subscriptions/-/mongoose-subscriptions-1.15.2.tgz#21f055c08913ab95a1546f94249b2c677ba157ed"
mongoose-subscriptions@^1.16.0:
version "1.16.0"
resolved "https://registry.yarnpkg.com/mongoose-subscriptions/-/mongoose-subscriptions-1.16.0.tgz#6b5175e2be813d0c737df9ee3d0708b9f453cb2c"
dependencies:
mongoose-originals "^1.3.2"
shortid "^2.2.8"
xdate "^0.8.2"

mongoose@^4.8:
version "4.9.3"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-4.9.3.tgz#7e3ea176ed7d3d23940368704834890595aea040"
mongoose@4.10.8:
version "4.10.8"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-4.10.8.tgz#31f44ed7884756f9fd9b7708ddcb3fcb4250f34e"
dependencies:
async "2.1.4"
bson "~1.0.4"
hooks-fixed "2.0.0"
kareem "1.2.1"
mongodb "2.2.25"
mpath "0.2.1"
kareem "1.4.1"
mongodb "2.2.27"
mpath "0.3.0"
mpromise "0.5.5"
mquery "2.3.0"
ms "0.7.2"
mquery "2.3.1"
ms "2.0.0"
muri "1.2.1"
regexp-clone "0.0.1"
sliced "1.0.1"

mpath@0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.2.1.tgz#3a4e829359801de96309c27a6b2e102e89f9e96e"
mpath@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.3.0.tgz#7a58f789e9b5fd3c94520634157960f26bd5ef44"

[email protected]:
version "0.5.5"
resolved "https://registry.yarnpkg.com/mpromise/-/mpromise-0.5.5.tgz#f5b24259d763acc2257b0a0c8c6d866fd51732e6"

[email protected].0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/mquery/-/mquery-2.3.0.tgz#3d1717ad8958d0c99e42ea2461a109f3e5f3e458"
[email protected].1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/mquery/-/mquery-2.3.1.tgz#9ab36749714800ff0bb53a681ce4bc4d5f07c87b"
dependencies:
bluebird "2.10.2"
debug "2.2.0"
debug "2.6.8"
regexp-clone "0.0.1"
sliced "0.0.5"

[email protected]:
version "0.7.1"
resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098"

ms@0.7.2:
version "0.7.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765"
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"

[email protected]:
version "1.2.1"
Expand Down Expand Up @@ -549,16 +555,16 @@ [email protected]:
optionalDependencies:
debuglog "0.0.2"

readable-stream@2.1.5:
version "2.1.5"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0"
readable-stream@2.2.7:
version "2.2.7"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.7.tgz#07057acbe2467b22042d36f98c5ad507054e95b1"
dependencies:
buffer-shims "^1.0.0"
buffer-shims "~1.0.0"
core-util-is "~1.0.0"
inherits "~2.0.1"
isarray "~1.0.0"
process-nextick-args "~1.0.6"
string_decoder "~0.10.x"
string_decoder "~1.0.0"
util-deprecate "~1.0.1"

[email protected]:
Expand Down Expand Up @@ -590,6 +596,10 @@ right-align@^0.1.1:
dependencies:
align-text "^0.1.1"

safe-buffer@~5.1.0:
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"

[email protected], samsam@^1.1.3:
version "1.2.1"
resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.2.1.tgz#edd39093a3184370cb859243b2bdf255e7d8ea67"
Expand Down Expand Up @@ -651,6 +661,12 @@ string_decoder@~0.10.x:
version "0.10.31"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"

string_decoder@~1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab"
dependencies:
safe-buffer "~5.1.0"

[email protected], supports-color@^3.1.0:
version "3.1.2"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5"
Expand Down

0 comments on commit a6954a8

Please sign in to comment.