From ca4e08767961bf1dd4f360f119d43be62e36218e Mon Sep 17 00:00:00 2001 From: Stanley Date: Fri, 20 Sep 2024 15:50:47 +0800 Subject: [PATCH] Remove Test ENV condition --- app/controllers/users_controller.rb | 4 +--- .../gem_ext/action_controller/base.rb | 16 +++++++--------- lib/fat_free_crm/mail_processor/base.rb | 16 ++++++---------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e7767b207c..cf70b59644 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -63,9 +63,7 @@ def upload_avatar end end responds_to_parent do - # Without return RSpec2 screams bloody murder about rendering twice: - # within the block and after yield in responds_to_parent. - render && (return if Rails.env.test?) + render end end end diff --git a/lib/fat_free_crm/gem_ext/action_controller/base.rb b/lib/fat_free_crm/gem_ext/action_controller/base.rb index 19cf93cf8a..1155e5ba75 100755 --- a/lib/fat_free_crm/gem_ext/action_controller/base.rb +++ b/lib/fat_free_crm/gem_ext/action_controller/base.rb @@ -5,14 +5,12 @@ # 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 #------------------------------------------------------------------------------ -unless Rails.env.test? - class ActionController::Base - # Remove helpers residing in subdirectories from the list of application - # helpers. Basically we don't want helpers in app/helpers/admin/* to - # override the ones in app/helpers/*. - #---------------------------------------------------------------------------- - def self.all_application_helpers - super.delete_if { |helper| helper.include?(File::SEPARATOR) } - end +class ActionController::Base + # Remove helpers residing in subdirectories from the list of application + # helpers. Basically we don't want helpers in app/helpers/admin/* to + # override the ones in app/helpers/*. + #---------------------------------------------------------------------------- + def self.all_application_helpers + super.delete_if { |helper| helper.include?(File::SEPARATOR) } end end diff --git a/lib/fat_free_crm/mail_processor/base.rb b/lib/fat_free_crm/mail_processor/base.rb index dea333294d..2f4c00905e 100644 --- a/lib/fat_free_crm/mail_processor/base.rb +++ b/lib/fat_free_crm/mail_processor/base.rb @@ -104,10 +104,8 @@ def with_new_emails discard(uid) end rescue Exception => e - if %w[test development].include?(Rails.env) - warn e - warn e.backtrace - end + warn e + warn e.backtrace log "error processing email: #{e.inspect}", email discard(uid) end @@ -181,12 +179,10 @@ def sender_has_permissions_for?(asset) # Centralized logging. #-------------------------------------------------------------------------------------- def log(message, email = nil) - unless %w[test cucumber].include?(Rails.env) - klass = self.class.to_s.split("::").last - klass << " [Dry Run]" if @dry_run - puts "[#{Time.now.rfc822}] #{klass}: #{message}" - puts "[#{Time.now.rfc822}] #{klass}: From: #{email.from}, Subject: #{email.subject} (#{email.message_id})" if email - end + klass = self.class.to_s.split("::").last + klass << " [Dry Run]" if @dry_run + Rails.logger.info("[#{Time.now.rfc822}] #{klass}: #{message}") + Rails.logger.info("[#{Time.now.rfc822}] #{klass}: From: #{email.from}, Subject: #{email.subject} (#{email.message_id})") if email end # Returns the plain-text version of an email, or strips html tags