From e9a21228ec1314af756bcd381061539fbdc11cef Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 22 Aug 2013 22:29:24 +0200 Subject: [PATCH 01/10] Rails4 migration. --- Gemfile | 19 ++++++++----------- app/controllers/application_controller.rb | 11 ++++------- app/controllers/tickets_controller.rb | 2 +- config/application.rb | 8 +------- config/environments/development.rb | 3 --- config/environments/test.rb | 3 --- config/routes.rb | 7 +++++++ 7 files changed, 21 insertions(+), 32 deletions(-) diff --git a/Gemfile b/Gemfile index 5690a0b8f..871a3b305 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,8 @@ source 'http://rubygems.org' -gem 'rails', '3.2.14' - -# preparation for rails 4 -#gem 'rails', '4.0.0.rc1' -#gem 'rails-observers' -#gem 'activerecord-session_store' +gem 'rails', '4.0.0' +gem 'rails-observers' +gem 'activerecord-session_store' gem 'eco' @@ -19,10 +16,8 @@ gem 'json' group :assets do # preparation for rails 4 -# gem 'sass-rails', '~> 4.0.0.rc1' -# gem 'coffee-rails', '~> 4.0.0.rc1' - gem 'sass-rails', '~> 3.2.4' - gem 'coffee-rails', '~> 3.2.2' + gem 'sass-rails', '~> 4.0.0' + gem 'coffee-rails', '~> 4.0.0' gem 'uglifier' end @@ -76,6 +71,8 @@ gem 'em-websocket' # in production environments by default. group :development, :test do + gem 'test-unit' + gem 'sqlite3' # code coverage @@ -92,4 +89,4 @@ group :development, :test do # gem 'em-websocket-client' end -gem 'thin' +gem 'puma' diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c37b92707..7c745bb82 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,7 +14,8 @@ class ApplicationController < ActionController::Base :mode_show_rendeder, :model_index_render - before_filter :log_request, :set_user, :session_update + skip_before_filter :verify_authenticity_token + before_filter :set_user, :session_update before_filter :cors_preflight_check after_filter :set_access_control_headers @@ -52,10 +53,6 @@ class ApplicationController < ActionController::Base Observer::Ticket::Notification.transaction end - def log_request - puts Time.now().to_s + ' ' + request.original_fullpath.to_s - end - # Finds the User with the ID stored in the session with the key # :current_user_id This is a common way to handle user login in # a Rails application; logging in sets the session value and @@ -257,7 +254,7 @@ class ApplicationController < ActionController::Base begin # create object - generic_object = object.new( object.param_cleanup(params) ) + generic_object = object.new( object.param_cleanup( params[object.to_s.downcase] ) ) # save object generic_object.save! @@ -280,7 +277,7 @@ class ApplicationController < ActionController::Base generic_object = object.find( params[:id] ) # save object - generic_object.update_attributes!( object.param_cleanup(params) ) + generic_object.update_attributes!( object.param_cleanup( params[object.to_s.downcase] ) ) model_update_render_item(generic_object) rescue Exception => e logger.error e.message diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index ecd5a144f..fe1c5dc08 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -53,7 +53,7 @@ class TicketsController < ApplicationController if params[:article] form_id = params[:article][:form_id] params[:article].delete(:form_id) - @article = Ticket::Article.new( params[:article] ) + @article = Ticket::Article.new( Ticket::Article.param_validation( params[:article] ) ) @article.ticket_id = @ticket.id # find attachments in upload cache diff --git a/config/application.rb b/config/application.rb index 660fa2180..9e9c33930 100644 --- a/config/application.rb +++ b/config/application.rb @@ -79,11 +79,5 @@ module Zammad # REST api path config.api_path = '/api/v1' - # Enable threaded mode - config.threadsafe! - - # catch all router files - config.paths['config/routes'] += Dir[Rails.root.join("config/routes/*.rb")] - end -end +end \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index c9d05dbe1..c3c5b2862 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,9 +6,6 @@ Zammad::Application.configure do # since you don't have to restart the web server when you make code changes. config.cache_classes = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true - # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false diff --git a/config/environments/test.rb b/config/environments/test.rb index f3e3b8f66..8e7ee2ef8 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -15,9 +15,6 @@ Zammad::Application.configure do config.assets.compile = true config.assets.digest = true - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true - # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = true diff --git a/config/routes.rb b/config/routes.rb index ecf3f32e4..58108ab4e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,4 +8,11 @@ Zammad::Application.routes.draw do # just remember to delete public/index.html. root :to => 'init#index', :via => :get + # load routes from external files + dir = File.expand_path('../', __FILE__) + files = Dir.glob( "#{dir}/routes/*.rb" ) + for file in files + require file + end + end \ No newline at end of file From d55cb0ec7569c0c99695406d5693ed9784c1c15e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 22 Aug 2013 22:56:54 +0200 Subject: [PATCH 02/10] Moved owner_id set to model based on current user. --- app/controllers/taskbar_controller.rb | 2 -- app/models/taskbar.rb | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/taskbar_controller.rb b/app/controllers/taskbar_controller.rb index 8b0f1cee7..92e3e53c1 100644 --- a/app/controllers/taskbar_controller.rb +++ b/app/controllers/taskbar_controller.rb @@ -18,7 +18,6 @@ class TaskbarController < ApplicationController end def create - params[:user_id] = current_user.id model_create_render(Taskbar,params) end @@ -26,7 +25,6 @@ class TaskbarController < ApplicationController taskbar = Taskbar.find( params[:id] ) return if !access(taskbar) - params[:user_id] = current_user.id taskbar.update_attributes!( Taskbar.param_cleanup(params) ) model_update_render_item(taskbar) end diff --git a/app/models/taskbar.rb b/app/models/taskbar.rb index c9cab98c4..fd4636739 100644 --- a/app/models/taskbar.rb +++ b/app/models/taskbar.rb @@ -3,11 +3,14 @@ class Taskbar < ApplicationModel store :state store :params - before_create :update_last_contact - before_update :update_last_contact + before_create :update_last_contact, :set_user + before_update :update_last_contact, :set_user private def update_last_contact self.last_contact = Time.now end + def set_user + self.user_id = UserInfo.current_user_id + end end From d769f23f8e0101ec1d26b2ca065b207fb83b8096 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 22 Aug 2013 22:58:14 +0200 Subject: [PATCH 03/10] Removed not needed debug info. --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7c745bb82..7405f5cf1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -92,7 +92,7 @@ class ApplicationController < ActionController::Base def authentication_check_only - puts 'authentication_check' + #puts 'authentication_check' session[:request_type] = 1 #puts params.inspect #puts session.inspect @@ -100,7 +100,7 @@ class ApplicationController < ActionController::Base # check http basic auth authenticate_with_http_basic do |username, password| - puts 'http basic auth check' + #puts 'http basic auth check' session[:request_type] = 2 userdata = User.authenticate( username, password ) From 4ca49d6136402529a1048bbc214318cb9a1fa242 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 22 Aug 2013 23:15:23 +0200 Subject: [PATCH 04/10] Moved to rails4. --- app/models/application_model.rb | 12 +++++++----- config/application.rb | 6 ------ config/environments/test_mysql.rb | 3 --- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/models/application_model.rb b/app/models/application_model.rb index b591d47f8..663e6ba58 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -7,6 +7,7 @@ require 'sessions' class ApplicationModel < ActiveRecord::Base self.abstract_class = true + before_create :check_attributes_protected, :cache_delete, :fill_up_user_create before_create :cache_delete, :fill_up_user_create before_update :cache_delete_before, :fill_up_user_update before_destroy :cache_delete_before @@ -16,12 +17,11 @@ class ApplicationModel < ActiveRecord::Base @@import_class_list = ['Ticket', 'Ticket::Article', 'History', 'Ticket::State', 'Ticket::Priority', 'Group', 'User' ] - # for import of other objects, remove 'id' - def self.attributes_protected_by_default + def check_attributes_protected if Setting.get('import_mode') && @@import_class_list.include?( self.name.to_s ) - ['type'] + # do noting, use id as it is else - ['id','type'] + self[:id] = nil end end @@ -71,7 +71,9 @@ returns data.delete( :created_at ) data.delete( :updated_by_id ) data.delete( :created_by_id ) - + if data.respond_to?('permit!') + data.permit! + end data end diff --git a/config/application.rb b/config/application.rb index 9e9c33930..dcbe54f32 100644 --- a/config/application.rb +++ b/config/application.rb @@ -61,12 +61,6 @@ module Zammad # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql - # Enforce whitelist mode for mass assignment. - # This will create an empty whitelist of attributes available for mass-assignment for all models - # in your app. As such, your models will need to explicitly whitelist or blacklist accessible - # parameters by using an attr_accessible or attr_protected declaration. - # config.active_record.whitelist_attributes = true - # Enable the asset pipeline config.assets.enabled = true diff --git a/config/environments/test_mysql.rb b/config/environments/test_mysql.rb index f3e3b8f66..8e7ee2ef8 100644 --- a/config/environments/test_mysql.rb +++ b/config/environments/test_mysql.rb @@ -15,9 +15,6 @@ Zammad::Application.configure do config.assets.compile = true config.assets.digest = true - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true - # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = true From 067576f6f480626b993e184ad3bd0705d381edba Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 15 Sep 2013 23:40:25 +0200 Subject: [PATCH 05/10] Moved to rails4 settings. --- config/environments/development.rb | 7 ------- config/environments/production.rb | 4 ---- config/environments/test.rb | 3 --- config/environments/test_mysql.rb | 3 --- 4 files changed, 17 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index c3c5b2862..14f3377f7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -19,13 +19,6 @@ Zammad::Application.configure do # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 - # Do not compress assets config.assets.compress = false diff --git a/config/environments/production.rb b/config/environments/production.rb index 4ecfb86e5..4c418a760 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -61,10 +61,6 @@ Zammad::Application.configure do # Send deprecation notices to registered listeners config.active_support.deprecation = :notify - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - # config.active_record.auto_explain_threshold_in_seconds = 0.5 - # autoload on config.dependency_loading = true end diff --git a/config/environments/test.rb b/config/environments/test.rb index 8e7ee2ef8..37bab79d2 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -27,9 +27,6 @@ Zammad::Application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - # Print deprecation notices to the stderr config.active_support.deprecation = :stderr diff --git a/config/environments/test_mysql.rb b/config/environments/test_mysql.rb index 8e7ee2ef8..37bab79d2 100644 --- a/config/environments/test_mysql.rb +++ b/config/environments/test_mysql.rb @@ -27,9 +27,6 @@ Zammad::Application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - # Print deprecation notices to the stderr config.active_support.deprecation = :stderr From b3bda95b7c18819282bd0f8ee95446fe118af30d Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 20 Sep 2013 08:29:09 +0200 Subject: [PATCH 06/10] Moved to extra directory to extend ruby core. --- app/controllers/application_controller.rb | 9 ++++++-- config/initializers/core_ext.rb | 6 ++++++ lib/core_ext/class.rb | 6 ++++++ lib/core_ext/string.rb | 22 ++++++++++++++++++++ lib/notification_factory.rb | 25 +---------------------- 5 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 config/initializers/core_ext.rb create mode 100644 lib/core_ext/class.rb create mode 100644 lib/core_ext/string.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c5eef56c2..cf2233f11 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -257,7 +257,7 @@ class ApplicationController < ActionController::Base begin # create object - generic_object = object.new( object.param_cleanup( params[object.to_s.downcase] ) ) + generic_object = object.new( object.param_cleanup( params[object.to_app_model] ) ) # save object generic_object.save! @@ -266,6 +266,7 @@ class ApplicationController < ActionController::Base rescue Exception => e puts e.message.inspect logger.error e.message + logger.error e.backtrace.inspect render :json => { :error => e.message }, :status => :unprocessable_entity end end @@ -280,10 +281,11 @@ class ApplicationController < ActionController::Base generic_object = object.find( params[:id] ) # save object - generic_object.update_attributes!( object.param_cleanup( params[object.to_s.downcase] ) ) + generic_object.update_attributes!( object.param_cleanup( params[object.to_app_model] ) ) model_update_render_item(generic_object) rescue Exception => e logger.error e.message + logger.error e.backtrace.inspect render :json => { :error => e.message }, :status => :unprocessable_entity end end @@ -298,6 +300,7 @@ class ApplicationController < ActionController::Base model_destory_render_item() rescue Exception => e logger.error e.message + logger.error e.backtrace.inspect render :json => { :error => e.message }, :status => :unprocessable_entity end end @@ -311,6 +314,7 @@ class ApplicationController < ActionController::Base model_show_render_item(generic_object) rescue Exception => e logger.error e.message + logger.error e.backtrace.inspect render :json => { :error => e.message }, :status => :unprocessable_entity end end @@ -324,6 +328,7 @@ class ApplicationController < ActionController::Base model_index_render_result( generic_object ) rescue Exception => e logger.error e.message + logger.error e.backtrace.inspect render :json => { :error => e.message }, :status => :unprocessable_entity end end diff --git a/config/initializers/core_ext.rb b/config/initializers/core_ext.rb new file mode 100644 index 000000000..15097b71d --- /dev/null +++ b/config/initializers/core_ext.rb @@ -0,0 +1,6 @@ +# load all core_ext extentions +Dir["#{Rails.root}/lib/core_ext/*"].each {|file| + if File.file?(file) + require file + end +} diff --git a/lib/core_ext/class.rb b/lib/core_ext/class.rb new file mode 100644 index 000000000..b1dac68b7 --- /dev/null +++ b/lib/core_ext/class.rb @@ -0,0 +1,6 @@ +class Class + def to_app_model + name = self.to_s.downcase + name.gsub( /::/, '_' ) + end +end diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb new file mode 100644 index 000000000..1a293d2fe --- /dev/null +++ b/lib/core_ext/string.rb @@ -0,0 +1,22 @@ +class String + def message_quote + quote = self.split("\n") + body_quote = '' + quote.each do |line| + body_quote = body_quote + '> ' + line + "\n" + end + body_quote + end + def word_wrap(*args) + options = args.extract_options! + unless args.blank? + options[:line_width] = args[0] || 82 + end + options.reverse_merge!(:line_width => 82) + + lines = self + lines.split("\n").collect do |line| + line.length > options[:line_width] ? line.gsub(/(.{1,#{options[:line_width]}})(\s+|$)/, "\\1\n").strip : line + end * "\n" + end +end diff --git a/lib/notification_factory.rb b/lib/notification_factory.rb index 1126a5b11..35d908a4d 100644 --- a/lib/notification_factory.rb +++ b/lib/notification_factory.rb @@ -1,26 +1,3 @@ -class String - def message_quote - quote = self.split("\n") - body_quote = '' - quote.each do |line| - body_quote = body_quote + '> ' + line + "\n" - end - body_quote - end - def word_wrap(*args) - options = args.extract_options! - unless args.blank? - options[:line_width] = args[0] || 82 - end - options.reverse_merge!(:line_width => 82) - - lines = self - lines.split("\n").collect do |line| - line.length > options[:line_width] ? line.gsub(/(.{1,#{options[:line_width]}})(\s+|$)/, "\\1\n").strip : line - end * "\n" - end -end - module NotificationFactory def self.build(data) @@ -85,4 +62,4 @@ module NotificationFactory true ) end -end \ No newline at end of file +end From d6d21e6cfe0d6747d8d6c524ee8cb491b4cffa7e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 20 Sep 2013 13:40:25 +0200 Subject: [PATCH 07/10] Improved to_app_model. --- lib/core_ext/class.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/core_ext/class.rb b/lib/core_ext/class.rb index b1dac68b7..b1c3c4695 100644 --- a/lib/core_ext/class.rb +++ b/lib/core_ext/class.rb @@ -1,6 +1,10 @@ class Class def to_app_model - name = self.to_s.downcase - name.gsub( /::/, '_' ) + camel_cased_word = self.to_s + camel_cased_word.gsub(/::/, '_'). + gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). + gsub(/([a-z\d])([A-Z])/,'\1_\2'). + tr("-", "_"). + downcase end end From 0b525ca3d9f971262d5d341692695c65b5646ae5 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 20 Sep 2013 13:40:58 +0200 Subject: [PATCH 08/10] Improved error handling. --- app/models/application_model.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 663e6ba58..ef8509653 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -39,6 +39,10 @@ returns def self.param_cleanup(params) + if params == nil + raise "No params for #{self.to_s}!" + end + # only use object attributes data = {} self.new.attributes.each {|item| From 0ed5cbe74148ad706679dca00f69700b8aa89940 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 20 Sep 2013 13:58:06 +0200 Subject: [PATCH 09/10] Fixed require of level 1. --- app/models/application_model.rb | 4 ---- app/models/sla.rb | 2 -- app/models/ticket.rb | 3 --- app/models/user.rb | 4 ---- config/application.rb | 4 ++-- 5 files changed, 2 insertions(+), 15 deletions(-) diff --git a/app/models/application_model.rb b/app/models/application_model.rb index ef8509653..c8601c1d2 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -1,9 +1,5 @@ # Copyright (C) 2013-2013 Zammad Foundation, http://zammad-foundation.org/ -require 'cache' -require 'user_info' -require 'sessions' - class ApplicationModel < ActiveRecord::Base self.abstract_class = true diff --git a/app/models/sla.rb b/app/models/sla.rb index af26476e0..455589f78 100644 --- a/app/models/sla.rb +++ b/app/models/sla.rb @@ -1,7 +1,5 @@ # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ -require 'cache' - class Sla < ApplicationModel store :condition store :data diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 3669c13ac..b27c4211c 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -1,8 +1,5 @@ # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ -require 'time_calculation' -require 'sla' - class Ticket < ApplicationModel before_create :check_generate, :check_defaults before_update :check_defaults diff --git a/app/models/user.rb b/app/models/user.rb index b89a2aa88..d25505e69 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,9 +1,5 @@ # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ -require 'sso' -require 'digest/sha2' -require 'organization' - class User < ApplicationModel include User::Assets extend User::Search diff --git a/config/application.rb b/config/application.rb index dcbe54f32..9655249a6 100644 --- a/config/application.rb +++ b/config/application.rb @@ -16,7 +16,7 @@ module Zammad # -- all .rb files in that directory are automatically loaded. # Custom directories with classes and modules you want to be autoloadable. - config.autoload_paths += Dir["#{config.root}/lib/**/"] + config.autoload_paths += Dir["#{config.root}/lib/*", "#{config.root}/lib/**/"] # config.autoload_paths += %W(#{config.root}/lib) # Only load the plugins named here, in the order given (default is alphabetical). @@ -74,4 +74,4 @@ module Zammad config.api_path = '/api/v1' end -end \ No newline at end of file +end From 1d6c4c68e7f6379c7e09b5aa748986f3022e2434 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 20 Sep 2013 14:54:33 +0200 Subject: [PATCH 10/10] Moved to rails4 default settings. --- config/environments/development.rb | 7 +++++-- config/environments/production.rb | 24 +++++++++++++++++++----- config/environments/test.rb | 5 +++++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 14f3377f7..32a81aad6 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,6 +6,9 @@ Zammad::Application.configure do # since you don't have to restart the web server when you make code changes. config.cache_classes = false + # Do not eager load code on boot. + config.eager_load = false + # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false @@ -16,8 +19,8 @@ Zammad::Application.configure do # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin + # Raise an error on page load if there are pending migrations + config.active_record.migration_error = :page_load # Do not compress assets config.assets.compress = false diff --git a/config/environments/production.rb b/config/environments/production.rb index 4c418a760..e57a56520 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,6 +4,12 @@ Zammad::Application.configure do # Code is not reloaded between requests config.cache_classes = true + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both thread web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true @@ -14,14 +20,18 @@ Zammad::Application.configure do # Compress JavaScripts and CSS config.assets.compress = true + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = false # Generate digests for assets URLs config.assets.digest = true - # Defaults to Rails.root.join("public/assets") - # config.assets.manifest = YOUR_PATH + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' # Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache @@ -32,6 +42,7 @@ Zammad::Application.configure do # See everything in the log (default is :info) # config.log_level = :debug + config.log_level = :info # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] @@ -51,9 +62,6 @@ Zammad::Application.configure do # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false - # Enable threaded mode - # config.threadsafe! - # 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 @@ -61,6 +69,12 @@ Zammad::Application.configure do # Send deprecation notices to registered listeners config.active_support.deprecation = :notify + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + # autoload on config.dependency_loading = true + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new end diff --git a/config/environments/test.rb b/config/environments/test.rb index 37bab79d2..970488c3b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -7,6 +7,11 @@ Zammad::Application.configure do # 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 asset server for tests with Cache-Control for performance config.serve_static_assets = true config.static_cache_control = "public, max-age=3600"