Skip to content

Commit

Permalink
updated protactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Spratley committed Dec 1, 2014
1 parent af2e8ba commit 365ca4f
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 196 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ This is a boilerplate CMS built with Angular, Twitter Bootstrap and Node; it is

[![Build Status](https://travis-ci.org/jonniespratley/angular-cms.png)](https://travis-ci.org/jonniespratley/angular-cms)

[![Codacy Badge](https://www.codacy.com/project/badge/0825389c11854c23a05cc512385ec82d)](https://www.codacy.com/public/jonniespratley/angular-cms)

[![Coverage Status](https://coveralls.io/repos/jonniespratley/angular-cms/badge.png)](https://coveralls.io/r/jonniespratley/angular-cms)


[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/jonniespratley/angular-cms/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

[![Coverage Status](https://coveralls.io/repos/jonniespratley/angular-cms/badge.png)](https://coveralls.io/r/jonniespratley/angular-cms)



### Technologies
Some featured technologies used in this project include the following:
Expand Down Expand Up @@ -65,8 +71,8 @@ To run the application on your local machine please take the following steps.
To start mongodb execute the following command:

$ sh ./bin/db.sh
> **Note:** If errors when executing command remove the `db/mongod.lock` file.

> **Note:** If errors when executing command remove the `db/mongod.lock` file.
#### Step 2 - Start REST server
To start the server execute the following command:
Expand Down Expand Up @@ -133,7 +139,7 @@ $ grunt protractor
---

## RESTful Server
The server is a Node.js server that supports dynamic RESTful API calls to resource endpoints. It will automatically create a database if it does not exist and collection(s).
The server is a Node.js server that supports dynamic RESTful API calls to resource endpoints. It will automatically create a database if it does not exist and collection(s).

The base URL is `http://localhost:8181/api/v2`

Expand Down Expand Up @@ -194,7 +200,7 @@ my-theme/
sidebar.html
footer.html
content.html
```
```



Expand Down Expand Up @@ -230,7 +236,7 @@ Please don't edit files in the `dist` subdirectory as they are generated via Gru
## Modifying the code
First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.

Test that Grunt's CLI and Bower are installed by running `grunt --version` and `bower --version`.
Test that Grunt's CLI and Bower are installed by running `grunt --version` and `bower --version`.

1. Fork and clone the repo.
1. Run `npm install` to install all build dependencies (including Grunt).
Expand Down Expand Up @@ -275,4 +281,3 @@ The following list is features that are comming.
* SEO consideration for duplicate content (e.g use of canonical tag)

---

105 changes: 52 additions & 53 deletions app/scripts/controllers/users.coffee
Original file line number Diff line number Diff line change
@@ -1,63 +1,62 @@
'use strict'
angular.module('angularCmsApp').controller('UsersCtrl', ($scope, DataService) ->
$scope.awesomeThings = [
'HTML5 Boilerplate'
'AngularJS'
'Karma'
]

$scope.user =
username: null
email: null
password: null
role: null
created: new Date()
modified: new Date()
metadata:
avatar: ''
name: null
aboue: null

#Hold the users
$scope.users = []

#Holds the user groups
$scope.groups = ['Admin', 'Member', 'Public']

$scope.getGroups = () ->
DataService.fetch('groups').then((data) ->
$scope.groups = data
console.log(data)
)
$scope.awesomeThings = [
'HTML5 Boilerplate'
'AngularJS'
'Karma'
]

#Select user
$scope.selectUser = (user) ->
$scope.user = user
$scope.user =
username: null
email: null
password: null
role: null
created: new Date()
modified: new Date()
metadata:
avatar: ''
name: null
aboue: null

#Get users
$scope.getUsers = () ->
DataService.fetch('users').then((data) ->
$scope.users = data
$scope.getGroups() unless $scope.groups
)
#Hold the users
$scope.users = []

#Holds the user groups
$scope.groups = ['Admin', 'Member', 'Public']

#Delete user
$scope.deleteUser = (index, user) ->
ask = confirm "Delete #{user.email}?"
$scope.getGroups = () ->
DataService.fetch('groups').then((results) ->
$scope.groups = results.data
console.log(data)
)

if ask
DataService.destroy('users', user).then((data) ->
$scope.users.pop(index)
$scope.getUsers()
)
#Select user
$scope.selectUser = (user) ->
$scope.user = user

#Add user to database
$scope.addUser = (user) ->
DataService.save('users', user).then((data) ->
#Get users
$scope.getUsers = () ->
DataService.fetch('users').then((results) ->
$scope.users = results.data
$scope.getGroups() unless $scope.groups
)

#Delete user
$scope.deleteUser = (index, user) ->
ask = confirm "Delete #{user.email}?"

if ask
DataService.destroy('users', user).then((data) ->
$scope.users.pop(index)
$scope.getUsers()
#$scope.users.push(user) unless user._id
$scope.user = {}
$('#user-modal').modal('hide')
)


#Add user to database
$scope.addUser = (user) ->
DataService.save('users', user).then((data) ->
$scope.getUsers()
#$scope.users.push(user) unless user._id
$scope.user = {}
$('#user-modal').modal('hide')
)
)
4 changes: 3 additions & 1 deletion app/views/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<h1><i class="fa fa-1x fa-group"></i> Users
<button class="btn btn-default btn-sm" data-toggle="modal" data-target="#user-modal" ng-click="user = {}">
New User
</button></h1>
</button>
<button class="btn btn-default btn-sm" ng-click="getUsers()">Refresh</button>
</h1>
<hr>

<div class="row">
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"jasmine-core": "^2.1.2",
"jasmine-node": "~1.11.0",
"jasmine-reporters": "^1.0.1",
"jasmine-spec-reporter": "^1.1.0",
"karma": "^0.12.28",
"karma-chrome-launcher": "^0.1.5",
"karma-coverage": "^0.2.6",
Expand Down
43 changes: 26 additions & 17 deletions protractor.conf.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
// An example configuration file.
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
params: {
baseUrl: 'http://localhost:9000/#'
},

// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
}
,

// Spec patterns are relative to the current working directly when
// protractor is called.
specs: [
'.tmp/protractor/*.js',
'test/protractor/*.js'
],
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: [
'.tmp/protractor/*.js',
'test/protractor/*.js'
],

// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
},
onPrepare: function () {
var SpecReporter = require( 'jasmine-spec-reporter' );
// add jasmine spec reporter
jasmine.getEnv().addReporter( new SpecReporter( {displayStacktrace: true} ) );
}
};
5 changes: 4 additions & 1 deletion routes/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var path = require('path');
var Db = mongo.Db;
var BSON = mongo.BSONPure;
var express = require('express');
var utils = require('util');
var fs = require('fs');
var app = express();
var request = require('request');
Expand All @@ -49,6 +50,8 @@ var _ds = new DS({
host: 'localhost/angular-cms'
});



function delay(ms, value) {
// create a new Deferred
var deferred = new Deferred();
Expand Down Expand Up @@ -959,7 +962,7 @@ exports.rest = {


app.use(function (req, res, next) {
console.log('%s %s', req.method, req.body, req.url);
console.log('%s %s', req.method, utils.inspect(req.body, {colors: true}), req.url);
next();
});
});
Expand Down
Loading

0 comments on commit 365ca4f

Please sign in to comment.