diff --git a/Rakefile b/Rakefile index 829f4601de6..1ce89f95d9b 100755 --- a/Rakefile +++ b/Rakefile @@ -32,7 +32,7 @@ require File.expand_path("config/application", __dir__) -Rails.application.load_rake_tasks +Rails.application.load_tasks Rake::Task[:default].clear task default: "test:suite:run" diff --git a/app/workers/rake_job.rb b/app/workers/rake_job.rb index 1c7525ae98b..1b414fa1431 100644 --- a/app/workers/rake_job.rb +++ b/app/workers/rake_job.rb @@ -55,7 +55,7 @@ module RakeJob ## # Load tasks if we don't find our task def load_task - Rails.application.load_rake_tasks unless task_loaded? + Rails.application.load_tasks unless task_loaded? task_loaded? && Rake::Task[task_name] end diff --git a/bin/brakeman b/bin/brakeman new file mode 100755 index 00000000000..ace1c9ba08a --- /dev/null +++ b/bin/brakeman @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +ARGV.unshift("--ensure-latest") + +load Gem.bin_path("brakeman", "brakeman") diff --git a/bin/rails b/bin/rails index 07396602377..efc0377492f 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -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 17240489f64..4fbf10b960e 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -require_relative '../config/boot' -require 'rake' +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/bin/rubocop b/bin/rubocop index 671f09c3ee7..40330c0ff1c 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -1,4 +1,8 @@ #!/usr/bin/env ruby -load File.expand_path("spring", __dir__) -require 'bundler/setup' -load Gem.bin_path('rubocop', 'rubocop') +require "rubygems" +require "bundler/setup" + +# explicit rubocop config increases performance slightly while avoiding config confusion. +ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup index 5826ce42c28..3a78631323e 100755 --- a/bin/setup +++ b/bin/setup @@ -1,13 +1,14 @@ #!/usr/bin/env ruby +require "fileutils" -# path to your application root. -APP_ROOT = File.expand_path('..', __dir__) +APP_ROOT = File.expand_path("..", __dir__) +APP_NAME = "open-project" def system!(*args) system(*args, exception: true) end -Dir.chdir APP_ROOT do +FileUtils.chdir APP_ROOT do # 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. @@ -29,4 +30,8 @@ Dir.chdir APP_ROOT do puts "\n== Restarting application server ==" system! "bin/rails restart" + + # puts "\n== Configuring puma-dev ==" + # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}" + # system "curl -Is https://#{APP_NAME}.test/up | head -n 1" end diff --git a/config/environments/development.rb b/config/environments/development.rb index 3f5a499780d..05271b71ffd 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -58,6 +58,7 @@ Rails.application.configure do "Cache-Control" => "public, max-age=#{2.days.to_i}" } else + config.action_controller.perform_caching = false config.cache_store = :null_store end @@ -99,7 +100,7 @@ Rails.application.configure do # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names - # config.action_view.annotate_rendered_view_with_filenames = true + 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 @@ -118,6 +119,9 @@ Rails.application.configure do if ENV["OPENPROJECT_DEV_EXTRA_HOSTS"].present? config.hosts.push(*ENV["OPENPROJECT_DEV_EXTRA_HOSTS"].split(",")) end + + # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. + config.generators.apply_rubocop_autocorrect_after_generate! end ActiveRecord::Base.logger = ActiveSupport::Logger.new($stdout) unless String(ENV.fetch("SILENCE_SQL_LOGS", nil)).to_bool diff --git a/config/initializers/new_framework_defaults_7_2.rb b/config/initializers/new_framework_defaults_7_2.rb new file mode 100644 index 00000000000..683cc7b6362 --- /dev/null +++ b/config/initializers/new_framework_defaults_7_2.rb @@ -0,0 +1,70 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.2 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.2`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +### +# Controls whether Active Job's `#perform_later` and similar methods automatically defer +# the job queuing to after the current Active Record transaction is committed. +# +# Example: +# Topic.transaction do +# topic = Topic.create(...) +# NewTopicNotificationJob.perform_later(topic) +# end +# +# In this example, if the configuration is set to `:never`, the job will +# be enqueued immediately, even though the `Topic` hasn't been committed yet. +# Because of this, if the job is picked up almost immediately, or if the +# transaction doesn't succeed for some reason, the job will fail to find this +# topic in the database. +# +# If `enqueue_after_transaction_commit` is set to `:default`, the queue adapter +# will define the behaviour. +# +# Note: Active Job backends can disable this feature. This is generally done by +# backends that use the same database as Active Record as a queue, hence they +# don't need this feature. +#++ +Rails.application.config.active_job.enqueue_after_transaction_commit = :default + +### +# Adds image/webp to the list of content types Active Storage considers as an image +# Prevents automatic conversion to a fallback PNG, and assumes clients support WebP, as they support gif, jpeg, and png. +# This is possible due to broad browser support for WebP, but older browsers and email clients may still not support +# WebP. Requires imagemagick/libvips built with WebP support. +#++ +Rails.application.config.active_storage.web_image_content_types = %w[image/png image/jpeg image/gif image/webp] + +### +# Enable validation of migration timestamps. When set, an ActiveRecord::InvalidMigrationTimestampError +# will be raised if the timestamp prefix for a migration is more than a day ahead of the timestamp +# associated with the current time. This is done to prevent forward-dating of migration files, which can +# impact migration generation and other migration commands. +# +# Applications with existing timestamped migrations that do not adhere to the +# expected format can disable validation by setting this config to `false`. +#++ +Rails.application.config.active_record.validate_migration_timestamps = true + +### +# Controls whether the PostgresqlAdapter should decode dates automatically with manual queries. +# +# Example: +# ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.select_value("select '2024-01-01'::date") #=> Date +# +# This query used to return a `String`. +#++ +Rails.application.config.active_record.postgresql_adapter_decode_dates = true + +### +# Enables YJIT as of Ruby 3.3, to bring sizeable performance improvements. If you are +# deploying to a memory constrained environment you may want to set this to `false`. +#++ +Rails.application.config.yjit = true diff --git a/lib/open_project/patches/mailer_controller_preview.rb b/lib/open_project/patches/mailer_controller_preview.rb index 04090d2d853..0cbb8082f5a 100644 --- a/lib/open_project/patches/mailer_controller_preview.rb +++ b/lib/open_project/patches/mailer_controller_preview.rb @@ -41,6 +41,6 @@ module OpenProject::Patches::MailerControllerCsp end end -OpenProject::Patches.patch_gem_version "rails", "7.1.5" do +OpenProject::Patches.patch_gem_version "rails", "7.2.2" do Rails::MailersController.include OpenProject::Patches::MailerControllerCsp end