title: Why won't the state change in a unit test for an AngularJS controller?
body: <p>I'm using Angular-ui Router not $routeProvider. My controller is:</p>
  
  <pre><code>myApp.controller('LoginController', [
    '$scope', '$rootScope', '$state', 'userService', function($scope, $rootScope, $state, userService) {
      $scope.init = function() {
        $rootScope.pageTitle = 'Login';
        $scope.auth = {};
        return $scope.errors = null;
      };
      $scope.login = function() {
        return userService.login($scope.auth).then(function(response) {
          console.log(response);
          if (response.authenticated === true) {
            console.log("Movin states!");
            return $state.go('dashboard');
          } else {
            return $scope.errors = {
              message: 'Invalid credentials',
              type: 'error'
            };
          }
        });
      };
      return $scope.init();
    }
  ]);
  </code></pre>
  
  <p>In my test, I'm doing:</p>
  
  <pre><code>it('should properly authenticate a user', function() {
    $scope.init();
    $scope.auth = {
      username: 'test@test.com',
      password: 'mypassword'
    };
    $scope.login();
    deferred.resolve({
      authenticated: true
    });
    $rootScope.$apply();
    expect($state.current.name).toEqual('dashboard');
  });
  </code></pre>
  
  <p>However, the <code>$state.current.name</code> stays as <code>''</code>. Why won't it update?</p>