Skip to content

Commit

Permalink
karma refactor pending
Browse files Browse the repository at this point in the history
  • Loading branch information
Htunny committed Feb 15, 2016
1 parent 5509e64 commit 9ad90ff
Show file tree
Hide file tree
Showing 23 changed files with 215 additions and 300 deletions.
2 changes: 1 addition & 1 deletion public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pitchup.config(['$routeProvider', '$locationProvider',
})
.otherwise({
redirectTo: '/'
})
});
$locationProvider.html5Mode(true);
}
]);
Expand Down
2 changes: 1 addition & 1 deletion public/js/controllers/appController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pitchup.controller('AppController',
['$rootScope', 'UserAuth',
function ($rootScope, UserAuth){
var self = this
var self = this;
self.currentUser = undefined;

$rootScope.topScope = $rootScope;
Expand Down
8 changes: 4 additions & 4 deletions public/js/factories/userAuthFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function($q, $timeout, $http) {
});

return deferred.promise;
}
};

userAuth.login= function(username, password) {
var deferred = $q.defer();
Expand All @@ -36,7 +36,7 @@ function($q, $timeout, $http) {
});

return deferred.promise;
}
};

userAuth.logout = function() {
var deferred = $q.defer();
Expand All @@ -52,7 +52,7 @@ function($q, $timeout, $http) {
});

return deferred.promise;
}
};

userAuth.register = function(username, email, password) {
var deferred = $q.defer();
Expand All @@ -72,7 +72,7 @@ function($q, $timeout, $http) {
});

return deferred.promise;
}
};

return userAuth;
}]);
2 changes: 1 addition & 1 deletion public/js/factories/usersResourceFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function($http) {

usersResource.getUser = function(id) {
return $http.get('/users/' + id);
}
};

return usersResource;
}]);
28 changes: 0 additions & 28 deletions server/migrations/versions/046fd0c15c60_.py

This file was deleted.

33 changes: 0 additions & 33 deletions server/migrations/versions/386d83aee4eb_.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""empty message
Revision ID: 7cc6e82b4f5a
Revision ID: 63f1cba03ffa
Revises: None
Create Date: 2016-02-13 18:36:36.428664
Create Date: 2016-02-15 11:10:37.214435
"""

# revision identifiers, used by Alembic.
revision = '7cc6e82b4f5a'
revision = '63f1cba03ffa'
down_revision = None

from alembic import op
Expand All @@ -29,17 +29,16 @@ def upgrade():
sa.Column('capacity', sa.Integer(), nullable=True),
sa.Column('number_players', sa.Integer(), nullable=True),
sa.Column('created_by', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['created_by'], ['users.id'], ),
sa.ForeignKeyConstraint(['created_by'], ['users.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('enrollments',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('team_id', sa.Integer(), nullable=False),
sa.Column('number_players', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id', 'user_id', 'team_id')
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('user_id', 'team_id')
)
### end Alembic commands ###

Expand Down
26 changes: 0 additions & 26 deletions server/migrations/versions/7f230de7ce1e_.py

This file was deleted.

32 changes: 0 additions & 32 deletions server/migrations/versions/b84ea16b3b7a_.py

This file was deleted.

Empty file.
32 changes: 0 additions & 32 deletions test/front_end/controllers/logoutController.spec.js

This file was deleted.

42 changes: 42 additions & 0 deletions test/front_end/controllers/navbarController.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
describe('NavbarController', function() {
var ctrl;
var scope;
var locationMock;
var UserAuthMock;
var location;
var route;

beforeEach(function() {
locationMock = jasmine.createSpyObj(
'locationMock', ['path']
);
routeMock = jasmine.createSpyObj(
'routeMock', ['reload']
);
UserAuthMock = jasmine.createSpyObj(
'UserAuth', ['logout']
);

module('Pitchup', {
UserAuth: UserAuthMock,
$location: locationMock,
$route: routeMock
});
});

beforeEach(inject(function($controller, $q, $rootScope, $location, $route) {
UserAuthMock.logout.and.returnValue($q.when({}));
ctrl = $controller('NavbarController');
scope = $rootScope;
location = $location;
route = $route;
}));

describe('#logout', function() {
it('redirects the user to teams list on successful log out', function() {
ctrl.logout();
scope.$digest();
expect(location.path).toHaveBeenCalledWith('/');
});
});
});
20 changes: 15 additions & 5 deletions test/front_end/controllers/newEnrollmentController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,43 @@ describe('NewEnrollmentController', function() {
var response = { message: 'ok' };
var ctrl;
var scope;
var windowMock;
var locationMock;
var EnrollmentsResourceFactoryMock;
var idMock;
var location;
var route;

beforeEach(function() {
windowMock = { location : { href: jasmine.createSpy() } };
locationMock = jasmine.createSpyObj(
'locationMock', ['path']
);
routeMock = jasmine.createSpyObj(
'routeMock', ['reload']
);
EnrollmentsResourceFactoryMock = jasmine.createSpyObj(
'EnrollmentsResource', ['postEnrollments']
);
module('Pitchup', {
EnrollmentsResource: EnrollmentsResourceFactoryMock,
$window: windowMock
$location: locationMock,
$route: routeMock
});
});

beforeEach(inject(function($controller, $q, $rootScope) {
beforeEach(inject(function($controller, $q, $rootScope, $location, $route) {
EnrollmentsResourceFactoryMock.postEnrollments.and.returnValue($q.when(response));
ctrl = $controller('NewEnrollmentController');
scope = $rootScope;
location = $location;
route = $route;
}));

describe('#enroll', function() {
it('redirects to /#/teams/:id when a user successfully joins a team', function() {
ctrl.id = 55;
ctrl.enroll();
scope.$digest();
expect(windowMock.location.href).toEqual('/#/teams/55');
expect(location.path).toHaveBeenCalledWith('/teams/55');
});
});
});
Loading

0 comments on commit 9ad90ff

Please sign in to comment.