Auto-merge from CI [skip ci]

This commit is contained in:
Continuous Integration
2015-05-28 14:31:25 +10:00
76 changed files with 1274 additions and 626 deletions

View File

@@ -22,8 +22,8 @@ describe "AdminOrderMgmtCtrl", ->
returnedOrderCycles = [ "oc1", "oc2", "oc3" ]
httpBackend.expectGET("/api/users/authorise_api?token=API_KEY").respond success: "Use of API Authorised"
httpBackend.expectGET("/api/enterprises/accessible?template=bulk_index&q[is_primary_producer_eq]=true").respond returnedSuppliers
httpBackend.expectGET("/api/enterprises/accessible?template=bulk_index&q[is_distributor_eq]=true").respond returnedDistributors
httpBackend.expectGET("/api/order_cycles/accessible").respond returnedOrderCycles
httpBackend.expectGET("/api/enterprises/accessible?template=bulk_index&q[sells_in][]=own&q[sells_in][]=any").respond returnedDistributors
httpBackend.expectGET("/api/order_cycles/accessible?as=distributor&q[orders_close_at_gt]=SomeDate").respond returnedOrderCycles
spyOn(scope, "initialiseVariables").andCallThrough()
spyOn(scope, "fetchOrders").andReturn "nothing"
#spyOn(returnedSuppliers, "unshift")
@@ -33,8 +33,8 @@ describe "AdminOrderMgmtCtrl", ->
httpBackend.flush()
expect(scope.suppliers).toEqual [{ id : '0', name : 'All' }, 'list of suppliers']
expect(scope.distributors).toEqual [ { id : '0', name : 'All' }, 'list of distributors' ]
expect(scope.orderCycles).toEqual [ { id : '0', name : 'All' }, 'oc1', 'oc2', 'oc3' ]
expect(scope.distributors).toEqual [ { id : '0', name : 'All' }, 'list of distributors' ]
expect(scope.orderCycles).toEqual [ { id : '0', name : 'All' }, 'oc1', 'oc2', 'oc3' ]
expect(scope.initialiseVariables.calls.length).toBe 1
expect(scope.fetchOrders.calls.length).toBe 1
@@ -43,7 +43,7 @@ describe "AdminOrderMgmtCtrl", ->
describe "fetching orders", ->
beforeEach ->
scope.initialiseVariables()
httpBackend.expectGET("/api/orders/managed?template=bulk_index;page=1;per_page=500;q[completed_at_not_null]=true;q[completed_at_gt]=SomeDate;q[completed_at_lt]=SomeDate").respond "list of orders"
httpBackend.expectGET("/admin/orders/managed?template=bulk_index;page=1;per_page=500;q[state_not_eq]=canceled;q[completed_at_not_null]=true;q[completed_at_gt]=SomeDate;q[completed_at_lt]=SomeDate").respond "list of orders"
it "makes a call to dataFetcher, with current start and end date parameters", ->
scope.fetchOrders()
@@ -350,6 +350,33 @@ describe "AdminOrderMgmtCtrl", ->
spyOn(VariantUnitManager, "getUnitName").andReturn "kg"
expect(scope.formattedValueWithUnitName(2000,unitsVariant)).toEqual "2 kg"
describe "updating the price upon updating the weight of a line item", ->
it "resets the weight if the weight is set to zero", ->
scope.filteredLineItems = [
{ units_variant: { unit_value: 100 }, price: 2, unit_value: 0 }
]
expect(scope.weightAdjustedPrice(scope.filteredLineItems[0], 100)).toEqual scope.filteredLineItems[0].price
it "updates the price if the weight is changed", ->
scope.filteredLineItems = [
{ units_variant: { unit_value: 100 }, price: 2, unit_value: 200 }
]
old_value = scope.filteredLineItems[0].units_variant.unit_value
new_value = scope.filteredLineItems[0].unit_value
sp = scope.filteredLineItems[0].price * new_value / old_value
expect(scope.weightAdjustedPrice(scope.filteredLineItems[0], old_value)).toEqual sp
it "doesn't update the price if the weight is not changed", ->
scope.filteredLineItems = [
{ units_variant: { unit_value: 100 }, price: 2, unit_value: 100 }
]
old_value = scope.filteredLineItems[0].unit_value
new_value = scope.filteredLineItems[0].unit_value
sp = scope.filteredLineItems[0].price
expect(scope.weightAdjustedPrice(scope.filteredLineItems[0], old_value)).toEqual sp
describe "managing pending changes", ->
dataSubmitter = pendingChangesService = null