diff --git a/Gemfile b/Gemfile index 6de200c..f71cf65 100644 --- a/Gemfile +++ b/Gemfile @@ -2,10 +2,15 @@ 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 '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 f85a85e..940abbf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,14 +1,13 @@ -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: . specs: activeadmin-mongoid (1.0.0) - activeadmin (>= 1.4.3) + activeadmin (>= 1.3.0, <= 2.8.0) jquery-rails kaminari-mongoid mongoid (>= 6.0, < 8.a) @@ -17,225 +16,261 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (5.2.3) - actionpack (= 5.2.3) + actioncable (6.0.6.1) + actionpack (= 6.0.6.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) + 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.3) - actionview (= 5.2.3) - activesupport (= 5.2.3) - rack (~> 2.0) + 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.3) - activesupport (= 5.2.3) + 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.3) - activesupport (= 5.2.3) + activejob (6.0.6.1) + activesupport (= 6.0.6.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) - arel (>= 9.0) - activestorage (5.2.3) - actionpack (= 5.2.3) - activerecord (= 5.2.3) - marcel (~> 0.3.1) - activesupport (5.2.3) + 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) - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - arbre (1.2.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) - arel (9.0.0) - ast (2.4.0) - bcrypt (3.1.13) - bson (4.7.1) - builder (3.2.4) - capybara (3.12.0) + ruby2_keywords (>= 0.0.2) + ast (2.4.2) + base64 (0.3.0) + bcrypt (3.1.20) + bson (4.15.0) + builder (3.3.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.2) + regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + childprocess (5.1.0) + logger (~> 1.5) cliver (0.3.2) - coderay (1.1.2) - concurrent-ruby (1.1.6) + coderay (1.1.3) + concurrent-ruby (1.3.4) crass (1.0.6) - devise (4.7.1) + date (3.4.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) - erubi (1.9.0) - ffi (1.12.1) - 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) + diff-lcs (1.5.1) + docile (1.4.1) + 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.7) concurrent-ruby (~> 1.0) - inherited_resources (1.11.0) - actionpack (>= 5.0, < 6.1) - has_scope (~> 0.6) - railties (>= 5.0, < 6.1) - responders (>= 2, < 4) - jaro_winkler (1.5.4) - jquery-rails (4.3.3) + 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) 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) - kaminari (1.2.1) + json (2.7.2) + 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) + launchy (3.0.1) + addressable (~> 2.8) + childprocess (~> 5.0) + logger (1.6.0) + loofah (2.24.1) 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) - 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) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.2) + method_source (1.1.0) + mini_mime (1.1.5) + 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.5.1, < 3.0.0) - nio4r (2.3.1) - nokogiri (1.10.9) - mini_portile2 (~> 2.4.0) + 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.1) + net-protocol + nio4r (2.7.4) + nokogiri (1.18.8) + 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 (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) + 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.17) + rack-test (2.2.0) + rack (>= 1.3) + 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.3) + railties (= 6.0.6.1) sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.3.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.2) + loofah (~> 2.21) + 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) - rainbow (3.0.0) - rake (12.3.3) - ransack (2.3.2) - activerecord (>= 5.2.1) - activesupport (>= 5.2.1) + thor (>= 0.20.3, < 2.0) + rainbow (3.1.1) + rake (13.3.0) + ransack (2.1.1) + actionpack (>= 5.0) + activerecord (>= 5.0) + activesupport (>= 5.0) i18n - polyamorous (= 2.3.2) - regexp_parser (1.3.0) - 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) + regexp_parser (2.9.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) @@ -244,10 +279,11 @@ 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) - sassc (2.2.1) + sassc (2.4.0) ffi (~> 1.9) sassc-rails (2.1.2) railties (>= 4.0.0) @@ -255,31 +291,37 @@ 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) - sprockets (3.7.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) - 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) + strscan (3.1.0) + thor (1.3.2) thread_safe (0.3.6) - tilt (2.0.10) - tzinfo (1.2.7) + 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.8) - rack (>= 2.0.6) - websocket-driver (0.7.0) + warden (1.2.9) + rack (>= 2.0.9) + 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 @@ -287,18 +329,23 @@ PLATFORMS DEPENDENCIES activeadmin-mongoid! capybara + concurrent-ruby (= 1.3.4) devise jquery-rails jquery-ui-rails jslint launchy + 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 - 1.17.3 + 2.5.17 diff --git a/README.md b/README.md index 60feb35..e643cf4 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,13 @@ 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 Grzegorz Jakubiak, Nic Boie, JD Guzman, Elia Schito and other ActiveAdmin and community members. +### 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)) +* Tested working on Rails 5.1.x ### Requirements for version 1.0.0 * Ruby 2.4.0 or greater. * Tested working on Rails 5.2.3 + * 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.4.3 or greater * `ransack-mongoid` - it needs to be explicitly declared in Gemfile, pointing to github's master since it has no releases on rubygems yet. @@ -23,6 +27,9 @@ ActiveAdmin is holding off on pulling Mongoid support into the core ActiveAdmin This gem has been brought into the ActiveAdmin org for support and maintenance. + + # ActiveAdmin::Mongoid ActiveAdmin hacks to support Mongoid. diff --git a/activeadmin-mongoid.gemspec b/activeadmin-mongoid.gemspec index 9634269..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.4.3' + 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/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/controllers/resource_controller.rb b/lib/active_admin/mongoid/controllers/resource_controller.rb index 67a3d12..c5b510e 100644 --- a/lib/active_admin/mongoid/controllers/resource_controller.rb +++ b/lib/active_admin/mongoid/controllers/resource_controller.rb @@ -6,7 +6,7 @@ class ActiveAdmin::ResourceController def build_new_resource scoped_collection.send( method_for_build, - *resource_params + # *resource_params ) end end 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/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 diff --git a/lib/active_admin/mongoid/inputs/filters/select_input.rb b/lib/active_admin/mongoid/inputs/filters/select_input.rb index 713fa8e..7a29960 100644 --- a/lib/active_admin/mongoid/inputs/filters/select_input.rb +++ b/lib/active_admin/mongoid/inputs/filters/select_input.rb @@ -2,11 +2,18 @@ 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 + 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/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/app/models/post.rb b/test_app/app/models/post.rb index 57b9704..357c9d9 100644 --- a/test_app/app/models/post.rb +++ b/test_app/app/models/post.rb @@ -10,4 +10,9 @@ class Post embeds_one :author field :'author.city.name' + + def self.ransack(*args) + 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/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 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 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