diff --git a/Gemfile b/Gemfile index 2f687f717b..6c75cf5a2b 100644 --- a/Gemfile +++ b/Gemfile @@ -87,8 +87,8 @@ group :heroku do gem 'puma' end -gem 'responds_to_parent', git: 'https://github.com/CloCkWeRX/responds_to_parent.git', branch: 'patch-2' # Temporarily pointed at git until https://github.com/zendesk/responds_to_parent/pull/7 is released -gem 'acts_as_commentable', git: 'https://github.com/fatfreecrm/acts_as_commentable.git', branch: 'rails-61' # Our fork +gem 'responds_to_parent' +gem 'acts_as_commentable' gem 'sassc-rails' gem 'coffee-rails' gem 'uglifier' diff --git a/Gemfile.lock b/Gemfile.lock index 16bc9fbaf1..6b756c1585 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,87 +1,78 @@ -GIT - remote: https://github.com/CloCkWeRX/responds_to_parent.git - revision: b1ab71e59b2d5b0b4351a1b18af9372f517e939e - branch: patch-2 - specs: - responds_to_parent (2.0.0) - actionpack (>= 3.2.22, < 6.2) - -GIT - remote: https://github.com/fatfreecrm/acts_as_commentable.git - revision: e695ef5a2a8117109cca8e6911e1266d3a37872d - branch: rails-61 - specs: - acts_as_commentable (6.1.0) - activerecord (~> 6.1.0) - GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.4) - actionpack (= 6.1.7.4) - activesupport (= 6.1.7.4) + actioncable (7.0.5) + actionpack (= 7.0.5) + activesupport (= 7.0.5) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.4) - actionpack (= 6.1.7.4) - activejob (= 6.1.7.4) - activerecord (= 6.1.7.4) - activestorage (= 6.1.7.4) - activesupport (= 6.1.7.4) + actionmailbox (7.0.5) + actionpack (= 7.0.5) + activejob (= 7.0.5) + activerecord (= 7.0.5) + activestorage (= 7.0.5) + activesupport (= 7.0.5) mail (>= 2.7.1) - actionmailer (6.1.7.4) - actionpack (= 6.1.7.4) - actionview (= 6.1.7.4) - activejob (= 6.1.7.4) - activesupport (= 6.1.7.4) + net-imap + net-pop + net-smtp + actionmailer (7.0.5) + actionpack (= 7.0.5) + actionview (= 7.0.5) + activejob (= 7.0.5) + activesupport (= 7.0.5) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7.4) - actionview (= 6.1.7.4) - activesupport (= 6.1.7.4) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.5) + actionview (= 7.0.5) + activesupport (= 7.0.5) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.4) - actionpack (= 6.1.7.4) - activerecord (= 6.1.7.4) - activestorage (= 6.1.7.4) - activesupport (= 6.1.7.4) + actiontext (7.0.5) + actionpack (= 7.0.5) + activerecord (= 7.0.5) + activestorage (= 7.0.5) + activesupport (= 7.0.5) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.4) - activesupport (= 6.1.7.4) + actionview (7.0.5) + activesupport (= 7.0.5) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.4) - activesupport (= 6.1.7.4) + activejob (7.0.5) + activesupport (= 7.0.5) globalid (>= 0.3.6) - activemodel (6.1.7.4) - activesupport (= 6.1.7.4) + activemodel (7.0.5) + activesupport (= 7.0.5) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (6.1.7.4) - activemodel (= 6.1.7.4) - activesupport (= 6.1.7.4) - activestorage (6.1.7.4) - actionpack (= 6.1.7.4) - activejob (= 6.1.7.4) - activerecord (= 6.1.7.4) - activesupport (= 6.1.7.4) + activerecord (7.0.5) + activemodel (= 7.0.5) + activesupport (= 7.0.5) + activestorage (7.0.5) + actionpack (= 7.0.5) + activejob (= 7.0.5) + activerecord (= 7.0.5) + activesupport (= 7.0.5) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.4) + activesupport (7.0.5) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) acts-as-taggable-on (9.0.1) activerecord (>= 6.0, < 7.1) + acts_as_commentable (4.0.2) acts_as_list (1.1.0) activerecord (>= 4.2) addressable (2.8.4) @@ -89,7 +80,7 @@ GEM airbrussh (1.4.1) sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) - autoprefixer-rails (10.3.3.0) + autoprefixer-rails (10.4.13.0) execjs (~> 2) base64 (0.1.1) bcrypt (3.1.18) @@ -170,7 +161,7 @@ GEM factory_bot (~> 6.2.0) railties (>= 5.0.0) ffaker (2.21.0) - ffi (1.15.4) + ffi (1.15.5) font-awesome-rails (4.7.0.8) railties (>= 3.2, < 8.0) formatador (1.1.0) @@ -193,8 +184,9 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - haml (5.2.2) - temple (>= 0.8.0) + haml (6.1.1) + temple (>= 0.8.2) + thor tilt headless (2.3.1) htmlentities (4.3.4) @@ -228,12 +220,18 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2023.0218.1) + mimemagic (0.3.10) + nokogiri (~> 1) + rake mini_magick (4.12.0) mini_mime (1.1.2) mini_racer (0.6.4) libv8-node (~> 16.19.0.0) minitest (5.19.0) - msgpack (1.6.0) + msgpack (1.7.1) nenv (0.3.0) net-imap (0.3.6) date @@ -262,7 +260,7 @@ GEM ast (~> 2.4.1) racc pg (1.5.3) - popper_js (2.9.3) + popper_js (2.11.7) premailer (1.21.0) addressable css_parser (>= 1.12.0) @@ -279,21 +277,20 @@ GEM rack (2.2.8) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.4) - actioncable (= 6.1.7.4) - actionmailbox (= 6.1.7.4) - actionmailer (= 6.1.7.4) - actionpack (= 6.1.7.4) - actiontext (= 6.1.7.4) - actionview (= 6.1.7.4) - activejob (= 6.1.7.4) - activemodel (= 6.1.7.4) - activerecord (= 6.1.7.4) - activestorage (= 6.1.7.4) - activesupport (= 6.1.7.4) + rails (7.0.5) + actioncable (= 7.0.5) + actionmailbox (= 7.0.5) + actionmailer (= 7.0.5) + actionpack (= 7.0.5) + actiontext (= 7.0.5) + actionview (= 7.0.5) + activejob (= 7.0.5) + activemodel (= 7.0.5) + activerecord (= 7.0.5) + activestorage (= 7.0.5) + activesupport (= 7.0.5) bundler (>= 1.15.0) - railties (= 6.1.7.4) - sprockets-rails (>= 2.0.0) + railties (= 7.0.5) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -315,16 +312,19 @@ GEM rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging - rails_autolink (1.1.6) - rails (> 3.1) + rails_autolink (1.1.8) + actionview (> 3.1) + activesupport (> 3.1) + railties (> 3.1) rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (6.1.7.4) - actionpack (= 6.1.7.4) - activesupport (= 6.1.7.4) + railties (7.0.5) + actionpack (= 7.0.5) + activesupport (= 7.0.5) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) ransack (2.6.0) @@ -346,7 +346,8 @@ GEM rack (>= 1.4) responders (3.1.0) actionpack (>= 5.2) - railties (>= 5.2) + railties (>= 5.2) + responds_to_parent (1.1.0) rexml (3.2.6) rspec (3.12.0) rspec-core (~> 3.12.0) @@ -424,9 +425,11 @@ GEM sshkit (1.21.5) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - temple (0.8.2) + temple (0.10.2) + terrapin (0.6.0) + climate_control (>= 0.0.3, < 1.0) thor (1.2.2) - tilt (2.0.10) + tilt (2.1.0) timecop (0.9.6) timeout (0.4.0) tzinfo (2.0.6) @@ -460,7 +463,7 @@ DEPENDENCIES activejob activemodel-serializers-xml acts-as-taggable-on (>= 3.4.3) - acts_as_commentable! + acts_as_commentable acts_as_list bootsnap bootstrap (= 5.0.0) @@ -502,7 +505,7 @@ DEPENDENCIES premailer pry-rails puma - rails (~> 6.1.0) + rails (~> 7.0.0) rails-controller-testing rails-i18n rails-observers @@ -510,13 +513,13 @@ DEPENDENCIES rails_12factor rails_autolink rainbow - ransack (>= 1.6.2) + ransack (~> 2.0) ransack_ui rb-fchange rb-fsevent rb-inotify responders (~> 3.0) - responds_to_parent! + responds_to_parent rspec-activemodel-mocks rspec-rails rubocop diff --git a/app/models/fields/custom_field.rb b/app/models/fields/custom_field.rb index 7be39fe4c4..d320e2d9ca 100644 --- a/app/models/fields/custom_field.rb +++ b/app/models/fields/custom_field.rb @@ -49,6 +49,8 @@ # since changing the type of the database column would cause data to be lost. # +require_relative 'field' + class CustomField < Field delegate :table_name, to: :klass diff --git a/app/models/users/user.rb b/app/models/users/user.rb index 7c634ec60c..e274727fbe 100644 --- a/app/models/users/user.rb +++ b/app/models/users/user.rb @@ -61,7 +61,7 @@ class User < ActiveRecord::Base has_many :opportunities has_many :assigned_opportunities, class_name: 'Opportunity', foreign_key: 'assigned_to' has_many :permissions, dependent: :destroy - has_many :preferences, dependent: :destroy + has_many :preferences, class_name: 'Preference', dependent: :destroy has_many :lists has_and_belongs_to_many :groups diff --git a/bin/rails b/bin/rails index a31728ab97..efc0377492 100755 --- a/bin/rails +++ b/bin/rails @@ -1,6 +1,4 @@ #!/usr/bin/env ruby -# frozen_string_literal: true - -APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake index c199955006..4fbf10b960 100755 --- a/bin/rake +++ b/bin/rake @@ -1,6 +1,4 @@ #!/usr/bin/env ruby -# frozen_string_literal: true - -require_relative '../config/boot' -require 'rake' +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/bin/setup b/bin/setup index ac9f62467c..ec47b79b3b 100755 --- a/bin/setup +++ b/bin/setup @@ -1,38 +1,33 @@ #!/usr/bin/env ruby -# frozen_string_literal: true - -require 'fileutils' +require "fileutils" # path to your application root. -APP_ROOT = File.expand_path('..', __dir__) +APP_ROOT = File.expand_path("..", __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end FileUtils.chdir APP_ROOT do - # This script is a way to setup or update your development environment automatically. - # This script is idempotent, so that you can run it at anytime and get an expectable outcome. + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') - - # Install JavaScript dependencies - # system('bin/yarn') + 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') - # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" # end puts "\n== Preparing database ==" - system! 'bin/rails db:prepare' + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/config/application.rb b/config/application.rb index 80c5731238..b20f1f9d9b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,11 +1,4 @@ -# frozen_string_literal: true - -# Copyright (c) 2008-2013 Michael Dvorkin and contributors. -# -# Fat Free CRM is freely distributable under the terms of MIT license. -# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php -#------------------------------------------------------------------------------ -require_relative 'boot' +require_relative "boot" require 'rubygems' require 'rails/all' @@ -18,23 +11,16 @@ require "sprockets/railtie" require 'ransack' -# require "rails/test_unit/railtie" -# # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -# Override Rails Engines so that plugins have higher priority than the Application -require 'fat_free_crm/gem_ext/rails/engine' - module FatFreeCRM class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.0 - - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. + config.load_defaults 7.0 + config.generators.template_engine = :haml + config.autoloader = :zeitwerk # Models are organized in sub-directories config.autoload_paths += Dir[Rails.root.join("app/models/**")] + @@ -46,19 +32,12 @@ class Application < Rails::Application # Activate observers that should always be running. config.active_record.observers = :lead_observer, :opportunity_observer, :task_observer, :entity_observer unless ARGV.join.include?('assets:precompile') - # Load development rake tasks (RSpec, Gem packaging, etc.) - rake_tasks do - Dir.glob(Rails.root.join('lib', 'development_tasks', '*.rake')).each { |t| load t } + + Dir[Rails.root.join('lib', 'development_tasks', '*.rake')].each do |task| + load task end - # Add migrations from all engines - # Railties.engines.each do |engine| - # # config.paths['db/migrate'] += engine.paths['db/migrate'].existent - # end - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named. - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. @@ -87,7 +66,3 @@ class Application < Rails::Application ] end end - -# Require fat_free_crm after FatFreeCRM::Application class is defined, -# so that FatFreeCRM::Engine is skipped. -require 'fat_free_crm' diff --git a/config/boot.rb b/config/boot.rb index 783eaee77f..988a5ddc46 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,14 +1,4 @@ -# frozen_string_literal: true +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -# Copyright (c) 2008-2013 Michael Dvorkin and contributors. -# -# Fat Free CRM is freely distributable under the terms of MIT license. -# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php -#------------------------------------------------------------------------------ - -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) - -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) - -require 'bootsnap/setup' +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 0000000000..9a3d0773bb --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: test + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: fat_free_crm_production diff --git a/config/environment.rb b/config/environment.rb index 6d77f556fb..cac5315775 100755 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,12 +1,5 @@ -# frozen_string_literal: true +# Load the Rails application. +require_relative "application" -# Copyright (c) 2008-2013 Michael Dvorkin and contributors. -# -# Fat Free CRM is freely distributable under the terms of MIT license. -# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php -#------------------------------------------------------------------------------ -# Load the rails application -require_relative 'application' - -# Initialize the rails application +# Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 787792dae2..5e3be06e8d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,47 +1,36 @@ -# frozen_string_literal: true - -# Copyright (c) 2008-2013 Michael Dvorkin and contributors. -# -# Fat Free CRM is freely distributable under the terms of MIT license. -# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php -#------------------------------------------------------------------------------ -if defined?(FatFreeCRM::Application) - FatFreeCRM::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - config.eager_load = false - - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.cache_classes = false - - config.assets.quiet = true - - # Show full error reports and disable caching - config.consider_all_requests_local = true - config.action_controller.perform_caching = false +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. - config.action_mailer.delivery_method = :file - config.action_mailer.default_url_options = { host: 'localhost:3000' } + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false - # Don't care if the mailer can't send - config.action_mailer.raise_delivery_errors = false + # Do not eager load code on boot. + config.eager_load = false - # Print deprecation notices to the Rails logger - config.active_support.deprecation = :log + # Show full error reports. + config.consider_all_requests_local = true - # Only use best-standards-support built into browsers - # config.action_dispatch.best_standards_support = :builtin + # Enable server timing + config.server_timing = true - # Raise an error on page load if there are pending migrations - config.active_record.migration_error = :page_load + # Enable/disable caching. By default caching is disabled. + # 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.enable_fragment_cache_logging = true - # Expands the lines which load the assets - config.assets.debug = true + config.cache_store = :memory_store + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true + config.cache_store = :null_store # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. @@ -51,4 +40,39 @@ # Store files locally. config.active_storage.service = :local end + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # 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 + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index f8db447e96..a8615f44ee 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,68 +1,93 @@ -# frozen_string_literal: true +require "active_support/core_ext/integer/time" -# Copyright (c) 2008-2013 Michael Dvorkin and contributors. -# -# Fat Free CRM is freely distributable under the terms of MIT license. -# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php -#------------------------------------------------------------------------------ -if defined?(FatFreeCRM::Application) - FatFreeCRM::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - config.eager_load = true +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. - # Code is not reloaded between requests - config.cache_classes = true + # Code is not reloaded between requests. + config.cache_classes = true - # Full error reports are enabled, since this is an internal application. - config.consider_all_requests_local = false - # Caching is turned on - config.action_controller.perform_caching = true + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true - # Disable Rails's static asset server (Apache or nginx will already do this) - config.public_file_server.enabled = true + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true - # Compress JavaScripts and CSS - config.assets.compress = 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 - # Don't fallback to assets pipeline if a precompiled asset is missed - config.assets.compile = false + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? - # Generate digests for assets URLs - config.assets.digest = true + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass - # Defaults to Rails.root.join("public/assets") - # config.assets.manifest = YOUR_PATH + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false - # 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 + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + # 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 - # See everything in the log (default is :info) - config.log_level = :info + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local - # Use a different logger for distributed setups - # config.logger = SyslogLogger.new + # Mount Action Cable outside main process or domain. + # config.action_cable.mount_path = nil + # config.action_cable.url = "wss://example.com/cable" + # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] - # Use a different cache store in production - # config.cache_store = :mem_cache_store + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true - # Enable serving of images, stylesheets, and JavaScripts from an asset server - # config.action_controller.asset_host = "http://assets.example.com" + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) - config.i18n.fallbacks = true + # Use a different cache store in production. + # config.cache_store = :mem_cache_store - # Send deprecation notices to registered listeners - config.active_support.deprecation = :notify + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "fat_free_crm_production" - # Do not dump schema after migrations. - config.active_record.dump_schema_after_migration = false + 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 raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # 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-name") + + 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 index 9abc693c2e..35264b4f7b 100755 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,63 +1,60 @@ -# frozen_string_literal: true - -# Copyright (c) 2008-2013 Michael Dvorkin and contributors. -# -# Fat Free CRM is freely distributable under the terms of MIT license. -# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php -#------------------------------------------------------------------------------ -if defined?(FatFreeCRM::Application) - FatFreeCRM::Application.configure do - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true - - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # 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.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 - config.action_controller.perform_caching = false - - # Raise exceptions instead of rendering exception templates - config.action_dispatch.show_exceptions = false - - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = 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 - - # Set default host for mailer specs - config.action_mailer.default_url_options = { host: "www.example.com" } - - # Randomize the order test cases are executed. - config.active_support.test_order = :random - - # Print deprecation notices to the stderr - config.active_support.deprecation = :stderr - - # Store uploaded files on the local file system in a temporary directory - config.active_storage.service = :test - - config.action_mailer.perform_caching = false - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true - end - - # Optionally load 'awesome_print' for debugging in development mode. - begin - require 'ruby-debug' - require 'ap' - rescue LoadError - end +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Turn false under Spring and add config.action_view.cache_template_loading = true. + config.cache_classes = false + + # Eager loading loads your whole application. When running a single test locally, + # this probably isn't necessary. It's a good idea to do in a continuous integration + # system, or in some way before deploying your code. + config.eager_load = ENV["CI"].present? + + # 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=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + + 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 + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true end diff --git a/config/initializers/action_mailer.rb b/config/initializers/action_mailer.rb index b6a5b79f2b..776437a436 100644 --- a/config/initializers/action_mailer.rb +++ b/config/initializers/action_mailer.rb @@ -11,6 +11,7 @@ # unless Rails.env.test? + require './app/models/setting.rb' smtp_settings = Setting.smtp || {} Rails.application.config.action_mailer.smtp_settings = smtp_settings.symbolize_keys if smtp_settings["address"].present? diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index f9daa07046..2eeef966fe 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,16 +1,12 @@ -# frozen_string_literal: true - # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path -# Add Yarn node_modules folder to the asset load path. -Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. -Rails.application.config.assets.precompile += %w[print.css] +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index f3bcce5465..54f47cf15f 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,31 +1,25 @@ -# frozen_string_literal: true # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header -# Rails.application.config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # If you are using webpack-dev-server then specify webpack-dev-server host -# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? - -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap and inline scripts +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true # end - -# If you are using UJS then enable automatic nonce generation -# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } - -# Set the nonce only to specific directives -# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) - -# Report CSP violations to a specified URI -# For further information see the following documentation: -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only -# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/custom_field_ransack_translations.rb b/config/initializers/custom_field_ransack_translations.rb index f601a36116..731c9c365d 100644 --- a/config/initializers/custom_field_ransack_translations.rb +++ b/config/initializers/custom_field_ransack_translations.rb @@ -6,6 +6,10 @@ # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php #------------------------------------------------------------------------------ # Load field names for custom fields, for Ransack search + +require './app/models/fields/custom_field.rb' +require './app/models/setting.rb' + if Setting.database_and_table_exists? Rails.application.config.after_initialize do I18n.backend.load_translations diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 7a4f47b4c2..adc6568ce8 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,6 +1,8 @@ -# frozen_string_literal: true - # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +# Configure parameters to be filtered from the log file. Use this to limit dissemination of +# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported +# notations and behaviors. +Rails.application.config.filter_parameters += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/config/initializers/gravatar.rb b/config/initializers/gravatar.rb index a5bda1eb81..7c62bd33c2 100644 --- a/config/initializers/gravatar.rb +++ b/config/initializers/gravatar.rb @@ -5,6 +5,8 @@ # Fat Free CRM is freely distributable under the terms of MIT license. # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php #------------------------------------------------------------------------------ + +require './lib/gravatar_image_tag.rb' GravatarImageTag.configure do |config| config.default_image = :mm # Set this to use your own default gravatar image rather then serving up Gravatar's default image [ 'http://example.com/images/default_gravitar.jpg', :identicon, :monsterid, :wavatar, 404 ]. config.filetype = nil # Set this if you require a specific image file format ['gif', 'jpg' or 'png']. Gravatar's default is png diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index aa7435fbc9..3860f659ea 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,17 +1,16 @@ -# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' +# inflect.acronym "RESTful" # end diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb index 93fc45d1a1..22a7b357fe 100644 --- a/config/initializers/locale.rb +++ b/config/initializers/locale.rb @@ -14,6 +14,8 @@ I18n.config.enforce_available_locales = false Rails.application.config.i18n.fallbacks = true +require './lib/fat_free_crm.rb' + FatFreeCRM.application.config.after_initialize do I18n.default_locale = Setting.locale I18n.fallbacks[:en] = [:"en-US"] diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb new file mode 100644 index 0000000000..0f8d420541 --- /dev/null +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -0,0 +1,148 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.0 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `7.0`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +# `button_to` view helper will render `