unsakini 0.0.4.pre.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -27
- data/angular/angular-cli.json +3 -5
- data/{public/unsakini/app → angular/dist}/favicon.ico +0 -0
- data/angular/dist/index.html +14 -0
- data/angular/dist/inline.bundle.js +139 -0
- data/angular/dist/inline.map +1 -0
- data/angular/dist/main.bundle.js +64689 -0
- data/angular/dist/main.map +1 -0
- data/angular/dist/styles.bundle.js +364 -0
- data/angular/dist/styles.map +1 -0
- data/angular/package.json +1 -4
- data/angular/src/app/app.component.html +4 -1
- data/angular/src/app/app.module.ts +7 -8
- data/angular/src/app/app.routes.module.ts +2 -12
- data/angular/src/app/index.ts +0 -2
- data/angular/src/app/registration/registration.component.html +12 -70
- data/angular/src/app/registration/registration.component.spec.ts +11 -8
- data/angular/src/app/registration/registration.component.ts +8 -10
- data/angular/src/environments/environment.prod.ts +1 -2
- data/angular/src/environments/environment.ts +1 -2
- data/angular/src/index.html +1 -1
- data/angular/src/styles.css +1 -0
- data/app/controllers/api/boards_controller.rb +73 -0
- data/app/controllers/api/comments_controller.rb +51 -0
- data/app/controllers/api/posts_controller.rb +58 -0
- data/app/controllers/api/share_board_controller.rb +118 -0
- data/app/controllers/api/users_controller.rb +40 -0
- data/app/controllers/application_controller.rb +2 -2
- data/app/controllers/concerns/board_owner_controller_concern.rb +38 -0
- data/app/controllers/concerns/comment_owner_controller_concern.rb +33 -0
- data/app/controllers/concerns/logged_in_controller_concern.rb +21 -0
- data/app/controllers/concerns/post_owner_controller_concern.rb +36 -0
- data/app/controllers/concerns/serializer_controller_concern.rb +11 -0
- data/app/controllers/user_token_controller.rb +2 -0
- data/app/controllers/web_base_controller.rb +23 -0
- data/app/models/application_record.rb +5 -0
- data/app/models/board.rb +14 -0
- data/app/models/comment.rb +9 -0
- data/app/models/concerns/encryptable_model_concern.rb +96 -0
- data/app/models/post.rb +12 -0
- data/app/models/user.rb +15 -0
- data/app/models/user_board.rb +82 -0
- data/app/serializers/board_serializer.rb +5 -0
- data/app/serializers/{unsakini/comment_serializer.rb → comment_serializer.rb} +3 -6
- data/app/serializers/post_serializer.rb +23 -0
- data/app/serializers/user_board_serializer.rb +11 -0
- data/app/serializers/{unsakini/user_serializer.rb → user_serializer.rb} +2 -5
- data/app/views/{unsakini/web → web_base}/index.html.erb +169 -65
- data/config/routes.rb +10 -10
- data/db/migrate/20161116114222_create_boards.rb +9 -0
- data/db/migrate/{20161116200034_create_unsakini_user_boards.rb → 20161116200034_create_user_boards.rb} +2 -3
- data/db/migrate/{20161118031023_create_unsakini_posts.rb → 20161118031023_create_posts.rb} +2 -2
- data/db/migrate/{20161118100454_create_unsakini_comments.rb → 20161118100454_create_comments.rb} +2 -2
- data/db/migrate/20161118221508_add_encrypted_password_to_user_board.rb +5 -0
- data/db/migrate/20161122211105_create_users.rb +12 -0
- data/db/migrate/20161124102633_add_is_shared_to_boards.rb +5 -0
- data/lib/generators/unsakini/angular/USAGE +8 -0
- data/lib/generators/unsakini/angular/angular_generator.rb +7 -0
- data/lib/generators/unsakini/config/config_generator.rb +1 -3
- data/lib/tasks/unsakini_tasks.rake +37 -6
- data/lib/unsakini/engine.rb +0 -2
- data/lib/unsakini/version.rb +1 -1
- data/public/css/custom.css +1 -5
- data/public/images/logo.svg +619 -0
- data/spec/concerns/models/encryptable_concern.rb +2 -3
- data/spec/controllers/{web_controller_spec.rb → web_base_controller_spec.rb} +3 -4
- data/spec/dummy/config/application.rb +1 -3
- data/spec/dummy/config/environments/development.rb +0 -2
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20161124210219_create_boards.unsakini_engine.rb +10 -0
- data/spec/dummy/db/migrate/20161124210220_create_user_boards.unsakini_engine.rb +12 -0
- data/spec/dummy/db/migrate/20161124210221_create_posts.unsakini_engine.rb +13 -0
- data/spec/dummy/db/migrate/20161124210222_create_comments.unsakini_engine.rb +12 -0
- data/spec/dummy/db/migrate/20161124210223_add_encrypted_password_to_user_board.unsakini_engine.rb +6 -0
- data/spec/dummy/db/migrate/20161124210224_create_users.unsakini_engine.rb +13 -0
- data/spec/dummy/db/migrate/20161124210225_add_is_shared_to_boards.unsakini_engine.rb +6 -0
- data/spec/dummy/db/schema.rb +14 -16
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/app/favicon.ico +0 -0
- data/spec/dummy/public/app/index.html +14 -0
- data/spec/dummy/public/app/inline.bundle.js +139 -0
- data/spec/dummy/public/app/inline.map +1 -0
- data/spec/dummy/public/app/main.bundle.js +64689 -0
- data/spec/dummy/public/app/main.map +1 -0
- data/spec/dummy/public/app/styles.bundle.js +364 -0
- data/spec/dummy/public/app/styles.map +1 -0
- data/spec/dummy/tmp/unsakini-ng2/LICENSE +21 -0
- data/spec/dummy/tmp/unsakini-ng2/README.md +1 -0
- data/spec/dummy/tmp/unsakini-ng2/angular-cli.json +59 -0
- data/spec/dummy/tmp/unsakini-ng2/e2e/app.e2e-spec.ts +14 -0
- data/spec/dummy/tmp/unsakini-ng2/e2e/app.po.ts +11 -0
- data/spec/dummy/tmp/unsakini-ng2/e2e/signup.e2e-spec.ts +28 -0
- data/spec/dummy/tmp/unsakini-ng2/e2e/signup.po.ts +31 -0
- data/spec/dummy/tmp/unsakini-ng2/e2e/tsconfig.json +16 -0
- data/spec/dummy/tmp/unsakini-ng2/karma.conf.js +45 -0
- data/spec/dummy/tmp/unsakini-ng2/package.json +49 -0
- data/spec/dummy/tmp/unsakini-ng2/protractor.conf.js +32 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.component.css +0 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.component.html +4 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.component.spec.ts +47 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.component.ts +10 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.module.ts +29 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/app.routes.module.ts +29 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/index.ts +2 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.css +0 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.html +14 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.spec.ts +157 -0
- data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.ts +42 -0
- data/spec/dummy/tmp/unsakini-ng2/src/environments/environment.prod.ts +3 -0
- data/spec/dummy/tmp/unsakini-ng2/src/environments/environment.ts +8 -0
- data/spec/dummy/tmp/unsakini-ng2/src/favicon.ico +0 -0
- data/spec/dummy/tmp/unsakini-ng2/src/index.html +14 -0
- data/spec/dummy/tmp/unsakini-ng2/src/main.ts +12 -0
- data/spec/dummy/tmp/unsakini-ng2/src/polyfills.ts +19 -0
- data/spec/dummy/tmp/unsakini-ng2/src/styles.css +1 -0
- data/spec/dummy/tmp/unsakini-ng2/src/test.ts +31 -0
- data/spec/dummy/tmp/unsakini-ng2/src/tsconfig.json +18 -0
- data/spec/dummy/tmp/unsakini-ng2/src/typings.d.ts +2 -0
- data/spec/dummy/tmp/unsakini-ng2/tslint.json +114 -0
- data/spec/dummy/tmp/unsakini-ng2/typings.json +4 -0
- data/spec/factories/boards.rb +1 -1
- data/spec/factories/comments.rb +1 -1
- data/spec/factories/posts.rb +1 -1
- data/spec/factories/user_boards.rb +1 -1
- data/spec/factories/users.rb +1 -1
- data/spec/models/board_spec.rb +2 -2
- data/spec/models/comment_spec.rb +2 -2
- data/spec/models/post_spec.rb +2 -2
- data/spec/models/user_board_spec.rb +19 -19
- data/spec/models/user_spec.rb +1 -1
- data/spec/requests/{boards/boards_crud_spec.rb → api/boards/api_boards_crud_spec.rb} +26 -26
- data/spec/requests/{boards/boards_pagination_spec.rb → api/boards/api_boards_pagination_spec.rb} +7 -7
- data/spec/requests/{boards/private_board_spec.rb → api/boards/api_private_board_spec.rb} +26 -26
- data/spec/requests/{boards/shared_board_spec.rb → api/boards/api_shared_board_spec.rb} +9 -9
- data/spec/requests/{boards/sharing_board_spec.rb → api/boards/api_sharing_board_spec.rb} +13 -13
- data/spec/requests/{comments/comments_pagination_spec.rb → api/comments/api_comments_pagination_spec.rb} +3 -3
- data/spec/requests/{comments/comments_private_board_spec.rb → api/comments/api_comments_private_board_spec.rb} +20 -20
- data/spec/requests/{comments/comments_shared_board_spec.rb → api/comments/api_comments_shared_board_spec.rb} +17 -17
- data/spec/requests/{posts/posts_pagination_spec.rb → api/posts/api_posts_pagination_spec.rb} +3 -3
- data/spec/requests/{posts/posts_private_board_spec.rb → api/posts/api_posts_private_board_spec.rb} +22 -22
- data/spec/requests/{posts/posts_shared_board_spec.rb → api/posts/api_posts_shared_board_spec.rb} +24 -24
- data/spec/requests/{user/user_create_spec.rb → api/user/api_user_create_spec.rb} +23 -19
- data/spec/requests/{user/user_search_spec.rb → api/user/api_user_search_spec.rb} +9 -9
- data/spec/spec_helper.rb +0 -1
- data/spec/support/auth_helper.rb +2 -0
- metadata +202 -135
- data/angular/npm-debug.log +0 -54
- data/angular/src/app/confirm-account/confirm-account.component.ts +0 -27
- data/angular/src/app/confirm-account/confirm-account.html +0 -41
- data/angular/src/app/confirm-account/confirm-account.module.ts +0 -24
- data/angular/src/app/confirm-account/confirm-account.scss +0 -3
- data/angular/src/app/confirm-account/confirm-account.service.ts +0 -27
- data/angular/src/app/confirm-account/index.ts +0 -3
- data/angular/src/app/login/index.ts +0 -3
- data/angular/src/app/login/login.component.ts +0 -40
- data/angular/src/app/login/login.html +0 -43
- data/angular/src/app/login/login.module.ts +0 -27
- data/angular/src/app/login/login.service.ts +0 -48
- data/angular/src/app/registration/index.ts +0 -3
- data/angular/src/app/registration/registration.module.ts +0 -23
- data/angular/src/app/registration/registration.service.ts +0 -46
- data/angular/src/app/registration/registration.services.spec.ts +0 -71
- data/angular/src/app/services/auth-http/auth.http.service.ts +0 -35
- data/angular/src/app/services/auth-http/index.ts +0 -1
- data/angular/src/app/services/http/http.service.spec.ts +0 -205
- data/angular/src/app/services/http/http.service.ts +0 -40
- data/angular/src/app/services/http/index.ts +0 -1
- data/angular/src/app/services/index.ts +0 -3
- data/angular/src/app/services/services.module.ts +0 -33
- data/angular/src/assets/global.scss +0 -3
- data/angular/src/environments/custom.ts +0 -4
- data/app/controllers/concerns/unsakini/board_owner_controller_concern.rb +0 -42
- data/app/controllers/concerns/unsakini/comment_owner_controller_concern.rb +0 -36
- data/app/controllers/concerns/unsakini/logged_in_controller_concern.rb +0 -23
- data/app/controllers/concerns/unsakini/post_owner_controller_concern.rb +0 -38
- data/app/controllers/concerns/unsakini/serializer_controller_concern.rb +0 -13
- data/app/controllers/unsakini/base_controller.rb +0 -6
- data/app/controllers/unsakini/boards_controller.rb +0 -76
- data/app/controllers/unsakini/comments_controller.rb +0 -54
- data/app/controllers/unsakini/posts_controller.rb +0 -61
- data/app/controllers/unsakini/share_board_controller.rb +0 -122
- data/app/controllers/unsakini/user_token_controller.rb +0 -17
- data/app/controllers/unsakini/users_controller.rb +0 -69
- data/app/controllers/unsakini/web_controller.rb +0 -27
- data/app/mailers/unsakini/user_mailer.rb +0 -13
- data/app/models/concerns/unsakini/encryptable_model_concern.rb +0 -97
- data/app/models/unsakini/application_record.rb +0 -7
- data/app/models/unsakini/board.rb +0 -16
- data/app/models/unsakini/comment.rb +0 -12
- data/app/models/unsakini/post.rb +0 -15
- data/app/models/unsakini/user.rb +0 -43
- data/app/models/unsakini/user_board.rb +0 -84
- data/app/models/unsakini.rb +0 -5
- data/app/serializers/unsakini/board_serializer.rb +0 -7
- data/app/serializers/unsakini/post_serializer.rb +0 -26
- data/app/serializers/unsakini/user_board_serializer.rb +0 -14
- data/app/views/unsakini/user_mailer/confirm_account.html.erb +0 -3
- data/db/migrate/20161116114222_create_unsakini_boards.rb +0 -10
- data/db/migrate/20161126145352_create_unsakini_users.rb +0 -15
- data/lib/generators/unsakini/dependencies/USAGE +0 -5
- data/lib/generators/unsakini/dependencies/dependencies_generator.rb +0 -19
- data/public/images/unsakini.svg +0 -56
- data/public/unsakini/app/448c34a56d699c29117adc64c43affeb.woff2 +0 -0
- data/public/unsakini/app/89889688147bd7575d6327160d64e760.svg +0 -288
- data/public/unsakini/app/assets/global.scss +0 -3
- data/public/unsakini/app/e18bbf611f2a2e43afc071aa2f4e1512.ttf +0 -0
- data/public/unsakini/app/f4769f9bdb7466be65088239c12046d1.eot +0 -0
- data/public/unsakini/app/fa2772327f55d8198301fdb8bcfc8158.woff +0 -0
- data/public/unsakini/app/index.html +0 -14
- data/public/unsakini/app/inline.d41d8cd98f00b204e980.bundle.js +0 -2
- data/public/unsakini/app/inline.d41d8cd98f00b204e980.bundle.map +0 -1
- data/public/unsakini/app/main.54f49c65d3d20650a5d5.bundle.js +0 -2152
- data/public/unsakini/app/main.54f49c65d3d20650a5d5.bundle.js.gz +0 -0
- data/public/unsakini/app/main.54f49c65d3d20650a5d5.bundle.map +0 -1
- data/public/unsakini/app/styles.58e065928ed8ebd0b582.bundle.js +0 -2
- data/public/unsakini/app/styles.58e065928ed8ebd0b582.bundle.map +0 -1
- data/public/unsakini/app/styles.5dac0e986fce6f8738b300cb558b56a0.bundle.css +0 -8
- data/spec/dummy/config/initializers/knock.rb +0 -59
- data/spec/schema/jwt.json +0 -9
@@ -0,0 +1,32 @@
|
|
1
|
+
// Protractor configuration file, see link for more information
|
2
|
+
// https://github.com/angular/protractor/blob/master/docs/referenceConf.js
|
3
|
+
|
4
|
+
/*global jasmine */
|
5
|
+
var SpecReporter = require('jasmine-spec-reporter');
|
6
|
+
|
7
|
+
exports.config = {
|
8
|
+
allScriptsTimeout: 11000,
|
9
|
+
specs: [
|
10
|
+
'./e2e/**/*.e2e-spec.ts'
|
11
|
+
],
|
12
|
+
capabilities: {
|
13
|
+
'browserName': 'chrome'
|
14
|
+
},
|
15
|
+
directConnect: true,
|
16
|
+
baseUrl: 'http://localhost:3000/app/',
|
17
|
+
framework: 'jasmine',
|
18
|
+
jasmineNodeOpts: {
|
19
|
+
showColors: true,
|
20
|
+
defaultTimeoutInterval: 30000,
|
21
|
+
print: function() {}
|
22
|
+
},
|
23
|
+
useAllAngular2AppRoots: true,
|
24
|
+
beforeLaunch: function() {
|
25
|
+
require('ts-node').register({
|
26
|
+
project: 'e2e'
|
27
|
+
});
|
28
|
+
},
|
29
|
+
onPrepare: function() {
|
30
|
+
jasmine.getEnv().addReporter(new SpecReporter());
|
31
|
+
}
|
32
|
+
};
|
File without changes
|
@@ -0,0 +1,47 @@
|
|
1
|
+
/* tslint:disable:no-unused-variable */
|
2
|
+
|
3
|
+
import { TestBed, async } from '@angular/core/testing';
|
4
|
+
import { AppComponent } from './app.component';
|
5
|
+
import { RouterTestingModule } from '@angular/router/testing';
|
6
|
+
|
7
|
+
describe('AppComponent', () => {
|
8
|
+
|
9
|
+
beforeEach(() => {
|
10
|
+
TestBed.configureTestingModule({
|
11
|
+
imports: [
|
12
|
+
RouterTestingModule
|
13
|
+
],
|
14
|
+
declarations:
|
15
|
+
[
|
16
|
+
AppComponent
|
17
|
+
],
|
18
|
+
});
|
19
|
+
});
|
20
|
+
|
21
|
+
it('should create the app', async(() => {
|
22
|
+
let fixture = TestBed.createComponent(AppComponent);
|
23
|
+
let app = fixture.debugElement.componentInstance;
|
24
|
+
expect(app).toBeTruthy();
|
25
|
+
}));
|
26
|
+
|
27
|
+
it(`should have as title 'app works!'`, async(() => {
|
28
|
+
let fixture = TestBed.createComponent(AppComponent);
|
29
|
+
let app = fixture.debugElement.componentInstance;
|
30
|
+
expect(app.title).toEqual('app works!');
|
31
|
+
}));
|
32
|
+
|
33
|
+
it('should render title in a h1 tag', async(() => {
|
34
|
+
let fixture = TestBed.createComponent(AppComponent);
|
35
|
+
fixture.detectChanges();
|
36
|
+
let compiled = fixture.debugElement.nativeElement;
|
37
|
+
expect(compiled.querySelector('h1').textContent).toContain('app works!');
|
38
|
+
}));
|
39
|
+
|
40
|
+
it('should have router outlet', async(() => {
|
41
|
+
let fixture = TestBed.createComponent(AppComponent);
|
42
|
+
fixture.detectChanges();
|
43
|
+
let compiled = fixture.debugElement.nativeElement;
|
44
|
+
expect(compiled.querySelector('router-outlet')).toBeTruthy()
|
45
|
+
}));
|
46
|
+
|
47
|
+
});
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { BrowserModule } from '@angular/platform-browser';
|
2
|
+
import { NgModule } from '@angular/core';
|
3
|
+
import { FormsModule } from '@angular/forms';
|
4
|
+
import { HttpModule } from '@angular/http';
|
5
|
+
import { Angular2TokenService, A2tUiModule } from 'angular2-token';
|
6
|
+
|
7
|
+
import { AppRoutesModule } from './app.routes.module';
|
8
|
+
|
9
|
+
import { AppComponent } from './app.component';
|
10
|
+
import { RegistrationComponent } from './registration/registration.component';
|
11
|
+
|
12
|
+
@NgModule({
|
13
|
+
imports: [
|
14
|
+
BrowserModule,
|
15
|
+
FormsModule,
|
16
|
+
HttpModule,
|
17
|
+
AppRoutesModule,
|
18
|
+
A2tUiModule,
|
19
|
+
],
|
20
|
+
declarations: [
|
21
|
+
AppComponent,
|
22
|
+
RegistrationComponent
|
23
|
+
],
|
24
|
+
providers: [
|
25
|
+
Angular2TokenService,
|
26
|
+
],
|
27
|
+
bootstrap: [AppComponent]
|
28
|
+
})
|
29
|
+
export class AppModule { }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { NgModule } from '@angular/core';
|
2
|
+
import { RouterModule } from '@angular/router';
|
3
|
+
|
4
|
+
import { RegistrationComponent } from './registration/registration.component'
|
5
|
+
|
6
|
+
|
7
|
+
const routes = [
|
8
|
+
{
|
9
|
+
path: '',
|
10
|
+
redirectTo: 'registration',
|
11
|
+
pathMatch: 'full'
|
12
|
+
},
|
13
|
+
{
|
14
|
+
path: 'registration',
|
15
|
+
component: RegistrationComponent
|
16
|
+
}
|
17
|
+
];
|
18
|
+
|
19
|
+
@NgModule({
|
20
|
+
imports: [
|
21
|
+
RouterModule.forRoot(routes)
|
22
|
+
],
|
23
|
+
exports: [
|
24
|
+
RouterModule
|
25
|
+
],
|
26
|
+
providers: []
|
27
|
+
})
|
28
|
+
|
29
|
+
export class AppRoutesModule {}
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
<form (ngSubmit)="doSubmit()">
|
3
|
+
<div class="alert alert-success" *ngIf="success">Registration successful. Please confirm your email sent to {{user.email}} to proceed.</div>
|
4
|
+
<div class="alert alert-danger" *ngIf="errors">
|
5
|
+
<p *ngFor="let e of errors">{{e}}</p>
|
6
|
+
</div>
|
7
|
+
<input type="text" name="name">
|
8
|
+
<input type="email" name="email">
|
9
|
+
<input type="password" name="password">
|
10
|
+
<input type="password" name="password_confirmation">
|
11
|
+
<button type="submit">Sign Up</button>
|
12
|
+
</form>
|
13
|
+
|
14
|
+
<div (click)="doSubmit()">CLICK ME</div>
|
@@ -0,0 +1,157 @@
|
|
1
|
+
/* tslint:disable:no-unused-variable */
|
2
|
+
|
3
|
+
import { inject, async, ComponentFixture, TestBed } from '@angular/core/testing';
|
4
|
+
import { Observable } from 'rxjs/Observable';
|
5
|
+
import 'rxjs/add/observable/of';
|
6
|
+
import 'rxjs/add/observable/throw';
|
7
|
+
import { By } from '@angular/platform-browser';
|
8
|
+
import { DebugElement } from '@angular/core';
|
9
|
+
import { Angular2TokenService } from 'angular2-token';
|
10
|
+
|
11
|
+
import { RegistrationComponent } from './registration.component';
|
12
|
+
|
13
|
+
let user = {
|
14
|
+
name: 'first last',
|
15
|
+
email: 'hello@world.com',
|
16
|
+
password: null,
|
17
|
+
password_confirmation: null
|
18
|
+
}
|
19
|
+
|
20
|
+
let status = 0
|
21
|
+
let errors = []
|
22
|
+
|
23
|
+
class Angular2TokenServiceMock {
|
24
|
+
registerAccount(user) {
|
25
|
+
|
26
|
+
if (status === 200) {
|
27
|
+
return Observable.of({
|
28
|
+
status: 200,
|
29
|
+
json: () => {
|
30
|
+
return {
|
31
|
+
user
|
32
|
+
}
|
33
|
+
}
|
34
|
+
});
|
35
|
+
} else {
|
36
|
+
return Observable.throw({
|
37
|
+
status: status,
|
38
|
+
json: () => {
|
39
|
+
return {
|
40
|
+
errors: errors
|
41
|
+
}
|
42
|
+
}
|
43
|
+
});
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
describe('RegistrationComponent', () => {
|
49
|
+
let component: RegistrationComponent;
|
50
|
+
let fixture: ComponentFixture<RegistrationComponent>;
|
51
|
+
let compiled: any;
|
52
|
+
|
53
|
+
beforeEach(async(() => {
|
54
|
+
TestBed.configureTestingModule({
|
55
|
+
imports: [
|
56
|
+
],
|
57
|
+
declarations: [RegistrationComponent],
|
58
|
+
providers: [
|
59
|
+
{
|
60
|
+
provide: Angular2TokenService,
|
61
|
+
useClass: Angular2TokenServiceMock
|
62
|
+
},
|
63
|
+
]
|
64
|
+
})
|
65
|
+
.compileComponents();
|
66
|
+
}));
|
67
|
+
|
68
|
+
beforeEach(() => {
|
69
|
+
fixture = TestBed.createComponent(RegistrationComponent);
|
70
|
+
component = fixture.componentInstance;
|
71
|
+
compiled = fixture.debugElement.nativeElement;
|
72
|
+
fixture.detectChanges();
|
73
|
+
});
|
74
|
+
|
75
|
+
describe('Component', () => {
|
76
|
+
|
77
|
+
it('should create', () => {
|
78
|
+
expect(component).toBeTruthy();
|
79
|
+
});
|
80
|
+
|
81
|
+
it('should have token service', () => {
|
82
|
+
expect(component.service).toBeDefined();
|
83
|
+
});
|
84
|
+
|
85
|
+
it('should have user', () => {
|
86
|
+
expect(component.user).toEqual({
|
87
|
+
name: '',
|
88
|
+
email: '',
|
89
|
+
password: '',
|
90
|
+
password_confirmation: ''
|
91
|
+
});
|
92
|
+
});
|
93
|
+
|
94
|
+
it('should handle http 422', () => {
|
95
|
+
status = 422
|
96
|
+
errors = ['some errors']
|
97
|
+
component.user = user
|
98
|
+
component.doSubmit()
|
99
|
+
expect(component.success).toBe(false)
|
100
|
+
expect(component.errors).toEqual(errors)
|
101
|
+
fixture.detectChanges();
|
102
|
+
expect(compiled.querySelector('.alert-success')).toBeFalsy()
|
103
|
+
expect(compiled.querySelector('.alert-danger').textContent).toContain('some errors')
|
104
|
+
})
|
105
|
+
|
106
|
+
it('should handle http 500 and other errors', () => {
|
107
|
+
status = 500
|
108
|
+
component.user = user
|
109
|
+
component.doSubmit()
|
110
|
+
expect(component.success).toBe(false)
|
111
|
+
expect(component.errors).toEqual(['Something went wrong.'])
|
112
|
+
fixture.detectChanges();
|
113
|
+
expect(compiled.querySelector('.alert-success')).toBeFalsy()
|
114
|
+
expect(compiled.querySelector('.alert-danger').textContent).toContain('Something went wrong')
|
115
|
+
})
|
116
|
+
|
117
|
+
it('should notify when success', () => {
|
118
|
+
component.user = user
|
119
|
+
status = 200
|
120
|
+
component.doSubmit()
|
121
|
+
expect(component.success).toBe(true)
|
122
|
+
fixture.detectChanges();
|
123
|
+
expect(compiled.querySelector('.alert-success')).toBeTruthy()
|
124
|
+
expect(compiled.querySelector('.alert-success').textContent).toContain('Registration successful')
|
125
|
+
})
|
126
|
+
|
127
|
+
});
|
128
|
+
|
129
|
+
describe('View', () => {
|
130
|
+
|
131
|
+
it('should have form', () => {
|
132
|
+
expect(compiled.querySelector('form')).toBeTruthy();
|
133
|
+
});
|
134
|
+
|
135
|
+
it('should have input name', () => {
|
136
|
+
expect(compiled.querySelector('input[name="name"]')).toBeTruthy();
|
137
|
+
});
|
138
|
+
|
139
|
+
it('should have input email', () => {
|
140
|
+
expect(compiled.querySelector('input[name="email"][type="email"]')).toBeTruthy();
|
141
|
+
});
|
142
|
+
|
143
|
+
it('should have input password', () => {
|
144
|
+
expect(compiled.querySelector('input[name="password"][type="password"]')).toBeTruthy();
|
145
|
+
});
|
146
|
+
|
147
|
+
it('should have input password confirmation', () => {
|
148
|
+
expect(compiled.querySelector('input[name="password_confirmation"][type="password"]')).toBeTruthy();
|
149
|
+
});
|
150
|
+
|
151
|
+
it('should have submit button', () => {
|
152
|
+
expect(compiled.querySelector('button[type="submit"]')).toBeTruthy();
|
153
|
+
});
|
154
|
+
|
155
|
+
});
|
156
|
+
|
157
|
+
});
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { Component, OnInit } from '@angular/core';
|
2
|
+
import { Angular2TokenService } from 'angular2-token';
|
3
|
+
|
4
|
+
@Component({
|
5
|
+
selector: 'app-registration',
|
6
|
+
templateUrl: './registration.component.html',
|
7
|
+
styleUrls: ['./registration.component.css']
|
8
|
+
})
|
9
|
+
export class RegistrationComponent implements OnInit {
|
10
|
+
|
11
|
+
user: any;
|
12
|
+
errors: any;
|
13
|
+
success = false;
|
14
|
+
|
15
|
+
constructor(public service: Angular2TokenService) {
|
16
|
+
this.user = {
|
17
|
+
name: '',
|
18
|
+
email: '',
|
19
|
+
password: '',
|
20
|
+
password_confirmation: ''
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
doSubmit () {
|
25
|
+
this.service.registerAccount(this.user).subscribe(
|
26
|
+
(res) => {
|
27
|
+
this.success = true;
|
28
|
+
},
|
29
|
+
(res) => {
|
30
|
+
if (res.status == 422) {
|
31
|
+
this.errors = res.json().errors
|
32
|
+
} else {
|
33
|
+
this.errors = ['Something went wrong.']
|
34
|
+
}
|
35
|
+
}
|
36
|
+
);
|
37
|
+
}
|
38
|
+
|
39
|
+
ngOnInit() {
|
40
|
+
}
|
41
|
+
|
42
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
// The file contents for the current environment will overwrite these during build.
|
2
|
+
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
|
3
|
+
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
4
|
+
// The list of which env maps to which file can be found in `angular-cli.json`.
|
5
|
+
|
6
|
+
export const environment = {
|
7
|
+
production: false
|
8
|
+
};
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Angular</title>
|
6
|
+
<base href="/app/">
|
7
|
+
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
9
|
+
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<app-root>Loading...</app-root>
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import './polyfills.ts';
|
2
|
+
|
3
|
+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
4
|
+
import { enableProdMode } from '@angular/core';
|
5
|
+
import { environment } from './environments/environment';
|
6
|
+
import { AppModule } from './app/';
|
7
|
+
|
8
|
+
if (environment.production) {
|
9
|
+
enableProdMode();
|
10
|
+
}
|
11
|
+
|
12
|
+
platformBrowserDynamic().bootstrapModule(AppModule);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// This file includes polyfills needed by Angular 2 and is loaded before
|
2
|
+
// the app. You can add your own extra polyfills to this file.
|
3
|
+
import 'core-js/es6/symbol';
|
4
|
+
import 'core-js/es6/object';
|
5
|
+
import 'core-js/es6/function';
|
6
|
+
import 'core-js/es6/parse-int';
|
7
|
+
import 'core-js/es6/parse-float';
|
8
|
+
import 'core-js/es6/number';
|
9
|
+
import 'core-js/es6/math';
|
10
|
+
import 'core-js/es6/string';
|
11
|
+
import 'core-js/es6/date';
|
12
|
+
import 'core-js/es6/array';
|
13
|
+
import 'core-js/es6/regexp';
|
14
|
+
import 'core-js/es6/map';
|
15
|
+
import 'core-js/es6/set';
|
16
|
+
import 'core-js/es6/reflect';
|
17
|
+
|
18
|
+
import 'core-js/es7/reflect';
|
19
|
+
import 'zone.js/dist/zone';
|
@@ -0,0 +1 @@
|
|
1
|
+
/* You can add global styles to this file, and also import other style files */
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import './polyfills.ts';
|
2
|
+
import 'zone.js/dist/long-stack-trace-zone';
|
3
|
+
import 'zone.js/dist/proxy.js';
|
4
|
+
import 'zone.js/dist/sync-test';
|
5
|
+
import 'zone.js/dist/jasmine-patch';
|
6
|
+
import 'zone.js/dist/async-test';
|
7
|
+
import 'zone.js/dist/fake-async-test';
|
8
|
+
import { getTestBed } from '@angular/core/testing';
|
9
|
+
import {
|
10
|
+
BrowserDynamicTestingModule,
|
11
|
+
platformBrowserDynamicTesting
|
12
|
+
} from '@angular/platform-browser-dynamic/testing';
|
13
|
+
|
14
|
+
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
|
15
|
+
declare var __karma__: any;
|
16
|
+
declare var require: any;
|
17
|
+
|
18
|
+
// Prevent Karma from running prematurely.
|
19
|
+
__karma__.loaded = function () {};
|
20
|
+
|
21
|
+
// First, initialize the Angular testing environment.
|
22
|
+
getTestBed().initTestEnvironment(
|
23
|
+
BrowserDynamicTestingModule,
|
24
|
+
platformBrowserDynamicTesting()
|
25
|
+
);
|
26
|
+
// Then we find all the tests.
|
27
|
+
let context = require.context('./', true, /\.spec\.ts/);
|
28
|
+
// And load the modules.
|
29
|
+
context.keys().map(context);
|
30
|
+
// Finally, start Karma to run the tests.
|
31
|
+
__karma__.start();
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"baseUrl": "",
|
4
|
+
"declaration": false,
|
5
|
+
"emitDecoratorMetadata": true,
|
6
|
+
"experimentalDecorators": true,
|
7
|
+
"lib": ["es6", "dom"],
|
8
|
+
"mapRoot": "./",
|
9
|
+
"module": "es6",
|
10
|
+
"moduleResolution": "node",
|
11
|
+
"outDir": "../dist/out-tsc",
|
12
|
+
"sourceMap": true,
|
13
|
+
"target": "es5",
|
14
|
+
"typeRoots": [
|
15
|
+
"../node_modules/@types"
|
16
|
+
]
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,114 @@
|
|
1
|
+
{
|
2
|
+
"rulesDirectory": [
|
3
|
+
"node_modules/codelyzer"
|
4
|
+
],
|
5
|
+
"rules": {
|
6
|
+
"class-name": true,
|
7
|
+
"comment-format": [
|
8
|
+
true,
|
9
|
+
"check-space"
|
10
|
+
],
|
11
|
+
"curly": true,
|
12
|
+
"eofline": true,
|
13
|
+
"forin": true,
|
14
|
+
"indent": [
|
15
|
+
true,
|
16
|
+
"spaces"
|
17
|
+
],
|
18
|
+
"label-position": true,
|
19
|
+
"label-undefined": true,
|
20
|
+
"max-line-length": [
|
21
|
+
true,
|
22
|
+
140
|
23
|
+
],
|
24
|
+
"member-access": false,
|
25
|
+
"member-ordering": [
|
26
|
+
true,
|
27
|
+
"static-before-instance",
|
28
|
+
"variables-before-functions"
|
29
|
+
],
|
30
|
+
"no-arg": true,
|
31
|
+
"no-bitwise": true,
|
32
|
+
"no-console": [
|
33
|
+
true,
|
34
|
+
"debug",
|
35
|
+
"info",
|
36
|
+
"time",
|
37
|
+
"timeEnd",
|
38
|
+
"trace"
|
39
|
+
],
|
40
|
+
"no-construct": true,
|
41
|
+
"no-debugger": true,
|
42
|
+
"no-duplicate-key": true,
|
43
|
+
"no-duplicate-variable": true,
|
44
|
+
"no-empty": false,
|
45
|
+
"no-eval": true,
|
46
|
+
"no-inferrable-types": true,
|
47
|
+
"no-shadowed-variable": true,
|
48
|
+
"no-string-literal": false,
|
49
|
+
"no-switch-case-fall-through": true,
|
50
|
+
"no-trailing-whitespace": true,
|
51
|
+
"no-unused-expression": true,
|
52
|
+
"no-unused-variable": true,
|
53
|
+
"no-unreachable": true,
|
54
|
+
"no-use-before-declare": true,
|
55
|
+
"no-var-keyword": true,
|
56
|
+
"object-literal-sort-keys": false,
|
57
|
+
"one-line": [
|
58
|
+
true,
|
59
|
+
"check-open-brace",
|
60
|
+
"check-catch",
|
61
|
+
"check-else",
|
62
|
+
"check-whitespace"
|
63
|
+
],
|
64
|
+
"quotemark": [
|
65
|
+
true,
|
66
|
+
"single"
|
67
|
+
],
|
68
|
+
"radix": true,
|
69
|
+
"semicolon": [
|
70
|
+
"always"
|
71
|
+
],
|
72
|
+
"triple-equals": [
|
73
|
+
true,
|
74
|
+
"allow-null-check"
|
75
|
+
],
|
76
|
+
"typedef-whitespace": [
|
77
|
+
true,
|
78
|
+
{
|
79
|
+
"call-signature": "nospace",
|
80
|
+
"index-signature": "nospace",
|
81
|
+
"parameter": "nospace",
|
82
|
+
"property-declaration": "nospace",
|
83
|
+
"variable-declaration": "nospace"
|
84
|
+
}
|
85
|
+
],
|
86
|
+
"variable-name": false,
|
87
|
+
"whitespace": [
|
88
|
+
true,
|
89
|
+
"check-branch",
|
90
|
+
"check-decl",
|
91
|
+
"check-operator",
|
92
|
+
"check-separator",
|
93
|
+
"check-type"
|
94
|
+
],
|
95
|
+
|
96
|
+
"directive-selector-prefix": [true, "app"],
|
97
|
+
"component-selector-prefix": [true, "app"],
|
98
|
+
"directive-selector-name": [true, "camelCase"],
|
99
|
+
"component-selector-name": [true, "kebab-case"],
|
100
|
+
"directive-selector-type": [true, "attribute"],
|
101
|
+
"component-selector-type": [true, "element"],
|
102
|
+
"use-input-property-decorator": true,
|
103
|
+
"use-output-property-decorator": true,
|
104
|
+
"use-host-property-decorator": true,
|
105
|
+
"no-input-rename": true,
|
106
|
+
"no-output-rename": true,
|
107
|
+
"use-life-cycle-interface": true,
|
108
|
+
"use-pipe-transform-interface": true,
|
109
|
+
"component-class-suffix": true,
|
110
|
+
"directive-class-suffix": true,
|
111
|
+
"templates-use-public": true,
|
112
|
+
"invoke-injectable": true
|
113
|
+
}
|
114
|
+
}
|
data/spec/factories/boards.rb
CHANGED
data/spec/factories/comments.rb
CHANGED
data/spec/factories/posts.rb
CHANGED