Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
fix(customer-groups): store customer group in local cache after creat…
Browse files Browse the repository at this point in the history
…ing a new one
  • Loading branch information
philippspo committed May 9, 2016
1 parent 8819034 commit fc913e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/customer-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class CustomerImport {
return Promise.resolve(customerGroupId)
}
return this.insertCustomerGroup(customerGroupName)
.then(({ body: customerGroup }) => {
.then(customerGroup => {
return customerGroup.id
})
}
Expand All @@ -128,6 +128,10 @@ export default class CustomerImport {

insertCustomerGroup (customerGroupName) {
return this.client.customerGroups.create({ groupName: customerGroupName })
.then(({ body: newCustomerGroup }) => {
this.customerGroups[customerGroupName] = newCustomerGroup.id
return newCustomerGroup
})
}

validateCustomer (customer) {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/customer-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ describe('customer import module', function () {
email: '[email protected]',
customerGroup: 'commercetools'
}
customerImport.insertCustomerGroup('commercetools')
customerImport.loadCustomerGroups()
.then(() => {
customerImport.loadCustomerGroups()
customerImport.insertCustomerGroup('commercetools')
.then(() => {
customerImport.importCustomer(customer)
.then((customerWithGroupReference) => {
Expand Down

0 comments on commit fc913e8

Please sign in to comment.