diff --git a/.circleci/config.yml b/.circleci/config.yml index f595ae07..4586a22b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,19 +16,12 @@ workflows: database-migration: true database-migration-command: "SKIP_CUSTOM_INIT=true bundle exec rails db:schema:load --trace" rspec-system-args: "SIMPLE_COV_RUN=true" - cc-report-collect-ruby: "2.7.5-node" + cc-report-collect-ruby: "3.0.0-node" cc-report-collect-rails: "~> 6" matrix: parameters: - ruby-version: ["2.7.5-node" , "3.0.0-node", "3.0.3-node"] - rails-version: ["~> 5.2", "~> 6.0.0" , "~> 6"] - exclude: - - ruby-version: "3.0.0-node" - rails-version: "~> 5.2" - - ruby-version: "3.0.3-node" - rails-version: "~> 5.2" - - ruby-version: "3.1.0-node" - rails-version: "~> 5.2" + ruby-version: ["2.7.5-node" , "3.0.0-node", "3.0.3-node", "3.1.2-node"] + rails-version: ["~> 6.0.0" , "~> 6", "~> 7.0.0", "~> 7"] alias: required-matrix-tests name: test-ruby<< matrix.ruby-version >>-rails<< matrix.rails-version >> - cst/publish-gem: diff --git a/Gemfile b/Gemfile index d573e218..0a212517 100644 --- a/Gemfile +++ b/Gemfile @@ -3,11 +3,15 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gemspec -gem 'rails', ENV.fetch("BUNDLER_RAILS_VERSION", '~> 6') - +gem 'rails', ENV.fetch("BUNDLER_RAILS_VERSION", '~> 7') +gem "pry" gem 'sidekiq' gem 'webrick' # needed to run with ruby 3 +gem 'net-smtp' +gem 'net-imap' +gem 'net-pop' + group :test do gem 'database_cleaner-active_record' gem 'null-logger', require: 'null_logger' diff --git a/Gemfile.lock b/Gemfile.lock index 52df3014..177e3b50 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rails_base (0.72.1) + rails_base (0.80.0) allow_numeric bootstrap (~> 4.6.0) browser @@ -13,6 +13,7 @@ PATH jquery-rails (~> 4.3, >= 4.3.3) jquery_mask_rails mysql2 + psych (< 4) rails rails-ujs (~> 0.1.0) redis (>= 4.2.5) @@ -26,83 +27,89 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (6.1.5.1) - actionpack (= 6.1.5.1) - activesupport (= 6.1.5.1) + actioncable (7.0.4) + actionpack (= 7.0.4) + activesupport (= 7.0.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.5.1) - actionpack (= 6.1.5.1) - activejob (= 6.1.5.1) - activerecord (= 6.1.5.1) - activestorage (= 6.1.5.1) - activesupport (= 6.1.5.1) + actionmailbox (7.0.4) + actionpack (= 7.0.4) + activejob (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) mail (>= 2.7.1) - actionmailer (6.1.5.1) - actionpack (= 6.1.5.1) - actionview (= 6.1.5.1) - activejob (= 6.1.5.1) - activesupport (= 6.1.5.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.4) + actionpack (= 7.0.4) + actionview (= 7.0.4) + activejob (= 7.0.4) + activesupport (= 7.0.4) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.5.1) - actionview (= 6.1.5.1) - activesupport (= 6.1.5.1) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.4) + actionview (= 7.0.4) + activesupport (= 7.0.4) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.5.1) - actionpack (= 6.1.5.1) - activerecord (= 6.1.5.1) - activestorage (= 6.1.5.1) - activesupport (= 6.1.5.1) + actiontext (7.0.4) + actionpack (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.5.1) - activesupport (= 6.1.5.1) + actionview (7.0.4) + activesupport (= 7.0.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.5.1) - activesupport (= 6.1.5.1) + activejob (7.0.4) + activesupport (= 7.0.4) globalid (>= 0.3.6) - activemodel (6.1.5.1) - activesupport (= 6.1.5.1) - activerecord (6.1.5.1) - activemodel (= 6.1.5.1) - activesupport (= 6.1.5.1) - activestorage (6.1.5.1) - actionpack (= 6.1.5.1) - activejob (= 6.1.5.1) - activerecord (= 6.1.5.1) - activesupport (= 6.1.5.1) + activemodel (7.0.4) + activesupport (= 7.0.4) + activerecord (7.0.4) + activemodel (= 7.0.4) + activesupport (= 7.0.4) + activestorage (7.0.4) + actionpack (= 7.0.4) + activejob (= 7.0.4) + activerecord (= 7.0.4) + activesupport (= 7.0.4) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.5.1) + activesupport (7.0.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) allow_numeric (0.1.0) annotate (3.2.0) activerecord (>= 3.2, < 8.0) rake (>= 10.4, < 14.0) - autoprefixer-rails (10.4.2.0) + autoprefixer-rails (10.4.7.0) execjs (~> 2) - bcrypt (3.1.17) + bcrypt (3.1.18) bindex (0.8.1) - bootstrap (4.6.1) + bootstrap (4.6.2) autoprefixer-rails (>= 9.1.0) - popper_js (>= 1.14.3, < 2) + popper_js (>= 1.16.1, < 2) sassc-rails (>= 2.0.0) browser (5.3.1) builder (3.2.4) byebug (11.1.3) - capybara (3.36.0) + capybara (3.37.1) addressable matrix mini_mime (>= 0.1.3) @@ -111,6 +118,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + coderay (1.1.3) coffee-rails (5.0.0) coffee-script (>= 2.2.0) railties (>= 5.2.0) @@ -119,9 +127,9 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.1.10) - connection_pool (2.2.5) + connection_pool (2.3.0) crass (1.0.6) - dalli (3.2.1) + dalli (3.2.2) database_cleaner-active_record (2.0.1) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) @@ -137,47 +145,28 @@ GEM dotiw (5.3.3) activesupport i18n - erubi (1.10.0) + erubi (1.11.0) execjs (2.8.1) - faraday (1.10.0) - faraday-em_http (~> 1.0) - faraday-em_synchrony (~> 1.0) - faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0) - faraday-multipart (~> 1.0) - faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.0) - faraday-patron (~> 1.0) - faraday-rack (~> 1.0) - faraday-retry (~> 1.0) + faraday (2.6.0) + faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) - faraday-em_http (1.0.0) - faraday-em_synchrony (1.0.0) - faraday-excon (1.1.0) - faraday-httpclient (1.0.1) - faraday-multipart (1.0.3) - multipart-post (>= 1.2, < 3) - faraday-net_http (1.0.1) - faraday-net_http_persistent (1.2.0) - faraday-patron (1.0.0) - faraday-rack (1.0.0) - faraday-retry (1.0.3) + faraday-net_http (3.0.1) ffi (1.15.5) globalid (1.0.0) activesupport (>= 5.0) - i18n (1.10.0) + i18n (1.12.0) concurrent-ruby (~> 1.0) interactor (3.1.2) - jquery-rails (4.4.0) + jquery-rails (4.5.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery_mask_rails (0.1.0) - jwt (2.3.0) + jwt (2.5.0) listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.17.0) + loofah (2.19.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -186,35 +175,45 @@ GEM matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.2) - minitest (5.15.0) - multipart-post (2.1.1) - mysql2 (0.5.3) + minitest (5.16.3) + mysql2 (0.5.4) + net-imap (0.3.1) + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.1.3) + timeout + net-smtp (0.3.2) + net-protocol nio4r (2.5.8) - nokogiri (1.13.4-x86_64-linux) + nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) null-logger (0.1.7) orm_adapter (0.5.0) - popper_js (1.16.0) - public_suffix (4.0.7) + popper_js (1.16.1) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) + psych (3.3.4) + public_suffix (5.0.0) racc (1.6.0) - rack (2.2.3) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (6.1.5.1) - actioncable (= 6.1.5.1) - actionmailbox (= 6.1.5.1) - actionmailer (= 6.1.5.1) - actionpack (= 6.1.5.1) - actiontext (= 6.1.5.1) - actionview (= 6.1.5.1) - activejob (= 6.1.5.1) - activemodel (= 6.1.5.1) - activerecord (= 6.1.5.1) - activestorage (= 6.1.5.1) - activesupport (= 6.1.5.1) + rack (2.2.4) + rack-test (2.0.2) + rack (>= 1.3) + rails (7.0.4) + actioncable (= 7.0.4) + actionmailbox (= 7.0.4) + actionmailer (= 7.0.4) + actionpack (= 7.0.4) + actiontext (= 7.0.4) + actionview (= 7.0.4) + activejob (= 7.0.4) + activemodel (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) bundler (>= 1.15.0) - railties (= 6.1.5.1) - sprockets-rails (>= 2.0.0) + railties (= 7.0.4) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -222,45 +221,46 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) + rails-html-sanitizer (1.4.3) loofah (~> 2.3) rails-ujs (0.1.0) railties (>= 3.1) - railties (6.1.5.1) - actionpack (= 6.1.5.1) - activesupport (= 6.1.5.1) + railties (7.0.4) + actionpack (= 7.0.4) + activesupport (= 7.0.4) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rake (13.0.6) - rb-fsevent (0.11.1) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - redis (4.6.0) - redis-namespace (1.8.2) - redis (>= 3.0.4) - regexp_parser (2.3.1) + redis (4.8.0) + redis-namespace (1.9.0) + redis (>= 4) + regexp_parser (2.6.0) responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) rspec-core (3.11.0) rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rspec-expectations (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-mocks (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) - rspec-rails (5.1.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.11.0) - rspec_junit_formatter (0.5.1) + rspec-rails (6.0.0) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.11) + rspec-expectations (~> 3.11) + rspec-mocks (~> 3.11) + rspec-support (~> 3.11) + rspec-support (3.11.1) + rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) ruby2_keywords (0.0.5) sass-rails (6.0.0) @@ -273,21 +273,21 @@ GEM sprockets (> 3.0) sprockets-rails tilt - sidekiq (6.4.2) - connection_pool (>= 2.2.2) + sidekiq (6.5.7) + connection_pool (>= 2.2.5) rack (~> 2.0) - redis (>= 4.2.0) + redis (>= 4.5.0, < 5) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - spring (2.1.1) - spring-watcher-listen (2.0.1) + spring (4.1.0) + spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) - sprockets (4.0.3) + spring (>= 4) + sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.4.2) @@ -296,16 +296,17 @@ GEM sprockets (>= 3.0.0) switch_user (1.5.4) thor (1.2.1) - tilt (2.0.10) + tilt (2.0.11) timecop (0.9.5) + timeout (0.3.0) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) - twilio-ruby (5.66.2) - faraday (>= 0.9, < 2.0) + twilio-ruby (5.72.1) + faraday (>= 0.9, < 3.0) jwt (>= 1.5, <= 2.5) nokogiri (>= 1.6, < 2.0) - tzinfo (2.0.4) + tzinfo (2.0.5) concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) @@ -322,7 +323,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.5.4) + zeitwerk (2.6.1) PLATFORMS x86_64-linux @@ -333,8 +334,12 @@ DEPENDENCIES capybara (>= 2.15) database_cleaner-active_record listen + net-imap + net-pop + net-smtp null-logger - rails (~> 6) + pry + rails (~> 7) rails-controller-testing rails_base! rspec-rails @@ -348,4 +353,4 @@ DEPENDENCIES webrick BUNDLED WITH - 2.3.8 + 2.3.23 diff --git a/app/assets/javascripts/rails_base/application.js b/app/assets/javascripts/rails_base/application.js index 82815324..72f040b4 100644 --- a/app/assets/javascripts/rails_base/application.js +++ b/app/assets/javascripts/rails_base/application.js @@ -11,7 +11,6 @@ // about supported directives. // // = require rails-ujs -// = require turbolinks // = require_tree . // = require jquery3 diff --git a/app/mailers/rails_base/application_mailer.rb b/app/mailers/rails_base/application_mailer.rb index 42e80d4e..9ad471d9 100644 --- a/app/mailers/rails_base/application_mailer.rb +++ b/app/mailers/rails_base/application_mailer.rb @@ -1,5 +1,5 @@ class RailsBase::ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' + default from: -> { Rails.configuration.action_mailer.smtp_settings[:user_name] } layout 'mailer' CONTACT_URL = [ diff --git a/app/mailers/rails_base/email_verification_mailer.rb b/app/mailers/rails_base/email_verification_mailer.rb index 383a1f4e..94f86f4f 100644 --- a/app/mailers/rails_base/email_verification_mailer.rb +++ b/app/mailers/rails_base/email_verification_mailer.rb @@ -1,5 +1,4 @@ class RailsBase::EmailVerificationMailer < RailsBase::ApplicationMailer - default from: Rails.configuration.mail_from def email_verification(user:, url:) @user = user diff --git a/app/mailers/rails_base/event_mailer.rb b/app/mailers/rails_base/event_mailer.rb index 34844f20..ee2fb8a4 100644 --- a/app/mailers/rails_base/event_mailer.rb +++ b/app/mailers/rails_base/event_mailer.rb @@ -1,6 +1,4 @@ class RailsBase::EventMailer < RailsBase::ApplicationMailer - default from: Rails.configuration.mail_from - def send_sso(user:, message:) @user = user @message = message diff --git a/app/models/user.rb b/app/models/user.rb index 277d46d7..1f725d7d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,6 @@ +require RailsBase::Engine.root.join('app','models','rails_base', 'application_record.rb') +require RailsBase::Engine.root.join('app','models','rails_base', 'user_constants.rb') + # == Schema Information # # Table name: users diff --git a/config/initializers/admin_action_helper.rb b/config/initializers/admin_action_helper.rb index 84c9eae6..72c9c500 100644 --- a/config/initializers/admin_action_helper.rb +++ b/config/initializers/admin_action_helper.rb @@ -1,88 +1,91 @@ -require 'rails_base/admin/action_helper' +Rails.application.config.to_prepare do + require 'rails_base/admin/action_helper' -proc = Proc.new do |req, params, admin_user, user, title, struct| - actions_mapping = { - index: 'Viewed Settings page', - edit_name: 'Modified name', - edit_password: 'Modified Password', - destroy_user: '!Destroyed User!' - } - - if actions_mapping.keys.include?(params[:action].to_sym) - { - admin_user: admin_user, - user: user, - action: actions_mapping[params[:action].to_sym] , - original_attribute: struct&.original_attribute, - new_attribute: struct&.new_attribute + proc = Proc.new do |req, params, admin_user, user, title, struct| + actions_mapping = { + index: 'Viewed Settings page', + edit_name: 'Modified name', + edit_password: 'Modified Password', + destroy_user: '!Destroyed User!' } - else - nil - end -end -# For all User Settings routes -params = { - proc: proc, - controller: RailsBase::UserSettingsController, - default: true -} -RailsBase::Admin::ActionHelper.new(**params).add! + if actions_mapping.keys.include?(params[:action].to_sym) + { + admin_user: admin_user, + user: user, + action: actions_mapping[params[:action].to_sym] , + original_attribute: struct&.original_attribute, + new_attribute: struct&.new_attribute + } + else + nil + end + end -proc = Proc.new do |req, params, admin_user, user, title, struct| - actions_mapping = { - update_attribute: "Updated [#{params[:attribute]}]", - update_name: 'Updated Name', - update_email: 'Updated Email', - update_phone: 'Updated Phone number', - index: 'Viewed Admin Index', - sso_send: 'Sent SSO to user' + # For all User Settings routes + params = { + proc: proc, + controller: RailsBase::UserSettingsController, + default: true } + RailsBase::Admin::ActionHelper.new(**params).add! + - if actions_mapping.keys.include?(params[:action].to_sym) - { - admin_user: admin_user, - user: struct&.user, - action: actions_mapping[params[:action].to_sym], - original_attribute: struct&.original_attribute, - new_attribute: struct&.new_attribute + proc = Proc.new do |req, params, admin_user, user, title, struct| + actions_mapping = { + update_attribute: "Updated [#{params[:attribute]}]", + update_name: 'Updated Name', + update_email: 'Updated Email', + update_phone: 'Updated Phone number', + index: 'Viewed Admin Index', + sso_send: 'Sent SSO to user' } - else - nil + + if actions_mapping.keys.include?(params[:action].to_sym) + { + admin_user: admin_user, + user: struct&.user, + action: actions_mapping[params[:action].to_sym], + original_attribute: struct&.original_attribute, + new_attribute: struct&.new_attribute + } + else + nil + end end -end -# For all Admin routes -params = { - proc: proc, - controller: RailsBase::AdminController, - default: true -} -RailsBase::Admin::ActionHelper.new(**params).add! + # For all Admin routes + params = { + proc: proc, + controller: RailsBase::AdminController, + default: true + } + RailsBase::Admin::ActionHelper.new(**params).add! -params = { - proc: nil, - title: 'Removed Phone from account', - controller: RailsBase::SecondaryAuthenticationController, - action: 'remove_phone_mfa', - default: true -} -RailsBase::Admin::ActionHelper.new(**params).add! + params = { + proc: nil, + title: 'Removed Phone from account', + controller: RailsBase::SecondaryAuthenticationController, + action: 'remove_phone_mfa', + default: true + } + RailsBase::Admin::ActionHelper.new(**params).add! -params = { - proc: nil, - title: 'Setting Phone on account', - controller: RailsBase::SecondaryAuthenticationController, - action: 'phone_registration', - default: true -} -RailsBase::Admin::ActionHelper.new(**params).add! + params = { + proc: nil, + title: 'Setting Phone on account', + controller: RailsBase::SecondaryAuthenticationController, + action: 'phone_registration', + default: true + } + RailsBase::Admin::ActionHelper.new(**params).add! -params = { - proc: nil, - title: 'Impersonation', - controller: RailsBase::SwitchUserController, - action: 'set_current_user', - default: true -} -RailsBase::Admin::ActionHelper.new(**params).add! + params = { + proc: nil, + title: 'Impersonation', + controller: RailsBase::SwitchUserController, + action: 'set_current_user', + default: true + } + RailsBase::Admin::ActionHelper.new(**params).add! +end diff --git a/docker-compose.yml b/docker-compose.yml index 2cb955ad..c434d777 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,7 +25,7 @@ x-common-environment: &common-environment SESSION_TIMEOUT_WARNING: "true" RAILS_MAX_THREADS: "1" REDIS_URL: "redis://redis" - BUNDLER_RAILS_VERSION: "~> 6" + BUNDLER_RAILS_VERSION: "~> 7" services: mysql: diff --git a/lib/rails_base.rb b/lib/rails_base.rb index d11b0269..9ca6a722 100644 --- a/lib/rails_base.rb +++ b/lib/rails_base.rb @@ -57,8 +57,6 @@ def self.route_exist?(path) def self.configure(&block) yield(config) if block_given? - - config.validate_configs! end def self.config diff --git a/lib/rails_base/admin/action_helper.rb b/lib/rails_base/admin/action_helper.rb index 567b7969..1c8e36fa 100644 --- a/lib/rails_base/admin/action_helper.rb +++ b/lib/rails_base/admin/action_helper.rb @@ -4,7 +4,8 @@ module RailsBase::Admin class ActionHelper ACTIONS_KEY = "___all_actions_#{(rand*10**10).to_i}___" CONTROLLER_ACTIONS_KEY = "___all_controller_actions__#{(rand*10**10).to_i}___" - DEFAULT_ALLOWED_KLASSES = [ApplicationController, RailsBaseApplicationController, ::SwitchUserController] + DEFAULT_ALLOWED_KLASSES = [::ApplicationController, RailsBaseApplicationController, ::SwitchUserController] + class << self def allowed_inherited_klasses DEFAULT_ALLOWED_KLASSES + (@allowed_klasses || []) diff --git a/lib/rails_base/configuration/mailer.rb b/lib/rails_base/configuration/mailer.rb index 07fc226c..7aa86313 100644 --- a/lib/rails_base/configuration/mailer.rb +++ b/lib/rails_base/configuration/mailer.rb @@ -8,8 +8,11 @@ class Mailer < Base CUSTOM_MAILER_METHOD = :deliver_me FROM_PROC = Proc.new do |val, _instance| - hash = Rails.configuration.action_mailer.default_options || {} - ACTION_MAILER_PROC.call(:default_options, hash.merge(from: val)) + options = Rails.configuration.action_mailer.default_options || {} + url_options = Rails.configuration.action_mailer.default_url_options || {} + ACTION_MAILER_PROC.call(:default_options, options.merge(from: val)) + domain = val.split("@")[-1] + ACTION_MAILER_PROC.call(:default_url_options, url_options.merge(host: domain)) end SMTP_OPTIONS_PROC = Proc.new do |field, val| diff --git a/lib/rails_base/engine.rb b/lib/rails_base/engine.rb index 12849160..dc9dd825 100644 --- a/lib/rails_base/engine.rb +++ b/lib/rails_base/engine.rb @@ -19,21 +19,24 @@ class Engine < ::Rails::Engine RailsBase.config if RailsBase.___execute_initializer___? end - initializer 'rails_base.config.remove_write_acess', after: 'after_initialize' do |app| + config.after_initialize do + RailsBase.config.validate_configs! RailsBase::Configuration::Base._unset_allow_write! if RailsBase.___execute_initializer___? end initializer 'rails_base.magic_convenience_methods.model', after: 'active_record.initialize_database' do |app| if RailsBase.___execute_initializer___? # need to eager load Models - Rails.application.eager_load! + Rails.application.config.to_prepare do + # Rails.application.eager_load! - # create a connection - ActiveRecord::Base.retrieve_connection + # create a connection + ActiveRecord::Base.retrieve_connection - #explicitly load engine routes - RailsBase::ApplicationRecord.descendants.each do |model| - model._magically_defined_time_objects + #explicitly load engine routes + RailsBase::ApplicationRecord.descendants.each do |model| + model._magically_defined_time_objects + end end end end diff --git a/lib/rails_base/version.rb b/lib/rails_base/version.rb index 8f53ef76..e0153d99 100644 --- a/lib/rails_base/version.rb +++ b/lib/rails_base/version.rb @@ -1,6 +1,6 @@ module RailsBase MAJOR = '0' - MINOR = '74' + MINOR = '80' PATCH = '0' VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}" diff --git a/rails_base.gemspec b/rails_base.gemspec index 5ab2b1ca..9229da37 100644 --- a/rails_base.gemspec +++ b/rails_base.gemspec @@ -35,6 +35,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'redis', '>= 4.2.5' spec.add_dependency 'redis-namespace', '>= 1.8.1' spec.add_dependency 'switch_user' + spec.add_dependency 'psych', "< 4" spec.add_development_dependency 'annotate' spec.add_development_dependency 'spring-watcher-listen' diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js index 01868ef5..67ce4675 100644 --- a/test/dummy/app/assets/javascripts/application.js +++ b/test/dummy/app/assets/javascripts/application.js @@ -12,5 +12,4 @@ // //= require rails-ujs //= require activestorage -//= require turbolinks //= require_tree . diff --git a/test/dummy/app/mailers/application_mailer.rb b/test/dummy/app/mailers/application_mailer.rb index 286b2239..00eb9b01 100644 --- a/test/dummy/app/mailers/application_mailer.rb +++ b/test/dummy/app/mailers/application_mailer.rb @@ -1,3 +1,5 @@ +require "net/smtp" + class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout 'mailer' diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 59016847..052562f1 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -34,6 +34,7 @@ config.action_mailer.raise_delivery_errors = false config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = { host: '' } # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/test/dummy/config/initializers/rails_base_config.rb b/test/dummy/config/initializers/rails_base_config.rb index cd6ccf02..85130d7b 100644 --- a/test/dummy/config/initializers/rails_base_config.rb +++ b/test/dummy/config/initializers/rails_base_config.rb @@ -1,5 +1,7 @@ -RailsBase.configure do |config| - config.owner.max = 3 - config.admin.admin_type_tile_users = ->(user) { user.active && user.at_least_super? } - config.admin.default_admin_type = :super -end +# Rails.application.config.to_prepare do + RailsBase.configure do |config| + config.owner.max = 3 + config.admin.admin_type_tile_users = ->(user) { user.active && user.at_least_super? } + config.admin.default_admin_type = :super + end +# end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index cbc1b2ba..384beee0 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -2,17 +2,16 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_04_06_015744) do - - create_table "admin_actions", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| +ActiveRecord::Schema[7.0].define(version: 2021_04_06_015744) do + create_table "admin_actions", charset: "utf8", force: :cascade do |t| t.bigint "admin_user_id", null: false t.bigint "user_id" t.string "action", null: false @@ -25,7 +24,7 @@ t.index ["user_id"], name: "index_admin_actions_on_user_id" end - create_table "secrets", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "secrets", charset: "utf8", force: :cascade do |t| t.integer "version" t.text "secret" t.string "name" @@ -33,7 +32,7 @@ t.datetime "updated_at", null: false end - create_table "short_lived_data", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "short_lived_data", charset: "utf8", force: :cascade do |t| t.integer "user_id", null: false t.string "data", null: false t.string "reason" @@ -47,7 +46,7 @@ t.index ["data"], name: "index_short_lived_data_on_data" end - create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "users", charset: "utf8", force: :cascade do |t| t.string "first_name", default: "", null: false t.string "last_name", default: "", null: false t.string "phone_number"