Skip to content

Commit

Permalink
Merge pull request #479 from platanus/v1-backport-AA-v3-support-and-r…
Browse files Browse the repository at this point in the history
…elease-new-version

V1 backport ActiveAdmin v3 support and release new version
  • Loading branch information
difernandez authored Aug 24, 2023
2 parents 3f5a834 + 9bed815 commit bea9423
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 65 deletions.
5 changes: 2 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ executors:
parameters:
ruby-version:
description: "Ruby version"
default: "2.7"
default: "3.2"
type: string
docker:
- image: *ruby-image
Expand All @@ -27,7 +27,6 @@ commands:
steps:
- checkout
- browser-tools/install-chrome
- browser-tools/install-chromedriver
- restore_cache:
keys:
- bundler-dependencies-{{ checksum "Gemfile.lock" }}
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7
3.2
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
71 changes: 33 additions & 38 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ 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)
inherited_resources (~> 1.7)
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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -366,9 +361,9 @@ PLATFORMS

DEPENDENCIES
aasm
activeadmin
activeadmin (~> 3.0)
activeadmin_addons!
capybara-selenium
capybara
database_cleaner
enumerize (~> 2.0)
factory_bot_rails
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions activeadmin_addons.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
2 changes: 1 addition & 1 deletion app/inputs/nested_level_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion app/inputs/search_select_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion app/inputs/selected_list_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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%")
Expand Down
4 changes: 2 additions & 2 deletions docs/select2_nested_select.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 }
```
Expand Down
2 changes: 1 addition & 1 deletion docs/select2_search.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion docs/select2_selected_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
2 changes: 1 addition & 1 deletion lib/activeadmin_addons/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ActiveadminAddons
VERSION = "1.10.0"
VERSION = "1.10.1"
end
9 changes: 9 additions & 0 deletions spec/dummy/app/models/category.rb
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions spec/dummy/app/models/city.rb
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions spec/dummy/app/models/country.rb
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions spec/dummy/app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions spec/dummy/app/models/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit bea9423

Please sign in to comment.