diff --git a/.circleci/config.yml b/.circleci/config.yml index 62dcfadb..811b5a34 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,7 @@ executors: parameters: ruby-version: description: "Ruby version" - default: "2.7" + default: "3.2" type: string docker: - image: *ruby-image @@ -27,7 +27,6 @@ commands: steps: - checkout - browser-tools/install-chrome - - browser-tools/install-chromedriver - restore_cache: keys: - bundler-dependencies-{{ checksum "Gemfile.lock" }} @@ -140,7 +139,7 @@ workflows: - test: matrix: parameters: - ruby-version: ["2.6", "2.7", "3.0", "3.1"] + ruby-version: ["3.0", "3.1", "3.2"] - deploy: context: org-global filters: diff --git a/.ruby-version b/.ruby-version index 1effb003..a3ec5a4b 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7 +3.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index d4ccb72e..9b73d75a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -### Unreleased +### 1.10.1 + +* Backport [#477](https://github.com/platanus/activeadmin_addons/pull/477) to have ActiveAdmin v3 compatibility [#479](https://github.com/platanus/activeadmin_addons/pull/479) ### 1.10.0 diff --git a/Gemfile b/Gemfile index 0dd5fb81..26aea313 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gemspec # To use debugger # gem "debugger" -gem "activeadmin" +gem "activeadmin", '~> 3.0' gem "mimemagic", github: "mimemagicrb/mimemagic", ref: "01f92d86d15d85cfd0f20dabd025dcbd36a8a60f" gem "webpacker", "~> 5.0", require: ENV["SPROCKETS"] != "true" diff --git a/Gemfile.lock b/Gemfile.lock index 2274628a..c01176d6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -61,7 +61,7 @@ GEM rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) active_material (1.5.2) - activeadmin (2.13.1) + activeadmin (3.0.0) arbre (~> 1.2, >= 1.2.1) formtastic (>= 3.1, < 5.0) formtastic_i18n (~> 0.4) @@ -69,7 +69,7 @@ GEM jquery-rails (~> 4.2) kaminari (~> 1.0, >= 1.2.1) railties (>= 6.1, < 7.1) - ransack (>= 2.1.1, < 4) + ransack (>= 4.0, < 5) activejob (6.1.7) activesupport (= 6.1.7) globalid (>= 0.3.6) @@ -91,25 +91,22 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - arbre (1.5.0) + addressable (2.8.5) + public_suffix (>= 2.0.2, < 6.0) + arbre (1.6.0) activesupport (>= 3.0.0, < 7.1) ruby2_keywords (>= 0.0.2, < 1.0) ast (2.4.0) builder (3.2.4) - capybara (3.31.0) + capybara (3.39.2) addressable + matrix mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.5) + regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - capybara-selenium (0.0.6) - capybara - selenium-webdriver - childprocess (3.0.0) climate_control (0.2.0) coderay (1.1.2) concurrent-ruby (1.1.10) @@ -148,7 +145,7 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - has_scope (0.8.0) + has_scope (0.8.1) actionpack (>= 5.2) activesupport (>= 5.2) i18n (1.12.0) @@ -194,13 +191,13 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2019.1009) mini_magick (4.11.0) - mini_mime (1.1.2) - mini_portile2 (2.8.0) + mini_mime (1.1.5) + mini_portile2 (2.8.4) minitest (5.16.3) nenv (0.3.0) nio4r (2.5.8) - nokogiri (1.13.9) - mini_portile2 (~> 2.8.0) + nokogiri (1.15.4) + mini_portile2 (~> 2.8.2) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) @@ -221,14 +218,14 @@ GEM pry-rails (0.3.9) pry (>= 0.10.4) psych (3.1.0) - public_suffix (4.0.6) + public_suffix (5.0.3) puma (5.3.1) nio4r (~> 2.0) - racc (1.6.0) - rack (2.2.4) + racc (1.7.1) + rack (2.2.8) rack-proxy (0.6.5) rack - rack-test (2.0.2) + rack-test (2.1.0) rack (>= 1.3) rails (6.1.7) actioncable (= 6.1.7) @@ -258,19 +255,19 @@ GEM thor (~> 1.0) rainbow (3.0.0) rake (13.0.6) - ransack (3.0.1) - activerecord (>= 6.0.4) - activesupport (>= 6.0.4) + ransack (4.0.0) + activerecord (>= 6.1.5) + activesupport (>= 6.1.5) i18n rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) redcarpet (3.6.0) - regexp_parser (1.6.0) + regexp_parser (2.8.1) require_all (3.0.0) - responders (3.0.1) - actionpack (>= 5.0) - railties (>= 5.0) + responders (3.1.0) + actionpack (>= 5.2) + railties (>= 5.2) rexml (3.2.5) rspec (3.9.0) rspec-core (~> 3.9.0) @@ -308,7 +305,7 @@ GEM ruby-vips (2.1.4) ffi (~> 1.12) ruby2_keywords (0.0.5) - rubyzip (2.2.0) + rubyzip (2.3.2) sassc (2.4.0) ffi (~> 1.9) sassc-rails (2.1.2) @@ -317,9 +314,10 @@ GEM sprockets (> 3.0) sprockets-rails tilt - selenium-webdriver (3.142.7) - childprocess (>= 0.5, < 4.0) - rubyzip (>= 1.2.2) + selenium-webdriver (4.11.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) semantic_range (3.0.0) shellany (0.0.1) shoulda-matchers (4.2.0) @@ -342,15 +340,12 @@ GEM tzinfo (2.0.5) concurrent-ruby (~> 1.0) unicode-display_width (1.4.1) - webdrivers (4.2.0) - nokogiri (~> 1.6) - rubyzip (>= 1.3.0) - selenium-webdriver (>= 3.0, < 4.0) webpacker (5.3.0) activesupport (>= 5.2) rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) + websocket (1.2.9) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -366,9 +361,9 @@ PLATFORMS DEPENDENCIES aasm - activeadmin + activeadmin (~> 3.0) activeadmin_addons! - capybara-selenium + capybara database_cleaner enumerize (~> 2.0) factory_bot_rails @@ -385,10 +380,10 @@ DEPENDENCIES rspec-rails rspec_junit_formatter rubocop (~> 0.65.0) + selenium-webdriver (~> 4.10) shoulda-matchers shrine (~> 3.0) sqlite3 - webdrivers webpacker (~> 5.0) BUNDLED WITH diff --git a/activeadmin_addons.gemspec b/activeadmin_addons.gemspec index 68ebc348..03624c97 100644 --- a/activeadmin_addons.gemspec +++ b/activeadmin_addons.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |s| s.add_dependency "xdan-datetimepicker-rails", "~> 2.5.1" s.add_development_dependency "aasm" - s.add_development_dependency "capybara-selenium" + s.add_development_dependency "capybara" s.add_development_dependency "database_cleaner" s.add_development_dependency "enumerize", "~> 2.0" s.add_development_dependency "factory_bot_rails" @@ -43,8 +43,8 @@ Gem::Specification.new do |s| s.add_development_dependency "rspec-rails" s.add_development_dependency "rspec_junit_formatter" s.add_development_dependency "rubocop", "~> 0.65.0" + s.add_development_dependency "selenium-webdriver", '~> 4.10' s.add_development_dependency "shoulda-matchers" s.add_development_dependency "shrine", "~> 3.0" s.add_development_dependency "sqlite3" - s.add_development_dependency "webdrivers" end diff --git a/app/inputs/nested_level_input.rb b/app/inputs/nested_level_input.rb index be3a12bf..c5ae4ee9 100644 --- a/app/inputs/nested_level_input.rb +++ b/app/inputs/nested_level_input.rb @@ -16,7 +16,7 @@ def render_custom_input def load_control_attributes load_class(@options[:class]) load_data_attr(:fields, default: ["name"], formatter: :to_json) - load_data_attr(:predicate, default: "contains") + load_data_attr(:predicate, default: "cont") load_data_attr(:filters) load_data_attr(:model, value: model_name) load_data_attr(:display_name, default: "name") diff --git a/app/inputs/search_select_input.rb b/app/inputs/search_select_input.rb index cb96250f..15a455d0 100644 --- a/app/inputs/search_select_input.rb +++ b/app/inputs/search_select_input.rb @@ -14,7 +14,7 @@ def input_method def load_control_attributes load_class(@options[:class]) load_data_attr(:fields, default: ["name"], formatter: :to_json) - load_data_attr(:predicate, default: "contains") + load_data_attr(:predicate, default: "cont") load_data_attr(:url, default: url_from_method) load_data_attr(:response_root, default: tableize_method) load_data_attr(:display_name, default: "name") diff --git a/app/inputs/selected_list_input.rb b/app/inputs/selected_list_input.rb index 188c54b2..0fc904ad 100644 --- a/app/inputs/selected_list_input.rb +++ b/app/inputs/selected_list_input.rb @@ -11,7 +11,7 @@ def load_control_attributes load_data_attr(:url, default: url_from_method) load_data_attr(:response_root, default: tableize_method) load_data_attr(:fields, default: ["name"], formatter: :to_json) - load_data_attr(:predicate, default: "contains") + load_data_attr(:predicate, default: "cont") load_data_attr(:display_name, default: "name") load_data_attr(:minimum_input_length, default: 1) load_data_attr(:width, default: "100%") diff --git a/docs/select2_nested_select.md b/docs/select2_nested_select.md index 93cbc92d..9bb517c9 100644 --- a/docs/select2_nested_select.md +++ b/docs/select2_nested_select.md @@ -91,7 +91,7 @@ Nested select, allows you to customize the general behavior of the input: * `display_name`: **(optional)** You can pass an optional `display_name` to set the attribute (or method) to show results on the select. It **defaults to**: `name` * `minimum_input_length`: **(optional)** Minimum number of characters required to initiate the search. It **defaults to**: `1`. Set this value to `0` to disable type-to-search and show a static list. * `response_root`: **(optional)** If you have defined the `url` attribute and a request to that url responds with a root, you can indicate the name of that root with this attribute. By default, the gem will try to infer the root from url. For example: if `url` is `GET /admin/countries`, the root will be `countries`. If you have a rootless api, you don't need to worry about this attribute. -* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `contains` +* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `cont` ```ruby f.input :city_id, as: :nested_select, @@ -139,7 +139,7 @@ f.input :city_id, as: :nested_select, level_1: { attribute: :country_id }, level_2: { attribute: :region_id, - filters: { name_contains: "Cuy", id_gt: 22 } + filters: { name_cont: "Cuy", id_gt: 22 } }, level_3: { attribute: :city_id } ``` diff --git a/docs/select2_search.md b/docs/select2_search.md index f81619d2..91e72ac5 100644 --- a/docs/select2_search.md +++ b/docs/select2_search.md @@ -43,5 +43,5 @@ In case you need to filter with an attribute of another table you need to includ * `class`: **(optional)** You can pass extra classes for your field. * `width`: **(optional)** You can set the select input width (px or %). * `order_by`: **(optional)** Order (sort) results by a specific attribute, suffixed with `_desc` or `_asc`. Eg: `description_desc`. By **default** is used the first field in descending direction. -* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `contains`. +* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `cont`. * `method_model`: **(optional)** Use in case you need to search or filter an attribute of another table. diff --git a/docs/select2_selected_list.md b/docs/select2_selected_list.md index cf26c0d7..8613824b 100644 --- a/docs/select2_selected_list.md +++ b/docs/select2_selected_list.md @@ -37,4 +37,4 @@ To get... * `display_name`: **(optional)** You can pass an optional `display_name` to set the attribute to show results on the select. It **defaults to**: `name`. * `width`: **(optional)** You can set the select input width (px or %). * `order_by`: **(optional)** Order (sort) results by a specific attribute, suffixed with `_desc` or `_asc`. Eg: `description_desc`. By **default** is used the first field in descending direction. -* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `contains` +* `predicate`: **(optional)** You can change the default [ransack predicate](https://github.com/activerecord-hackery/ransack#search-matchers). It **defaults to** `cont` diff --git a/lib/activeadmin_addons/version.rb b/lib/activeadmin_addons/version.rb index 7b7529a3..fb3d2a2d 100644 --- a/lib/activeadmin_addons/version.rb +++ b/lib/activeadmin_addons/version.rb @@ -1,3 +1,3 @@ module ActiveadminAddons - VERSION = "1.10.0" + VERSION = "1.10.1" end diff --git a/spec/dummy/app/models/category.rb b/spec/dummy/app/models/category.rb index 27e6dd5e..87883f4c 100644 --- a/spec/dummy/app/models/category.rb +++ b/spec/dummy/app/models/category.rb @@ -1,6 +1,15 @@ class Category < ActiveRecord::Base has_many :invoices + def shiny_name "My shiny #{name}" end + + def self.ransackable_attributes(_auth_object = nil) + ["created_at", "description", "id", "name", "updated_at"] + end + + def self.ransackable_associations(_auth_object = nil) + ["invoices"] + end end diff --git a/spec/dummy/app/models/city.rb b/spec/dummy/app/models/city.rb index 08b35b52..a03b939e 100644 --- a/spec/dummy/app/models/city.rb +++ b/spec/dummy/app/models/city.rb @@ -1,3 +1,13 @@ class City < ActiveRecord::Base belongs_to :region + has_many :departments_cities, dependent: :destroy + has_many :departments, through: :departments_cities + + def self.ransackable_attributes(_auth_object = nil) + ["created_at", "id", "information", "name", "region_id", "updated_at"] + end + + def self.ransackable_associations(_auth_object = nil) + ["region", "deparments_cities", "departments"] + end end diff --git a/spec/dummy/app/models/country.rb b/spec/dummy/app/models/country.rb index b7cec2b6..a2dfeb26 100644 --- a/spec/dummy/app/models/country.rb +++ b/spec/dummy/app/models/country.rb @@ -1,2 +1,12 @@ class Country < ActiveRecord::Base + has_many :regions, dependent: :destroy + has_many :cities, through: :regions + + def self.ransackable_attributes(_auth_object = nil) + ["created_at", "id", "information", "name", "updated_at"] + end + + def self.ransackable_associations(_auth_object = nil) + ["regions", "cities"] + end end diff --git a/spec/dummy/app/models/invoice.rb b/spec/dummy/app/models/invoice.rb index f8f1fab9..a62c01d8 100644 --- a/spec/dummy/app/models/invoice.rb +++ b/spec/dummy/app/models/invoice.rb @@ -98,4 +98,22 @@ def self.colors "#B9BF00" ] end + + def set_default_state + self.state ||= 'pending' + end + + def self.ransackable_attributes(_auth_object = nil) + [ + "aasm_state", "active", "amount", "attachment_content_type", "attachment_file_name", + "attachment_file_size", "attachment_updated_at", "category_id", "city_id", "client_id", + "color", "created_at", "description", "id", "legal_date", "number", "paid", + "photo_content_type", "photo_file_name", "photo_file_size", "photo_updated_at", + "picture_data", "position", "shipping_status", "state", "status", "updated_at" + ] + end + + def self.ransackable_associations(_auth_object = nil) + ["category", "city", "items", "other_items"] + end end diff --git a/spec/dummy/app/models/item.rb b/spec/dummy/app/models/item.rb index 52483640..a72f4064 100644 --- a/spec/dummy/app/models/item.rb +++ b/spec/dummy/app/models/item.rb @@ -4,4 +4,12 @@ class Item < ActiveRecord::Base def full_name "##{id} - #{name}" end + + def self.ransackable_attributes(_auth_object = nil) + ["created_at", "description", "id", "name", "updated_at"] + end + + def self.ransackable_associations(_auth_object = nil) + ["invoices"] + end end diff --git a/spec/dummy/app/models/region.rb b/spec/dummy/app/models/region.rb index a07419dc..1e53ebf1 100644 --- a/spec/dummy/app/models/region.rb +++ b/spec/dummy/app/models/region.rb @@ -1,3 +1,12 @@ class Region < ActiveRecord::Base belongs_to :country + has_many :cities, dependent: :destroy + + def self.ransackable_attributes(_auth_object = nil) + ["country_id", "created_at", "id", "information", "name", "updated_at"] + end + + def self.ransackable_associations(_auth_object = nil) + ["country", "cities"] + end end diff --git a/spec/dummy/config/initializers/active_admin.rb b/spec/dummy/config/initializers/active_admin.rb index 322a6663..3cd0a029 100644 --- a/spec/dummy/config/initializers/active_admin.rb +++ b/spec/dummy/config/initializers/active_admin.rb @@ -303,7 +303,7 @@ # :title, # :email, # ] - # config.filter_method_for_large_association, '_starts_with' + # config.filter_method_for_large_association, '_start' # == Head # diff --git a/spec/features/inputs/nested_select_input_spec.rb b/spec/features/inputs/nested_select_input_spec.rb index a683a873..8611b15b 100644 --- a/spec/features/inputs/nested_select_input_spec.rb +++ b/spec/features/inputs/nested_select_input_spec.rb @@ -196,8 +196,8 @@ level_1: { attribute: :country_id }, level_2: { attribute: :region_id, - filters: { name_contains: 'Met' } - }, + filters: { name_cont: 'Met' } + }, level_3: { attribute: :city_id } end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index bf83ef32..0d895bbe 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -4,7 +4,6 @@ require File.expand_path("../dummy/config/environment", __FILE__) require 'rspec/rails' require 'factory_bot_rails' -require 'webdrivers' require 'capybara/rspec' require 'capybara/rails' require 'selenium-webdriver' @@ -12,7 +11,6 @@ require 'enumerize' require 'paperclip' require 'database_cleaner' -require 'pry' ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../') Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each { |f| require f } @@ -39,12 +37,6 @@ DatabaseCleaner.clean end - # Cache the download of chrome driver for 1 day - Webdrivers.cache_time = 86_400 - - # Allow override of default path to Chrome (we use this in Travis) - Selenium::WebDriver::Chrome.path = ENV['CHROME_PATH'] if ENV['CHROME_PATH'] - Capybara.register_driver :chrome do |app| Capybara::Selenium::Driver.new(app, browser: :chrome) end