unsakini 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -5
- data/app/controllers/api/boards_controller.rb +8 -2
- data/app/controllers/api/comments_controller.rb +1 -1
- data/app/controllers/api/posts_controller.rb +1 -1
- data/app/controllers/api/share_board_controller.rb +7 -7
- data/app/controllers/api/users_controller.rb +1 -1
- data/app/controllers/concerns/board_owner_controller_concern.rb +2 -2
- data/app/controllers/concerns/comment_owner_controller_concern.rb +2 -2
- data/app/controllers/concerns/logged_in_controller_concern.rb +1 -1
- data/app/controllers/concerns/post_owner_controller_concern.rb +2 -2
- data/app/controllers/web_base_controller.rb +4 -0
- data/app/models/user_board.rb +11 -0
- data/app/serializers/user_board_serializer.rb +2 -1
- data/app/views/web_base/index.html +16 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20161124102633_add_is_shared_to_boards.rb +5 -0
- data/lib/tasks/unsakini_tasks.rake +28 -30
- data/lib/unsakini/engine.rb +7 -8
- data/lib/unsakini/version.rb +1 -1
- data/spec/{requests/render_app_index_spec.rb → controllers/web_base_controller_spec.rb} +7 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -1
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +0 -7
- data/spec/dummy/config/environments/development.rb +7 -0
- data/spec/dummy/config/environments/production.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +6 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/config/secrets.yml +2 -2
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20161124184342_add_is_shared_to_boards.unsakini_engine.rb +6 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/app/index.html +0 -14
- data/spec/dummy/public/app/inline.map +1 -1
- data/spec/dummy/public/app/main.bundle.js +110 -64
- data/spec/dummy/public/app/main.map +1 -1
- data/spec/dummy/public/app/styles.map +1 -1
- data/spec/dummy/tmp/unsakini-ng2/LICENSE +21 -0
- data/spec/dummy/tmp/unsakini-ng2/README.md +1 -0
- data/{angular → spec/dummy/tmp/unsakini-ng2}/angular-cli.json +1 -1
- data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.css +0 -0
- data/spec/models/user_board_spec.rb +2 -0
- data/spec/requests/api/boards/api_boards_crud_spec.rb +174 -0
- data/spec/requests/api/boards/api_boards_pagination_spec.rb +51 -0
- data/spec/requests/api/{api_boards_spec.rb → boards/api_private_board_spec.rb} +1 -98
- data/spec/requests/api/boards/api_shared_board_spec.rb +66 -0
- data/spec/support/scenario_helper.rb +66 -34
- data/spec/support/serialize_helper.rb +4 -0
- metadata +154 -127
- data/angular/README.md +0 -31
- data/config/initializers/unsakini.rb +0 -4
- data/spec/dummy/angular/README.md +0 -31
- data/spec/dummy/angular/angular-cli.json +0 -59
- data/spec/dummy/angular/karma.conf.js +0 -45
- data/spec/dummy/angular/package.json +0 -49
- data/spec/dummy/angular/protractor.conf.js +0 -32
- data/spec/dummy/angular/src/app/app.component.html +0 -4
- data/spec/dummy/angular/src/app/app.component.spec.ts +0 -47
- data/spec/dummy/angular/src/app/app.component.ts +0 -10
- data/spec/dummy/angular/src/app/app.module.ts +0 -29
- data/spec/dummy/angular/src/app/app.routes.module.ts +0 -29
- data/spec/dummy/angular/src/app/index.ts +0 -2
- data/spec/dummy/angular/src/app/registration/registration.component.html +0 -14
- data/spec/dummy/angular/src/app/registration/registration.component.spec.ts +0 -157
- data/spec/dummy/angular/src/app/registration/registration.component.ts +0 -42
- data/spec/dummy/angular/src/environments/environment.prod.ts +0 -3
- data/spec/dummy/angular/src/environments/environment.ts +0 -8
- data/spec/dummy/angular/src/favicon.ico +0 -0
- data/spec/dummy/angular/src/index.html +0 -14
- data/spec/dummy/angular/src/main.ts +0 -12
- data/spec/dummy/angular/src/polyfills.ts +0 -19
- data/spec/dummy/angular/src/styles.css +0 -1
- data/spec/dummy/angular/src/test.ts +0 -31
- data/spec/dummy/angular/src/tsconfig.json +0 -18
- data/spec/dummy/angular/src/typings.d.ts +0 -2
- data/spec/dummy/angular/tslint.json +0 -114
- data/spec/dummy/angular/typings.json +0 -4
- data/spec/dummy/config/crypto.yml +0 -7
- data/spec/dummy/config/initializers/cors.rb +0 -16
- data/spec/dummy/db/schema.rb +0 -56
- data/spec/dummy/db/test.sqlite3 +0 -0
- /data/spec/dummy/db/migrate/{20161123150822_create_boards.unsakini_engine.rb → 20161124184336_create_boards.unsakini_engine.rb} +0 -0
- /data/spec/dummy/db/migrate/{20161123150823_create_user_boards.unsakini_engine.rb → 20161124184337_create_user_boards.unsakini_engine.rb} +0 -0
- /data/spec/dummy/db/migrate/{20161123150824_create_posts.unsakini_engine.rb → 20161124184338_create_posts.unsakini_engine.rb} +0 -0
- /data/spec/dummy/db/migrate/{20161123150825_create_comments.unsakini_engine.rb → 20161124184339_create_comments.unsakini_engine.rb} +0 -0
- /data/spec/dummy/db/migrate/{20161123150826_add_encrypted_password_to_user_board.unsakini_engine.rb → 20161124184340_add_encrypted_password_to_user_board.unsakini_engine.rb} +0 -0
- /data/spec/dummy/db/migrate/{20161123150827_create_users.unsakini_engine.rb → 20161124184341_create_users.unsakini_engine.rb} +0 -0
- /data/{angular/src/app/app.component.css → spec/dummy/public/apple-touch-icon-precomposed.png} +0 -0
- /data/{angular/src/app/registration/registration.component.css → spec/dummy/public/apple-touch-icon.png} +0 -0
- /data/spec/dummy/{angular/src/app/app.component.css → public/favicon.ico} +0 -0
- /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/app.e2e-spec.ts +0 -0
- /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/app.po.ts +0 -0
- /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/signup.e2e-spec.ts +0 -0
- /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/signup.po.ts +0 -0
- /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/tsconfig.json +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/karma.conf.js +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/package.json +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/protractor.conf.js +0 -0
- /data/spec/dummy/{angular/src/app/registration/registration.component.css → tmp/unsakini-ng2/src/app/app.component.css} +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.component.html +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.component.spec.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.component.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.module.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.routes.module.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/index.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/registration/registration.component.html +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/registration/registration.component.spec.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/registration/registration.component.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/environments/environment.prod.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/environments/environment.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/favicon.ico +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/index.html +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/main.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/polyfills.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/styles.css +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/test.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/tsconfig.json +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/typings.d.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/tslint.json +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/typings.json +0 -0
- /data/spec/requests/api/{api_share_board_spec.rb → boards/api_sharing_board_spec.rb} +0 -0
- /data/spec/requests/api/{board/post/api_board_post_comments_spec.rb → comments/api_comments_spec.rb} +0 -0
- /data/spec/requests/api/{board/api_board_posts_spec.rb → posts/api_posts_spec.rb} +0 -0
@@ -1,31 +0,0 @@
|
|
1
|
-
# Angular
|
2
|
-
|
3
|
-
This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.20-4.
|
4
|
-
|
5
|
-
## Development server
|
6
|
-
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
7
|
-
|
8
|
-
## Code scaffolding
|
9
|
-
|
10
|
-
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class`.
|
11
|
-
|
12
|
-
## Build
|
13
|
-
|
14
|
-
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
|
15
|
-
|
16
|
-
## Running unit tests
|
17
|
-
|
18
|
-
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
19
|
-
|
20
|
-
## Running end-to-end tests
|
21
|
-
|
22
|
-
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
|
23
|
-
Before running the tests make sure you are serving the app via `ng serve`.
|
24
|
-
|
25
|
-
## Deploying to Github Pages
|
26
|
-
|
27
|
-
Run `ng github-pages:deploy` to deploy to Github Pages.
|
28
|
-
|
29
|
-
## Further help
|
30
|
-
|
31
|
-
To get more help on the `angular-cli` use `ng --help` or go check out the [Angular-CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
|
@@ -1,59 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"project": {
|
3
|
-
"version": "1.0.0-beta.20-4",
|
4
|
-
"name": "angular"
|
5
|
-
},
|
6
|
-
"apps": [
|
7
|
-
{
|
8
|
-
"root": "src",
|
9
|
-
"outDir": "../public/app",
|
10
|
-
"assets": [
|
11
|
-
"assets",
|
12
|
-
"favicon.ico"
|
13
|
-
],
|
14
|
-
"index": "index.html",
|
15
|
-
"main": "main.ts",
|
16
|
-
"test": "test.ts",
|
17
|
-
"tsconfig": "tsconfig.json",
|
18
|
-
"prefix": "app",
|
19
|
-
"mobile": false,
|
20
|
-
"styles": [
|
21
|
-
"styles.css"
|
22
|
-
],
|
23
|
-
"scripts": [],
|
24
|
-
"environments": {
|
25
|
-
"source": "environments/environment.ts",
|
26
|
-
"dev": "environments/environment.ts",
|
27
|
-
"prod": "environments/environment.prod.ts"
|
28
|
-
}
|
29
|
-
}
|
30
|
-
],
|
31
|
-
"addons": [],
|
32
|
-
"packages": [],
|
33
|
-
"e2e": {
|
34
|
-
"protractor": {
|
35
|
-
"config": "./protractor.conf.js"
|
36
|
-
}
|
37
|
-
},
|
38
|
-
"test": {
|
39
|
-
"karma": {
|
40
|
-
"config": "./karma.conf.js"
|
41
|
-
}
|
42
|
-
},
|
43
|
-
"defaults": {
|
44
|
-
"styleExt": "css",
|
45
|
-
"prefixInterfaces": false,
|
46
|
-
"inline": {
|
47
|
-
"style": false,
|
48
|
-
"template": false
|
49
|
-
},
|
50
|
-
"spec": {
|
51
|
-
"class": false,
|
52
|
-
"component": true,
|
53
|
-
"directive": true,
|
54
|
-
"module": false,
|
55
|
-
"pipe": true,
|
56
|
-
"service": true
|
57
|
-
}
|
58
|
-
}
|
59
|
-
}
|
@@ -1,45 +0,0 @@
|
|
1
|
-
// Karma configuration file, see link for more information
|
2
|
-
// https://karma-runner.github.io/0.13/config/configuration-file.html
|
3
|
-
|
4
|
-
module.exports = function (config) {
|
5
|
-
config.set({
|
6
|
-
basePath: '',
|
7
|
-
frameworks: ['jasmine', 'angular-cli'],
|
8
|
-
plugins: [
|
9
|
-
require('karma-jasmine'),
|
10
|
-
require('karma-phantomjs-launcher'),
|
11
|
-
// require('karma-chrome-launcher'),
|
12
|
-
require('karma-remap-istanbul'),
|
13
|
-
require('angular-cli/plugins/karma')
|
14
|
-
],
|
15
|
-
files: [
|
16
|
-
{ pattern: './src/test.ts', watched: false }
|
17
|
-
],
|
18
|
-
preprocessors: {
|
19
|
-
'./src/test.ts': ['angular-cli']
|
20
|
-
},
|
21
|
-
mime: {
|
22
|
-
'text/x-typescript': ['ts','tsx']
|
23
|
-
},
|
24
|
-
remapIstanbulReporter: {
|
25
|
-
reports: {
|
26
|
-
html: 'coverage',
|
27
|
-
lcovonly: './coverage/coverage.lcov'
|
28
|
-
}
|
29
|
-
},
|
30
|
-
angularCli: {
|
31
|
-
config: './angular-cli.json',
|
32
|
-
environment: 'dev'
|
33
|
-
},
|
34
|
-
reporters: config.angularCli && config.angularCli.codeCoverage
|
35
|
-
? ['progress', 'karma-remap-istanbul']
|
36
|
-
: ['progress'],
|
37
|
-
port: 9874,
|
38
|
-
colors: true,
|
39
|
-
logLevel: config.LOG_INFO,
|
40
|
-
autoWatch: true,
|
41
|
-
// browsers: ['Chrome'],
|
42
|
-
browsers: ['PhantomJS'],
|
43
|
-
singleRun: false
|
44
|
-
});
|
45
|
-
};
|
@@ -1,49 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "angular",
|
3
|
-
"version": "0.0.0",
|
4
|
-
"license": "MIT",
|
5
|
-
"angular-cli": {},
|
6
|
-
"scripts": {
|
7
|
-
"start": "ng serve",
|
8
|
-
"lint": "tslint \"src/**/*.ts\"",
|
9
|
-
"test": "ng test",
|
10
|
-
"pree2e": "webdriver-manager update",
|
11
|
-
"e2e": "protractor"
|
12
|
-
},
|
13
|
-
"private": true,
|
14
|
-
"dependencies": {
|
15
|
-
"@angular/common": "^2.1.0",
|
16
|
-
"@angular/compiler": "^2.1.0",
|
17
|
-
"@angular/core": "^2.1.0",
|
18
|
-
"@angular/forms": "^2.1.0",
|
19
|
-
"@angular/http": "^2.1.0",
|
20
|
-
"@angular/platform-browser": "^2.1.0",
|
21
|
-
"@angular/platform-browser-dynamic": "^2.1.0",
|
22
|
-
"@angular/router": "^3.1.0",
|
23
|
-
"angular2-token": "^0.2.0-beta.3",
|
24
|
-
"core-js": "^2.4.1",
|
25
|
-
"rxjs": "5.0.0-beta.12",
|
26
|
-
"ts-helpers": "^1.1.1",
|
27
|
-
"zone.js": "^0.6.23"
|
28
|
-
},
|
29
|
-
"devDependencies": {
|
30
|
-
"@angular/compiler-cli": "^2.1.0",
|
31
|
-
"@types/jasmine": "^2.2.30",
|
32
|
-
"@types/node": "^6.0.42",
|
33
|
-
"angular-cli": "1.0.0-beta.20-4",
|
34
|
-
"codelyzer": "~1.0.0-beta.3",
|
35
|
-
"jasmine-core": "2.4.1",
|
36
|
-
"jasmine-spec-reporter": "2.5.0",
|
37
|
-
"karma": "1.2.0",
|
38
|
-
"karma-chrome-launcher": "^2.0.0",
|
39
|
-
"karma-cli": "^1.0.1",
|
40
|
-
"karma-jasmine": "^1.0.2",
|
41
|
-
"karma-phantomjs-launcher": "^1.0.2",
|
42
|
-
"karma-remap-istanbul": "^0.2.1",
|
43
|
-
"protractor": "4.0.9",
|
44
|
-
"ts-node": "1.2.1",
|
45
|
-
"tslint": "3.13.0",
|
46
|
-
"typescript": "~2.0.3",
|
47
|
-
"webdriver-manager": "10.2.5"
|
48
|
-
}
|
49
|
-
}
|
@@ -1,32 +0,0 @@
|
|
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
|
-
};
|
@@ -1,47 +0,0 @@
|
|
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
|
-
});
|
@@ -1,29 +0,0 @@
|
|
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 { }
|
@@ -1,29 +0,0 @@
|
|
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 {}
|
@@ -1,14 +0,0 @@
|
|
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>
|
@@ -1,157 +0,0 @@
|
|
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
|
-
});
|
@@ -1,42 +0,0 @@
|
|
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
|
-
}
|
@@ -1,8 +0,0 @@
|
|
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
|
@@ -1,14 +0,0 @@
|
|
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>
|
@@ -1,12 +0,0 @@
|
|
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);
|
@@ -1,19 +0,0 @@
|
|
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';
|
@@ -1 +0,0 @@
|
|
1
|
-
/* You can add global styles to this file, and also import other style files */
|
@@ -1,31 +0,0 @@
|
|
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();
|