ctws 0.1.5.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +295 -0
- data/Rakefile +21 -0
- data/app/auth/ctws/authenticate_user.rb +36 -0
- data/app/auth/ctws/authorize_api_request.rb +44 -0
- data/app/controllers/concerns/ctws/exception_handler.rb +58 -0
- data/app/controllers/concerns/ctws/response.rb +25 -0
- data/app/controllers/concerns/ctws/v1/exception_handler.rb +6 -0
- data/app/controllers/concerns/ctws/v1/response.rb +6 -0
- data/app/controllers/ctws/application_controller.rb +5 -0
- data/app/controllers/ctws/authentication_controller.rb +28 -0
- data/app/controllers/ctws/ctws_controller.rb +24 -0
- data/app/controllers/ctws/min_app_versions_controller.rb +55 -0
- data/app/controllers/ctws/users_controller.rb +39 -0
- data/app/controllers/ctws/v1/authentication_controller.rb +6 -0
- data/app/controllers/ctws/v1/ctws_controller.rb +9 -0
- data/app/controllers/ctws/v1/min_app_versions_controller.rb +6 -0
- data/app/controllers/ctws/v1/users_controller.rb +6 -0
- data/app/controllers/ctws/v2/ctws_controller.rb +9 -0
- data/app/controllers/ctws/v2/min_app_versions_controller.rb +6 -0
- data/app/jobs/ctws/application_job.rb +4 -0
- data/app/lib/ctws/json_web_token.rb +25 -0
- data/app/lib/ctws/message.rb +43 -0
- data/app/mailers/ctws/application_mailer.rb +6 -0
- data/app/models/ctws/application_record.rb +5 -0
- data/app/models/ctws/min_app_version.rb +22 -0
- data/config/initializers/ctws.rb +5 -0
- data/config/initializers/mime_types.rb +1 -0
- data/config/routes.rb +18 -0
- data/db/migrate/20170425110839_create_ctws_min_app_versions.rb +13 -0
- data/db/migrate/20170425110933_add_values_to_ctws_min_app_versions.rb +26 -0
- data/lib/ctws/engine.rb +13 -0
- data/lib/ctws/version.rb +3 -0
- data/lib/ctws.rb +18 -0
- data/lib/tasks/ctws_tasks.rake +4 -0
- data/spec/auth/ctws/authenticate_user_spec.rb +34 -0
- data/spec/auth/ctws/authorize_api_request_spec.rb +62 -0
- data/spec/controllers/ctws/ctws_controller_spec.rb +41 -0
- data/spec/controllers/ctws/users_controller_spec.rb +7 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/javascripts/cable.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 +3 -0
- data/spec/dummy/app/controllers/user_controller.rb +18 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/user_helper.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/models/user.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -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 +15 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +54 -0
- data/spec/dummy/config/environments/production.rb +86 -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/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -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 +24 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -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 +5 -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/migrate/20170622072636_create_users.rb +10 -0
- data/spec/dummy/db/schema.rb +39 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +29 -0
- data/spec/dummy/log/test.log +31496 -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/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/ctws/ctws_user.rb +7 -0
- data/spec/factories/ctws_min_app_version.rb +9 -0
- data/spec/models/ctws/min_app_version_spec.rb +11 -0
- data/spec/models/ctws/user_spec.rb +8 -0
- data/spec/rails_helper.rb +88 -0
- data/spec/requests/ctws/authentication_spec.rb +47 -0
- data/spec/requests/ctws/min_app_version_spec.rb +169 -0
- data/spec/requests/ctws/users_spec.rb +46 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/ctws/controller_spec_helper.rb +29 -0
- data/spec/support/ctws/request_spec_helper.rb +10 -0
- metadata +367 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
module Ctws
|
2
|
+
class JsonWebToken
|
3
|
+
require 'jwt'
|
4
|
+
|
5
|
+
# secret to encode and decode token
|
6
|
+
HMAC_SECRET = Rails.application.secrets.secret_key_base
|
7
|
+
|
8
|
+
def self.encode(payload, exp = Ctws.jwt_expiration_time)
|
9
|
+
# set expiry to 24 hours from creation time
|
10
|
+
payload[:exp] = exp.to_i
|
11
|
+
# sign token with application secret
|
12
|
+
JWT.encode(payload, HMAC_SECRET)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.decode(token)
|
16
|
+
# get payload; first index in decoded Array
|
17
|
+
body = JWT.decode(token, HMAC_SECRET)[0]
|
18
|
+
HashWithIndifferentAccess.new body
|
19
|
+
# rescue from expiry exception
|
20
|
+
rescue JWT::ExpiredSignature, JWT::VerificationError => e
|
21
|
+
# raise custom error to be handled by custom handler
|
22
|
+
raise Ctws::ExceptionHandler::ExpiredSignature, e.message
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Ctws
|
2
|
+
class Message
|
3
|
+
def self.not_found(record = 'record')
|
4
|
+
"Sorry, #{record} not found."
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.unmatched_route(route = 'route')
|
8
|
+
"No route matches #{route}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.invalid_credentials
|
12
|
+
'Invalid credentials'
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.invalid_token
|
16
|
+
'Invalid token'
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.missing_token
|
20
|
+
'Missing token'
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.unauthorized
|
24
|
+
'Unauthorized request'
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.account_created
|
28
|
+
'Account created successfully'
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.account_not_created
|
32
|
+
'Account could not be created'
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.authenticated_user_success
|
36
|
+
'Authenticated user successfully'
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.expired_token
|
40
|
+
'Sorry, your token has expired. Please login to continue.'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Ctws
|
2
|
+
class MinAppVersion < ApplicationRecord
|
3
|
+
validates_presence_of :codename, :description, :platform, :min_version, :store_uri
|
4
|
+
|
5
|
+
def as_jsonapi(options={})
|
6
|
+
{
|
7
|
+
type: ActiveModel::Naming.param_key(self),
|
8
|
+
id: self.id,
|
9
|
+
attributes: {
|
10
|
+
codename: self.codename,
|
11
|
+
description: self.description,
|
12
|
+
min_version: self.min_version,
|
13
|
+
platform: self.platform,
|
14
|
+
store_uri: self.store_uri,
|
15
|
+
updated_at: self.updated_at
|
16
|
+
}
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Mime::Type.register "application/vnd.api+json", :json
|
data/config/routes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Ctws::Engine.routes.draw do
|
2
|
+
namespace :v1 do
|
3
|
+
resources :min_app_versions
|
4
|
+
get 'min_app_version', to: 'min_app_versions#min_app_version'
|
5
|
+
post 'signup', to: 'users#create'
|
6
|
+
post 'login', to: 'authentication#authenticate'
|
7
|
+
end
|
8
|
+
namespace :v2 do
|
9
|
+
# resources :min_app_versions
|
10
|
+
get 'min_app_version', to: 'min_app_versions#min_app_version'
|
11
|
+
end
|
12
|
+
|
13
|
+
get '*unmatched_route', to: 'ctws#raise_not_found!'
|
14
|
+
|
15
|
+
# match '/', :to => 'base#raise_not_found!', via: :all
|
16
|
+
# match '*other', :to => 'base#raise_not_found!', via: :all
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateCtwsMinAppVersions < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :ctws_min_app_versions do |t|
|
4
|
+
t.string :codename
|
5
|
+
t.text :description
|
6
|
+
t.string :platform
|
7
|
+
t.string :min_version
|
8
|
+
t.string :store_uri
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class AddValuesToCtwsMinAppVersions < ActiveRecord::Migration[5.0]
|
2
|
+
def up
|
3
|
+
min_app_version_ios = Ctws::MinAppVersion.create!({
|
4
|
+
codename: "First Release",
|
5
|
+
description: "You need to update your app. You will be redirected to the corresponding store",
|
6
|
+
platform: "ios",
|
7
|
+
min_version: "0.0.1",
|
8
|
+
store_uri: "https://itunes.apple.com/"
|
9
|
+
})
|
10
|
+
|
11
|
+
min_app_version_android = Ctws::MinAppVersion.create!({
|
12
|
+
codename: "First Release",
|
13
|
+
description: "You need to update your app. You will be redirected to the corresponding store",
|
14
|
+
platform: "android",
|
15
|
+
min_version: "0.0.1",
|
16
|
+
store_uri: "https://play.google.com"
|
17
|
+
})
|
18
|
+
end
|
19
|
+
|
20
|
+
def down
|
21
|
+
min_app_version_ios = Ctws::MinAppVersion.find_by_min_version( "0.0.1" )
|
22
|
+
min_app_version_ios.destroy
|
23
|
+
min_app_version_android = Ctws::MinAppVersion.find_by_min_version( "0.0.1" )
|
24
|
+
min_app_version_android.destroy
|
25
|
+
end
|
26
|
+
end
|
data/lib/ctws/engine.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ctws
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace Ctws
|
4
|
+
config.generators.api_only = true
|
5
|
+
|
6
|
+
config.generators do |g|
|
7
|
+
g.test_framework :rspec, :fixture => false
|
8
|
+
g.fixture_replacement :factory_girl_rails, :dir => 'spec/factories'
|
9
|
+
g.assets false
|
10
|
+
g.helper false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/ctws/version.rb
ADDED
data/lib/ctws.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "ctws/engine"
|
2
|
+
|
3
|
+
module Ctws
|
4
|
+
mattr_accessor :user_class
|
5
|
+
mattr_accessor :user_class_strong_params
|
6
|
+
mattr_accessor :user_validate_with_password
|
7
|
+
mattr_accessor :jwt_expiration_time
|
8
|
+
mattr_accessor :jwt_auth_token_attrs
|
9
|
+
|
10
|
+
def self.user_class
|
11
|
+
@@user_class.constantize
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.jwt_auth_token_attrs
|
15
|
+
# TODO: implement
|
16
|
+
@@jwt_auth_token_attrs
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module Ctws
|
4
|
+
RSpec.describe AuthenticateUser, class: 'Ctws::AuthenticateUser' do
|
5
|
+
# create test user
|
6
|
+
let(:ctws_user) { create(:ctws_user) }
|
7
|
+
# valid request subject
|
8
|
+
subject(:valid_auth_obj) { described_class.new(ctws_user.email, ctws_user.password) }
|
9
|
+
# invalid request subject
|
10
|
+
subject(:invalid_auth_obj) { described_class.new('foo', 'bar') }
|
11
|
+
|
12
|
+
# Test suite for AuthenticateUser#call
|
13
|
+
describe '#call' do
|
14
|
+
# return token when valid request
|
15
|
+
context 'when valid credentials' do
|
16
|
+
it 'returns an auth token' do
|
17
|
+
token = valid_auth_obj.call
|
18
|
+
expect(token).not_to be_nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# raise Authentication Error when invalid request
|
23
|
+
context 'when invalid credentials' do
|
24
|
+
it 'raises an authentication error' do
|
25
|
+
expect { invalid_auth_obj.call }
|
26
|
+
.to raise_error(
|
27
|
+
Ctws::ExceptionHandler::AuthenticationError,
|
28
|
+
/Invalid credentials/
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module Ctws
|
4
|
+
RSpec.describe AuthorizeApiRequest, class: 'Ctws::AuthorizeApiRequest' do
|
5
|
+
# Create test user
|
6
|
+
let(:ctws_user) { create(:ctws_user) }
|
7
|
+
|
8
|
+
# Mock `Authorization` header
|
9
|
+
let(:header) { { 'Authorization' => token_generator(ctws_user.id) } }
|
10
|
+
# Invalid request subject
|
11
|
+
subject(:invalid_request_obj) { described_class.new({}) }
|
12
|
+
# Valid request subject
|
13
|
+
subject(:request_obj) { described_class.new(header) }
|
14
|
+
|
15
|
+
# Test Suite for AuthorizeApiRequest#call
|
16
|
+
# This is our entry point into the service class
|
17
|
+
describe '#call' do
|
18
|
+
# returns user object when request is valid
|
19
|
+
context 'when valid request' do
|
20
|
+
it 'returns user object' do
|
21
|
+
result = request_obj.call
|
22
|
+
expect(result[:user]).to eq(ctws_user)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# returns error message when invalid request
|
27
|
+
context 'when invalid request' do
|
28
|
+
context 'when missing token' do
|
29
|
+
it 'raises a MissingToken error' do
|
30
|
+
expect { invalid_request_obj.call }
|
31
|
+
.to raise_error(Ctws::ExceptionHandler::MissingToken, 'Missing token')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when invalid token' do
|
36
|
+
subject(:invalid_request_obj) do
|
37
|
+
# custom helper method `token_generator`
|
38
|
+
described_class.new('Authorization' => token_generator(5))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'raises an InvalidToken error' do
|
42
|
+
expect { invalid_request_obj.call }
|
43
|
+
.to raise_error(Ctws::ExceptionHandler::InvalidToken, /Invalid token/)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when token is expired' do
|
48
|
+
let(:header) { { 'Authorization' => expired_token_generator(ctws_user.id) } }
|
49
|
+
subject(:request_obj) { described_class.new(header) }
|
50
|
+
|
51
|
+
it 'raises ExceptionHandler::ExpiredSignature error' do
|
52
|
+
expect { request_obj.call }
|
53
|
+
.to raise_error(
|
54
|
+
Ctws::ExceptionHandler::ExpiredSignature,
|
55
|
+
/Signature has expired/
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module Ctws
|
4
|
+
RSpec.describe CtwsController, type: :controller do
|
5
|
+
# create test ctws_user
|
6
|
+
let!(:ctws_user) { create(:ctws_user) }
|
7
|
+
# set headers for authorization
|
8
|
+
let(:headers) { { 'Authorization' => token_generator(ctws_user.id) } }
|
9
|
+
let(:invalid_headers) { { 'Authorization' => nil } }
|
10
|
+
|
11
|
+
describe "authorize_request" do
|
12
|
+
context "when auth token is passed" do
|
13
|
+
before { allow(request).to receive(:headers).and_return(headers) }
|
14
|
+
|
15
|
+
# private method authorize_request returns current ctws_user
|
16
|
+
it "sets the current ctws_user" do
|
17
|
+
expect(subject.instance_eval { authorize_request }).to eq(ctws_user)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when auth token is not passed" do
|
22
|
+
before do
|
23
|
+
allow(request).to receive(:headers).and_return(invalid_headers)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "raises MissingToken error" do
|
27
|
+
expect { subject.instance_eval { authorize_request } }.
|
28
|
+
to raise_error(Ctws::ExceptionHandler::MissingToken, /Missing token/)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe "routes" do
|
33
|
+
context "when route is not found" do
|
34
|
+
xit "returns 404" do
|
35
|
+
to raise_error(Ctws::ExceptionHandler::RoutingError, /No route matches/)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the rails generate channel command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class UserController < ApplicationController
|
2
|
+
=begin
|
3
|
+
def create
|
4
|
+
# We use Active Record's create! method so that in the event there's an error,
|
5
|
+
# an exception will be raised and handled in the exception handler.
|
6
|
+
ctws_user = Ctws.user_class.create!(ctws_user_params)
|
7
|
+
auth_token = Ctws::AuthenticateUser.new(ctws_user.email, ctws_user.password).call
|
8
|
+
response = { message: Ctws::Message.account_created, auth_token: auth_token }
|
9
|
+
json_response(response, :created)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def ctws_user_params
|
15
|
+
params.permit(:email, :password, :password_confirmation)
|
16
|
+
end
|
17
|
+
=end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
|
7
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
8
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<%= yield %>
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a starting point to setup your application.
|
15
|
+
# Add necessary setup steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
# puts "\n== Copying sample files =="
|
22
|
+
# unless File.exist?('config/database.yml')
|
23
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
24
|
+
# end
|
25
|
+
|
26
|
+
puts "\n== Preparing database =="
|
27
|
+
system! 'bin/rails db:setup'
|
28
|
+
|
29
|
+
puts "\n== Removing old logs and tempfiles =="
|
30
|
+
system! 'bin/rails log:clear tmp:clear'
|
31
|
+
|
32
|
+
puts "\n== Restarting application server =="
|
33
|
+
system! 'bin/rails restart'
|
34
|
+
end
|