unsakini 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +34 -0
- data/angular/README.md +31 -0
- data/angular/angular-cli.json +59 -0
- data/angular/karma.conf.js +45 -0
- data/angular/package.json +49 -0
- data/angular/protractor.conf.js +32 -0
- data/angular/src/app/app.component.css +0 -0
- data/angular/src/app/app.component.html +4 -0
- data/angular/src/app/app.component.spec.ts +47 -0
- data/angular/src/app/app.component.ts +10 -0
- data/angular/src/app/app.module.ts +29 -0
- data/angular/src/app/app.routes.module.ts +29 -0
- data/angular/src/app/index.ts +2 -0
- data/angular/src/app/registration/registration.component.css +0 -0
- data/angular/src/app/registration/registration.component.html +14 -0
- data/angular/src/app/registration/registration.component.spec.ts +157 -0
- data/angular/src/app/registration/registration.component.ts +42 -0
- data/angular/src/environments/environment.prod.ts +3 -0
- data/angular/src/environments/environment.ts +8 -0
- data/angular/src/favicon.ico +0 -0
- data/angular/src/index.html +14 -0
- data/angular/src/main.ts +12 -0
- data/angular/src/polyfills.ts +19 -0
- data/angular/src/styles.css +1 -0
- data/angular/src/test.ts +31 -0
- data/angular/src/tsconfig.json +18 -0
- data/angular/src/typings.d.ts +2 -0
- data/angular/tslint.json +114 -0
- data/angular/typings.json +4 -0
- data/app/controllers/api/boards_controller.rb +67 -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 +27 -0
- data/app/controllers/application_controller.rb +5 -0
- 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 +11 -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 +6 -0
- data/app/models/user_board.rb +71 -0
- data/app/serializers/board_serializer.rb +5 -0
- data/app/serializers/comment_serializer.rb +10 -0
- data/app/serializers/post_serializer.rb +23 -0
- data/app/serializers/user_board_serializer.rb +10 -0
- data/app/serializers/user_serializer.rb +6 -0
- data/config/initializers/unsakini.rb +4 -0
- data/config/routes.rb +22 -0
- data/db/migrate/20161116114222_create_boards.rb +9 -0
- data/db/migrate/20161116200034_create_user_boards.rb +11 -0
- data/db/migrate/20161118031023_create_posts.rb +12 -0
- data/db/migrate/20161118100454_create_comments.rb +11 -0
- data/db/migrate/20161118221508_add_encrypted_password_to_user_board.rb +5 -0
- data/db/migrate/20161122211105_create_users.rb +12 -0
- data/lib/generators/unsakini/angular/USAGE +8 -0
- data/lib/generators/unsakini/angular/angular_generator.rb +7 -0
- data/lib/generators/unsakini/config/USAGE +8 -0
- data/lib/generators/unsakini/config/config_generator.rb +7 -0
- data/lib/generators/unsakini/config/templates/unsakini.rb +4 -0
- data/lib/tasks/unsakini_tasks.rake +33 -0
- data/lib/unsakini/engine.rb +30 -0
- data/lib/unsakini/version.rb +3 -0
- data/lib/unsakini.rb +5 -0
- data/spec/concerns/models/encryptable_concern.rb +40 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/angular/README.md +31 -0
- data/spec/dummy/angular/angular-cli.json +59 -0
- data/spec/dummy/angular/e2e/app.e2e-spec.ts +14 -0
- data/spec/dummy/angular/e2e/app.po.ts +11 -0
- data/spec/dummy/angular/e2e/signup.e2e-spec.ts +28 -0
- data/spec/dummy/angular/e2e/signup.po.ts +31 -0
- data/spec/dummy/angular/e2e/tsconfig.json +16 -0
- data/spec/dummy/angular/karma.conf.js +45 -0
- data/spec/dummy/angular/package.json +50 -0
- data/spec/dummy/angular/protractor.conf.js +32 -0
- data/spec/dummy/angular/src/app/app.component.css +0 -0
- data/spec/dummy/angular/src/app/app.component.html +4 -0
- data/spec/dummy/angular/src/app/app.component.spec.ts +47 -0
- data/spec/dummy/angular/src/app/app.component.ts +10 -0
- data/spec/dummy/angular/src/app/app.module.ts +29 -0
- data/spec/dummy/angular/src/app/app.routes.module.ts +29 -0
- data/spec/dummy/angular/src/app/index.ts +2 -0
- data/spec/dummy/angular/src/app/registration/registration.component.css +0 -0
- data/spec/dummy/angular/src/app/registration/registration.component.html +14 -0
- data/spec/dummy/angular/src/app/registration/registration.component.spec.ts +157 -0
- data/spec/dummy/angular/src/app/registration/registration.component.ts +42 -0
- data/spec/dummy/angular/src/environments/environment.prod.ts +3 -0
- data/spec/dummy/angular/src/environments/environment.ts +8 -0
- data/spec/dummy/angular/src/favicon.ico +0 -0
- data/spec/dummy/angular/src/index.html +14 -0
- data/spec/dummy/angular/src/main.ts +12 -0
- data/spec/dummy/angular/src/polyfills.ts +19 -0
- data/spec/dummy/angular/src/styles.css +1 -0
- data/spec/dummy/angular/src/test.ts +31 -0
- data/spec/dummy/angular/src/tsconfig.json +18 -0
- data/spec/dummy/angular/src/typings.d.ts +2 -0
- data/spec/dummy/angular/tslint.json +114 -0
- data/spec/dummy/angular/typings.json +4 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config/application.rb +22 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/crypto.yml +7 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +47 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cors.rb +16 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +18 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +56 -0
- 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/factories/boards.rb +5 -0
- data/spec/factories/comments.rb +7 -0
- data/spec/factories/posts.rb +8 -0
- data/spec/factories/user_boards.rb +9 -0
- data/spec/factories/users.rb +10 -0
- data/spec/models/board_spec.rb +19 -0
- data/spec/models/comment_spec.rb +26 -0
- data/spec/models/post_spec.rb +19 -0
- data/spec/models/user_board_spec.rb +193 -0
- data/spec/models/user_spec.rb +5 -0
- data/spec/rails_helper.rb +58 -0
- data/spec/requests/api/api_boards_spec.rb +238 -0
- data/spec/requests/api/api_share_board_spec.rb +167 -0
- data/spec/requests/api/api_users_spec.rb +52 -0
- data/spec/requests/api/board/api_board_posts_spec.rb +299 -0
- data/spec/requests/api/board/post/api_board_post_comments_spec.rb +370 -0
- data/spec/requests/render_app_index_spec.rb +19 -0
- data/spec/schema/board.json +39 -0
- data/spec/schema/comment.json +51 -0
- data/spec/schema/post.json +87 -0
- data/spec/schema/user.json +27 -0
- data/spec/spec_helper.rb +67 -0
- data/spec/support/auth_helper.rb +17 -0
- data/spec/support/scenario_helper.rb +134 -0
- data/spec/support/serialize_helper.rb +37 -0
- metadata +540 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5c2db76ad117d5f468e15d77b47f47ee6e6235bc
|
4
|
+
data.tar.gz: 3d18db630e818d60aa071caa7cda14e7e4302b78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 316d42aba0b7cf7362f7bc84b481d576dcff778916d456ab9ad7bc390196fb853d5bc3b036886485734308349c3d224010ec40db6c4bc49559fb33dadc2d8f0a
|
7
|
+
data.tar.gz: 9b7aaa3f513a66d2d8916baf8f7439e5437db28acf78ffda14f8a70306b922c53f469206999097b727046285efb1c794ec5d84228b3dca8ecfee0b3482447662
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Adones Pitogo
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Unsakini
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'unsakini'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install unsakini
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Unsakini'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
|
19
|
+
load 'rails/tasks/engine.rake'
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
|
23
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
24
|
+
|
25
|
+
|
26
|
+
require 'rspec/core'
|
27
|
+
require 'rspec/core/rake_task'
|
28
|
+
|
29
|
+
require 'bundler/gem_tasks'
|
30
|
+
|
31
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
32
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
33
|
+
|
34
|
+
task :default => :spec
|
data/angular/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
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).
|
@@ -0,0 +1,59 @@
|
|
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
|
+
}
|
@@ -0,0 +1,45 @@
|
|
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
|
+
};
|
@@ -0,0 +1,49 @@
|
|
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
|
+
}
|
@@ -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
|