This is a controller with a submit function:
$scope.submit = function(){
$http.post(\'/api/project\', $scope.project)
.success(function(data, stat
This Github issue about Unit Testing UI Router explains more fully what's happening.
The problem is that $httpBackend.flush() triggers a broadcast which then triggers the otherwise case of the stateProvider.
A simple solution can be to do the following setup, as mentionned by @darinclark in Github thread mentionned above. This is valid if you do not need to test state transitions. Otherwise have a look to @rosswil's answer that is inspired by @Vratislav answer on Github.
beforeEach(module(function ($urlRouterProvider) {
$urlRouterProvider.otherwise(function(){return false;});
}));
EDITED
Thanks to Chris T to report this in the comments, seems after v0.2.14? the best way to do this is to use
beforeEach(module(function($urlRouterProvider) {
$urlRouterProvider.deferIntercept();
}));