Skip to content

Commit e1f4bc8

Browse files
committed
JWT Unit Test with email verification + Standardjs Format + Codeclimate
1 parent 87c18d2 commit e1f4bc8

20 files changed

+87
-124
lines changed

.codeclimate.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ languages:
1111
PHP: true
1212
Python: false
1313
exclude_paths:
14+
- "gulpfile.js"
1415
- "public/js/vendor.js"
16+
- "public/dist/js/app.js"
17+
- "tasks/**"
18+
- "tests/**"

.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"globals": {
1616
"angular": true,
1717
"module": true,
18-
"inject": true
18+
"inject": true,
19+
"jQuery": true,
20+
"$": true,
21+
"swal": true,
22+
"ngDescribe": true
1923
}
2024
}

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ Plus Oauth and JWT authentication on the side.
55
[![Build Status](https://travis-ci.org/silverbux/laravel-angular-admin.svg?branch=master)](https://travis-ci.org/silverbux/laravel-angular-admin)
66
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
77
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/silverbux/laravel-angular-admin/master/LICENSE)
8-
[![wercker status](https://app.wercker.com/status/92444e926f721c992f7f41c605d5cbc4/s/master "wercker status")](https://app.wercker.com/project/bykey/92444e926f721c992f7f41c605d5cbc4)
8+
[![Code Climate](https://codeclimate.com/github/silverbux/laravel-angular-admin/badges/gpa.svg)](https://codeclimate.com/github/silverbux/laravel-angular-admin)
9+
[![Issue Count](https://codeclimate.com/github/silverbux/laravel-angular-admin/badges/issue_count.svg)](https://codeclimate.com/github/silverbux/laravel-angular-admin)
10+
11+
[![wercker status](https://app.wercker.com/status/92444e926f721c992f7f41c605d5cbc4/m "wercker status")](https://app.wercker.com/project/bykey/92444e926f721c992f7f41c605d5cbc4)
912

1013
## Screenshots
1114
![Dashboard Screenshot](https://cloud.githubusercontent.com/assets/1888261/14597104/53b404b6-057d-11e6-876d-c83630686590.png)
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
class ComingSoonController{
2-
constructor(){
3-
'ngInject';
1+
class ComingSoonController {
2+
constructor () {
3+
'ngInject'
44

5-
//
6-
}
5+
//
6+
}
77

8-
$onInit(){
9-
}
8+
$onInit () {}
109
}
1110

1211
export const ComingSoonComponent = {
13-
templateUrl: './views/app/components/coming-soon/coming-soon.component.html',
14-
controller: ComingSoonController,
15-
controllerAs: 'vm',
16-
bindings: {}
12+
templateUrl: './views/app/components/coming-soon/coming-soon.component.html',
13+
controller: ComingSoonController,
14+
controllerAs: 'vm',
15+
bindings: {}
1716
}
18-
19-

angular/app/components/create_post_form/create_post_form.component.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

angular/app/components/create_post_form/create_post_form.component.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

angular/app/components/create_post_form/create_post_form.less

Whitespace-only changes.

angular/app/components/dashboard/dashboard.component.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ class DashboardController {
99
[28, 48, 40, 19, 86, 27, 90]
1010
]
1111

12-
$scope.onClick = function () {
13-
14-
}
12+
$scope.onClick = function () {}
1513

1614
$scope.pieLabels = ['Download Sales', 'In-Store Sales', 'Mail-Order Sales']
1715
$scope.pieData = [300, 500, 100]

angular/app/components/user-permissions/user-permissions.component.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ class UserPermissionsController {
6161
API.one('users').one('permissions', permissionId).remove()
6262
.then(() => {
6363
swal({
64-
title: "Deleted!",
65-
text: "User Permission has been deleted.",
66-
type: "success",
67-
confirmButtonText: "OK",
68-
closeOnConfirm: true
69-
}, function() {
70-
$state.reload()
64+
title: 'Deleted!',
65+
text: 'User Permission has been deleted.',
66+
type: 'success',
67+
confirmButtonText: 'OK',
68+
closeOnConfirm: true
69+
}, function () {
70+
$state.reload()
7171
})
7272
})
7373
})
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
class UserVerificationController{
2-
constructor($stateParams){
3-
'ngInject';
4-
this.alerts = []
5-
6-
if($stateParams.status === 'success') {
7-
this.alerts.push({ type: 'success', 'title': 'Success!', msg: 'Email Verification Success.' })
8-
} else {
9-
this.alerts.push({ type: 'danger', 'title': 'Error:', msg: 'Email verification failed.' })
10-
}
1+
class UserVerificationController {
2+
constructor ($stateParams) {
3+
'ngInject'
4+
this.alerts = []
115

6+
if ($stateParams.status === 'success') {
7+
this.alerts.push({ type: 'success', 'title': 'Success!', msg: 'Email Verification Success.' })
8+
} else {
9+
this.alerts.push({ type: 'danger', 'title': 'Error:', msg: 'Email verification failed.' })
1210
}
11+
}
1312

14-
$onInit(){
15-
}
13+
$onInit () {}
1614
}
1715

1816
export const UserVerificationComponent = {
19-
templateUrl: './views/app/components/user-verification/user-verification.component.html',
20-
controller: UserVerificationController,
21-
controllerAs: 'vm',
22-
bindings: {}
17+
templateUrl: './views/app/components/user-verification/user-verification.component.html',
18+
controller: UserVerificationController,
19+
controllerAs: 'vm',
20+
bindings: {}
2321
}
24-
25-

angular/config/acl.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export function AclConfig (AclServiceProvider) {
88

99
/*eslint-disable */
1010
AclServiceProvider.config(myConfig)
11-
/*eslint-enable */
11+
/*eslint-enable */
1212
}

angular/index.components.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {UserVerificationComponent} from './app/components/user-verification/user-verification.component';
2-
import { ComingSoonComponent } from './app/components/coming-soon/coming-soon.component';
1+
import { UserVerificationComponent } from './app/components/user-verification/user-verification.component'
2+
import { ComingSoonComponent } from './app/components/coming-soon/coming-soon.component'
33
import { UserEditComponent } from './app/components/user-edit/user-edit.component'
44
import { UserPermissionsEditComponent } from './app/components/user-permissions-edit/user-permissions-edit.component'
55
import { UserPermissionsAddComponent } from './app/components/user-permissions-add/user-permissions-add.component'
@@ -14,11 +14,10 @@ import { NavHeaderComponent } from './app/components/nav-header/nav-header.compo
1414
import { LoginLoaderComponent } from './app/components/login-loader/login-loader.component'
1515
import { LoginFormComponent } from './app/components/login-form/login-form.component'
1616
import { RegisterFormComponent } from './app/components/register-form/register-form.component'
17-
import { CreatePostFormComponent } from './app/components/create_post_form/create_post_form.component'
1817

1918
angular.module('app.components')
20-
.component('userVerification', UserVerificationComponent)
21-
.component('comingsoon', ComingSoonComponent)
19+
.component('userVerification', UserVerificationComponent)
20+
.component('comingsoon', ComingSoonComponent)
2221
.component('useredit', UserEditComponent)
2322
.component('userpermissionsedit', UserPermissionsEditComponent)
2423
.component('userpermissionsadd', UserPermissionsAddComponent)
@@ -33,4 +32,3 @@ angular.module('app.components')
3332
.component('loginLoader', LoginLoaderComponent)
3433
.component('loginForm', LoginFormComponent)
3534
.component('registerForm', RegisterFormComponent)
36-
.component('createPostForm', CreatePostFormComponent)

angular/run/routes.run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ export function RoutesRun ($rootScope, $state, $auth, AclService, $timeout) {
3535

3636
$rootScope.$on('$destroy', deregisterationCallback)
3737
$rootScope.$on('$stateChangeSuccess', fixSideBar)
38-
/*eslint-enable */
38+
/*eslint-enable */
3939
}

angular/services/API.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class APIService {
1414
.setErrorInterceptor(function (response) {
1515
if (response.status === 422) {
1616
// for (var error in response.data.errors) {
17-
// return ToastService.error(response.data.errors[error][0])
17+
// return ToastService.error(response.data.errors[error][0])
1818
// }
1919
}
2020
})

app/Http/Controllers/Auth/AuthController.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,13 @@ public function verifyUserEmail($verificationCode)
185185
*/
186186
public function postRegister(Request $request)
187187
{
188-
$verificationCode = str_random(40);
189-
190-
Mail::send('emails.userverification', ['verificationCode' => $verificationCode], function ($m) use ($request) {
191-
$m->to($request->email, 'test')->subject('Email Confirmation');
192-
});
193-
194188
$this->validate($request, [
195189
'name' => 'required|min:3',
196190
'email' => 'required|email|unique:users',
197191
'password' => 'required|min:8',
198192
]);
199193

194+
$verificationCode = str_random(40);
200195
$user = new User;
201196
$user->name = trim($request->name);
202197
$user->email = trim(strtolower($request->email));
@@ -206,6 +201,10 @@ public function postRegister(Request $request)
206201

207202
$token = JWTAuth::fromUser($user);
208203

204+
Mail::send('emails.userverification', ['verificationCode' => $verificationCode], function ($m) use ($request) {
205+
$m->to($request->email, 'test')->subject('Email Confirmation');
206+
});
207+
209208
return response()->success(compact('user', 'token'));
210209
}
211210
}

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = function (config) {
2626
plugins: [
2727
'karma-jasmine',
2828
'karma-phantomjs-launcher',
29-
'karma-browserify',
29+
'karma-browserify'
3030
]
3131

3232
// define reporters, port, logLevel, browsers etc.

tasks/angular.task.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Elixir.extend('angular', function (src, output, outputFilename) {
1717
return gulp.src([baseDir + 'index.main.js', baseDir + '**/*.*.js'])
1818
.pipe(eslint({
1919
globals: {
20-
'jQuery':false,
21-
'$':true,
22-
'swal': true
20+
'jQuery': false,
21+
'$': true,
22+
'swal': true
2323
}
2424
}))
2525
.pipe(eslint.format())

tests/JwtAuthTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public function testSuccessfulLogin()
1313
{
1414
$user = factory(App\User::class)->create([
1515
'password' => bcrypt('test12345'),
16+
'email_verified' => '1'
1617
]);
1718

1819
$this->post('/api/auth/login', [
@@ -30,7 +31,9 @@ public function testSuccessfulLogin()
3031
*/
3132
public function testFailedLogin()
3233
{
33-
$user = factory(App\User::class)->create();
34+
$user = factory(App\User::class)->create([
35+
'email_verified' => '1'
36+
]);
3437

3538
$this->post('/api/auth/login', [
3639
'email' => $user->email,
@@ -49,9 +52,10 @@ public function testSuccessfulRegistration()
4952
$user = factory(App\User::class)->make();
5053

5154
$this->post('/api/auth/register', [
52-
'name' => $user->name,
53-
'email' => $user->email,
54-
'password' => 'test15125',
55+
'name' => $user->name,
56+
'email' => $user->email,
57+
'password' => 'test15125',
58+
'email_verified' => '1'
5559
])
5660
->seeApiSuccess()
5761
->seeJsonKeyValueString('email', $user->email)
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
ngDescribe({
2-
name: 'Test coming-soon component',
3-
modules: 'app',
4-
element: '<coming-soon></coming-soon>',
5-
tests: function (deps) {
6-
7-
it('basic test', () => {
8-
//
9-
});
10-
}
11-
});
2+
name: 'Test coming-soon component',
3+
modules: 'app',
4+
element: '<coming-soon></coming-soon>',
5+
tests: function (deps) {
6+
it('basic test', () => {
7+
//
8+
})
9+
}
10+
})
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
ngDescribe({
2-
name: 'Test user-verification component',
3-
modules: 'app',
4-
element: '<user-verification></user-verification>',
5-
tests: function (deps) {
6-
7-
it('basic test', () => {
8-
//
9-
});
10-
}
11-
});
2+
name: 'Test user-verification component',
3+
modules: 'app',
4+
element: '<user-verification></user-verification>',
5+
tests: function (deps) {
6+
it('basic test', () => {
7+
//
8+
})
9+
}
10+
})

0 commit comments

Comments
 (0)