Commit 32e82533 by source_reader

migrated to rails 5.2.2

parent 60d1cc21
...@@ -2,6 +2,7 @@ AllCops: ...@@ -2,6 +2,7 @@ AllCops:
TargetRubyVersion: 2.3 TargetRubyVersion: 2.3
Include: Include:
- '**/config.ru' - '**/config.ru'
- 'spec/**/*'
Exclude: Exclude:
- '**/Rakefile' - '**/Rakefile'
- 'db/**/*' - 'db/**/*'
......
...@@ -2,7 +2,7 @@ source 'https://rubygems.org' ...@@ -2,7 +2,7 @@ source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.2.0' gem 'rails', '5.2.2'
# Use SCSS for stylesheets # Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0' gem 'sass-rails', '~> 5.0'
...@@ -38,6 +38,8 @@ gem 'devise_invitable' ...@@ -38,6 +38,8 @@ gem 'devise_invitable'
gem 'omniauth' gem 'omniauth'
gem 'oj' # fast json gem 'oj' # fast json
gem 'mini_magick' gem 'mini_magick'
gem 'bootsnap'
gem 'rubocop-rspec'
group :development, :test do group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console # Call 'byebug' anywhere in the code to stop execution and get a debugger console
......
#!/usr/bin/env ruby #!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle') load Gem.bin_path('bundler', 'bundle')
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'pathname'
require 'fileutils' require 'fileutils'
include FileUtils include FileUtils
# path to your application root. # path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) APP_ROOT = File.expand_path('..', __dir__)
def system!(*args) def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==") system(*args) || abort("\n== Command #{args} failed ==")
...@@ -18,7 +17,6 @@ chdir APP_ROOT do ...@@ -18,7 +17,6 @@ chdir APP_ROOT do
system! 'gem install bundler --conservative' system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install') system('bundle check') || system!('bundle install')
# puts "\n== Copying sample files ==" # puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml') # unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml' # cp 'config/database.yml.sample', 'config/database.yml'
......
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'pathname'
require 'fileutils' require 'fileutils'
include FileUtils include FileUtils
# path to your application root. # path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) APP_ROOT = File.expand_path('..', __dir__)
def system!(*args) def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==") system(*args) || abort("\n== Command #{args} failed ==")
......
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile. require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
...@@ -13,12 +13,13 @@ Rails.application.configure do ...@@ -13,12 +13,13 @@ Rails.application.configure do
config.consider_all_requests_local = true config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist? # Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
config.cache_store = :memory_store config.cache_store = :memory_store
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" 'Cache-Control' => "public, max-age=#{2.days.to_i}"
} }
else else
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
...@@ -26,16 +27,13 @@ Rails.application.configure do ...@@ -26,16 +27,13 @@ Rails.application.configure do
config.cache_store = :null_store config.cache_store = :null_store
end end
# render json on error since this is an API app # Store uploaded files on the local file system (see config/storage.yml for options)
config.debug_exception_response_format = :api config.active_storage.service = :local
# Don't care if the mailer can't send. # Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings =
{ :address => "localhost", :port => 1025 }
# Print deprecation notices to the Rails logger. # Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log config.active_support.deprecation = :log
...@@ -43,32 +41,14 @@ Rails.application.configure do ...@@ -43,32 +41,14 @@ Rails.application.configure do
# Raise an error on page load if there are pending migrations. # Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets. # Highlight code that triggered database queries in logs.
# This option may cause significant delays in view rendering with a large config.active_record.verbose_query_logs = true
# number of complex assets.
config.assets.debug = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations # Raises error for missing translations
# config.action_view.raise_on_missing_translations = true # config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code, # Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem. # routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*',
:headers => :any,
:expose => ['access-token', 'expiry', 'token-type', 'uid', 'client'],
:methods => [:get, :post, :options, :delete, :put]
end
end
config.interface_url_template = lambda do |id|
#return "http://#{id}.interfaces.wattsworth.local"
return "http://wattsworth.local/api/interfaces/#{id}/"
end
end end
...@@ -4,6 +4,10 @@ Rails.application.configure do ...@@ -4,6 +4,10 @@ Rails.application.configure do
# Code is not reloaded between requests. # Code is not reloaded between requests.
config.cache_classes = true config.cache_classes = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Eager load code on boot. This eager loads most of Rails and # Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers # your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better. # and those relying on copy on write to perform better.
......
...@@ -15,7 +15,7 @@ Rails.application.configure do ...@@ -15,7 +15,7 @@ Rails.application.configure do
# Configure public file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.enabled = true
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
} }
# Show full error reports and disable caching. # Show full error reports and disable caching.
......
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
# ApplicationController.renderer.defaults.merge!( # ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org', # http_host: 'example.org',
# https: false # https: false
# ) # )
# end
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.2 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Make Active Record use stable #cache_key alongside new #cache_version method.
# This is needed for recyclable cache keys.
Rails.application.config.active_record.cache_versioning = true
# Use AES-256-GCM authenticated encryption for encrypted cookies.
# Also, embed cookie expiry in signed or encrypted cookies for increased security.
#
# This option is not backwards compatible with earlier Rails versions.
# It's best enabled when your entire app is migrated and stable on 5.2.
#
# Existing cookies will be converted on read then written with the new scheme.
Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true
# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages
# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true.
Rails.application.config.active_support.use_authenticated_message_encryption = true
# Add default protection from forgery to ActionController::Base instead of in
# ApplicationController.
Rails.application.config.action_controller.default_protect_from_forgery = true
# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and
# 'f' after migrating old data.
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header.
Rails.application.config.active_support.use_sha1_digests = true
# Make `form_with` generate id attributes for any generated HTML tags.
Rails.application.config.action_view.form_with_generates_ids = true
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
# service: S3
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
# region: us-east-1
# bucket: your_own_bucket
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
# service: AzureStorage
# storage_account_name: your_account_name
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
# container: your_container_name
# mirror:
# service: Mirror
# primary: local
# mirrors: [ amazon, google, microsoft ]
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
http_interactions: http_interactions:
- request: - request:
method: get method: get
uri: http://nuc:8088/modules.json uri: http://nuc:8088/modules.json?statistics=1
body: body:
encoding: US-ASCII encoding: US-ASCII
string: '' string: ''
......
...@@ -2,7 +2,7 @@ FactoryBot.define do ...@@ -2,7 +2,7 @@ FactoryBot.define do
factory :data_view do factory :data_view do
name { Faker::Lorem.words(3).join(' ') } name { Faker::Lorem.words(3).join(' ') }
description { Faker::Lorem.sentence } description { Faker::Lorem.sentence }
visibility "public" visibility { "public" }
redux_json "auto generated from factory" redux_json { "auto generated from factory" }
end end
end end
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
FactoryBot.define do FactoryBot.define do
factory :db_element do factory :db_element do
name { Faker::Lorem.unique.words(3).join(' ') } name { Faker::Lorem.unique.words(3).join(' ') }
units 'volts' units { 'volts' }
sequence(:column) sequence(:column)
default_max 100 default_max { 100 }
default_min 0 default_min { 0 }
scale_factor 1.0 scale_factor { 1.0 }
offset 0.0 offset { 0.0 }
plottable true plottable { true }
display_type 'continuous' display_type { 'continuous' }
end end
end end
...@@ -8,7 +8,7 @@ FactoryBot.define do ...@@ -8,7 +8,7 @@ FactoryBot.define do
start_time { Faker::Number.number(6)} start_time { Faker::Number.number(6)}
end_time { start_time + Faker::Number.number(5) } end_time { start_time + Faker::Number.number(5) }
size_on_disk { Faker::Number.number(6) } size_on_disk { Faker::Number.number(6) }
hidden false hidden { false }
path { "/root/#{Faker::Lorem.word}/#{Faker::Number.unique.number(4)}" } path { "/root/#{Faker::Lorem.word}/#{Faker::Number.unique.number(4)}" }
end end
end end
...@@ -6,18 +6,18 @@ FactoryBot.define do ...@@ -6,18 +6,18 @@ FactoryBot.define do
name { Faker::Lorem.words(3).join(' ') } name { Faker::Lorem.words(3).join(' ') }
name_abbrev { Faker::Lorem.word } name_abbrev { Faker::Lorem.word }
description { Faker::Lorem.sentence } description { Faker::Lorem.sentence }
delete_locked false delete_locked { false }
start_time { Faker::Number.number(6).to_i} start_time { Faker::Number.number(6).to_i}
end_time { start_time + Faker::Number.number(5).to_i } end_time { start_time + Faker::Number.number(5).to_i }
total_time {end_time - start_time} total_time {end_time - start_time}
size_on_disk { Faker::Number.number(6).to_i } size_on_disk { Faker::Number.number(6).to_i }
hidden false hidden { false }
path { "/root/streams/#{Faker::Lorem.unique.word}" } path { "/root/streams/#{Faker::Lorem.unique.word}" }
data_type { "float32_#{elements_count}" } data_type { "float32_#{elements_count}" }
transient do transient do
elements_count 4 elements_count { 4 }
decimations_count 0 decimations_count { 0 }
end end
after(:create) do |stream, evaluator| after(:create) do |stream, evaluator|
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
FactoryBot.define do FactoryBot.define do
factory :db do factory :db do
url "" url { "" }
max_points_per_plot { Faker::Number.number(3) } max_points_per_plot { Faker::Number.number(3) }
size_db { Faker::Number.number(5) } size_db { Faker::Number.number(5) }
size_other { Faker::Number.number(5) } size_other { Faker::Number.number(5) }
size_total { size_db + size_other } size_total { size_db + size_other }
available true available { true }
root_folder root_folder
end end
end end
...@@ -2,9 +2,9 @@ FactoryBot.define do ...@@ -2,9 +2,9 @@ FactoryBot.define do
factory :joule_module do factory :joule_module do
name { Faker::Lorem.words(3).join(' ') } name { Faker::Lorem.words(3).join(' ') }
description { Faker::Lorem.sentence } description { Faker::Lorem.sentence }
exec_cmd '/path/to/cmd' exec_cmd { '/path/to/cmd' }
web_interface false web_interface { false }
status 'running' status { 'running' }
joule_id Faker::Number.number(3).to_i joule_id { Faker::Number.number(3).to_i }
end end
end end
...@@ -8,11 +8,11 @@ FactoryBot.define do ...@@ -8,11 +8,11 @@ FactoryBot.define do
name {Faker::Lorem.unique.words(3).join(' ')} name {Faker::Lorem.unique.words(3).join(' ')}
description { Faker::Lorem.sentence } description { Faker::Lorem.sentence }
url {Faker::Internet.unique.url} url {Faker::Internet.unique.url}
node_type 'nilmdb' node_type { 'nilmdb' }
transient do transient do
admins [] admins { [] }
owners [] owners { [] }
viewers [] viewers { [] }
end end
after(:create) do |nilm, evaluator| after(:create) do |nilm, evaluator|
......
FactoryBot.define do FactoryBot.define do
factory :permission do factory :permission do
nilm nilm
role "admin" role { "admin" }
after(:build) do |permission| after(:build) do |permission|
# if no user or group specified, create a user # if no user or group specified, create a user
if(permission.user.blank? && if(permission.user.blank? &&
......
FactoryBot.define do FactoryBot.define do
factory :user_group do factory :user_group do
transient do transient do
members [] members { [] }
end end
sequence :name do |n| "group#{n}" end sequence :name do |n| "group#{n}" end
...@@ -11,7 +11,7 @@ FactoryBot.define do ...@@ -11,7 +11,7 @@ FactoryBot.define do
factory :test_user_group do factory :test_user_group do
transient do transient do
size [] size { [] }
end end
name { Faker::Company.unique.name } name { Faker::Company.unique.name }
description { Faker::ChuckNorris.fact } description { Faker::ChuckNorris.fact }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment