Upgrade to Rails 5.0 (#3) - warvox - Unnamed repository; edit this file 'descri… | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit 9897a9c2356d90c2ebbb675af18b35740ad1bca5 | |
parent 8fa0ede5ca4efb70d2f59f8d3081e050f468eca0 | |
Author: Chee Yeo <[email protected]> | |
Date: Tue, 23 Aug 2016 09:25:06 +0100 | |
Upgrade to Rails 5.0 (#3) | |
- Remove protected_attributes and use strong_params | |
- Update to gems used | |
- Fix issues with some templates | |
- Update authlogic to work with rails 5.0 | |
Diffstat: | |
M Gemfile | 16 ++++++++-------- | |
M Gemfile.lock | 138 ++++++++++++++++-------------… | |
A app/assets/config/manifest.js | 3 +++ | |
A app/assets/images/.keep | 0 | |
M app/controllers/application_contro… | 4 ++-- | |
A app/controllers/concerns/.keep | 0 | |
M app/controllers/jobs_controller.rb | 7 ++++++- | |
M app/controllers/projects_controlle… | 10 ++++++++-- | |
M app/controllers/providers_controll… | 26 ++++++++++++++++---------- | |
M app/controllers/user_sessions_cont… | 12 +++++++++--- | |
M app/controllers/users_controller.rb | 16 +++++++++++----- | |
A app/models/application_record.rb | 3 +++ | |
M app/models/call.rb | 2 +- | |
M app/models/call_medium.rb | 2 +- | |
A app/models/concerns/.keep | 0 | |
M app/models/job.rb | 12 +----------- | |
M app/models/line.rb | 2 +- | |
M app/models/line_attribute.rb | 2 +- | |
M app/models/project.rb | 4 +--- | |
M app/models/provider.rb | 4 +--- | |
M app/models/settings.rb | 2 +- | |
M app/models/signature.rb | 2 +- | |
M app/models/signature_fp.rb | 2 +- | |
M app/models/user.rb | 2 +- | |
M app/views/users/edit.html.erb | 2 +- | |
M bin/setup | 29 +++++++++++++++++------------ | |
A bin/update | 29 +++++++++++++++++++++++++++++ | |
M config/application.rb | 14 +++++++++----- | |
M config/boot.rb | 2 +- | |
A config/cable.yml | 9 +++++++++ | |
M config/environment.rb | 2 +- | |
M config/environments/development.rb | 36 +++++++++++++++++++----------… | |
M config/environments/production.rb | 36 ++++++++++++++++-------------… | |
M config/environments/test.rb | 12 ++++++------ | |
A config/initializers/application_co… | 6 ++++++ | |
M config/initializers/cookies_serial… | 2 ++ | |
A config/initializers/new_framework_… | 24 ++++++++++++++++++++++++ | |
M config/initializers/wrap_parameter… | 4 ++-- | |
A config/unicorn.rb | 0 | |
A db/seeds.rb | 7 +++++++ | |
A lib/assets/.keep | 0 | |
A lib/tasks/.keep | 0 | |
D script/rails | 6 ------ | |
M spec/rails_helper.rb | 12 ++++++++---- | |
M spec/spec_helper.rb | 25 +++++++++++++++++-------- | |
M spec/support/auth_logic_helpers.rb | 5 ++--- | |
A spec/support/factory_girl.rb | 3 +++ | |
47 files changed, 335 insertions(+), 201 deletions(-) | |
--- | |
diff --git a/Gemfile b/Gemfile | |
@@ -1,24 +1,22 @@ | |
source 'https://rubygems.org' | |
gem 'unicorn' | |
-gem 'rails', '~> 4.2', '>= 4.2.7.1' | |
-gem 'pg', '~> 0.15' | |
+gem 'rails', '5.0.0' | |
+gem 'pg', '~> 0.18' | |
gem 'jquery-rails' | |
gem 'jquery-datatables-rails', git: 'https://github.com/rweng/jquery-datatable… | |
-#gem 'postgres_ext', :git => 'git://github.com/dockyard/postgres_ext.git' | |
gem 'kissfft' | |
gem 'rex', '~> 2.0.10' | |
gem 'bootstrap-sass', '>= 3.2.0' | |
gem 'sass-rails', '~> 5.0' | |
-gem 'coffee-rails', '~> 4.1.0' | |
+gem 'coffee-rails', '~> 4.2' | |
gem 'uglifier', '>= 1.3.0' | |
-gem 'protected_attributes', '~> 1.0.7' | |
gem 'autoprefixer-rails' | |
-gem 'authlogic', '>= 3.4.0' | |
+gem 'authlogic', git: "https://github.com/binarylogic/authlogic.git" | |
gem 'rails-settings-cached', '>= 0.4.1' | |
gem "breadcrumbs_on_rails" | |
@@ -43,13 +41,13 @@ group :development do | |
gem 'rails_layout' | |
gem 'guard-livereload', '~> 2.4', require: false | |
gem 'annotate' | |
- gem 'web-console', '~> 2.0' | |
+ gem 'web-console' | |
end | |
group :development, :test do | |
gem 'factory_girl_rails' | |
gem 'faker' | |
gem 'rspec-rails' | |
- gem 'byebug' | |
+ gem 'byebug', platform: :mri | |
end | |
group :test do | |
gem 'capybara' | |
@@ -58,3 +56,5 @@ group :test do | |
gem 'selenium-webdriver' | |
gem 'shoulda-matchers', '2.8' | |
end | |
+ | |
+gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] | |
diff --git a/Gemfile.lock b/Gemfile.lock | |
@@ -1,4 +1,14 @@ | |
GIT | |
+ remote: https://github.com/binarylogic/authlogic.git | |
+ revision: c74344b705f0637f7f0ee0489a6832b0b5a851b9 | |
+ specs: | |
+ authlogic (3.4.6) | |
+ activerecord (>= 3.2, < 5.1) | |
+ activesupport (>= 3.2, < 5.1) | |
+ request_store (~> 1.0) | |
+ scrypt (>= 1.2, < 4.0) | |
+ | |
+GIT | |
remote: https://github.com/hdm/reportable.git | |
revision: 073bc1657ee301f4c961f14247ef1a58cf38bd1f | |
specs: | |
@@ -19,51 +29,48 @@ GIT | |
GEM | |
remote: https://rubygems.org/ | |
specs: | |
- actionmailer (4.2.7.1) | |
- actionpack (= 4.2.7.1) | |
- actionview (= 4.2.7.1) | |
- activejob (= 4.2.7.1) | |
+ actioncable (5.0.0) | |
+ actionpack (= 5.0.0) | |
+ nio4r (~> 1.2) | |
+ websocket-driver (~> 0.6.1) | |
+ actionmailer (5.0.0) | |
+ actionpack (= 5.0.0) | |
+ actionview (= 5.0.0) | |
+ activejob (= 5.0.0) | |
mail (~> 2.5, >= 2.5.4) | |
- rails-dom-testing (~> 1.0, >= 1.0.5) | |
- actionpack (4.2.7.1) | |
- actionview (= 4.2.7.1) | |
- activesupport (= 4.2.7.1) | |
- rack (~> 1.6) | |
- rack-test (~> 0.6.2) | |
- rails-dom-testing (~> 1.0, >= 1.0.5) | |
+ rails-dom-testing (~> 2.0) | |
+ actionpack (5.0.0) | |
+ actionview (= 5.0.0) | |
+ activesupport (= 5.0.0) | |
+ rack (~> 2.0) | |
+ rack-test (~> 0.6.3) | |
+ rails-dom-testing (~> 2.0) | |
rails-html-sanitizer (~> 1.0, >= 1.0.2) | |
- actionview (4.2.7.1) | |
- activesupport (= 4.2.7.1) | |
+ actionview (5.0.0) | |
+ activesupport (= 5.0.0) | |
builder (~> 3.1) | |
erubis (~> 2.7.0) | |
- rails-dom-testing (~> 1.0, >= 1.0.5) | |
+ rails-dom-testing (~> 2.0) | |
rails-html-sanitizer (~> 1.0, >= 1.0.2) | |
- activejob (4.2.7.1) | |
- activesupport (= 4.2.7.1) | |
- globalid (>= 0.3.0) | |
- activemodel (4.2.7.1) | |
- activesupport (= 4.2.7.1) | |
- builder (~> 3.1) | |
- activerecord (4.2.7.1) | |
- activemodel (= 4.2.7.1) | |
- activesupport (= 4.2.7.1) | |
- arel (~> 6.0) | |
- activesupport (4.2.7.1) | |
+ activejob (5.0.0) | |
+ activesupport (= 5.0.0) | |
+ globalid (>= 0.3.6) | |
+ activemodel (5.0.0) | |
+ activesupport (= 5.0.0) | |
+ activerecord (5.0.0) | |
+ activemodel (= 5.0.0) | |
+ activesupport (= 5.0.0) | |
+ arel (~> 7.0) | |
+ activesupport (5.0.0) | |
+ concurrent-ruby (~> 1.0, >= 1.0.2) | |
i18n (~> 0.7) | |
- json (~> 1.7, >= 1.7.7) | |
minitest (~> 5.1) | |
- thread_safe (~> 0.3, >= 0.3.4) | |
tzinfo (~> 1.1) | |
addressable (2.4.0) | |
annotate (2.7.1) | |
activerecord (>= 3.2, < 6.0) | |
rake (>= 10.4, < 12.0) | |
- arel (6.0.3) | |
- authlogic (3.4.6) | |
- activerecord (>= 3.2) | |
- activesupport (>= 3.2) | |
- request_store (~> 1.0) | |
- scrypt (>= 1.2, < 3.0) | |
+ arel (7.1.1) | |
autoprefixer-rails (6.4.0.2) | |
execjs | |
binding_of_caller (0.7.2) | |
@@ -84,9 +91,9 @@ GEM | |
childprocess (0.5.9) | |
ffi (~> 1.0, >= 1.0.11) | |
coderay (1.1.1) | |
- coffee-rails (4.1.1) | |
+ coffee-rails (4.2.1) | |
coffee-script (>= 2.2.0) | |
- railties (>= 4.0.0, < 5.1.x) | |
+ railties (>= 4.0.0, < 5.2.x) | |
coffee-script (2.4.1) | |
coffee-script-source | |
execjs | |
@@ -157,7 +164,7 @@ GEM | |
thor (>= 0.14, < 2.0) | |
jsobfu (0.4.1) | |
rkelly-remix (= 0.0.6) | |
- json (1.8.3) | |
+ json (2.0.2) | |
kgio (2.10.0) | |
kissfft (0.0.2) | |
launchy (2.4.3) | |
@@ -181,6 +188,7 @@ GEM | |
minitest (5.9.0) | |
multi_json (1.12.1) | |
nenv (0.3.0) | |
+ nio4r (1.2.1) | |
nokogiri (1.6.8) | |
mini_portile2 (~> 2.1.0) | |
pkg-config (~> 1.1.7) | |
@@ -189,41 +197,38 @@ GEM | |
shellany (~> 0.0) | |
pg (0.18.4) | |
pkg-config (1.1.7) | |
- protected_attributes (1.0.9) | |
- activemodel (>= 4.0.1, < 5.0) | |
pry (0.10.4) | |
coderay (~> 1.1.0) | |
method_source (~> 0.8.1) | |
slop (~> 3.4) | |
psych_shield (0.0.4) | |
- rack (1.6.4) | |
+ rack (2.0.1) | |
rack-test (0.6.3) | |
rack (>= 1.0) | |
- rails (4.2.7.1) | |
- actionmailer (= 4.2.7.1) | |
- actionpack (= 4.2.7.1) | |
- actionview (= 4.2.7.1) | |
- activejob (= 4.2.7.1) | |
- activemodel (= 4.2.7.1) | |
- activerecord (= 4.2.7.1) | |
- activesupport (= 4.2.7.1) | |
+ rails (5.0.0) | |
+ actioncable (= 5.0.0) | |
+ actionmailer (= 5.0.0) | |
+ actionpack (= 5.0.0) | |
+ actionview (= 5.0.0) | |
+ activejob (= 5.0.0) | |
+ activemodel (= 5.0.0) | |
+ activerecord (= 5.0.0) | |
+ activesupport (= 5.0.0) | |
bundler (>= 1.3.0, < 2.0) | |
- railties (= 4.2.7.1) | |
- sprockets-rails | |
- rails-deprecated_sanitizer (1.0.3) | |
- activesupport (>= 4.2.0.alpha) | |
- rails-dom-testing (1.0.7) | |
- activesupport (>= 4.2.0.beta, < 5.0) | |
+ railties (= 5.0.0) | |
+ sprockets-rails (>= 2.0.0) | |
+ rails-dom-testing (2.0.1) | |
+ activesupport (>= 4.2.0, < 6.0) | |
nokogiri (~> 1.6.0) | |
- rails-deprecated_sanitizer (>= 1.0.1) | |
rails-html-sanitizer (1.0.3) | |
loofah (~> 2.0) | |
rails-settings-cached (0.6.5) | |
rails (>= 4.2.0) | |
rails_layout (1.0.29) | |
- railties (4.2.7.1) | |
- actionpack (= 4.2.7.1) | |
- activesupport (= 4.2.7.1) | |
+ railties (5.0.0) | |
+ actionpack (= 5.0.0) | |
+ activesupport (= 5.0.0) | |
+ method_source | |
rake (>= 0.8.7) | |
thor (>= 0.18.1, < 2.0) | |
raindrops (0.17.0) | |
@@ -274,8 +279,8 @@ GEM | |
sprockets (>= 2.8, < 4.0) | |
sprockets-rails (>= 2.0, < 4.0) | |
tilt (>= 1.1, < 3) | |
- scrypt (2.1.1) | |
- ffi-compiler (>= 0.0.2) | |
+ scrypt (3.0.3) | |
+ ffi-compiler (>= 1.0.0) | |
rake | |
selenium-webdriver (2.53.4) | |
childprocess (~> 0.5) | |
@@ -311,6 +316,9 @@ GEM | |
railties (>= 4.0) | |
sprockets-rails (>= 2.0, < 4.0) | |
websocket (1.2.3) | |
+ websocket-driver (0.6.4) | |
+ websocket-extensions (>= 0.1.0) | |
+ websocket-extensions (0.1.2) | |
will_paginate (3.1.0) | |
will_paginate-bootstrap (1.0.1) | |
will_paginate (>= 3.0.3) | |
@@ -322,13 +330,13 @@ PLATFORMS | |
DEPENDENCIES | |
annotate | |
- authlogic (>= 3.4.0) | |
+ authlogic! | |
autoprefixer-rails | |
bootstrap-sass (>= 3.2.0) | |
breadcrumbs_on_rails | |
byebug | |
capybara | |
- coffee-rails (~> 4.1.0) | |
+ coffee-rails (~> 4.2) | |
database_cleaner | |
dynamic_form (>= 1.1.4) | |
factory_girl_rails | |
@@ -344,10 +352,9 @@ DEPENDENCIES | |
jquery-rails | |
kissfft | |
launchy | |
- pg (~> 0.15) | |
- protected_attributes (~> 1.0.7) | |
+ pg (~> 0.18) | |
psych_shield | |
- rails (~> 4.2, >= 4.2.7.1) | |
+ rails (= 5.0.0) | |
rails-settings-cached (>= 0.4.1) | |
rails_layout | |
reportable! | |
@@ -358,9 +365,10 @@ DEPENDENCIES | |
selenium-webdriver | |
shoulda-matchers (= 2.8) | |
therubyracer | |
+ tzinfo-data | |
uglifier (>= 1.3.0) | |
unicorn | |
- web-console (~> 2.0) | |
+ web-console | |
will_paginate (~> 3.0) | |
will_paginate-bootstrap | |
diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js | |
@@ -0,0 +1,3 @@ | |
+//= link_tree ../images | |
+//= link_directory ../javascripts .js | |
+//= link_directory ../stylesheets .css | |
diff --git a/app/assets/images/.keep b/app/assets/images/.keep | |
diff --git a/app/controllers/application_controller.rb b/app/controllers/applic… | |
@@ -1,9 +1,9 @@ | |
class ApplicationController < ActionController::Base | |
- protect_from_forgery | |
+ protect_from_forgery with: :exception | |
helper :all | |
helper_method :current_user_session, :current_user | |
- before_filter :require_user, :load_project | |
+ before_action :require_user, :load_project | |
add_breadcrumb :projects, :root_path | |
include ActionView::Helpers::NumberHelper | |
diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep | |
diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controll… | |
@@ -156,7 +156,7 @@ class JobsController < ApplicationController | |
end | |
def dialer | |
- @job = Job.new(params[:job]) | |
+ @job = Job.new(job_params) | |
@job.created_by = @current_user.login | |
@job.task = 'dialer' | |
@job.range.to_s.gsub!(/[^0-9X:,\n]/, '') | |
@@ -343,4 +343,9 @@ class JobsController < ApplicationController | |
end | |
end | |
+ private | |
+ | |
+ def job_params | |
+ params.require(:job).permit(:project_id, :range, :range_file, :seconds, :l… | |
+ end | |
end | |
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_… | |
@@ -96,7 +96,7 @@ class ProjectsController < ApplicationController | |
end | |
def create | |
- @new_project = Project.new(params[:project]) | |
+ @new_project = Project.new(project_params) | |
@new_project.created_by = current_user.login | |
respond_to do |format| | |
@@ -114,7 +114,7 @@ class ProjectsController < ApplicationController | |
@project = Project.find(params[:id]) | |
respond_to do |format| | |
- if @project.update_attributes(params[:project]) | |
+ if @project.update_attributes(project_params) | |
format.html { redirect_to projects_path } | |
format.xml { head :ok } | |
else | |
@@ -133,4 +133,10 @@ class ProjectsController < ApplicationController | |
format.xml { head :ok } | |
end | |
end | |
+ | |
+ private | |
+ | |
+ def project_params | |
+ params.require(:project).permit(:name, :description) | |
+ end | |
end | |
diff --git a/app/controllers/providers_controller.rb b/app/controllers/provider… | |
@@ -18,8 +18,8 @@ class ProvidersController < ApplicationController | |
def new | |
@provider = Provider.new | |
- @provider.enabled = true | |
- @provider.port = 4569 | |
+ @provider.enabled = true | |
+ @provider.port = 4569 | |
respond_to do |format| | |
format.html # new.html.erb | |
@@ -29,12 +29,12 @@ class ProvidersController < ApplicationController | |
def edit | |
@provider = Provider.find(params[:id]) | |
- @provider.pass = "********" | |
+ @provider.pass = "********" | |
end | |
def create | |
- @provider = Provider.new(params[:provider]) | |
- @provider.enabled = true | |
+ @provider = Provider.new(provider_params) | |
+ @provider.enabled = true | |
respond_to do |format| | |
if @provider.save | |
@@ -52,13 +52,13 @@ class ProvidersController < ApplicationController | |
def update | |
@provider = Provider.find(params[:id]) | |
- # Dont set the password if its the placeholder | |
- if params[:provider] and params[:provider][:pass] and params[:provider][:pas… | |
- params[:provider].delete(:pass) | |
- end | |
+ # Dont set the password if its the placeholder | |
+ if params[:provider] and params[:provider][:pass] and params[:provider][:p… | |
+ params[:provider].delete(:pass) | |
+ end | |
respond_to do |format| | |
- if @provider.update_attributes(params[:provider]) | |
+ if @provider.update_attributes(provider_params) | |
flash[:notice] = 'Provider was successfully updated.' | |
format.html { redirect_to providers_path } | |
format.xml { head :ok } | |
@@ -78,4 +78,10 @@ class ProvidersController < ApplicationController | |
format.xml { head :ok } | |
end | |
end | |
+ | |
+ private | |
+ | |
+ def provider_params | |
+ params.require(:provider).permit(:name, :host, :port, :user, :pass, :lines) | |
+ end | |
end | |
diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user… | |
@@ -1,6 +1,6 @@ | |
class UserSessionsController < ApplicationController | |
- before_filter :require_no_user, :only => [:new, :create] | |
- before_filter :require_user, :only => :destroy | |
+ before_action :require_no_user, :only => [:new, :create] | |
+ before_action :require_user, :only => :destroy | |
layout 'login' | |
def new | |
@@ -8,7 +8,7 @@ class UserSessionsController < ApplicationController | |
end | |
def create | |
- @user_session = UserSession.new(params[:user_session]) | |
+ @user_session = UserSession.new(user_session_params) | |
if @user_session.save | |
redirect_back_or_default projects_path | |
else | |
@@ -20,4 +20,10 @@ class UserSessionsController < ApplicationController | |
current_user_session.destroy | |
redirect_back_or_default login_path | |
end | |
+ | |
+ private | |
+ | |
+ def user_session_params | |
+ params.require(:user_session).permit(:login, :password) | |
+ end | |
end | |
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_contro… | |
@@ -1,13 +1,13 @@ | |
class UsersController < ApplicationController | |
- before_filter :require_no_user, :only => [:new, :create] | |
- before_filter :require_user, :only => [:show, :edit, :update] | |
+ before_action :require_no_user, :only => [:new, :create] | |
+ before_action :require_user, :only => [:show, :edit, :update] | |
def new | |
@user = User.new | |
end | |
def create | |
- @user = User.new(params[:user]) | |
+ @user = User.new(user_params) | |
if @user.save | |
flash[:notice] = "Account registered!" | |
redirect_back_or_default user_path(@user) | |
@@ -26,11 +26,17 @@ class UsersController < ApplicationController | |
def update | |
@user = @current_user # makes our views "cleaner" and more consistent | |
- if @user.update_attributes(params[:user]) | |
+ if @user.update_attributes(user_params) | |
flash[:notice] = "Account updated!" | |
- redirect_to account_url | |
+ redirect_to user_path(@user) | |
else | |
render :action => :edit | |
end | |
end | |
+ | |
+ private | |
+ | |
+ def user_params | |
+ params.require(:user).permit(:login, :password, :password_confirmation) | |
+ end | |
end | |
diff --git a/app/models/application_record.rb b/app/models/application_record.rb | |
@@ -0,0 +1,3 @@ | |
+class ApplicationRecord < ActiveRecord::Base | |
+ self.abstract_class = true | |
+end | |
diff --git a/app/models/call.rb b/app/models/call.rb | |
@@ -24,7 +24,7 @@ | |
# fprint :integer is an Array | |
# | |
-class Call < ActiveRecord::Base | |
+class Call < ApplicationRecord | |
reportable :hourly, :aggregation => :count, :grouping => :hour, :live_data =… | |
reportable :daily, :aggregation => :count, :grouping => :day, :live_data => … | |
diff --git a/app/models/call_medium.rb b/app/models/call_medium.rb | |
@@ -14,7 +14,7 @@ | |
# png_sig_freq :binary | |
# | |
-class CallMedium < ActiveRecord::Base | |
+class CallMedium < ApplicationRecord | |
belongs_to :call | |
belongs_to :project | |
end | |
diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep | |
diff --git a/app/models/job.rb b/app/models/job.rb | |
@@ -18,7 +18,7 @@ | |
# progress :integer default(0) | |
# | |
-class Job < ActiveRecord::Base | |
+class Job < ApplicationRecord | |
reportable :hourly, :aggregation => :count, :grouping => :hour, :date_column… | |
reportable :daily, :aggregation => :count, :grouping => :day, :date_column =… | |
@@ -75,13 +75,8 @@ class Job < ActiveRecord::Base | |
belongs_to :project | |
- attr_accessible :task, :status, :progress | |
- | |
validates_presence_of :project_id | |
- attr_accessible :project_id | |
- | |
- | |
# Allow the base Job class to be used for Dial Jobs | |
attr_accessor :range | |
attr_accessor :range_file | |
@@ -89,16 +84,11 @@ class Job < ActiveRecord::Base | |
attr_accessor :seconds | |
attr_accessor :cid_mask | |
- attr_accessible :range, :seconds, :lines, :cid_mask, :range_file | |
- | |
attr_accessor :scope | |
attr_accessor :force | |
attr_accessor :target_id | |
attr_accessor :target_ids | |
- attr_accessible :scope, :force, :target_id, :target_ids | |
- | |
- | |
validates_with JobValidator | |
def stop | |
diff --git a/app/models/line.rb b/app/models/line.rb | |
@@ -11,7 +11,7 @@ | |
# notes :text | |
# | |
-class Line < ActiveRecord::Base | |
+class Line < ApplicationRecord | |
has_many :line_attributes, :dependent => :delete_all | |
belongs_to :project | |
diff --git a/app/models/line_attribute.rb b/app/models/line_attribute.rb | |
@@ -12,7 +12,7 @@ | |
# content_type :string(255) default("text") | |
# | |
-class LineAttribute < ActiveRecord::Base | |
+class LineAttribute < ApplicationRecord | |
belongs_to :line | |
belongs_to :project | |
end | |
diff --git a/app/models/project.rb b/app/models/project.rb | |
@@ -12,13 +12,11 @@ | |
# created_by :string(255) | |
# | |
-class Project < ActiveRecord::Base | |
+class Project < ApplicationRecord | |
validates_presence_of :name | |
validates_uniqueness_of :name | |
- attr_accessible :name, :description, :included, :excluded | |
- | |
# This is optimized for fast project deletion, even with thousands of calls/… | |
has_many :lines, :dependent => :delete_all | |
has_many :line_attributes, :dependent => :delete_all | |
diff --git a/app/models/provider.rb b/app/models/provider.rb | |
@@ -14,12 +14,10 @@ | |
# enabled :boolean default(TRUE) | |
# | |
-class Provider < ActiveRecord::Base | |
+class Provider < ApplicationRecord | |
has_many :dial_results | |
validates_presence_of :name, :host, :port, :user, :pass, :lines | |
validates_numericality_of :port, :less_than => 65536, :greater_than => 0 | |
validates_numericality_of :lines, :less_than => 255, :greater_than => 0 | |
- | |
- attr_accessible :enabled, :name, :host, :port, :user, :pass, :lines | |
end | |
diff --git a/app/models/settings.rb b/app/models/settings.rb | |
@@ -12,5 +12,5 @@ | |
# | |
class Settings < RailsSettings::Base | |
- attr_accessible :var | |
+ # attr_accessible :var | |
end | |
diff --git a/app/models/signature.rb b/app/models/signature.rb | |
@@ -13,7 +13,7 @@ | |
# risk :integer | |
# | |
-class Signature < ActiveRecord::Base | |
+class Signature < ApplicationRecord | |
has_many :signature_fps | |
end | |
diff --git a/app/models/signature_fp.rb b/app/models/signature_fp.rb | |
@@ -1,4 +1,4 @@ | |
-class SignatureFp < ActiveRecord::Base | |
+class SignatureFp < ApplicationRecord | |
belongs_to :signature | |
end | |
diff --git a/app/models/user.rb b/app/models/user.rb | |
@@ -23,7 +23,7 @@ | |
# admin :boolean default(TRUE) | |
# | |
-class User < ActiveRecord::Base | |
+class User < ApplicationRecord | |
include RailsSettings::Extend | |
acts_as_authentic do |c| | |
c.validate_email_field = false | |
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb | |
@@ -1,6 +1,6 @@ | |
<h1>Edit My Account</h1> | |
-<% form_for @user, :url => user_path(@user) do |f| %> | |
+<%= form_for @user, :url => user_path(@user) do |f| %> | |
<%= f.error_messages %> | |
<%= render :partial => "form", :object => f %> | |
<%= f.submit "Update" %> | |
diff --git a/bin/setup b/bin/setup | |
@@ -1,29 +1,34 @@ | |
#!/usr/bin/env ruby | |
require 'pathname' | |
+require 'fileutils' | |
+include FileUtils | |
# path to your application root. | |
-APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | |
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | |
-Dir.chdir APP_ROOT do | |
+def system!(*args) | |
+ system(*args) || abort("\n== Command #{args} failed ==") | |
+end | |
+ | |
+chdir APP_ROOT do | |
# This script is a starting point to setup your application. | |
- # Add necessary setup steps to this file: | |
+ # Add necessary setup steps to this file. | |
- puts "== Installing dependencies ==" | |
- system "gem install bundler --conservative" | |
- system "bundle check || bundle install" | |
+ puts '== Installing dependencies ==' | |
+ system! 'gem install bundler --conservative' | |
+ system('bundle check') || system!('bundle install') | |
# puts "\n== Copying sample files ==" | |
- # unless File.exist?("config/database.yml") | |
- # system "cp config/database.yml.sample config/database.yml" | |
+ # unless File.exist?('config/database.yml') | |
+ # cp 'config/database.yml.sample', 'config/database.yml' | |
# end | |
puts "\n== Preparing database ==" | |
- system "bin/rake db:setup" | |
+ system! 'bin/rails db:setup' | |
puts "\n== Removing old logs and tempfiles ==" | |
- system "rm -f log/*" | |
- system "rm -rf tmp/cache" | |
+ system! 'bin/rails log:clear tmp:clear' | |
puts "\n== Restarting application server ==" | |
- system "touch tmp/restart.txt" | |
+ system! 'bin/rails restart' | |
end | |
diff --git a/bin/update b/bin/update | |
@@ -0,0 +1,29 @@ | |
+#!/usr/bin/env ruby | |
+require 'pathname' | |
+require 'fileutils' | |
+include FileUtils | |
+ | |
+# path to your application root. | |
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | |
+ | |
+def system!(*args) | |
+ system(*args) || abort("\n== Command #{args} failed ==") | |
+end | |
+ | |
+chdir APP_ROOT do | |
+ # This script is a way to update your development environment automatically. | |
+ # Add necessary update steps to this file. | |
+ | |
+ puts '== Installing dependencies ==' | |
+ system! 'gem install bundler --conservative' | |
+ system('bundle check') || system!('bundle install') | |
+ | |
+ puts "\n== Updating database ==" | |
+ system! 'bin/rails db:migrate' | |
+ | |
+ puts "\n== Removing old logs and tempfiles ==" | |
+ system! 'bin/rails log:clear tmp:clear' | |
+ | |
+ puts "\n== Restarting application server ==" | |
+ system! 'bin/rails restart' | |
+end | |
diff --git a/config/application.rb b/config/application.rb | |
@@ -1,6 +1,13 @@ | |
-require File.expand_path('../boot', __FILE__) | |
+require_relative 'boot' | |
-require 'rails/all' | |
+require "rails" | |
+# Pick the frameworks you want: | |
+require "active_model/railtie" | |
+require "active_record/railtie" | |
+require "action_controller/railtie" | |
+require "action_mailer/railtie" | |
+require "action_view/railtie" | |
+require "sprockets/railtie" | |
# Require the gems listed in Gemfile, including any gems | |
# you've limited to :test, :development, or :production. | |
@@ -28,8 +35,5 @@ module Web | |
# Enable escaping HTML in JSON. | |
config.active_support.escape_html_entities_in_json = true | |
- | |
- # Do not swallow errors in after_commit/after_rollback callbacks. | |
- config.active_record.raise_in_transactional_callbacks = true | |
end | |
end | |
diff --git a/config/boot.rb b/config/boot.rb | |
@@ -1,3 +1,3 @@ | |
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | |
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) | |
require 'bundler/setup' # Set up gems listed in the Gemfile. | |
diff --git a/config/cable.yml b/config/cable.yml | |
@@ -0,0 +1,9 @@ | |
+development: | |
+ adapter: async | |
+ | |
+test: | |
+ adapter: async | |
+ | |
+production: | |
+ adapter: redis | |
+ url: redis://localhost:6379/1 | |
diff --git a/config/environment.rb b/config/environment.rb | |
@@ -1,5 +1,5 @@ | |
# Load the Rails application. | |
-require File.expand_path('../application', __FILE__) | |
+require_relative 'application' | |
# Initialize the Rails application. | |
Rails.application.initialize! | |
diff --git a/config/environments/development.rb b/config/environments/developme… | |
@@ -11,11 +11,26 @@ Rails.application.configure do | |
# Show full error reports and disable caching. | |
config.consider_all_requests_local = true | |
- config.action_controller.perform_caching = false | |
+ | |
+ # Enable/disable caching. By default caching is disabled. | |
+ if Rails.root.join('tmp/caching-dev.txt').exist? | |
+ config.action_controller.perform_caching = true | |
+ | |
+ config.cache_store = :memory_store | |
+ config.public_file_server.headers = { | |
+ 'Cache-Control' => 'public, max-age=172800' | |
+ } | |
+ else | |
+ config.action_controller.perform_caching = false | |
+ | |
+ config.cache_store = :null_store | |
+ end | |
# Don't care if the mailer can't send. | |
config.action_mailer.raise_delivery_errors = false | |
+ config.action_mailer.perform_caching = false | |
+ | |
# Print deprecation notices to the Rails logger. | |
config.active_support.deprecation = :log | |
@@ -24,25 +39,18 @@ Rails.application.configure do | |
config.log_level = :debug | |
- # Do not compress assets | |
- config.assets.compress = false | |
- | |
- config.serve_static_files = true | |
- | |
# Debug mode disables concatenation and preprocessing of assets. | |
# This option may cause significant delays in view rendering with a large | |
# number of complex assets. | |
config.assets.debug = false | |
- # Asset digests allow you to set far-future HTTP expiration dates on all ass… | |
- # yet still be able to expire them through the digest params. | |
- config.assets.digest = true | |
- | |
- # Adds additional error checking when serving assets at runtime. | |
- # Checks for improperly declared sprockets dependencies. | |
- # Raises helpful error messages. | |
- config.assets.raise_runtime_errors = true | |
+ # Suppress logger output for asset requests. | |
+ config.assets.quiet = true | |
# Raises error for missing translations | |
# config.action_view.raise_on_missing_translations = true | |
+ | |
+ # Use an evented file watcher to asynchronously detect changes in source cod… | |
+ # routes, locales, etc. This feature depends on the listen gem. | |
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker | |
end | |
diff --git a/config/environments/production.rb b/config/environments/production… | |
@@ -14,15 +14,9 @@ Rails.application.configure do | |
config.consider_all_requests_local = false | |
config.action_controller.perform_caching = true | |
- # Enable Rack::Cache to put a simple HTTP cache in front of your application | |
- # Add `rack-cache` to your Gemfile before enabling this. | |
- # For large-scale production use, consider using a caching reverse proxy like | |
- # NGINX, varnish or squid. | |
- # config.action_dispatch.rack_cache = true | |
- | |
# Disable serving static files from the `/public` folder by default since | |
# Apache or NGINX already handles this. | |
- config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? | |
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? | |
# Compress JavaScripts and CSS. | |
config.assets.js_compressor = :uglifier | |
@@ -31,12 +25,11 @@ Rails.application.configure do | |
# Do not fallback to assets pipeline if a precompiled asset is missed. | |
config.assets.compile = true | |
- # Asset digests allow you to set far-future HTTP expiration dates on all ass… | |
- # yet still be able to expire them through the digest params. | |
- config.assets.digest = true | |
- | |
# `config.assets.precompile` and `config.assets.version` have moved to confi… | |
+ # Enable serving of images, stylesheets, and JavaScripts from an asset serve… | |
+ # config.action_controller.asset_host = 'http://assets.example.com' | |
+ | |
# Specifies the header that your server uses for sending files. | |
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache | |
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX | |
@@ -49,16 +42,15 @@ Rails.application.configure do | |
config.log_level = :debug | |
# Prepend all log lines with the following tags. | |
- # config.log_tags = [ :subdomain, :uuid ] | |
- | |
- # Use a different logger for distributed setups. | |
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) | |
+ config.log_tags = [ :request_id ] | |
# Use a different cache store in production. | |
# config.cache_store = :mem_cache_store | |
- # Enable serving of images, stylesheets, and JavaScripts from an asset serve… | |
- # config.action_controller.asset_host = 'http://assets.example.com' | |
+ # Use a real queuing backend for Active Job (and separate queues per environ… | |
+ # config.active_job.queue_adapter = :resque | |
+ # config.active_job.queue_name_prefix = "barerails5app_#{Rails.env}" | |
+ config.action_mailer.perform_caching = false | |
# Ignore bad email addresses and do not raise email delivery errors. | |
# Set this to true and configure the email server for immediate delivery to … | |
@@ -74,6 +66,16 @@ Rails.application.configure do | |
# Use default logging formatter so that PID and timestamp are not suppressed. | |
config.log_formatter = ::Logger::Formatter.new | |
+ # Use a different logger for distributed setups. | |
+ # require 'syslog/logger' | |
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-n… | |
+ | |
+ if ENV["RAILS_LOG_TO_STDOUT"].present? | |
+ logger = ActiveSupport::Logger.new(STDOUT) | |
+ logger.formatter = config.log_formatter | |
+ config.logger = ActiveSupport::TaggedLogging.new(logger) | |
+ end | |
+ | |
# Do not dump schema after migrations. | |
config.active_record.dump_schema_after_migration = false | |
end | |
diff --git a/config/environments/test.rb b/config/environments/test.rb | |
@@ -12,9 +12,11 @@ Rails.application.configure do | |
# preloads Rails for running tests, you may have to set it to true. | |
config.eager_load = false | |
- # Configure static file server for tests with Cache-Control for performance. | |
- config.serve_static_files = true | |
- config.static_cache_control = 'public, max-age=3600' | |
+ # Configure public file server for tests with Cache-Control for performance. | |
+ config.public_file_server.enabled = true | |
+ config.public_file_server.headers = { | |
+ 'Cache-Control' => 'public, max-age=3600' | |
+ } | |
# Show full error reports and disable caching. | |
config.consider_all_requests_local = true | |
@@ -25,15 +27,13 @@ Rails.application.configure do | |
# Disable request forgery protection in test environment. | |
config.action_controller.allow_forgery_protection = false | |
+ config.action_mailer.perform_caching = false | |
# Tell Action Mailer not to deliver emails to the real world. | |
# The :test delivery method accumulates sent emails in the | |
# ActionMailer::Base.deliveries array. | |
config.action_mailer.delivery_method = :test | |
- # Randomize the order test cases are executed. | |
- config.active_support.test_order = :random | |
- | |
# Print deprecation notices to the stderr. | |
config.active_support.deprecation = :stderr | |
diff --git a/config/initializers/application_controller_renderer.rb b/config/in… | |
@@ -0,0 +1,6 @@ | |
+# Be sure to restart your server when you modify this file. | |
+ | |
+# ApplicationController.renderer.defaults.merge!( | |
+# http_host: 'example.org', | |
+# https: false | |
+# ) | |
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/co… | |
@@ -1,3 +1,5 @@ | |
# Be sure to restart your server when you modify this file. | |
+# Specify a serializer for the signed and encrypted cookie jars. | |
+# Valid options are :json, :marshal, and :hybrid. | |
Rails.application.config.action_dispatch.cookies_serializer = :marshal | |
diff --git a/config/initializers/new_framework_defaults.rb b/config/initializer… | |
@@ -0,0 +1,24 @@ | |
+# Be sure to restart your server when you modify this file. | |
+# | |
+# This file contains migration options to ease your Rails 5.0 upgrade. | |
+# | |
+# Read the Rails 5.0 release notes for more info on each option. | |
+ | |
+# Enable per-form CSRF tokens. Previous versions had false. | |
+Rails.application.config.action_controller.per_form_csrf_tokens = true | |
+ | |
+# Enable origin-checking CSRF mitigation. Previous versions had false. | |
+Rails.application.config.action_controller.forgery_protection_origin_check = t… | |
+ | |
+# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. | |
+# Previous versions had false. | |
+ActiveSupport.to_time_preserves_timezone = true | |
+ | |
+# Require `belongs_to` associations by default. Previous versions had false. | |
+Rails.application.config.active_record.belongs_to_required_by_default = true | |
+ | |
+# Do not halt callback chains when a callback returns false. Previous versions… | |
+ActiveSupport.halt_callback_chains_on_return_false = false | |
+ | |
+# Configure SSL options to enable HSTS with subdomains. Previous versions had … | |
+Rails.application.config.ssl_options = { hsts: { subdomains: true } } | |
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_… | |
@@ -5,10 +5,10 @@ | |
# Enable parameter wrapping for JSON. You can disable this by setting :format … | |
ActiveSupport.on_load(:action_controller) do | |
- wrap_parameters format: [:json] if respond_to?(:wrap_parameters) | |
+ wrap_parameters format: [:json] | |
end | |
# To enable root element in JSON for ActiveRecord objects. | |
# ActiveSupport.on_load(:active_record) do | |
-# self.include_root_in_json = true | |
+# self.include_root_in_json = true | |
# end | |
diff --git a/config/unicorn.rb b/config/unicorn.rb | |
diff --git a/db/seeds.rb b/db/seeds.rb | |
@@ -0,0 +1,7 @@ | |
+# This file should contain all the record creation needed to seed the database… | |
+# The data can then be loaded with the rails db:seed command (or created along… | |
+# | |
+# Examples: | |
+# | |
+# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' … | |
+# Character.create(name: 'Luke', movie: movies.first) | |
diff --git a/lib/assets/.keep b/lib/assets/.keep | |
diff --git a/lib/tasks/.keep b/lib/tasks/.keep | |
diff --git a/script/rails b/script/rails | |
@@ -1,6 +0,0 @@ | |
-#!/usr/bin/env ruby | |
-# This command will automatically be run when you run "rails" with Rails 3 gem… | |
- | |
-APP_PATH = File.expand_path('../../config/application', __FILE__) | |
-require File.expand_path('../../config/boot', __FILE__) | |
-require 'rails/commands' | |
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb | |
@@ -7,6 +7,8 @@ require 'spec_helper' | |
require 'rspec/rails' | |
# Add additional requires below this line. Rails is not loaded until this poin… | |
+require 'capybara/rails' | |
+ | |
# Requires supporting ruby files with custom matchers and macros, etc, in | |
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are | |
# run as spec files by default. This means that files in spec/support that end | |
@@ -22,14 +24,11 @@ require 'rspec/rails' | |
# | |
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } | |
-# Checks for pending migrations before tests are run. | |
+# Checks for pending migration and applies them before tests are run. | |
# If you are not using ActiveRecord, you can remove this line. | |
ActiveRecord::Migration.maintain_test_schema! | |
RSpec.configure do |config| | |
- # FactoryGirl Syntax | |
- config.include FactoryGirl::Syntax::Methods | |
- | |
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures | |
config.fixture_path = "#{::Rails.root}/spec/fixtures" | |
@@ -52,4 +51,9 @@ RSpec.configure do |config| | |
# The different available types are documented in the features, such as in | |
# https://relishapp.com/rspec/rspec-rails/docs | |
config.infer_spec_type_from_file_location! | |
+ | |
+ # Filter lines from Rails gems in backtraces. | |
+ config.filter_rails_from_backtrace! | |
+ # arbitrary gems may also be filtered via: | |
+ # config.filter_gems_from_backtrace("gem name") | |
end | |
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb | |
@@ -1,3 +1,5 @@ | |
+require 'capybara/rspec' | |
+ | |
# This file was generated by the `rails generate rspec:install` command. Conve… | |
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. | |
# The generated `.rspec` file contains `--require spec_helper` which will cause | |
@@ -40,15 +42,22 @@ RSpec.configure do |config| | |
mocks.verify_partial_doubles = true | |
end | |
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will | |
+ # have no way to turn it off -- the option exists only for backwards | |
+ # compatibility in RSpec 3). It causes shared context metadata to be | |
+ # inherited by the metadata hash of host groups and examples, rather than | |
+ # triggering implicit auto-inclusion in groups with matching metadata. | |
+ config.shared_context_metadata_behavior = :apply_to_host_groups | |
+ | |
# The settings below are suggested to provide a good initial experience | |
# with RSpec, but feel free to customize to your heart's content. | |
=begin | |
- # These two settings work together to allow you to limit a spec run | |
- # to individual examples or groups you care about by tagging them with | |
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples | |
- # get run. | |
- config.filter_run :focus | |
- config.run_all_when_everything_filtered = true | |
+ # This allows you to limit a spec run to individual examples or groups | |
+ # you care about by tagging them with `:focus` metadata. When nothing | |
+ # is tagged with `:focus`, all examples get run. RSpec also provides | |
+ # aliases for `it`, `describe`, and `context` that include `:focus` | |
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively. | |
+ config.filter_run_when_matching :focus | |
# Allows RSpec to persist some state between runs in order to support | |
# the `--only-failures` and `--next-failure` CLI options. We recommend | |
@@ -57,9 +66,9 @@ RSpec.configure do |config| | |
# Limits the available syntax to the non-monkey patched syntax that is | |
# recommended. For more details, see: | |
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax | |
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ | |
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectatio… | |
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new_… | |
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey… | |
config.disable_monkey_patching! | |
# Many RSpec users commonly either run the entire suite or an individual | |
diff --git a/spec/support/auth_logic_helpers.rb b/spec/support/auth_logic_helpe… | |
@@ -2,7 +2,7 @@ module Authlogic | |
module TestHelper | |
def create_user_session(user) | |
visit login_path | |
- within "#new_user_session" do | |
+ within "form#new_user_session" do | |
expect(page).to have_content "Username" | |
expect(page).to have_content "Password" | |
fill_in "user_session_login", with: user.login | |
@@ -17,4 +17,4 @@ end | |
RSpec.configure do |config| | |
config.include Authlogic::TestHelper, type: :request | |
config.include Authlogic::TestHelper, type: :feature | |
-end | |
-\ No newline at end of file | |
+end | |
diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb | |
@@ -0,0 +1,3 @@ | |
+RSpec.configure do |config| | |
+ config.include FactoryGirl::Syntax::Methods | |
+end |