diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 410a396..78ace07 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -1,8 +1,6 @@ 'use strict'; angular.module('robotoPromotoApp') - .controller('MainCtrl', function ($scope, $http) { - $http.get('/api/awesomeThings').success(function(awesomeThings) { - $scope.awesomeThings = awesomeThings; - }); - }); +.controller('MainCtrl', function ($scope, $http) { + +}); diff --git a/lib/controllers/api.js b/lib/controllers/api.js deleted file mode 100644 index 91ec7da..0000000 --- a/lib/controllers/api.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var mongoose = require('mongoose'), - Promotion = mongoose.model('Promotion'), - Thing = mongoose.model('Thing'); - -/** - * Get awesome things - */ -exports.awesomeThings = function(req, res) { - return Thing.find(function (err, things) { - if (!err) { - return res.json(things); - } else { - return res.send(err); - } - }); -}; diff --git a/lib/models/thing.js b/lib/models/thing.js deleted file mode 100644 index 111e91e..0000000 --- a/lib/models/thing.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -var mongoose = require('mongoose'), - Schema = mongoose.Schema; - -/** - * Thing Schema - */ -var ThingSchema = new Schema({ - name: String, - info: String, - awesomeness: Number -}); - -/** - * Validations - */ -ThingSchema.path('awesomeness').validate(function (num) { - return num >= 1 && num <= 10; -}, 'Awesomeness must be between 1 and 10'); - -mongoose.model('Thing', ThingSchema); diff --git a/lib/routes.js b/lib/routes.js index f56f49a..b48b48e 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -1,10 +1,9 @@ 'use strict'; -var api = require('./controllers/api'), -index = require('./controllers'), -users = require('./controllers/users'), -promotions = require('./controllers/promotions'), -session = require('./controllers/session'); +var index = require('./controllers'), + users = require('./controllers/users'), + promotions = require('./controllers/promotions'), + session = require('./controllers/session'); var middleware = require('./middleware'); @@ -14,7 +13,6 @@ var middleware = require('./middleware'); module.exports = function(app) { // Server API Routes - app.get('/api/awesomeThings', api.awesomeThings); app.get('/api/promotions', promotions.list); app.post('/api/promotions', promotions.create); app.post('/api/promotions/:id', promotions.show); diff --git a/test/client/spec/controllers/main.js b/test/client/spec/controllers/main.js index 32c38a9..4e4e39b 100644 --- a/test/client/spec/controllers/main.js +++ b/test/client/spec/controllers/main.js @@ -2,27 +2,27 @@ describe('Controller: MainCtrl', function () { - // load the controller's module - beforeEach(module('robotoApp')); + // load the controller's module + beforeEach(module('robotoApp')); - var MainCtrl, + var MainCtrl, scope, $httpBackend; - // Initialize the controller and a mock scope - beforeEach(inject(function (_$httpBackend_, $controller, $rootScope) { - $httpBackend = _$httpBackend_; - $httpBackend.expectGET('/api/awesomeThings') - .respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']); - scope = $rootScope.$new(); - MainCtrl = $controller('MainCtrl', { - $scope: scope - }); - })); + // Initialize the controller and a mock scope + beforeEach(inject(function (_$httpBackend_, $controller, $rootScope) { + $httpBackend = _$httpBackend_; + $httpBackend.expectGET('/api/promotions') + .respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']); + scope = $rootScope.$new(); + MainCtrl = $controller('MainCtrl', { + $scope: scope + }); + })); - it('should attach a list of awesomeThings to the scope', function () { - expect(scope.awesomeThings).toBeUndefined(); - $httpBackend.flush(); - expect(scope.awesomeThings.length).toBe(4); - }); + it('should attach a list of promotions to the scope', function () { + expect(scope.promotions).toBeUndefined(); + $httpBackend.flush(); + expect(scope.promotions.length).toBe(4); + }); }); diff --git a/test/client/spec/controllers/promotions.js b/test/client/spec/controllers/promotions.js index eef9e5f..572603d 100644 --- a/test/client/spec/controllers/promotions.js +++ b/test/client/spec/controllers/promotions.js @@ -2,21 +2,21 @@ describe('Controller: PromotionsCtrl', function () { - // load the controller's module - beforeEach(module('robotoPromotoApp')); + // load the controller's module + beforeEach(module('robotoPromotoApp')); - var PromotionsCtrl, + var PromotionsCtrl, scope; - // Initialize the controller and a mock scope - beforeEach(inject(function ($controller, $rootScope) { - scope = $rootScope.$new(); - PromotionsCtrl = $controller('PromotionsCtrl', { - $scope: scope - }); - })); + // Initialize the controller and a mock scope + beforeEach(inject(function ($controller, $rootScope) { + scope = $rootScope.$new(); + PromotionsCtrl = $controller('PromotionsCtrl', { + $scope: scope + }); + })); - it('should attach a list of awesomeThings to the scope', function () { - expect(scope.awesomeThings.length).toBe(3); - }); + it('should attach a list of promotions to the scope', function () { + expect(scope.promotions.length).toBe(3); + }); });