Skip to content

Commit

Permalink
Refactor based on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
junajan committed Aug 26, 2016
1 parent fde65e2 commit 6c34f70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
18 changes: 7 additions & 11 deletions src/coffee/product-type-import.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ class ProductTypeImporter
else
credentialsPromise = ProjectCredentialsConfig.create()
.then (credentials) ->
Promise.resolve
config: credentials.enrichCredentials
project_key: argv.projectKey
client_id: argv.clientId
client_secret: argv.clientSecret
config: credentials.enrichCredentials
project_key: argv.projectKey
client_id: argv.clientId
client_secret: argv.clientSecret

credentialsPromise.then (credentials) ->
options = _.extend credentials,
Expand All @@ -64,18 +63,15 @@ class ProductTypeImporter
options.rejectUnauthorized = false
options.oauth_protocol = argv.sphereAuthProtocol if argv.sphereAuthProtocol

config =
sphereClientConfig: options

Promise.resolve config
sphereClientConfig: options

###
Create sphere product import class
###
_ensureProductTypeImporter: (argv, logger) ->
@_ensureCredentials argv
.then (credentials) ->
new ProductTypeImport.default(logger, credentials)
.then (credentials) =>
@sphereImporter = new ProductTypeImport.default(logger, credentials)

###
Import product types using sphere product import tool
Expand Down
5 changes: 4 additions & 1 deletion src/spec/product-type-importer.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,7 @@ describe 'ProductTypeImporter', ->
.then ->
done "Importer wrong product type"
.catch ->
done()
sphereClient.productTypes.fetch()
.then (res) ->
expect(res.body.results.length).toEqual 0
done()

0 comments on commit 6c34f70

Please sign in to comment.