Make simple create redirect to OC list but normal create to jump to incoming settings

This commit is contained in:
luisramos0
2019-11-03 13:28:47 +00:00
parent 6615469f8b
commit 5fdb86ae43
5 changed files with 32 additions and 6 deletions

View File

@@ -348,17 +348,28 @@ describe 'OrderCycle service', ->
beforeEach ->
spyOn(OrderCycle, 'confirmNoDistributors').and.returnValue true
it 'redirects to the destination page on success', ->
it 'redirects to the given destination on success', ->
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')
$httpBackend.expectPOST('/admin/order_cycles.json', {
order_cycle: 'this is the submit data'
}).respond {success: true}
}).respond {success: true, edit_path: "/edit/path"}
OrderCycle.create('/destination/page')
$httpBackend.flush()
expect($window.location).toEqual('/destination/page')
it 'redirects to the edit_path on success if no destination is given', ->
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')
$httpBackend.expectPOST('/admin/order_cycles.json', {
order_cycle: 'this is the submit data'
}).respond {success: true, edit_path: "/edit/path"}
OrderCycle.create()
$httpBackend.flush()
expect($window.location).toEqual('/edit/path')
it 'does not redirect on error', ->
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')