From 30fe1de0b88649837fc8bdc8d70ddcee6a98cee6 Mon Sep 17 00:00:00 2001 From: Nic Boie Date: Tue, 31 Jul 2018 22:15:14 -0500 Subject: [PATCH 01/11] Bump version for release, update readme --- README.md | 20 ++++++++--------- activeadmin-mongoid.gemspec | 2 +- lib/active_admin/mongoid/version.rb | 2 +- test_app/Gemfile | 2 ++ test_app/Gemfile.lock | 35 +++++++++++++++-------------- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index fd334e8..c43a3c8 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ ActiveAdmin is holding off on pulling Mongoid support into the core ActiveAdmin application. This repo was pulled into the ActiveAdmin org from previous work done by Elia Schito, and will be maintained by Nic Boie, JD Guzman, Elia Schito and other ActiveAdmin and community members. -### Requirements for version 0.6.0 +### Requirements for version 0.7.0 * Ruby 2.2.2 or greater. (Note, ruby-2.4.0 fails specs, see [this issue](https://github.com/DatabaseCleaner/database_cleaner/issues/466)) -* Requires Rails 5.0.x (also tested working on Rails 5.1.x) +* Tested working on Rails 5.1.x * Mongoid 6.x (**WARNING**:, using a Mongoid version >= 6.1.x has resulted in a fair amount of errors seen in the wild. Test your upgrade very carefully with any apps in which you're using this gem with Mongoid >= 6.1.x!) * ActiveAdmin 1.3 @@ -17,7 +17,7 @@ ActiveAdmin is holding off on pulling Mongoid support into the core ActiveAdmin ## ♻️ INFO -This gem has been brought into the ActiveAdmin org for support and maintenance. +This gem has been brought into the ActiveAdmin org for support and maintenance. @@ -38,7 +38,7 @@ For more on Mongoid support in ActiveAdmin see [this issue](https://github.com/g Add the following gems to your application's Gemfile, and lock the version: ```ruby -gem 'activeadmin-mongoid', '0.4.0' +gem 'activeadmin-mongoid', '0.7.0' ``` You can safely remove the following lines, since are already activeadmin-mongoid dependencies: @@ -48,13 +48,13 @@ gem 'activeadmin' ``` ### Remove Application Dependencies -In your config/application.rb, replace : +In your config/application.rb, replace: ```ruby require 'rails/all' ``` -with : +with: ```ruby require "action_controller/railtie" @@ -64,7 +64,7 @@ require "sprockets/railtie" require "rails/test_unit/railtie" ``` -rails/all includes elements requiring ActiveRecord::Connection ... +NOTE: This gem will NOT work if you use both ActiveRecord AND Mongoid in the same app. rails/all includes elements requiring ActiveRecord::Connection ### Bundle & Crank @@ -81,10 +81,10 @@ You may find a line like this : require 'devise/orm/mongoid' ``` -Then create the admin user: +Then create an admin user: - $ rails console - >> AdminUser.create :email => 'admin@example.com', :password => 'password', :password_confirmation => 'password' + $ bundle exec rails console + >> AdminUser.create email: 'admin@example.com', password: 'password', password_confirmation: 'password' And that's pretty much it ! diff --git a/activeadmin-mongoid.gemspec b/activeadmin-mongoid.gemspec index fd276f4..4f4baf4 100644 --- a/activeadmin-mongoid.gemspec +++ b/activeadmin-mongoid.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |gem| gem.license = 'MIT' gem.add_runtime_dependency 'mongoid', ['~> 6.0'] - gem.add_runtime_dependency 'activeadmin', '~> 1.3.0' + gem.add_runtime_dependency 'activeadmin', '>= 1.3.0' gem.add_runtime_dependency 'jquery-rails' gem.add_runtime_dependency 'sass-rails', ['>= 3.1.4'] diff --git a/lib/active_admin/mongoid/version.rb b/lib/active_admin/mongoid/version.rb index ebb4a2f..68ba6fa 100644 --- a/lib/active_admin/mongoid/version.rb +++ b/lib/active_admin/mongoid/version.rb @@ -1,5 +1,5 @@ module ActiveAdmin module Mongoid - VERSION = '0.6.0' + VERSION = '0.7.0' end end diff --git a/test_app/Gemfile b/test_app/Gemfile index 02d4483..a7366a4 100644 --- a/test_app/Gemfile +++ b/test_app/Gemfile @@ -16,6 +16,8 @@ gem 'kaminari', '~> 1.0' gem 'kaminari-mongoid' gem 'ransack', '< 1.8.7' +gem 'sprockets', '>= 3.7.2' + # Gems used only for assets and not required # in production environments by default. gem 'sass-rails' diff --git a/test_app/Gemfile.lock b/test_app/Gemfile.lock index ecdcef5..761d61b 100644 --- a/test_app/Gemfile.lock +++ b/test_app/Gemfile.lock @@ -1,11 +1,11 @@ PATH remote: .. specs: - activeadmin-mongoid (0.5.0) - activeadmin (~> 1.2.0) + activeadmin-mongoid (0.6.0) + activeadmin (>= 1.3.0) jquery-rails - mongoid (~> 6.0.3) - sass-rails (>= 3.1.4, <= 5.0.6) + mongoid (~> 6.0) + sass-rails (>= 3.1.4) GEM remote: https://rubygems.org/ @@ -33,15 +33,15 @@ GEM erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activeadmin (1.2.1) + activeadmin (1.3.0) arbre (>= 1.1.1) coffee-rails formtastic (~> 3.1) formtastic_i18n - inherited_resources (~> 1.7) + inherited_resources (>= 1.7.0) jquery-rails (>= 4.2.0) - kaminari (>= 0.15, < 2.0) - railties (>= 4.2, < 5.2) + kaminari (>= 0.15) + railties (>= 4.2, < 5.3) ransack (~> 1.3) sass (~> 3.1) sprockets (< 4.1) @@ -64,7 +64,7 @@ GEM arbre (1.1.1) activesupport (>= 3.0.0) arel (8.0.0) - bcrypt (3.1.11) + bcrypt (3.1.12) bson (4.3.0) builder (3.2.3) capybara (2.15.1) @@ -85,10 +85,10 @@ GEM coffee-script-source (1.12.2) concurrent-ruby (1.0.5) crass (1.0.4) - devise (4.3.0) + devise (4.4.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.2) + railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) docile (1.1.5) @@ -151,7 +151,7 @@ GEM activemodel (~> 5.0) mongo (~> 2.3) nio4r (2.3.0) - nokogiri (1.8.2) + nokogiri (1.8.4) mini_portile2 (~> 2.3.0) orm_adapter (0.5.0) poltergeist (1.16.0) @@ -165,8 +165,8 @@ GEM method_source (~> 0.8.1) slop (~> 3.4) public_suffix (3.0.0) - rack (2.0.4) - rack-test (1.0.0) + rack (2.0.5) + rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.1.6) actioncable (= 5.1.6) @@ -221,7 +221,7 @@ GEM simplecov-html (~> 0.10.0) simplecov-html (0.10.2) slop (3.6.0) - sprockets (3.7.1) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) @@ -247,7 +247,7 @@ PLATFORMS ruby DEPENDENCIES - activeadmin (~> 1.2.0) + activeadmin (~> 1.3.0) activeadmin-mongoid! capybara coffee-rails @@ -265,7 +265,8 @@ DEPENDENCIES ransack (< 1.8.7) sass-rails simplecov + sprockets (>= 3.7.2) uglifier BUNDLED WITH - 1.16.1 + 1.16.3 From d924526efc1a817a558fa7b9b555165a3854fe55 Mon Sep 17 00:00:00 2001 From: Alex Kibler Date: Thu, 16 Nov 2023 09:32:51 -0700 Subject: [PATCH 02/11] Ensure searchable_method_name always returns a value --- lib/active_admin/mongoid/inputs/filters/select_input.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/active_admin/mongoid/inputs/filters/select_input.rb b/lib/active_admin/mongoid/inputs/filters/select_input.rb index 713fa8e..86c14e3 100644 --- a/lib/active_admin/mongoid/inputs/filters/select_input.rb +++ b/lib/active_admin/mongoid/inputs/filters/select_input.rb @@ -1,12 +1,16 @@ require 'active_admin/inputs/filters/select_input' class ActiveAdmin::Inputs::Filters::SelectInput + # Should never return a nil value - k1bs def searchable_method_name name = if searchable_has_many_through? "#{reflection.through_reflection.name}_#{reflection.foreign_key}" elsif reflection_searchable? reflection.key + else + method.to_s end + (name == '_id') ? 'id' : name end end From 9911c6da07008055bee15d5f9266f24115aca126 Mon Sep 17 00:00:00 2001 From: Alex Kibler Date: Wed, 29 Nov 2023 09:01:06 -0700 Subject: [PATCH 03/11] Ensure we aren't double populating relation attributes --- lib/active_admin/mongoid/controllers/resource_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_admin/mongoid/controllers/resource_controller.rb b/lib/active_admin/mongoid/controllers/resource_controller.rb index 9d9cac4..90e15fd 100644 --- a/lib/active_admin/mongoid/controllers/resource_controller.rb +++ b/lib/active_admin/mongoid/controllers/resource_controller.rb @@ -7,7 +7,7 @@ class ActiveAdmin::ResourceController def build_new_resource scoped_collection.send( method_for_build, - *resource_params + # *resource_params ) end end From 615656ae83bd12c413babde06783c9b32c0e034e Mon Sep 17 00:00:00 2001 From: Grzegorz Jakubiak Date: Thu, 5 Sep 2019 14:21:34 +0200 Subject: [PATCH 04/11] Delete select_input.rb --- .../mongoid/inputs/filters/select_input.rb | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 lib/active_admin/mongoid/inputs/filters/select_input.rb diff --git a/lib/active_admin/mongoid/inputs/filters/select_input.rb b/lib/active_admin/mongoid/inputs/filters/select_input.rb deleted file mode 100644 index 713fa8e..0000000 --- a/lib/active_admin/mongoid/inputs/filters/select_input.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'active_admin/inputs/filters/select_input' - -class ActiveAdmin::Inputs::Filters::SelectInput - def searchable_method_name - name = if searchable_has_many_through? - "#{reflection.through_reflection.name}_#{reflection.foreign_key}" - elsif reflection_searchable? - reflection.key - end - (name == '_id') ? 'id' : name - end -end From 9eb1b01a77ddd7f489982514f898e2a2d1d7908e Mon Sep 17 00:00:00 2001 From: Grzegorz Jakubiak Date: Thu, 5 Sep 2019 14:27:45 +0200 Subject: [PATCH 05/11] Remove require --- lib/active_admin/mongoid.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/active_admin/mongoid.rb b/lib/active_admin/mongoid.rb index fcf14c0..16e46df 100644 --- a/lib/active_admin/mongoid.rb +++ b/lib/active_admin/mongoid.rb @@ -16,7 +16,6 @@ require 'active_admin/mongoid/association/relatable' require 'active_admin/mongoid/inputs/filters/check_boxes_input' -require 'active_admin/mongoid/inputs/filters/select_input' require 'active_admin/mongoid/filters/active_filter' require 'active_admin/mongoid/filters/resource_extension' require 'active_admin/mongoid/controllers/resource_controller' From a66a6e06a8b52307793c0aaed1be59f44e1ba8f9 Mon Sep 17 00:00:00 2001 From: Nic Boie Date: Fri, 15 Dec 2023 11:23:46 -0600 Subject: [PATCH 06/11] Remove entries from count method --- lib/active_admin/mongoid/helpers/collection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_admin/mongoid/helpers/collection.rb b/lib/active_admin/mongoid/helpers/collection.rb index 10e5fd8..483bafa 100644 --- a/lib/active_admin/mongoid/helpers/collection.rb +++ b/lib/active_admin/mongoid/helpers/collection.rb @@ -8,7 +8,7 @@ module Collection def collection_size(collection = nil) collection ||= self.collection if collection.is_a?(::Mongoid::Criteria) - collection.entries.count + collection.count else original_collection_size(collection) end From dd48cee2f08690c40b180552881a63a0da6e6e2d Mon Sep 17 00:00:00 2001 From: Nic Boie Date: Mon, 12 Aug 2024 10:00:45 -0500 Subject: [PATCH 07/11] Allow mongoid 7 --- activeadmin-mongoid.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activeadmin-mongoid.gemspec b/activeadmin-mongoid.gemspec index 4f4baf4..4bb0e25 100644 --- a/activeadmin-mongoid.gemspec +++ b/activeadmin-mongoid.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |gem| gem.version = ActiveAdmin::Mongoid::VERSION gem.license = 'MIT' - gem.add_runtime_dependency 'mongoid', ['~> 6.0'] + gem.add_runtime_dependency 'mongoid', '>= 6.0', '< 8.a' gem.add_runtime_dependency 'activeadmin', '>= 1.3.0' gem.add_runtime_dependency 'jquery-rails' gem.add_runtime_dependency 'sass-rails', ['>= 3.1.4'] From 094761727d2eaa1825125513eab9f882f805288f Mon Sep 17 00:00:00 2001 From: Nic Boie Date: Mon, 12 Aug 2024 10:06:31 -0500 Subject: [PATCH 08/11] bundle installing with Ruby 3.0.x --- Gemfile.lock | 239 +++++++++++--------- activeadmin-mongoid.gemspec | 4 +- test_app/app/assets/config/manifest.js | 1 + test_app/config/environments/development.rb | 2 + test_app/config/environments/test.rb | 2 + 5 files changed, 135 insertions(+), 113 deletions(-) create mode 100644 test_app/app/assets/config/manifest.js diff --git a/Gemfile.lock b/Gemfile.lock index f85a85e..0d50522 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,7 @@ PATH remote: . specs: activeadmin-mongoid (1.0.0) - activeadmin (>= 1.4.3) + activeadmin (>= 1.3.0, <= 2.6.0) jquery-rails kaminari-mongoid mongoid (>= 6.0, < 8.a) @@ -17,25 +17,25 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (5.2.3) - actionpack (= 5.2.3) + actioncable (5.2.8.1) + actionpack (= 5.2.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) + actionmailer (5.2.8.1) + actionpack (= 5.2.8.1) + actionview (= 5.2.8.1) + activejob (= 5.2.8.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.3) - actionview (= 5.2.3) - activesupport (= 5.2.3) - rack (~> 2.0) + actionpack (5.2.8.1) + actionview (= 5.2.8.1) + activesupport (= 5.2.8.1) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.3) - activesupport (= 5.2.3) + actionview (5.2.8.1) + activesupport (= 5.2.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -51,45 +51,48 @@ GEM ransack (~> 2.1, >= 2.1.1) sassc-rails (~> 2.1) sprockets (>= 3.0, < 4.1) - activejob (5.2.3) - activesupport (= 5.2.3) + activejob (5.2.8.1) + activesupport (= 5.2.8.1) globalid (>= 0.3.6) - activemodel (5.2.3) - activesupport (= 5.2.3) - activerecord (5.2.3) - activemodel (= 5.2.3) - activesupport (= 5.2.3) + activemodel (5.2.8.1) + activesupport (= 5.2.8.1) + activerecord (5.2.8.1) + activemodel (= 5.2.8.1) + activesupport (= 5.2.8.1) arel (>= 9.0) - activestorage (5.2.3) - actionpack (= 5.2.3) - activerecord (= 5.2.3) - marcel (~> 0.3.1) - activesupport (5.2.3) + activestorage (5.2.8.1) + actionpack (= 5.2.8.1) + activerecord (= 5.2.8.1) + marcel (~> 1.0.0) + activesupport (5.2.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - arbre (1.2.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + arbre (1.7.0) activesupport (>= 3.0.0) + ruby2_keywords (>= 0.0.2) arel (9.0.0) ast (2.4.0) bcrypt (3.1.13) - bson (4.7.1) - builder (3.2.4) - capybara (3.12.0) + bson (5.0.1) + builder (3.3.0) + capybara (3.40.0) addressable + matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.2) + regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) cliver (0.3.2) coderay (1.1.2) - concurrent-ruby (1.1.6) + concurrent-ruby (1.3.4) crass (1.0.6) + date (3.3.4) devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -98,24 +101,24 @@ GEM warden (~> 1.2.3) diff-lcs (1.3) docile (1.3.1) - erubi (1.9.0) - ffi (1.12.1) + erubi (1.13.0) + ffi (1.17.0) formtastic (3.1.5) actionpack (>= 3.2.13) - formtastic_i18n (0.6.0) - globalid (0.4.2) - activesupport (>= 4.2.0) - has_scope (0.7.2) - actionpack (>= 4.1) - activesupport (>= 4.1) - i18n (1.8.2) + formtastic_i18n (0.7.0) + globalid (1.1.0) + activesupport (>= 5.0) + has_scope (0.8.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + i18n (1.14.5) concurrent-ruby (~> 1.0) - inherited_resources (1.11.0) - actionpack (>= 5.0, < 6.1) + inherited_resources (1.13.1) + actionpack (>= 5.2, < 7.1) has_scope (~> 0.6) - railties (>= 5.0, < 6.1) + railties (>= 5.2, < 7.1) responders (>= 2, < 4) - jaro_winkler (1.5.4) + jaro_winkler (1.5.6) jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -125,45 +128,56 @@ GEM jslint (1.2.0) json json (2.3.1) - kaminari (1.2.1) + kaminari (1.2.2) activesupport (>= 4.1.0) - kaminari-actionview (= 1.2.1) - kaminari-activerecord (= 1.2.1) - kaminari-core (= 1.2.1) - kaminari-actionview (1.2.1) + kaminari-actionview (= 1.2.2) + kaminari-activerecord (= 1.2.2) + kaminari-core (= 1.2.2) + kaminari-actionview (1.2.2) actionview - kaminari-core (= 1.2.1) - kaminari-activerecord (1.2.1) + kaminari-core (= 1.2.2) + kaminari-activerecord (1.2.2) activerecord - kaminari-core (= 1.2.1) - kaminari-core (1.2.1) - kaminari-mongoid (1.0.1) + kaminari-core (= 1.2.2) + kaminari-core (1.2.2) + kaminari-mongoid (1.0.2) kaminari-core (~> 1.0) mongoid launchy (2.4.3) addressable (~> 2.3) - loofah (2.5.0) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.2) method_source (0.9.2) - mimemagic (0.3.10) - nokogiri (~> 1) - rake - mini_mime (1.0.1) - mini_portile2 (2.4.0) - minitest (5.14.1) - mongo (2.11.3) - bson (>= 4.4.2, < 5.0.0) - mongoid (7.0.5) - activemodel (>= 5.1, < 6.1) - mongo (>= 2.5.1, < 3.0.0) - nio4r (2.3.1) - nokogiri (1.10.9) - mini_portile2 (~> 2.4.0) + mini_mime (1.1.5) + mini_portile2 (2.8.7) + minitest (5.24.1) + mongo (2.20.1) + bson (>= 4.14.1, < 6.0.0) + mongoid (7.5.4) + activemodel (>= 5.1, < 7.1, != 7.0.0) + mongo (>= 2.10.5, < 3.0.0) + ruby2_keywords (~> 0.0.5) + net-imap (0.4.14) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.16.7) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) orm_adapter (0.5.0) parallel (1.19.1) parser (2.7.0.2) @@ -179,42 +193,45 @@ GEM method_source (~> 0.9.0) pry-rails (0.3.8) pry (>= 0.10.4) - public_suffix (3.0.3) - rack (2.2.3) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (5.2.3) - actioncable (= 5.2.3) - actionmailer (= 5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) - activemodel (= 5.2.3) - activerecord (= 5.2.3) - activestorage (= 5.2.3) - activesupport (= 5.2.3) + public_suffix (6.0.1) + racc (1.8.1) + rack (2.2.9) + rack-test (2.1.0) + rack (>= 1.3) + rails (5.2.8.1) + actioncable (= 5.2.8.1) + actionmailer (= 5.2.8.1) + actionpack (= 5.2.8.1) + actionview (= 5.2.8.1) + activejob (= 5.2.8.1) + activemodel (= 5.2.8.1) + activerecord (= 5.2.8.1) + activestorage (= 5.2.8.1) + activesupport (= 5.2.8.1) bundler (>= 1.3.0) - railties (= 5.2.3) + railties (= 5.2.8.1) sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) - loofah (~> 2.3) - railties (5.2.3) - actionpack (= 5.2.3) - activesupport (= 5.2.3) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (5.2.8.1) + actionpack (= 5.2.8.1) + activesupport (= 5.2.8.1) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.0.0) - rake (12.3.3) + rake (13.2.1) ransack (2.3.2) activerecord (>= 5.2.1) activesupport (>= 5.2.1) i18n polyamorous (= 2.3.2) - regexp_parser (1.3.0) + regexp_parser (2.9.2) responders (2.4.1) actionpack (>= 4.2.0, < 6.0) railties (>= 4.2.0, < 6.0) @@ -245,9 +262,10 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) ruby-progressbar (1.10.1) + ruby2_keywords (0.0.5) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) - sassc (2.2.1) + sassc (2.4.0) ffi (~> 1.9) sassc-rails (2.1.2) railties (>= 4.0.0) @@ -260,22 +278,23 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - sprockets (3.7.2) + sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) sprockets (>= 3.0.0) - thor (0.20.3) + thor (1.3.1) thread_safe (0.3.6) - tilt (2.0.10) - tzinfo (1.2.7) + tilt (2.4.0) + timeout (0.4.1) + tzinfo (1.2.11) thread_safe (~> 0.1) unicode-display_width (1.6.1) warden (1.2.8) rack (>= 2.0.6) - websocket-driver (0.7.0) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) @@ -301,4 +320,4 @@ DEPENDENCIES simplecov BUNDLED WITH - 1.17.3 + 2.5.17 diff --git a/activeadmin-mongoid.gemspec b/activeadmin-mongoid.gemspec index 4894151..2c1a772 100644 --- a/activeadmin-mongoid.gemspec +++ b/activeadmin-mongoid.gemspec @@ -20,9 +20,7 @@ Gem::Specification.new do |gem| gem.required_ruby_version = '>= 2.4' gem.add_runtime_dependency 'mongoid', '>= 6.0', '< 8.a' - gem.add_runtime_dependency 'activeadmin', '>= 1.3.0' - gem.add_runtime_dependency 'jquery-rails' - gem.add_runtime_dependency 'sass-rails', ['>= 3.1.4'] + gem.add_runtime_dependency 'activeadmin', '>= 1.3.0', '<= 2.6.0' gem.add_runtime_dependency 'kaminari-mongoid' gem.add_runtime_dependency 'jquery-rails' gem.add_runtime_dependency 'sass-rails', ['>= 3.1.4'] diff --git a/test_app/app/assets/config/manifest.js b/test_app/app/assets/config/manifest.js new file mode 100644 index 0000000..e2c3235 --- /dev/null +++ b/test_app/app/assets/config/manifest.js @@ -0,0 +1 @@ +//= link active_admin.js diff --git a/test_app/config/environments/development.rb b/test_app/config/environments/development.rb index 8afe863..91850be 100644 --- a/test_app/config/environments/development.rb +++ b/test_app/config/environments/development.rb @@ -27,4 +27,6 @@ # Expands the lines which load the assets config.assets.debug = true + + config.eager_load = false end diff --git a/test_app/config/environments/test.rb b/test_app/config/environments/test.rb index 589d8a1..74e1057 100644 --- a/test_app/config/environments/test.rb +++ b/test_app/config/environments/test.rb @@ -33,4 +33,6 @@ # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + config.eager_load = false end From 0c79f67ca2e417286b68b2702c04922e5d54a227 Mon Sep 17 00:00:00 2001 From: Nic Boie Date: Mon, 9 Sep 2024 16:43:46 -0500 Subject: [PATCH 09/11] Updates for working with mongoid 7.x --- Gemfile | 4 +- Gemfile.lock | 130 +++++++++--------- docker-compose.yml | 13 ++ lib/active_admin/mongoid.rb | 1 + .../mongoid/inputs/filters/select_input.rb | 19 +++ test_app/app/models/post.rb | 9 ++ test_app/config/mongoid.6.yml | 2 +- 7 files changed, 114 insertions(+), 64 deletions(-) create mode 100644 docker-compose.yml create mode 100644 lib/active_admin/mongoid/inputs/filters/select_input.rb diff --git a/Gemfile b/Gemfile index 6de200c..1f230b5 100644 --- a/Gemfile +++ b/Gemfile @@ -2,9 +2,11 @@ source 'https://rubygems.org' gemspec -gem 'ransack-mongoid', git: 'https://github.com/activerecord-hackery/ransack-mongoid' +gem 'ransack-mongoid', path: "~/development/open_source/ransack-mongoid/"#, git: 'https://github.com/skalibog/ransack-mongoid' +gem 'ransack', '~> 2.1.0' gem 'rails', '>= 5.2', '< 6.1' +gem 'mongoid', '= 7.0.0' gem 'devise' diff --git a/Gemfile.lock b/Gemfile.lock index 0d50522..e7a2662 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,7 @@ -GIT - remote: https://github.com/activerecord-hackery/ransack-mongoid - revision: bd1935293d2f285fa7cf33d2c5c90d981bf67338 +PATH + remote: ../ransack-mongoid specs: - ransack-mongoid (0.1.0) + ransack-mongoid (0.1.2) PATH remote: . @@ -75,32 +74,34 @@ GEM activesupport (>= 3.0.0) ruby2_keywords (>= 0.0.2) arel (9.0.0) - ast (2.4.0) - bcrypt (3.1.13) + ast (2.4.2) + bcrypt (3.1.20) bson (5.0.1) builder (3.3.0) - capybara (3.40.0) + capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.11) + nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + childprocess (5.1.0) + logger (~> 1.5) cliver (0.3.2) - coderay (1.1.2) + coderay (1.1.3) concurrent-ruby (1.3.4) crass (1.0.6) date (3.3.4) - devise (4.7.1) + devise (4.9.4) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - diff-lcs (1.3) - docile (1.3.1) + diff-lcs (1.5.1) + docile (1.4.1) erubi (1.13.0) ffi (1.17.0) formtastic (3.1.5) @@ -119,15 +120,15 @@ GEM railties (>= 5.2, < 7.1) responders (>= 2, < 4) jaro_winkler (1.5.6) - jquery-rails (4.3.3) + jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (6.0.1) + jquery-ui-rails (7.0.0) railties (>= 3.2.16) jslint (1.2.0) json - json (2.3.1) + json (2.7.2) kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -143,8 +144,10 @@ GEM kaminari-mongoid (1.0.2) kaminari-core (~> 1.0) mongoid - launchy (2.4.3) - addressable (~> 2.3) + launchy (3.0.1) + addressable (~> 2.8) + childprocess (~> 5.0) + logger (1.6.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -155,16 +158,15 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.2) - method_source (0.9.2) + method_source (1.1.0) mini_mime (1.1.5) mini_portile2 (2.8.7) minitest (5.24.1) mongo (2.20.1) bson (>= 4.14.1, < 6.0.0) - mongoid (7.5.4) - activemodel (>= 5.1, < 7.1, != 7.0.0) - mongo (>= 2.10.5, < 3.0.0) - ruby2_keywords (~> 0.0.5) + mongoid (7.0.0) + activemodel (>= 5.1, < 6.0.0) + mongo (>= 2.5.1, < 3.0.0) net-imap (0.4.14) date net-protocol @@ -175,25 +177,24 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) - nokogiri (1.16.7) + nokogiri (1.15.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) orm_adapter (0.5.0) - parallel (1.19.1) - parser (2.7.0.2) - ast (~> 2.4.0) + parallel (1.26.2) + parser (3.3.4.2) + ast (~> 2.4.1) + racc poltergeist (1.18.1) capybara (>= 2.1, < 4) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) - polyamorous (2.3.2) - activerecord (>= 5.2.1) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-rails (0.3.8) - pry (>= 0.10.4) - public_suffix (6.0.1) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.11) + pry (>= 0.13.0) + public_suffix (5.1.1) racc (1.8.1) rack (2.2.9) rack-test (2.1.0) @@ -224,35 +225,36 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) - rainbow (3.0.0) + rainbow (3.1.1) rake (13.2.1) - ransack (2.3.2) - activerecord (>= 5.2.1) - activesupport (>= 5.2.1) + ransack (2.1.1) + actionpack (>= 5.0) + activerecord (>= 5.0) + activesupport (>= 5.0) i18n - polyamorous (= 2.3.2) regexp_parser (2.9.2) - responders (2.4.1) - actionpack (>= 4.2.0, < 6.0) - railties (>= 4.2.0, < 6.0) - rexml (3.2.5) - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.2) + responders (3.1.1) + actionpack (>= 5.2) + railties (>= 5.2) + rexml (3.3.5) + strscan + rspec-core (3.9.3) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.4) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.1) + rspec-support (~> 3.9.0) + rspec-rails (3.9.1) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.4) rubocop (0.80.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) @@ -261,7 +263,7 @@ GEM rexml ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) - ruby-progressbar (1.10.1) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) @@ -273,11 +275,12 @@ GEM sprockets (> 3.0) sprockets-rails tilt - simplecov (0.16.1) + simplecov (0.22.0) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -285,6 +288,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + strscan (3.1.0) thor (1.3.1) thread_safe (0.3.6) tilt (2.4.0) @@ -292,8 +296,8 @@ GEM tzinfo (1.2.11) thread_safe (~> 0.1) unicode-display_width (1.6.1) - warden (1.2.8) - rack (>= 2.0.6) + warden (1.2.9) + rack (>= 2.0.9) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -311,9 +315,11 @@ DEPENDENCIES jquery-ui-rails jslint launchy + mongoid (= 7.0.0) poltergeist pry-rails rails (>= 5.2, < 6.1) + ransack (~> 2.1.0) ransack-mongoid! rspec-rails (~> 3.6) rubocop (= 0.80.0) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e8b62d1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3' +services: + db: + image: mongo:6 + restart: unless-stopped + volumes: + - mongo5fission:/data/db + ports: + - "127.0.0.1:27017:27017" +volumes: + mongofission: + mongo5fission: + esdata: diff --git a/lib/active_admin/mongoid.rb b/lib/active_admin/mongoid.rb index 16e46df..fcf14c0 100644 --- a/lib/active_admin/mongoid.rb +++ b/lib/active_admin/mongoid.rb @@ -16,6 +16,7 @@ require 'active_admin/mongoid/association/relatable' require 'active_admin/mongoid/inputs/filters/check_boxes_input' +require 'active_admin/mongoid/inputs/filters/select_input' require 'active_admin/mongoid/filters/active_filter' require 'active_admin/mongoid/filters/resource_extension' require 'active_admin/mongoid/controllers/resource_controller' diff --git a/lib/active_admin/mongoid/inputs/filters/select_input.rb b/lib/active_admin/mongoid/inputs/filters/select_input.rb new file mode 100644 index 0000000..7a29960 --- /dev/null +++ b/lib/active_admin/mongoid/inputs/filters/select_input.rb @@ -0,0 +1,19 @@ +require 'active_admin/inputs/filters/select_input' + +class ActiveAdmin::Inputs::Filters::SelectInput + def searchable_method_name + if searchable_has_many_through? + "#{reflection.through_reflection.name}_#{reflection.foreign_key}" + else + reflection&.key || method + end + rescue => e + binding.pry + end + + def input_name + return method if seems_searchable? + + searchable_method_name&.to_s + (multiple? ? '_in' : '_eq') + end +end diff --git a/test_app/app/models/post.rb b/test_app/app/models/post.rb index 57b9704..2802148 100644 --- a/test_app/app/models/post.rb +++ b/test_app/app/models/post.rb @@ -10,4 +10,13 @@ class Post embeds_one :author field :'author.city.name' + + def self.ransack(*args) + + binding.pry unless args.first.empty? + + super + + end + end diff --git a/test_app/config/mongoid.6.yml b/test_app/config/mongoid.6.yml index 0ecd0c6..b361124 100644 --- a/test_app/config/mongoid.6.yml +++ b/test_app/config/mongoid.6.yml @@ -3,5 +3,5 @@ test: default: database: activeadmin_mongoid_test hosts: - - localhost:27017 + - db:27017 #scope_overwrite_exception: true From 813c2a1daa90bc76bfd900948d34eaa3c2477527 Mon Sep 17 00:00:00 2001 From: Nic Boie Date: Tue, 20 May 2025 17:22:09 -0500 Subject: [PATCH 10/11] Bump AA dep up to anything under 3 --- activeadmin-mongoid.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activeadmin-mongoid.gemspec b/activeadmin-mongoid.gemspec index 2c1a772..c85ff17 100644 --- a/activeadmin-mongoid.gemspec +++ b/activeadmin-mongoid.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |gem| gem.required_ruby_version = '>= 2.4' gem.add_runtime_dependency 'mongoid', '>= 6.0', '< 8.a' - gem.add_runtime_dependency 'activeadmin', '>= 1.3.0', '<= 2.6.0' + gem.add_runtime_dependency 'activeadmin', '>= 1.3.0', '<= 3.0.0' gem.add_runtime_dependency 'kaminari-mongoid' gem.add_runtime_dependency 'jquery-rails' gem.add_runtime_dependency 'sass-rails', ['>= 3.1.4'] From 1c73400e1daa21cd7a473e42b1e82b1330879326 Mon Sep 17 00:00:00 2001 From: Nic Boie Date: Mon, 9 Jun 2025 15:18:29 -0500 Subject: [PATCH 11/11] WIP: Working with Ruby 3.1 --- Gemfile | 7 +- Gemfile.lock | 186 ++++++++++-------- activeadmin-mongoid.gemspec | 4 +- lib/active_admin/mongoid/csv_builder.rb | 4 +- test_app/app/models/post.rb | 4 - test_app/bin/rails | 4 + test_app/bin/rake | 4 + test_app/bin/setup | 25 +++ test_app/config/boot.rb | 5 +- test_app/config/environment.rb | 6 +- .../application_controller_renderer.rb | 8 + test_app/config/initializers/assets.rb | 12 ++ .../initializers/content_security_policy.rb | 28 +++ .../config/initializers/cookies_serializer.rb | 5 + .../initializers/filter_parameter_logging.rb | 4 + test_app/config/initializers/inflections.rb | 11 +- .../new_framework_defaults_6_0.rb | 45 +++++ 17 files changed, 258 insertions(+), 104 deletions(-) create mode 100755 test_app/bin/rails create mode 100755 test_app/bin/rake create mode 100755 test_app/bin/setup create mode 100644 test_app/config/initializers/application_controller_renderer.rb create mode 100644 test_app/config/initializers/assets.rb create mode 100644 test_app/config/initializers/content_security_policy.rb create mode 100644 test_app/config/initializers/cookies_serializer.rb create mode 100644 test_app/config/initializers/filter_parameter_logging.rb create mode 100644 test_app/config/initializers/new_framework_defaults_6_0.rb diff --git a/Gemfile b/Gemfile index 1f230b5..f71cf65 100644 --- a/Gemfile +++ b/Gemfile @@ -5,9 +5,12 @@ gemspec gem 'ransack-mongoid', path: "~/development/open_source/ransack-mongoid/"#, git: 'https://github.com/skalibog/ransack-mongoid' gem 'ransack', '~> 2.1.0' -gem 'rails', '>= 5.2', '< 6.1' -gem 'mongoid', '= 7.0.0' +gem 'rails', '~> 6.0.3' +gem 'mongoid', '= 7.1.0' +gem 'concurrent-ruby', '1.3.4' +gem 'webrick', '~> 1.7' +gem 'mongo', '~> 2.16.4' gem 'devise' gem 'pry-rails' diff --git a/Gemfile.lock b/Gemfile.lock index e7a2662..940abbf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,7 @@ PATH remote: . specs: activeadmin-mongoid (1.0.0) - activeadmin (>= 1.3.0, <= 2.6.0) + activeadmin (>= 1.3.0, <= 2.8.0) jquery-rails kaminari-mongoid mongoid (>= 6.0, < 8.a) @@ -16,67 +16,81 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (5.2.8.1) - actionpack (= 5.2.8.1) + actioncable (6.0.6.1) + actionpack (= 6.0.6.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.8.1) - actionpack (= 5.2.8.1) - actionview (= 5.2.8.1) - activejob (= 5.2.8.1) + actionmailbox (6.0.6.1) + actionpack (= 6.0.6.1) + activejob (= 6.0.6.1) + activerecord (= 6.0.6.1) + activestorage (= 6.0.6.1) + activesupport (= 6.0.6.1) + mail (>= 2.7.1) + actionmailer (6.0.6.1) + actionpack (= 6.0.6.1) + actionview (= 6.0.6.1) + activejob (= 6.0.6.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.8.1) - actionview (= 5.2.8.1) - activesupport (= 5.2.8.1) + actionpack (6.0.6.1) + actionview (= 6.0.6.1) + activesupport (= 6.0.6.1) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.8.1) - activesupport (= 5.2.8.1) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.0.6.1) + actionpack (= 6.0.6.1) + activerecord (= 6.0.6.1) + activestorage (= 6.0.6.1) + activesupport (= 6.0.6.1) + nokogiri (>= 1.8.5) + actionview (6.0.6.1) + activesupport (= 6.0.6.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activeadmin (2.6.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activeadmin (2.8.0) arbre (~> 1.2, >= 1.2.1) - formtastic (~> 3.1) + formtastic (>= 3.1, < 5.0) formtastic_i18n (~> 0.4) inherited_resources (~> 1.7) jquery-rails (~> 4.2) - kaminari (~> 1.0, >= 1.0.1) + kaminari (~> 1.0, >= 1.2.1) railties (>= 5.2, < 6.1) ransack (~> 2.1, >= 2.1.1) sassc-rails (~> 2.1) sprockets (>= 3.0, < 4.1) - activejob (5.2.8.1) - activesupport (= 5.2.8.1) + activejob (6.0.6.1) + activesupport (= 6.0.6.1) globalid (>= 0.3.6) - activemodel (5.2.8.1) - activesupport (= 5.2.8.1) - activerecord (5.2.8.1) - activemodel (= 5.2.8.1) - activesupport (= 5.2.8.1) - arel (>= 9.0) - activestorage (5.2.8.1) - actionpack (= 5.2.8.1) - activerecord (= 5.2.8.1) - marcel (~> 1.0.0) - activesupport (5.2.8.1) + activemodel (6.0.6.1) + activesupport (= 6.0.6.1) + activerecord (6.0.6.1) + activemodel (= 6.0.6.1) + activesupport (= 6.0.6.1) + activestorage (6.0.6.1) + actionpack (= 6.0.6.1) + activejob (= 6.0.6.1) + activerecord (= 6.0.6.1) + marcel (~> 1.0) + activesupport (6.0.6.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) arbre (1.7.0) activesupport (>= 3.0.0) ruby2_keywords (>= 0.0.2) - arel (9.0.0) ast (2.4.2) + base64 (0.3.0) bcrypt (3.1.20) - bson (5.0.1) + bson (4.15.0) builder (3.3.0) capybara (3.39.2) addressable @@ -93,7 +107,7 @@ GEM coderay (1.1.3) concurrent-ruby (1.3.4) crass (1.0.6) - date (3.3.4) + date (3.4.1) devise (4.9.4) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -102,23 +116,23 @@ GEM warden (~> 1.2.3) diff-lcs (1.5.1) docile (1.4.1) - erubi (1.13.0) - ffi (1.17.0) - formtastic (3.1.5) - actionpack (>= 3.2.13) + erubi (1.13.1) + ffi (1.17.2) + formtastic (4.0.0) + actionpack (>= 5.2.0) formtastic_i18n (0.7.0) globalid (1.1.0) activesupport (>= 5.0) has_scope (0.8.2) actionpack (>= 5.2) activesupport (>= 5.2) - i18n (1.14.5) + i18n (1.14.7) concurrent-ruby (~> 1.0) - inherited_resources (1.13.1) - actionpack (>= 5.2, < 7.1) - has_scope (~> 0.6) - railties (>= 5.2, < 7.1) - responders (>= 2, < 4) + inherited_resources (1.14.0) + actionpack (>= 6.0) + has_scope (>= 0.6) + railties (>= 6.0) + responders (>= 2) jaro_winkler (1.5.6) jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) @@ -148,7 +162,7 @@ GEM addressable (~> 2.8) childprocess (~> 5.0) logger (1.6.0) - loofah (2.22.0) + loofah (2.24.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -160,24 +174,24 @@ GEM matrix (0.4.2) method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.7) - minitest (5.24.1) - mongo (2.20.1) - bson (>= 4.14.1, < 6.0.0) - mongoid (7.0.0) - activemodel (>= 5.1, < 6.0.0) - mongo (>= 2.5.1, < 3.0.0) - net-imap (0.4.14) + mini_portile2 (2.8.9) + minitest (5.25.5) + mongo (2.16.4) + bson (>= 4.8.2, < 5.0.0) + mongoid (7.1.0) + activemodel (>= 5.1, < 6.1) + mongo (>= 2.7.0, < 3.0.0) + net-imap (0.5.8) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.5.0) + net-smtp (0.5.1) net-protocol - nio4r (2.7.3) - nokogiri (1.15.6) + nio4r (2.7.4) + nokogiri (1.18.8) mini_portile2 (~> 2.8.2) racc (~> 1.4) orm_adapter (0.5.0) @@ -196,37 +210,39 @@ GEM pry (>= 0.13.0) public_suffix (5.1.1) racc (1.8.1) - rack (2.2.9) - rack-test (2.1.0) + rack (2.2.17) + rack-test (2.2.0) rack (>= 1.3) - rails (5.2.8.1) - actioncable (= 5.2.8.1) - actionmailer (= 5.2.8.1) - actionpack (= 5.2.8.1) - actionview (= 5.2.8.1) - activejob (= 5.2.8.1) - activemodel (= 5.2.8.1) - activerecord (= 5.2.8.1) - activestorage (= 5.2.8.1) - activesupport (= 5.2.8.1) + rails (6.0.6.1) + actioncable (= 6.0.6.1) + actionmailbox (= 6.0.6.1) + actionmailer (= 6.0.6.1) + actionpack (= 6.0.6.1) + actiontext (= 6.0.6.1) + actionview (= 6.0.6.1) + activejob (= 6.0.6.1) + activemodel (= 6.0.6.1) + activerecord (= 6.0.6.1) + activestorage (= 6.0.6.1) + activesupport (= 6.0.6.1) bundler (>= 1.3.0) - railties (= 5.2.8.1) + railties (= 6.0.6.1) sprockets-rails (>= 2.0.0) - rails-dom-testing (2.2.0) + rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.2) loofah (~> 2.21) - nokogiri (~> 1.14) - railties (5.2.8.1) - actionpack (= 5.2.8.1) - activesupport (= 5.2.8.1) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (6.0.6.1) + actionpack (= 6.0.6.1) + activesupport (= 6.0.6.1) method_source rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) + thor (>= 0.20.3, < 2.0) rainbow (3.1.1) - rake (13.2.1) + rake (13.3.0) ransack (2.1.1) actionpack (>= 5.0) activerecord (>= 5.0) @@ -289,20 +305,23 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) strscan (3.1.0) - thor (1.3.1) + thor (1.3.2) thread_safe (0.3.6) - tilt (2.4.0) - timeout (0.4.1) + tilt (2.6.0) + timeout (0.4.3) tzinfo (1.2.11) thread_safe (~> 0.1) unicode-display_width (1.6.1) warden (1.2.9) rack (>= 2.0.9) - websocket-driver (0.7.6) + webrick (1.9.1) + websocket-driver (0.8.0) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.6.18) PLATFORMS ruby @@ -310,20 +329,23 @@ PLATFORMS DEPENDENCIES activeadmin-mongoid! capybara + concurrent-ruby (= 1.3.4) devise jquery-rails jquery-ui-rails jslint launchy - mongoid (= 7.0.0) + mongo (~> 2.16.4) + mongoid (= 7.1.0) poltergeist pry-rails - rails (>= 5.2, < 6.1) + rails (~> 6.0.3) ransack (~> 2.1.0) ransack-mongoid! rspec-rails (~> 3.6) rubocop (= 0.80.0) simplecov + webrick (~> 1.7) BUNDLED WITH 2.5.17 diff --git a/activeadmin-mongoid.gemspec b/activeadmin-mongoid.gemspec index c85ff17..3495ff7 100644 --- a/activeadmin-mongoid.gemspec +++ b/activeadmin-mongoid.gemspec @@ -17,10 +17,10 @@ Gem::Specification.new do |gem| gem.version = ActiveAdmin::Mongoid::VERSION gem.license = 'MIT' - gem.required_ruby_version = '>= 2.4' + gem.required_ruby_version = '>= 3.0' gem.add_runtime_dependency 'mongoid', '>= 6.0', '< 8.a' - gem.add_runtime_dependency 'activeadmin', '>= 1.3.0', '<= 3.0.0' + gem.add_runtime_dependency 'activeadmin', '>= 1.3.0', '<= 2.8.0' gem.add_runtime_dependency 'kaminari-mongoid' gem.add_runtime_dependency 'jquery-rails' gem.add_runtime_dependency 'sass-rails', ['>= 3.1.4'] diff --git a/lib/active_admin/mongoid/csv_builder.rb b/lib/active_admin/mongoid/csv_builder.rb index 16fdcfd..2e91b57 100644 --- a/lib/active_admin/mongoid/csv_builder.rb +++ b/lib/active_admin/mongoid/csv_builder.rb @@ -11,13 +11,13 @@ def build(controller, csv) csv << bom if bom if column_names - csv << CSV.generate_line(columns.map { |c| encode c.name, options }, csv_options) + csv << CSV.generate_line(columns.map { |c| encode c.name, options }, **csv_options) end (1..paginated_collection.total_pages).each do |page| paginated_collection(page).each do |resource| resource = controller.send :apply_decorator, resource - csv << CSV.generate_line(build_row(resource, columns, options), csv_options) + csv << CSV.generate_line(build_row(resource, columns, options), **csv_options) end end diff --git a/test_app/app/models/post.rb b/test_app/app/models/post.rb index 2802148..357c9d9 100644 --- a/test_app/app/models/post.rb +++ b/test_app/app/models/post.rb @@ -12,11 +12,7 @@ class Post field :'author.city.name' def self.ransack(*args) - - binding.pry unless args.first.empty? - super - end end diff --git a/test_app/bin/rails b/test_app/bin/rails new file mode 100755 index 0000000..0739660 --- /dev/null +++ b/test_app/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test_app/bin/rake b/test_app/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/test_app/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test_app/bin/setup b/test_app/bin/setup new file mode 100755 index 0000000..2e29ac1 --- /dev/null +++ b/test_app/bin/setup @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby +require 'fileutils' + +# path to your application root. +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. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/test_app/config/boot.rb b/test_app/config/boot.rb index 4f49bfb..30f5120 100644 --- a/test_app/config/boot.rb +++ b/test_app/config/boot.rb @@ -1,6 +1,3 @@ -require 'rubygems' - -# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/test_app/config/environment.rb b/test_app/config/environment.rb index ad9dd14..426333b 100644 --- a/test_app/config/environment.rb +++ b/test_app/config/environment.rb @@ -1,5 +1,5 @@ -# Load the rails application -require File.expand_path('application', __dir__) +# Load the Rails application. +require_relative 'application' -# Initialize the rails application +# Initialize the Rails application. Rails.application.initialize! diff --git a/test_app/config/initializers/application_controller_renderer.rb b/test_app/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/test_app/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/test_app/config/initializers/assets.rb b/test_app/config/initializers/assets.rb new file mode 100644 index 0000000..fe48fc3 --- /dev/null +++ b/test_app/config/initializers/assets.rb @@ -0,0 +1,12 @@ +# 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' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path + +# 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( admin.js admin.css ) diff --git a/test_app/config/initializers/content_security_policy.rb b/test_app/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..41c4301 --- /dev/null +++ b/test_app/config/initializers/content_security_policy.rb @@ -0,0 +1,28 @@ +# 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 + +# 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 + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# 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/test_app/config/initializers/cookies_serializer.rb b/test_app/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..1389e86 --- /dev/null +++ b/test_app/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :marshal diff --git a/test_app/config/initializers/filter_parameter_logging.rb b/test_app/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/test_app/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# 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] diff --git a/test_app/config/initializers/inflections.rb b/test_app/config/initializers/inflections.rb index 5d8d9be..ac033bf 100644 --- a/test_app/config/initializers/inflections.rb +++ b/test_app/config/initializers/inflections.rb @@ -1,15 +1,16 @@ # Be sure to restart your server when you modify this file. -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| +# 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.uncountable %w( fish sheep ) # end -# + # These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections do |inflect| +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end diff --git a/test_app/config/initializers/new_framework_defaults_6_0.rb b/test_app/config/initializers/new_framework_defaults_6_0.rb new file mode 100644 index 0000000..92240ef --- /dev/null +++ b/test_app/config/initializers/new_framework_defaults_6_0.rb @@ -0,0 +1,45 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 6.0 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Don't force requests from old versions of IE to be UTF-8 encoded. +# Rails.application.config.action_view.default_enforce_utf8 = false + +# Embed purpose and expiry metadata inside signed and encrypted +# cookies for increased security. +# +# This option is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 6.0. +# Rails.application.config.action_dispatch.use_cookies_with_metadata = true + +# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification. +# Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false + +# Return false instead of self when enqueuing is aborted from a callback. +# Rails.application.config.active_job.return_false_on_aborted_enqueue = true + +# Send Active Storage analysis and purge jobs to dedicated queues. +# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis +# Rails.application.config.active_storage.queues.purge = :active_storage_purge + +# When assigning to a collection of attachments declared via `has_many_attached`, replace existing +# attachments instead of appending. Use #attach to add new attachments without replacing existing ones. +# Rails.application.config.active_storage.replace_on_assign_to_many = true + +# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail. +# +# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob), +# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions. +# If you send mail in the background, job workers need to have a copy of +# MailDeliveryJob to ensure all delivery jobs are processed properly. +# Make sure your entire app is migrated and stable on 6.0 before using this setting. +# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" + +# Enable the same cache key to be reused when the object being cached of type +# `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count) +# of the relation's cache key into the cache version to support recycling cache key. +# Rails.application.config.active_record.collection_cache_versioning = true