mirror of
https://github.com/fergalmoran/roboto-promoto.git
synced 2025-12-22 09:37:37 +00:00
Removed awesomeThings boilerplate
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('robotoPromotoApp')
|
angular.module('robotoPromotoApp')
|
||||||
.controller('MainCtrl', function ($scope, $http) {
|
.controller('MainCtrl', function ($scope, $http) {
|
||||||
$http.get('/api/awesomeThings').success(function(awesomeThings) {
|
|
||||||
$scope.awesomeThings = awesomeThings;
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -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);
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var api = require('./controllers/api'),
|
var index = require('./controllers'),
|
||||||
index = require('./controllers'),
|
users = require('./controllers/users'),
|
||||||
users = require('./controllers/users'),
|
promotions = require('./controllers/promotions'),
|
||||||
promotions = require('./controllers/promotions'),
|
session = require('./controllers/session');
|
||||||
session = require('./controllers/session');
|
|
||||||
|
|
||||||
var middleware = require('./middleware');
|
var middleware = require('./middleware');
|
||||||
|
|
||||||
@@ -14,7 +13,6 @@ var middleware = require('./middleware');
|
|||||||
module.exports = function(app) {
|
module.exports = function(app) {
|
||||||
|
|
||||||
// Server API Routes
|
// Server API Routes
|
||||||
app.get('/api/awesomeThings', api.awesomeThings);
|
|
||||||
app.get('/api/promotions', promotions.list);
|
app.get('/api/promotions', promotions.list);
|
||||||
app.post('/api/promotions', promotions.create);
|
app.post('/api/promotions', promotions.create);
|
||||||
app.post('/api/promotions/:id', promotions.show);
|
app.post('/api/promotions/:id', promotions.show);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ describe('Controller: MainCtrl', function () {
|
|||||||
// Initialize the controller and a mock scope
|
// Initialize the controller and a mock scope
|
||||||
beforeEach(inject(function (_$httpBackend_, $controller, $rootScope) {
|
beforeEach(inject(function (_$httpBackend_, $controller, $rootScope) {
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$httpBackend.expectGET('/api/awesomeThings')
|
$httpBackend.expectGET('/api/promotions')
|
||||||
.respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']);
|
.respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']);
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
MainCtrl = $controller('MainCtrl', {
|
MainCtrl = $controller('MainCtrl', {
|
||||||
@@ -20,9 +20,9 @@ describe('Controller: MainCtrl', function () {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should attach a list of awesomeThings to the scope', function () {
|
it('should attach a list of promotions to the scope', function () {
|
||||||
expect(scope.awesomeThings).toBeUndefined();
|
expect(scope.promotions).toBeUndefined();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
expect(scope.awesomeThings.length).toBe(4);
|
expect(scope.promotions.length).toBe(4);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ describe('Controller: PromotionsCtrl', function () {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should attach a list of awesomeThings to the scope', function () {
|
it('should attach a list of promotions to the scope', function () {
|
||||||
expect(scope.awesomeThings.length).toBe(3);
|
expect(scope.promotions.length).toBe(3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user