Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ indent_style = tab
# Standard at:
[Makefile]
indent_style = tab

# The indentation in package.json will always need to be 2 spaces
# https://github.com/npm/npm/issues/4718
[package.json, bower.json]
indent_style = space
indent_size = 2
33 changes: 18 additions & 15 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"name": "meanjs",
"version": "0.4.0",
"description": "Fullstack JavaScript with MongoDB, Express, AngularJS, and Node.js.",
"dependencies": {
"bootstrap": "~3",
"angular": "~1.2",
"angular-resource": "~1.2",
"angular-animate": "~1.2",
"angular-mocks": "~1.2",
"angular-bootstrap": "~0.11.2",
"angular-ui-utils": "~0.1.1",
"angular-ui-router": "~0.2.11",
"angular-file-upload": "~1.1.5"
}
}
"name": "meanjs",
"version": "0.4.0",
"description": "Fullstack JavaScript with MongoDB, Express, AngularJS, and Node.js.",
"dependencies": {
"bootstrap": "~3",
"angular": "~1.3",
"angular-resource": "~1.3",
"angular-animate": "~1.3",
"angular-mocks": "~1.3",
"angular-bootstrap": "~0.13",
"angular-ui-utils": "bower",
"angular-ui-router": "~0.2",
"angular-file-upload": "~1.1.5"
},
"resolutions": {
"angular": "~1.3"
}
}
89 changes: 45 additions & 44 deletions modules/articles/tests/server/article.server.routes.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ var app, agent, credentials, user, article;
/**
* Article routes tests
*/
describe('Article CRUD tests', function() {
before(function(done) {
describe('Article CRUD tests', function () {
before(function (done) {
// Get application
app = express.init(mongoose);
agent = request.agent(app);

done();
});

beforeEach(function(done) {
beforeEach(function (done) {
// Create user credentials
credentials = {
username: 'username',
Expand All @@ -44,7 +44,7 @@ describe('Article CRUD tests', function() {
});

// Save a user to the test db and create new article
user.save(function() {
user.save(function () {
article = {
title: 'Article Title',
content: 'Article Content'
Expand All @@ -54,11 +54,11 @@ describe('Article CRUD tests', function() {
});
});

it('should be able to save an article if logged in', function(done) {
it('should be able to save an article if logged in', function (done) {
agent.post('/api/auth/signin')
.send(credentials)
.expect(200)
.end(function(signinErr, signinRes) {
.end(function (signinErr, signinRes) {
// Handle signin error
if (signinErr) done(signinErr);

Expand All @@ -69,13 +69,13 @@ describe('Article CRUD tests', function() {
agent.post('/api/articles')
.send(article)
.expect(200)
.end(function(articleSaveErr, articleSaveRes) {
.end(function (articleSaveErr, articleSaveRes) {
// Handle article save error
if (articleSaveErr) done(articleSaveErr);

// Get a list of articles
agent.get('/api/articles')
.end(function(articlesGetErr, articlesGetRes) {
.end(function (articlesGetErr, articlesGetRes) {
// Handle article save error
if (articlesGetErr) done(articlesGetErr);

Expand All @@ -93,24 +93,24 @@ describe('Article CRUD tests', function() {
});
});

it('should not be able to save an article if not logged in', function(done) {
it('should not be able to save an article if not logged in', function (done) {
agent.post('/api/articles')
.send(article)
.expect(403)
.end(function(articleSaveErr, articleSaveRes) {
.end(function (articleSaveErr, articleSaveRes) {
// Call the assertion callback
done(articleSaveErr);
});
});

it('should not be able to save an article if no title is provided', function(done) {
it('should not be able to save an article if no title is provided', function (done) {
// Invalidate title field
article.title = '';

agent.post('/api/auth/signin')
.send(credentials)
.expect(200)
.end(function(signinErr, signinRes) {
.end(function (signinErr, signinRes) {
// Handle signin error
if (signinErr) done(signinErr);

Expand All @@ -121,7 +121,7 @@ describe('Article CRUD tests', function() {
agent.post('/api/articles')
.send(article)
.expect(400)
.end(function(articleSaveErr, articleSaveRes) {
.end(function (articleSaveErr, articleSaveRes) {
// Set message assertion
(articleSaveRes.body.message).should.match('Title cannot be blank');

Expand All @@ -131,11 +131,11 @@ describe('Article CRUD tests', function() {
});
});

it('should be able to update an article if signed in', function(done) {
it('should be able to update an article if signed in', function (done) {
agent.post('/api/auth/signin')
.send(credentials)
.expect(200)
.end(function(signinErr, signinRes) {
.end(function (signinErr, signinRes) {
// Handle signin error
if (signinErr) done(signinErr);

Expand All @@ -146,7 +146,7 @@ describe('Article CRUD tests', function() {
agent.post('/api/articles')
.send(article)
.expect(200)
.end(function(articleSaveErr, articleSaveRes) {
.end(function (articleSaveErr, articleSaveRes) {
// Handle article save error
if (articleSaveErr) done(articleSaveErr);

Expand All @@ -157,7 +157,7 @@ describe('Article CRUD tests', function() {
agent.put('/api/articles/' + articleSaveRes.body._id)
.send(article)
.expect(200)
.end(function(articleUpdateErr, articleUpdateRes) {
.end(function (articleUpdateErr, articleUpdateRes) {
// Handle article update error
if (articleUpdateErr) done(articleUpdateErr);

Expand All @@ -172,17 +172,17 @@ describe('Article CRUD tests', function() {
});
});

it('should be able to get a list of articles if not signed in', function(done) {
it('should be able to get a list of articles if not signed in', function (done) {
// Create new article model instance
var articleObj = new Article(article);

// Save the article
articleObj.save(function() {
articleObj.save(function () {
// Request articles
request(app).get('/api/articles')
.end(function(req, res) {
.end(function (req, res) {
// Set assertion
res.body.should.be.an.Array.with.lengthOf(1);
res.body.should.be.instanceof(Array).and.have.lengthOf(1);

// Call the assertion callback
done();
Expand All @@ -192,39 +192,40 @@ describe('Article CRUD tests', function() {
});


it('should be able to get a single article if not signed in', function(done) {
it('should be able to get a single article if not signed in', function (done) {
// Create new article model instance
var articleObj = new Article(article);

// Save the article
articleObj.save(function() {
articleObj.save(function () {
request(app).get('/api/articles/' + articleObj._id)
.end(function(req, res) {
.end(function (req, res) {
// Set assertion
res.body.should.be.an.Object.with.property('title', article.title);
res.body.should.be.instanceof(Object).and.have.property('title', article.title);

// Call the assertion callback
done();
});
});
});

it('should return proper error for single article which doesnt exist, if not signed in', function(done) {
request(app).get('/articles/test')
.end(function(req, res) {
it('should return proper error for single article which doesnt exist, if not signed in', function (done) {
request(app).get('/api/articles/test')
.end(function (req, res) {
console.log(res.body);
// Set assertion
res.body.should.be.an.Object.with.property('message', 'Article is invalid');
res.body.should.be.instanceof(Object).and.have.property('message', 'Article is invalid');

// Call the assertion callback
done();
});
});

it('should be able to delete an article if signed in', function(done) {
it('should be able to delete an article if signed in', function (done) {
agent.post('/api/auth/signin')
.send(credentials)
.expect(200)
.end(function(signinErr, signinRes) {
.end(function (signinErr, signinRes) {
// Handle signin error
if (signinErr) done(signinErr);

Expand All @@ -235,15 +236,15 @@ describe('Article CRUD tests', function() {
agent.post('/api/articles')
.send(article)
.expect(200)
.end(function(articleSaveErr, articleSaveRes) {
.end(function (articleSaveErr, articleSaveRes) {
// Handle article save error
if (articleSaveErr) done(articleSaveErr);

// Delete an existing article
agent.delete('/api/articles/' + articleSaveRes.body._id)
.send(article)
.expect(200)
.end(function(articleDeleteErr, articleDeleteRes) {
.end(function (articleDeleteErr, articleDeleteRes) {
// Handle article error error
if (articleDeleteErr) done(articleDeleteErr);

Expand All @@ -257,31 +258,31 @@ describe('Article CRUD tests', function() {
});
});

it('should not be able to delete an article if not signed in', function(done) {
it('should not be able to delete an article if not signed in', function (done) {
// Set article user
article.user = user;

// Create new article model instance
var articleObj = new Article(article);

// Save the article
articleObj.save(function() {
articleObj.save(function () {
// Try deleting article
request(app).delete('/api/articles/' + articleObj._id)
.expect(403)
.end(function(articleDeleteErr, articleDeleteRes) {
// Set message assertion
(articleDeleteRes.body.message).should.match('User is not authorized');
.expect(403)
.end(function (articleDeleteErr, articleDeleteRes) {
// Set message assertion
(articleDeleteRes.body.message).should.match('User is not authorized');

// Handle article error error
done(articleDeleteErr);
});
// Handle article error error
done(articleDeleteErr);
});

});
});

afterEach(function(done) {
User.remove().exec(function() {
afterEach(function (done) {
User.remove().exec(function () {
Article.remove().exec(done);
});
});
Expand Down
13 changes: 5 additions & 8 deletions modules/core/client/views/header.client.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
</div>
<nav class="collapse navbar-collapse" collapse="!isCollapsed" role="navigation">
<ul class="nav navbar-nav" data-ng-if="menu.shouldRender(authentication.user);">
<li data-ng-repeat="item in menu.items | orderBy: 'position'" data-ng-if="item.shouldRender(authentication.user);" ng-switch="item.type" data-ng-class="{active: $state.includes(item.state)}" class="{{item.class}}" dropdown="item.type === 'dropdown'">
<a ng-switch-when="dropdown" class="dropdown-toggle">
<span data-ng-bind="item.title"></span>
<b class="caret"></b>
</a>
<li data-ng-repeat="item in menu.items | orderBy: 'position'" data-ng-if="item.shouldRender(authentication.user);" ng-switch="item.type" data-ng-class="{ active: $state.includes(item.state), dropdown: item.type === 'dropdown' }" class="{{item.class}}" dropdown="item.type === 'dropdown'">
<a ng-switch-when="dropdown" class="dropdown-toggle" dropdown-toggle role="button">{{::item.title}}&nbsp;<span class="caret"></span></a>
<ul ng-switch-when="dropdown" class="dropdown-menu">
<li data-ng-repeat="subitem in item.items | orderBy: 'position'" data-ng-if="subitem.shouldRender(authentication.user);" data-ui-sref-active="active">
<a data-ui-sref="{{subitem.state}}" data-ng-bind="subitem.title"></a>
Expand All @@ -33,12 +30,12 @@
</li>
</ul>
<ul class="nav navbar-nav navbar-right" data-ng-show="authentication.user">
<li class="dropdown">
<a href="#" class="dropdown-toggle user-header-dropdown-toggle" data-toggle="dropdown">
<li class="dropdown" dropdown>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that dropdown text suppose to be there like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's how it works with ui-bootstrap.

<a class="dropdown-toggle user-header-dropdown-toggle" dropdown-toggle role="button">
<img data-ng-src="{{authentication.user.profileImageURL}}" alt="{{authentication.user.displayName}}" class="header-profile-image"/>
<span data-ng-bind="authentication.user.displayName"></span> <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<ul class="dropdown-menu" role="menu">
<li data-ui-sref-active="active">
<a data-ui-sref="settings.profile">Edit Profile</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h3 class="col-md-12 text-center">Reset your password</h3>
<input type="password" id="verifyPassword" name="verifyPassword" class="form-control" data-ng-model="passwordDetails.verifyPassword" placeholder="Verify Password">
</div>
<div class="text-center form-group">
<button type="submit" class="btn btn-large btn-primary">Update Password</button>
<button type="submit" class="btn btn-lg btn-primary">Update Password</button>
</div>
<div data-ng-show="error" class="text-center text-danger">
<strong>{{error}}</strong>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<input type="password" id="verifyPassword" name="verifyPassword" class="form-control" data-ng-model="passwordDetails.verifyPassword" placeholder="Verify Password">
</div>
<div class="text-center form-group">
<button type="submit" class="btn btn-large btn-primary">Save Password</button>
<button type="submit" class="btn btn-lg btn-primary">Save Password</button>
</div>
<div data-ng-show="success" class="text-center text-success">
<strong>Password Changed Successfully</strong>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<input type="text" id="username" name="username" class="form-control" data-ng-model="user.username" placeholder="Username">
</div>
<div class="text-center form-group">
<button type="submit" class="btn btn-large btn-primary">Save Profile</button>
<button type="submit" class="btn btn-lg btn-primary">Save Profile</button>
</div>
<div data-ng-show="success" class="text-center text-success">
<strong>Profile Saved Successfully</strong>
Expand Down
Loading