From 5461c358951a995376b63189d2ee3548407300fb Mon Sep 17 00:00:00 2001 From: Alex Emelyanov Date: Tue, 25 Apr 2023 09:40:41 +0300 Subject: [PATCH 1/2] Bump version to 0.7.0 --- .github/workflows/main.yaml | 2 -- .travis.yml | 26 ------------------------- README.md | 10 +++++----- lib/active_admin/ajax_filter/version.rb | 2 +- 4 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f94e530..204b69f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -10,8 +10,6 @@ on: jobs: build: runs-on: ubuntu-latest - env: - CODECLIMATE_REPO_TOKEN: 9c938a047651a943393f0f52bfc1d03d71fce0f19bf0f8c1265033af9b09a56e strategy: fail-fast: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 74226f4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -sudo: false -language: ruby -cache: bundler - -rvm: - - 2.5 - - 2.6 - - 2.7 - - ruby-head - -matrix: - allow_failures: - - rvm: ruby-head - fast_finish: true - -before_install: gem update --remote bundler -install: - - gem install bundler:1.17.2 - - bundle install --retry=3 -script: - - bundle exec rake dummy:prepare - - bundle exec rspec - -addons: - code_climate: - repo_token: 9c938a047651a943393f0f52bfc1d03d71fce0f19bf0f8c1265033af9b09a56e diff --git a/README.md b/README.md index 2604838..01ec8fe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ [![Gem Version](https://badge.fury.io/rb/activeadmin-ajax_filter.svg)](https://badge.fury.io/rb/activeadmin-ajax_filter) [![Build Status](https://github.com/holyketzer/activeadmin-ajax_filter/actions/workflows/main.yaml/badge.svg)](https://github.com/holyketzer/activeadmin-ajax_filter/actions) [![Code Climate](https://codeclimate.com/github/holyketzer/activeadmin-ajax_filter/badges/gpa.svg)](https://codeclimate.com/github/holyketzer/activeadmin-ajax_filter) -[![Test Coverage](https://codeclimate.com/github/holyketzer/activeadmin-ajax_filter/badges/coverage.svg)](https://codeclimate.com/github/holyketzer/activeadmin-ajax_filter/coverage) # Activeadmin::AjaxFilter @@ -15,6 +14,7 @@ This gem extends ActiveAdmin so that your can use filters with AJAX-powered inpu This extension assumes that you're using [Active Admin](https://github.com/activeadmin/activeadmin) with [Ransack](https://github.com/activerecord-hackery/ransack). And for AJAX input it uses [selectize-rails](https://github.com/manuelvanrijn/selectize-rails) Versions: +* `0.7.0` - Rails 7, minimum Ruby version `2.7` * `0.6.0` - Rails 6, minimum Ruby version `2.7` * `0.5.0` - Rails 5, minimum Ruby version `2.5` * `0.4.5` - could break you build due to issue with `sprockets` version major update, now it's yanked, use `0.4.6` instead. If you on `sprockets >= 4` and `rails >= 5` use version `0.5.0` @@ -37,11 +37,11 @@ Or install it yourself as: ## Usage -Include this line in your JavaScript code (active_admin.js.coffee) +Include this line in your JavaScript code (active_admin.js) -```coffeescript -#= require selectize -#= require activeadmin-ajax_filter +```js +//= require selectize +//= require activeadmin-ajax_filter ``` Include this line in your CSS code (active_admin.scss) diff --git a/lib/active_admin/ajax_filter/version.rb b/lib/active_admin/ajax_filter/version.rb index 00a02aa..ec90c53 100644 --- a/lib/active_admin/ajax_filter/version.rb +++ b/lib/active_admin/ajax_filter/version.rb @@ -1,5 +1,5 @@ module ActiveAdmin module AjaxFilter - VERSION = '0.6.0' + VERSION = '0.7.0' end end From bd51b706c9cc354735688b7d01792a532ed56b6a Mon Sep 17 00:00:00 2001 From: Alex Emelyanov Date: Tue, 25 Apr 2023 09:45:04 +0300 Subject: [PATCH 2/2] Add Rails 7 test app --- Gemfile.lock | 2 +- test_app/blog/.gitattributes | 7 + test_app/blog/.gitignore | 35 ++ test_app/blog/.ruby-version | 1 + test_app/blog/Gemfile | 83 +++++ test_app/blog/Gemfile.lock | 345 ++++++++++++++++++ test_app/blog/README.md | 24 ++ test_app/blog/Rakefile | 6 + test_app/blog/app/admin/admin_users.rb | 28 ++ test_app/blog/app/admin/categories.rb | 7 + test_app/blog/app/admin/dashboard.rb | 32 ++ test_app/blog/app/admin/items.rb | 38 ++ test_app/blog/app/admin/subcategories.rb | 8 + test_app/blog/app/admin/tags.rb | 22 ++ test_app/blog/app/assets/config/manifest.js | 2 + test_app/blog/app/assets/images/.keep | 0 .../app/assets/javascripts/active_admin.js | 4 + .../app/assets/stylesheets/active_admin.scss | 21 ++ .../app/assets/stylesheets/application.css | 15 + .../app/channels/application_cable/channel.rb | 4 + .../channels/application_cable/connection.rb | 4 + .../app/controllers/application_controller.rb | 2 + test_app/blog/app/controllers/concerns/.keep | 0 .../app/decorators/subcategory_decorator.rb | 5 + .../blog/app/helpers/application_helper.rb | 2 + test_app/blog/app/jobs/application_job.rb | 7 + .../blog/app/mailers/application_mailer.rb | 4 + test_app/blog/app/models/admin_user.rb | 6 + .../blog/app/models/application_record.rb | 3 + test_app/blog/app/models/category.rb | 6 + test_app/blog/app/models/concerns/.keep | 0 test_app/blog/app/models/item.rb | 6 + test_app/blog/app/models/subcategory.rb | 8 + test_app/blog/app/models/tag.rb | 6 + .../app/views/layouts/application.html.erb | 15 + .../blog/app/views/layouts/mailer.html.erb | 13 + .../blog/app/views/layouts/mailer.text.erb | 1 + test_app/blog/bin/bundle | 114 ++++++ test_app/blog/bin/rails | 4 + test_app/blog/bin/rake | 4 + test_app/blog/bin/setup | 33 ++ test_app/blog/config.ru | 6 + test_app/blog/config/application.rb | 22 ++ test_app/blog/config/boot.rb | 4 + test_app/blog/config/cable.yml | 10 + test_app/blog/config/credentials.yml.enc | 1 + test_app/blog/config/database.yml | 25 ++ test_app/blog/config/environment.rb | 5 + .../blog/config/environments/development.rb | 70 ++++ .../blog/config/environments/production.rb | 93 +++++ test_app/blog/config/environments/test.rb | 60 +++ .../blog/config/initializers/active_admin.rb | 335 +++++++++++++++++ test_app/blog/config/initializers/assets.rb | 12 + .../initializers/content_security_policy.rb | 25 ++ test_app/blog/config/initializers/devise.rb | 313 ++++++++++++++++ .../initializers/filter_parameter_logging.rb | 8 + .../blog/config/initializers/inflections.rb | 16 + .../config/initializers/permissions_policy.rb | 11 + test_app/blog/config/locales/devise.en.yml | 65 ++++ test_app/blog/config/locales/en.yml | 33 ++ test_app/blog/config/puma.rb | 43 +++ test_app/blog/config/routes.rb | 8 + test_app/blog/config/storage.yml | 34 ++ ...0230425060437_devise_create_admin_users.rb | 44 +++ ...0425060439_create_active_admin_comments.rb | 16 + .../migrate/20230425060707_initial_schema.rb | 17 + .../db/migrate/20230425060708_create_tags.rb | 13 + test_app/blog/db/schema.rb | 69 ++++ test_app/blog/db/seeds.rb | 33 ++ test_app/blog/lib/assets/.keep | 0 test_app/blog/lib/tasks/.keep | 0 test_app/blog/log/.keep | 0 test_app/blog/public/404.html | 67 ++++ test_app/blog/public/422.html | 67 ++++ test_app/blog/public/500.html | 66 ++++ .../public/apple-touch-icon-precomposed.png | 0 test_app/blog/public/apple-touch-icon.png | 0 test_app/blog/public/favicon.ico | 0 test_app/blog/public/robots.txt | 1 + test_app/blog/storage/.keep | 0 .../blog/test/application_system_test_case.rb | 5 + .../application_cable/connection_test.rb | 11 + test_app/blog/test/controllers/.keep | 0 test_app/blog/test/fixtures/admin_users.yml | 11 + test_app/blog/test/fixtures/files/.keep | 0 test_app/blog/test/helpers/.keep | 0 test_app/blog/test/integration/.keep | 0 test_app/blog/test/mailers/.keep | 0 test_app/blog/test/models/.keep | 0 test_app/blog/test/models/admin_user_test.rb | 7 + test_app/blog/test/system/.keep | 0 test_app/blog/test/test_helper.rb | 13 + test_app/blog/tmp/.keep | 0 test_app/blog/tmp/pids/.keep | 0 test_app/blog/tmp/storage/.keep | 0 test_app/blog/vendor/.keep | 0 96 files changed, 2565 insertions(+), 1 deletion(-) create mode 100644 test_app/blog/.gitattributes create mode 100644 test_app/blog/.gitignore create mode 100644 test_app/blog/.ruby-version create mode 100644 test_app/blog/Gemfile create mode 100644 test_app/blog/Gemfile.lock create mode 100644 test_app/blog/README.md create mode 100644 test_app/blog/Rakefile create mode 100644 test_app/blog/app/admin/admin_users.rb create mode 100644 test_app/blog/app/admin/categories.rb create mode 100644 test_app/blog/app/admin/dashboard.rb create mode 100644 test_app/blog/app/admin/items.rb create mode 100644 test_app/blog/app/admin/subcategories.rb create mode 100644 test_app/blog/app/admin/tags.rb create mode 100644 test_app/blog/app/assets/config/manifest.js create mode 100644 test_app/blog/app/assets/images/.keep create mode 100644 test_app/blog/app/assets/javascripts/active_admin.js create mode 100644 test_app/blog/app/assets/stylesheets/active_admin.scss create mode 100644 test_app/blog/app/assets/stylesheets/application.css create mode 100644 test_app/blog/app/channels/application_cable/channel.rb create mode 100644 test_app/blog/app/channels/application_cable/connection.rb create mode 100644 test_app/blog/app/controllers/application_controller.rb create mode 100644 test_app/blog/app/controllers/concerns/.keep create mode 100644 test_app/blog/app/decorators/subcategory_decorator.rb create mode 100644 test_app/blog/app/helpers/application_helper.rb create mode 100644 test_app/blog/app/jobs/application_job.rb create mode 100644 test_app/blog/app/mailers/application_mailer.rb create mode 100644 test_app/blog/app/models/admin_user.rb create mode 100644 test_app/blog/app/models/application_record.rb create mode 100644 test_app/blog/app/models/category.rb create mode 100644 test_app/blog/app/models/concerns/.keep create mode 100644 test_app/blog/app/models/item.rb create mode 100644 test_app/blog/app/models/subcategory.rb create mode 100644 test_app/blog/app/models/tag.rb create mode 100644 test_app/blog/app/views/layouts/application.html.erb create mode 100644 test_app/blog/app/views/layouts/mailer.html.erb create mode 100644 test_app/blog/app/views/layouts/mailer.text.erb create mode 100755 test_app/blog/bin/bundle create mode 100755 test_app/blog/bin/rails create mode 100755 test_app/blog/bin/rake create mode 100755 test_app/blog/bin/setup create mode 100644 test_app/blog/config.ru create mode 100644 test_app/blog/config/application.rb create mode 100644 test_app/blog/config/boot.rb create mode 100644 test_app/blog/config/cable.yml create mode 100644 test_app/blog/config/credentials.yml.enc create mode 100644 test_app/blog/config/database.yml create mode 100644 test_app/blog/config/environment.rb create mode 100644 test_app/blog/config/environments/development.rb create mode 100644 test_app/blog/config/environments/production.rb create mode 100644 test_app/blog/config/environments/test.rb create mode 100644 test_app/blog/config/initializers/active_admin.rb create mode 100644 test_app/blog/config/initializers/assets.rb create mode 100644 test_app/blog/config/initializers/content_security_policy.rb create mode 100644 test_app/blog/config/initializers/devise.rb create mode 100644 test_app/blog/config/initializers/filter_parameter_logging.rb create mode 100644 test_app/blog/config/initializers/inflections.rb create mode 100644 test_app/blog/config/initializers/permissions_policy.rb create mode 100644 test_app/blog/config/locales/devise.en.yml create mode 100644 test_app/blog/config/locales/en.yml create mode 100644 test_app/blog/config/puma.rb create mode 100644 test_app/blog/config/routes.rb create mode 100644 test_app/blog/config/storage.yml create mode 100644 test_app/blog/db/migrate/20230425060437_devise_create_admin_users.rb create mode 100644 test_app/blog/db/migrate/20230425060439_create_active_admin_comments.rb create mode 100644 test_app/blog/db/migrate/20230425060707_initial_schema.rb create mode 100644 test_app/blog/db/migrate/20230425060708_create_tags.rb create mode 100644 test_app/blog/db/schema.rb create mode 100644 test_app/blog/db/seeds.rb create mode 100644 test_app/blog/lib/assets/.keep create mode 100644 test_app/blog/lib/tasks/.keep create mode 100644 test_app/blog/log/.keep create mode 100644 test_app/blog/public/404.html create mode 100644 test_app/blog/public/422.html create mode 100644 test_app/blog/public/500.html create mode 100644 test_app/blog/public/apple-touch-icon-precomposed.png create mode 100644 test_app/blog/public/apple-touch-icon.png create mode 100644 test_app/blog/public/favicon.ico create mode 100644 test_app/blog/public/robots.txt create mode 100644 test_app/blog/storage/.keep create mode 100644 test_app/blog/test/application_system_test_case.rb create mode 100644 test_app/blog/test/channels/application_cable/connection_test.rb create mode 100644 test_app/blog/test/controllers/.keep create mode 100644 test_app/blog/test/fixtures/admin_users.yml create mode 100644 test_app/blog/test/fixtures/files/.keep create mode 100644 test_app/blog/test/helpers/.keep create mode 100644 test_app/blog/test/integration/.keep create mode 100644 test_app/blog/test/mailers/.keep create mode 100644 test_app/blog/test/models/.keep create mode 100644 test_app/blog/test/models/admin_user_test.rb create mode 100644 test_app/blog/test/system/.keep create mode 100644 test_app/blog/test/test_helper.rb create mode 100644 test_app/blog/tmp/.keep create mode 100644 test_app/blog/tmp/pids/.keep create mode 100644 test_app/blog/tmp/storage/.keep create mode 100644 test_app/blog/vendor/.keep diff --git a/Gemfile.lock b/Gemfile.lock index ff38fd8..7cf80aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - activeadmin-ajax_filter (0.6.0) + activeadmin-ajax_filter (0.7.0) activeadmin (>= 1.0) coffee-rails (>= 4.1.0) rails (>= 7.0) diff --git a/test_app/blog/.gitattributes b/test_app/blog/.gitattributes new file mode 100644 index 0000000..31eeee0 --- /dev/null +++ b/test_app/blog/.gitattributes @@ -0,0 +1,7 @@ +# See https://git-scm.com/docs/gitattributes for more about git attribute files. + +# Mark the database schema as having been generated. +db/schema.rb linguist-generated + +# Mark any vendored files as having been vendored. +vendor/* linguist-vendored diff --git a/test_app/blog/.gitignore b/test_app/blog/.gitignore new file mode 100644 index 0000000..886f714 --- /dev/null +++ b/test_app/blog/.gitignore @@ -0,0 +1,35 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-* + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/ +!/tmp/pids/.keep + +# Ignore uploaded files in development. +/storage/* +!/storage/.keep +/tmp/storage/* +!/tmp/storage/ +!/tmp/storage/.keep + +/public/assets + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/test_app/blog/.ruby-version b/test_app/blog/.ruby-version new file mode 100644 index 0000000..37c2961 --- /dev/null +++ b/test_app/blog/.ruby-version @@ -0,0 +1 @@ +2.7.2 diff --git a/test_app/blog/Gemfile b/test_app/blog/Gemfile new file mode 100644 index 0000000..ad579d9 --- /dev/null +++ b/test_app/blog/Gemfile @@ -0,0 +1,83 @@ +source "https://rubygems.org" +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby "2.7.2" + +# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" +gem "rails", "~> 7.0.4", ">= 7.0.4.3" + +# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] +gem "sprockets-rails" +gem "sassc" + +# Use sqlite3 as the database for Active Record +gem "sqlite3", "~> 1.4" + +# Use the Puma web server [https://github.com/puma/puma] +gem "puma", "~> 5.0" + +# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] +gem "importmap-rails" + +# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] +gem "turbo-rails" + +# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] +gem "stimulus-rails" + +# Build JSON APIs with ease [https://github.com/rails/jbuilder] +gem "jbuilder" + +# Use Redis adapter to run Action Cable in production +# gem "redis", "~> 4.0" + +# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] +# gem "kredis" + +# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] +# gem "bcrypt", "~> 3.1.7" + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] + +# Reduces boot times through caching; required in config/boot.rb +gem "bootsnap", require: false + +# Use Sass to process CSS +# gem "sassc-rails" + +# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] +# gem "image_processing", "~> 1.2" + +gem 'activeadmin' + +# Plus integrations with: +gem 'devise' +gem 'cancancan' +gem 'draper' +gem 'pundit' +gem 'activeadmin-ajax_filter', path: '../..' +gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main' + +group :development, :test do + # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem "debug", platforms: %i[ mri mingw x64_mingw ] +end + +group :development do + # Use console on exceptions pages [https://github.com/rails/web-console] + gem "web-console" + + # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] + # gem "rack-mini-profiler" + + # Speed up commands on slow machines / big apps [https://github.com/rails/spring] + # gem "spring" +end + +group :test do + # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] + gem "capybara" + gem "selenium-webdriver" + gem "webdrivers" +end diff --git a/test_app/blog/Gemfile.lock b/test_app/blog/Gemfile.lock new file mode 100644 index 0000000..3fd6c83 --- /dev/null +++ b/test_app/blog/Gemfile.lock @@ -0,0 +1,345 @@ +GIT + remote: https://github.com/faker-ruby/faker.git + revision: cfdcdc06e953d05755f2455f4d412cdd71a3dba6 + branch: main + specs: + faker (3.2.0) + i18n (>= 1.8.11, < 2) + +PATH + remote: ../.. + specs: + activeadmin-ajax_filter (0.6.0) + activeadmin (>= 1.0) + coffee-rails (>= 4.1.0) + rails (>= 7.0) + selectize-rails (>= 0.12.6) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.0.4.3) + actionpack (= 7.0.4.3) + activesupport (= 7.0.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.4.3) + actionpack (= 7.0.4.3) + activejob (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.4.3) + actionpack (= 7.0.4.3) + actionview (= 7.0.4.3) + activejob (= 7.0.4.3) + activesupport (= 7.0.4.3) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.0.4.3) + actionview (= 7.0.4.3) + activesupport (= 7.0.4.3) + rack (~> 2.0, >= 2.2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (7.0.4.3) + actionpack (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.4.3) + activesupport (= 7.0.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activeadmin (2.13.1) + 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) + activejob (7.0.4.3) + activesupport (= 7.0.4.3) + globalid (>= 0.3.6) + activemodel (7.0.4.3) + activesupport (= 7.0.4.3) + activemodel-serializers-xml (1.0.2) + activemodel (> 5.x) + activesupport (> 5.x) + builder (~> 3.1) + activerecord (7.0.4.3) + activemodel (= 7.0.4.3) + activesupport (= 7.0.4.3) + activestorage (7.0.4.3) + actionpack (= 7.0.4.3) + activejob (= 7.0.4.3) + activerecord (= 7.0.4.3) + activesupport (= 7.0.4.3) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + addressable (2.8.4) + public_suffix (>= 2.0.2, < 6.0) + arbre (1.5.0) + activesupport (>= 3.0.0, < 7.1) + ruby2_keywords (>= 0.0.2, < 1.0) + bcrypt (3.1.18) + bindex (0.8.1) + bootsnap (1.16.0) + msgpack (~> 1.2) + builder (3.2.4) + cancancan (3.5.0) + capybara (3.39.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + coffee-rails (5.0.0) + coffee-script (>= 2.2.0) + railties (>= 5.2.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.2.2) + crass (1.0.6) + date (3.3.3) + debug (1.7.2) + irb (>= 1.5.0) + reline (>= 0.3.1) + devise (4.9.2) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0) + responders + warden (~> 1.2.3) + draper (4.0.2) + actionpack (>= 5.0) + activemodel (>= 5.0) + activemodel-serializers-xml (>= 1.0) + activesupport (>= 5.0) + request_store (>= 1.0) + ruby2_keywords + erubi (1.12.0) + execjs (2.8.1) + ffi (1.15.5) + formtastic (4.0.0) + actionpack (>= 5.2.0) + formtastic_i18n (0.7.0) + globalid (1.1.0) + activesupport (>= 5.0) + has_scope (0.8.1) + actionpack (>= 5.2) + activesupport (>= 5.2) + i18n (1.12.0) + concurrent-ruby (~> 1.0) + importmap-rails (1.1.6) + actionpack (>= 6.0.0) + railties (>= 6.0.0) + inherited_resources (1.13.1) + actionpack (>= 5.2, < 7.1) + has_scope (~> 0.6) + railties (>= 5.2, < 7.1) + responders (>= 2, < 4) + io-console (0.6.0) + irb (1.6.4) + reline (>= 0.3.0) + jbuilder (2.11.5) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + jquery-rails (4.5.1) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + kaminari (1.2.2) + activesupport (>= 4.1.0) + 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.2) + kaminari-activerecord (1.2.2) + activerecord + kaminari-core (= 1.2.2) + kaminari-core (1.2.2) + loofah (2.20.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) + matrix (0.4.2) + method_source (1.0.0) + mini_mime (1.1.2) + mini_portile2 (2.8.1) + minitest (5.18.0) + msgpack (1.7.0) + net-imap (0.3.4) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol + nio4r (2.5.9) + nokogiri (1.14.3) + mini_portile2 (~> 2.8.0) + racc (~> 1.4) + orm_adapter (0.5.0) + public_suffix (5.0.1) + puma (5.6.5) + nio4r (~> 2.0) + pundit (2.3.0) + activesupport (>= 3.0.0) + racc (1.6.2) + rack (2.2.7) + rack-test (2.1.0) + rack (>= 1.3) + rails (7.0.4.3) + actioncable (= 7.0.4.3) + actionmailbox (= 7.0.4.3) + actionmailer (= 7.0.4.3) + actionpack (= 7.0.4.3) + actiontext (= 7.0.4.3) + actionview (= 7.0.4.3) + activejob (= 7.0.4.3) + activemodel (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) + bundler (>= 1.15.0) + railties (= 7.0.4.3) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) + railties (7.0.4.3) + actionpack (= 7.0.4.3) + activesupport (= 7.0.4.3) + method_source + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) + rake (13.0.6) + ransack (3.2.1) + activerecord (>= 6.1.5) + activesupport (>= 6.1.5) + i18n + regexp_parser (2.8.0) + reline (0.3.3) + io-console (~> 0.5) + request_store (1.5.1) + rack (>= 1.4) + responders (3.1.0) + actionpack (>= 5.2) + railties (>= 5.2) + rexml (3.2.5) + ruby2_keywords (0.0.5) + rubyzip (2.3.2) + sassc (2.4.0) + ffi (~> 1.9) + selectize-rails (0.12.6) + selenium-webdriver (4.9.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + sprockets (4.2.0) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + sprockets (>= 3.0.0) + sqlite3 (1.6.2) + mini_portile2 (~> 2.8.0) + stimulus-rails (1.2.1) + railties (>= 6.0.0) + thor (1.2.1) + timeout (0.3.2) + turbo-rails (1.4.0) + actionpack (>= 6.0.0) + activejob (>= 6.0.0) + railties (>= 6.0.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + warden (1.2.9) + rack (>= 2.0.9) + web-console (4.2.0) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) + bindex (>= 0.4.0) + railties (>= 6.0.0) + webdrivers (5.2.0) + nokogiri (~> 1.6) + rubyzip (>= 1.3.0) + selenium-webdriver (~> 4.0) + websocket (1.2.9) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + zeitwerk (2.6.7) + +PLATFORMS + ruby + +DEPENDENCIES + activeadmin + activeadmin-ajax_filter! + bootsnap + cancancan + capybara + debug + devise + draper + faker! + importmap-rails + jbuilder + puma (~> 5.0) + pundit + rails (~> 7.0.4, >= 7.0.4.3) + sassc + selenium-webdriver + sprockets-rails + sqlite3 (~> 1.4) + stimulus-rails + turbo-rails + tzinfo-data + web-console + webdrivers + +RUBY VERSION + ruby 2.7.2p137 + +BUNDLED WITH + 2.1.4 diff --git a/test_app/blog/README.md b/test_app/blog/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/test_app/blog/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/test_app/blog/Rakefile b/test_app/blog/Rakefile new file mode 100644 index 0000000..9a5ea73 --- /dev/null +++ b/test_app/blog/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative "config/application" + +Rails.application.load_tasks diff --git a/test_app/blog/app/admin/admin_users.rb b/test_app/blog/app/admin/admin_users.rb new file mode 100644 index 0000000..404a04e --- /dev/null +++ b/test_app/blog/app/admin/admin_users.rb @@ -0,0 +1,28 @@ +ActiveAdmin.register AdminUser do + permit_params :email, :password, :password_confirmation + + index do + selectable_column + id_column + column :email + column :current_sign_in_at + column :sign_in_count + column :created_at + actions + end + + filter :email + filter :current_sign_in_at + filter :sign_in_count + filter :created_at + + form do |f| + f.inputs do + f.input :email + f.input :password + f.input :password_confirmation + end + f.actions + end + +end diff --git a/test_app/blog/app/admin/categories.rb b/test_app/blog/app/admin/categories.rb new file mode 100644 index 0000000..6b9d002 --- /dev/null +++ b/test_app/blog/app/admin/categories.rb @@ -0,0 +1,7 @@ +ActiveAdmin.register Category do + include ActiveAdmin::AjaxFilter + + permit_params :id, :name + config.sort_order = 'id_asc' + config.per_page = 3 +end \ No newline at end of file diff --git a/test_app/blog/app/admin/dashboard.rb b/test_app/blog/app/admin/dashboard.rb new file mode 100644 index 0000000..86003e8 --- /dev/null +++ b/test_app/blog/app/admin/dashboard.rb @@ -0,0 +1,32 @@ +ActiveAdmin.register_page 'Dashboard' do + menu priority: 1, label: proc { I18n.t('active_admin.dashboard') } + + content title: proc { I18n.t('active_admin.dashboard') } do + div class: 'blank_slate_container', id: 'dashboard_default_message' do + span class: 'blank_slate' do + span I18n.t('active_admin.dashboard_welcome.welcome') + small I18n.t('active_admin.dashboard_welcome.call_to_action') + end + end + + # Here is an example of a simple dashboard with columns and panels. + # + # columns do + # column do + # panel "Recent Posts" do + # ul do + # Post.recent(5).map do |post| + # li link_to(post.title, admin_post_path(post)) + # end + # end + # end + # end + + # column do + # panel "Info" do + # para "Welcome to ActiveAdmin." + # end + # end + # end + end # content +end diff --git a/test_app/blog/app/admin/items.rb b/test_app/blog/app/admin/items.rb new file mode 100644 index 0000000..279d419 --- /dev/null +++ b/test_app/blog/app/admin/items.rb @@ -0,0 +1,38 @@ +ActiveAdmin.register Item do + permit_params :id, :name, :subcategory_id, tag_ids: [] + config.sort_order = 'id_asc' + + filter :subcategory, as: :ajax_select, data: { + url: :filter_admin_subcategories_path, + search_fields: [:name], + limit: 7, + } + + filter :tags, as: :ajax_select, data: { + url: :filter_admin_tags_path, + search_fields: [:name], + limit: 7, + } + + form do |f| + f.semantic_errors(*f.object.errors.attribute_names) + + f.inputs do + f.input :name + + f.input :subcategory, as: :ajax_select, data: { + search_fields: [:name], + url: '/admin/subcategories/filter', + limit: Subcategory::AJAX_LIMIT + } + + f.input :tags, as: :ajax_select, data: { + search_fields: ['name'], + url: '/admin/tags/filter' + } + end + + + f.actions + end +end diff --git a/test_app/blog/app/admin/subcategories.rb b/test_app/blog/app/admin/subcategories.rb new file mode 100644 index 0000000..95f61f2 --- /dev/null +++ b/test_app/blog/app/admin/subcategories.rb @@ -0,0 +1,8 @@ +ActiveAdmin.register Subcategory do + include ActiveAdmin::AjaxFilter + decorate_with SubcategoryDecorator.name + + permit_params :id, :name, :category_id + config.sort_order = 'id_asc' + config.per_page = 3 +end \ No newline at end of file diff --git a/test_app/blog/app/admin/tags.rb b/test_app/blog/app/admin/tags.rb new file mode 100644 index 0000000..9713246 --- /dev/null +++ b/test_app/blog/app/admin/tags.rb @@ -0,0 +1,22 @@ +ActiveAdmin.register Tag do + include ActiveAdmin::AjaxFilter + + permit_params :id, :name, :subcategory_id + config.sort_order = 'id_asc' + + form do |f| + f.semantic_errors(*f.object.errors.attribute_names) + + f.inputs do + f.input :name + f.input :subcategory, as: :ajax_select, data: { + search_fields: ['category.name'], + ordering: 'name ASC', + url: '/admin/subcategories/filter', + limit: Subcategory::AJAX_LIMIT + } + end + + f.actions + end +end diff --git a/test_app/blog/app/assets/config/manifest.js b/test_app/blog/app/assets/config/manifest.js new file mode 100644 index 0000000..5918193 --- /dev/null +++ b/test_app/blog/app/assets/config/manifest.js @@ -0,0 +1,2 @@ +//= link_tree ../images +//= link_directory ../stylesheets .css diff --git a/test_app/blog/app/assets/images/.keep b/test_app/blog/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/app/assets/javascripts/active_admin.js b/test_app/blog/app/assets/javascripts/active_admin.js new file mode 100644 index 0000000..745df93 --- /dev/null +++ b/test_app/blog/app/assets/javascripts/active_admin.js @@ -0,0 +1,4 @@ +//= require active_admin/base + +//= require selectize +//= require activeadmin-ajax_filter diff --git a/test_app/blog/app/assets/stylesheets/active_admin.scss b/test_app/blog/app/assets/stylesheets/active_admin.scss new file mode 100644 index 0000000..49737c3 --- /dev/null +++ b/test_app/blog/app/assets/stylesheets/active_admin.scss @@ -0,0 +1,21 @@ +// Sass variable overrides must be declared before loading up Active Admin's styles. +// +// To view the variables that Active Admin provides, take a look at +// `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the +// Active Admin source. +// +// For example, to change the sidebar width: +// $sidebar-width: 242px; + +// Active Admin's got SASS! +@import "active_admin/mixins"; +@import "active_admin/base"; + +// Overriding any non-variable Sass must be done after the fact. +// For example, to change the default status-tag color: +// +// .status_tag { background: #6090DB; } + +@import "selectize"; +@import "selectize.default"; +@import "activeadmin-ajax_filter"; diff --git a/test_app/blog/app/assets/stylesheets/application.css b/test_app/blog/app/assets/stylesheets/application.css new file mode 100644 index 0000000..288b9ab --- /dev/null +++ b/test_app/blog/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/test_app/blog/app/channels/application_cable/channel.rb b/test_app/blog/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/test_app/blog/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/test_app/blog/app/channels/application_cable/connection.rb b/test_app/blog/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/test_app/blog/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/test_app/blog/app/controllers/application_controller.rb b/test_app/blog/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/test_app/blog/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/test_app/blog/app/controllers/concerns/.keep b/test_app/blog/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/app/decorators/subcategory_decorator.rb b/test_app/blog/app/decorators/subcategory_decorator.rb new file mode 100644 index 0000000..9a79b9b --- /dev/null +++ b/test_app/blog/app/decorators/subcategory_decorator.rb @@ -0,0 +1,5 @@ +require 'draper' + +class SubcategoryDecorator < Draper::Decorator + delegate_all +end diff --git a/test_app/blog/app/helpers/application_helper.rb b/test_app/blog/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test_app/blog/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test_app/blog/app/jobs/application_job.rb b/test_app/blog/app/jobs/application_job.rb new file mode 100644 index 0000000..d394c3d --- /dev/null +++ b/test_app/blog/app/jobs/application_job.rb @@ -0,0 +1,7 @@ +class ApplicationJob < ActiveJob::Base + # Automatically retry jobs that encountered a deadlock + # retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer available + # discard_on ActiveJob::DeserializationError +end diff --git a/test_app/blog/app/mailers/application_mailer.rb b/test_app/blog/app/mailers/application_mailer.rb new file mode 100644 index 0000000..3c34c81 --- /dev/null +++ b/test_app/blog/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: "from@example.com" + layout "mailer" +end diff --git a/test_app/blog/app/models/admin_user.rb b/test_app/blog/app/models/admin_user.rb new file mode 100644 index 0000000..3c851a1 --- /dev/null +++ b/test_app/blog/app/models/admin_user.rb @@ -0,0 +1,6 @@ +class AdminUser < ApplicationRecord + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable + devise :database_authenticatable, + :recoverable, :rememberable, :validatable +end diff --git a/test_app/blog/app/models/application_record.rb b/test_app/blog/app/models/application_record.rb new file mode 100644 index 0000000..b63caeb --- /dev/null +++ b/test_app/blog/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + primary_abstract_class +end diff --git a/test_app/blog/app/models/category.rb b/test_app/blog/app/models/category.rb new file mode 100644 index 0000000..01f7afa --- /dev/null +++ b/test_app/blog/app/models/category.rb @@ -0,0 +1,6 @@ +class Category < ActiveRecord::Base + validates :name, presence: true + + has_many :subcategories + has_many :items, through: :subcategories +end \ No newline at end of file diff --git a/test_app/blog/app/models/concerns/.keep b/test_app/blog/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/app/models/item.rb b/test_app/blog/app/models/item.rb new file mode 100644 index 0000000..6f72d4f --- /dev/null +++ b/test_app/blog/app/models/item.rb @@ -0,0 +1,6 @@ +class Item < ActiveRecord::Base + validates :name, presence: true + + belongs_to :subcategory + has_and_belongs_to_many :tags +end diff --git a/test_app/blog/app/models/subcategory.rb b/test_app/blog/app/models/subcategory.rb new file mode 100644 index 0000000..f6643ee --- /dev/null +++ b/test_app/blog/app/models/subcategory.rb @@ -0,0 +1,8 @@ +class Subcategory < ActiveRecord::Base + AJAX_LIMIT = 3 + + validates :name, presence: true + + belongs_to :category + has_many :items +end diff --git a/test_app/blog/app/models/tag.rb b/test_app/blog/app/models/tag.rb new file mode 100644 index 0000000..5fccd14 --- /dev/null +++ b/test_app/blog/app/models/tag.rb @@ -0,0 +1,6 @@ +class Tag < ActiveRecord::Base + validates :name, presence: true + + belongs_to :subcategory + has_and_belongs_to_many :items +end diff --git a/test_app/blog/app/views/layouts/application.html.erb b/test_app/blog/app/views/layouts/application.html.erb new file mode 100644 index 0000000..3f69dd5 --- /dev/null +++ b/test_app/blog/app/views/layouts/application.html.erb @@ -0,0 +1,15 @@ + + + + Blog + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> + + + + <%= yield %> + + diff --git a/test_app/blog/app/views/layouts/mailer.html.erb b/test_app/blog/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/test_app/blog/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/test_app/blog/app/views/layouts/mailer.text.erb b/test_app/blog/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/test_app/blog/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/test_app/blog/bin/bundle b/test_app/blog/bin/bundle new file mode 100755 index 0000000..a71368e --- /dev/null +++ b/test_app/blog/bin/bundle @@ -0,0 +1,114 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'bundle' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "rubygems" + +m = Module.new do + module_function + + def invoked_as_script? + File.expand_path($0) == File.expand_path(__FILE__) + end + + def env_var_version + ENV["BUNDLER_VERSION"] + end + + def cli_arg_version + return unless invoked_as_script? # don't want to hijack other binstubs + return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + bundler_version = nil + update_index = nil + ARGV.each_with_index do |a, i| + if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN + bundler_version = a + end + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + bundler_version = $1 + update_index = i + end + bundler_version + end + + def gemfile + gemfile = ENV["BUNDLE_GEMFILE"] + return gemfile if gemfile && !gemfile.empty? + + File.expand_path("../../Gemfile", __FILE__) + end + + def lockfile + lockfile = + case File.basename(gemfile) + when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) + else "#{gemfile}.lock" + end + File.expand_path(lockfile) + end + + def lockfile_version + return unless File.file?(lockfile) + lockfile_contents = File.read(lockfile) + return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + Regexp.last_match(1) + end + + def bundler_version + @bundler_version ||= + env_var_version || cli_arg_version || + lockfile_version + end + + def bundler_requirement + return "#{Gem::Requirement.default}.a" unless bundler_version + + bundler_gem_version = Gem::Version.new(bundler_version) + + requirement = bundler_gem_version.approximate_recommendation + + return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0") + + requirement += ".a" if bundler_gem_version.prerelease? + + requirement + end + + def load_bundler! + ENV["BUNDLE_GEMFILE"] ||= gemfile + + activate_bundler + end + + def activate_bundler + gem_error = activation_error_handling do + gem "bundler", bundler_requirement + end + return if gem_error.nil? + require_error = activation_error_handling do + require "bundler/version" + end + return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" + exit 42 + end + + def activation_error_handling + yield + nil + rescue StandardError, LoadError => e + e + end +end + +m.load_bundler! + +if m.invoked_as_script? + load Gem.bin_path("bundler", "bundle") +end diff --git a/test_app/blog/bin/rails b/test_app/blog/bin/rails new file mode 100755 index 0000000..efc0377 --- /dev/null +++ b/test_app/blog/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/blog/bin/rake b/test_app/blog/bin/rake new file mode 100755 index 0000000..4fbf10b --- /dev/null +++ b/test_app/blog/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "rake" +Rake.application.run diff --git a/test_app/blog/bin/setup b/test_app/blog/bin/setup new file mode 100755 index 0000000..ec47b79 --- /dev/null +++ b/test_app/blog/bin/setup @@ -0,0 +1,33 @@ +#!/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 set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time 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== Copying sample files ==" + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" + # end + + puts "\n== Preparing database ==" + system! "bin/rails db:prepare" + + 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/blog/config.ru b/test_app/blog/config.ru new file mode 100644 index 0000000..4a3c09a --- /dev/null +++ b/test_app/blog/config.ru @@ -0,0 +1,6 @@ +# This file is used by Rack-based servers to start the application. + +require_relative "config/environment" + +run Rails.application +Rails.application.load_server diff --git a/test_app/blog/config/application.rb b/test_app/blog/config/application.rb new file mode 100644 index 0000000..6e6c48e --- /dev/null +++ b/test_app/blog/config/application.rb @@ -0,0 +1,22 @@ +require_relative "boot" + +require "rails/all" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Blog + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 7.0 + + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") + end +end diff --git a/test_app/blog/config/boot.rb b/test_app/blog/config/boot.rb new file mode 100644 index 0000000..988a5dd --- /dev/null +++ b/test_app/blog/config/boot.rb @@ -0,0 +1,4 @@ +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/test_app/blog/config/cable.yml b/test_app/blog/config/cable.yml new file mode 100644 index 0000000..0dc74e9 --- /dev/null +++ b/test_app/blog/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: test + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: blog_production diff --git a/test_app/blog/config/credentials.yml.enc b/test_app/blog/config/credentials.yml.enc new file mode 100644 index 0000000..9a71f96 --- /dev/null +++ b/test_app/blog/config/credentials.yml.enc @@ -0,0 +1 @@ +A8kWEy3wFj+ghe4jSmiVCG8yJ9e50QQVj4JIFaPT8mDwxnqUDA6UzrmgVapDK6Qndls2i2c1BCVp3mDj6spbFu03imZhAMcUWnmC9ykXQ6AoEIZSLoXiRNyOHMU0ey844X6CBt4WrieW8bngTUI0e+rqp+xyD0r8aSfXF3QeZcpavqI7xFlcEswAb60sZrkPF2PDj4BTYTrxnVmzxyfahjtMdBok9Z05AWwwa4kP4aoRqsdQfE1cPxYtcCNT9mvmV1yOk9gaRf/O6kIffMNWYqb/+k0aS/qsXS8LJCkB+vx3kXFzG2cne/zN8/JVCsKIIO1XxDNwKMy5VOLjJIkKNq8Ax/mFJ/812E4GmEJiP/DkKrEFA9aHGZsu+QmeNtITZCDvt8NuXrrZtjyb/fuWqBdMCR9dP6K7rbnv--9lbniAhRDeT6yZG3--HcGKhzEgjq4HBqiBSQa/Rg== \ No newline at end of file diff --git a/test_app/blog/config/database.yml b/test_app/blog/config/database.yml new file mode 100644 index 0000000..fcba57f --- /dev/null +++ b/test_app/blog/config/database.yml @@ -0,0 +1,25 @@ +# SQLite. Versions 3.8.0 and up are supported. +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem "sqlite3" +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/test_app/blog/config/environment.rb b/test_app/blog/config/environment.rb new file mode 100644 index 0000000..cac5315 --- /dev/null +++ b/test_app/blog/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative "application" + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/test_app/blog/config/environments/development.rb b/test_app/blog/config/environments/development.rb new file mode 100644 index 0000000..8500f45 --- /dev/null +++ b/test_app/blog/config/environments/development.rb @@ -0,0 +1,70 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable server timing + config.server_timing = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join("tmp/caching-dev.txt").exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true +end diff --git a/test_app/blog/config/environments/production.rb b/test_app/blog/config/environments/production.rb new file mode 100644 index 0000000..7a93dfe --- /dev/null +++ b/test_app/blog/config/environments/production.rb @@ -0,0 +1,93 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache + # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain. + # config.action_cable.mount_path = nil + # config.action_cable.url = "wss://example.com/cable" + # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "blog_production" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require "syslog/logger" + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/test_app/blog/config/environments/test.rb b/test_app/blog/config/environments/test.rb new file mode 100644 index 0000000..6ea4d1e --- /dev/null +++ b/test_app/blog/config/environments/test.rb @@ -0,0 +1,60 @@ +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Turn false under Spring and add config.action_view.cache_template_loading = true. + config.cache_classes = true + + # Eager loading loads your whole application. When running a single test locally, + # this probably isn't necessary. It's a good idea to do in a continuous integration + # system, or in some way before deploying your code. + config.eager_load = ENV["CI"].present? + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true +end diff --git a/test_app/blog/config/initializers/active_admin.rb b/test_app/blog/config/initializers/active_admin.rb new file mode 100644 index 0000000..ab072eb --- /dev/null +++ b/test_app/blog/config/initializers/active_admin.rb @@ -0,0 +1,335 @@ +ActiveAdmin.setup do |config| + # == Site Title + # + # Set the title that is displayed on the main layout + # for each of the active admin pages. + # + config.site_title = "Blog" + + # Set the link url for the title. For example, to take + # users to your main site. Defaults to no link. + # + # config.site_title_link = "/" + + # Set an optional image to be displayed for the header + # instead of a string (overrides :site_title) + # + # Note: Aim for an image that's 21px high so it fits in the header. + # + # config.site_title_image = "logo.png" + + # == Default Namespace + # + # Set the default namespace each administration resource + # will be added to. + # + # eg: + # config.default_namespace = :hello_world + # + # This will create resources in the HelloWorld module and + # will namespace routes to /hello_world/* + # + # To set no namespace by default, use: + # config.default_namespace = false + # + # Default: + # config.default_namespace = :admin + # + # You can customize the settings for each namespace by using + # a namespace block. For example, to change the site title + # within a namespace: + # + # config.namespace :admin do |admin| + # admin.site_title = "Custom Admin Title" + # end + # + # This will ONLY change the title for the admin section. Other + # namespaces will continue to use the main "site_title" configuration. + + # == User Authentication + # + # Active Admin will automatically call an authentication + # method in a before filter of all controller actions to + # ensure that there is a currently logged in admin user. + # + # This setting changes the method which Active Admin calls + # within the application controller. + config.authentication_method = :authenticate_admin_user! + + # == User Authorization + # + # Active Admin will automatically call an authorization + # method in a before filter of all controller actions to + # ensure that there is a user with proper rights. You can use + # CanCanAdapter or make your own. Please refer to documentation. + # config.authorization_adapter = ActiveAdmin::CanCanAdapter + + # In case you prefer Pundit over other solutions you can here pass + # the name of default policy class. This policy will be used in every + # case when Pundit is unable to find suitable policy. + # config.pundit_default_policy = "MyDefaultPunditPolicy" + + # If you wish to maintain a separate set of Pundit policies for admin + # resources, you may set a namespace here that Pundit will search + # within when looking for a resource's policy. + # config.pundit_policy_namespace = :admin + + # You can customize your CanCan Ability class name here. + # config.cancan_ability_class = "Ability" + + # You can specify a method to be called on unauthorized access. + # This is necessary in order to prevent a redirect loop which happens + # because, by default, user gets redirected to Dashboard. If user + # doesn't have access to Dashboard, he'll end up in a redirect loop. + # Method provided here should be defined in application_controller.rb. + # config.on_unauthorized_access = :access_denied + + # == Current User + # + # Active Admin will associate actions with the current + # user performing them. + # + # This setting changes the method which Active Admin calls + # (within the application controller) to return the currently logged in user. + config.current_user_method = :current_admin_user + + # == Logging Out + # + # Active Admin displays a logout link on each screen. These + # settings configure the location and method used for the link. + # + # This setting changes the path where the link points to. If it's + # a string, the strings is used as the path. If it's a Symbol, we + # will call the method to return the path. + # + # Default: + config.logout_link_path = :destroy_admin_user_session_path + + # This setting changes the http method used when rendering the + # link. For example :get, :delete, :put, etc.. + # + # Default: + # config.logout_link_method = :get + + # == Root + # + # Set the action to call for the root path. You can set different + # roots for each namespace. + # + # Default: + # config.root_to = 'dashboard#index' + + # == Admin Comments + # + # This allows your users to comment on any resource registered with Active Admin. + # + # You can completely disable comments: + # config.comments = false + # + # You can change the name under which comments are registered: + # config.comments_registration_name = 'AdminComment' + # + # You can change the order for the comments and you can change the column + # to be used for ordering: + # config.comments_order = 'created_at ASC' + # + # You can disable the menu item for the comments index page: + # config.comments_menu = false + # + # You can customize the comment menu: + # config.comments_menu = { parent: 'Admin', priority: 1 } + + # == Batch Actions + # + # Enable and disable Batch Actions + # + config.batch_actions = true + + # == Controller Filters + # + # You can add before, after and around filters to all of your + # Active Admin resources and pages from here. + # + # config.before_action :do_something_awesome + + # == Attribute Filters + # + # You can exclude possibly sensitive model attributes from being displayed, + # added to forms, or exported by default by ActiveAdmin + # + config.filter_attributes = [:encrypted_password, :password, :password_confirmation] + + # == Localize Date/Time Format + # + # Set the localize format to display dates and times. + # To understand how to localize your app with I18n, read more at + # https://guides.rubyonrails.org/i18n.html + # + # You can run `bin/rails runner 'puts I18n.t("date.formats")'` to see the + # available formats in your application. + # + config.localize_format = :long + + # == Setting a Favicon + # + # config.favicon = 'favicon.ico' + + # == Meta Tags + # + # Add additional meta tags to the head element of active admin pages. + # + # Add tags to all pages logged in users see: + # config.meta_tags = { author: 'My Company' } + + # By default, sign up/sign in/recover password pages are excluded + # from showing up in search engine results by adding a robots meta + # tag. You can reset the hash of meta tags included in logged out + # pages: + # config.meta_tags_for_logged_out_pages = {} + + # == Removing Breadcrumbs + # + # Breadcrumbs are enabled by default. You can customize them for individual + # resources or you can disable them globally from here. + # + # config.breadcrumb = false + + # == Create Another Checkbox + # + # Create another checkbox is disabled by default. You can customize it for individual + # resources or you can enable them globally from here. + # + # config.create_another = true + + # == Register Stylesheets & Javascripts + # + # We recommend using the built in Active Admin layout and loading + # up your own stylesheets / javascripts to customize the look + # and feel. + # + # To load a stylesheet: + # config.register_stylesheet 'my_stylesheet.css' + # + # You can provide an options hash for more control, which is passed along to stylesheet_link_tag(): + # config.register_stylesheet 'my_print_stylesheet.css', media: :print + # + # To load a javascript file: + # config.register_javascript 'my_javascript.js' + + # == CSV options + # + # Set the CSV builder separator + # config.csv_options = { col_sep: ';' } + # + # Force the use of quotes + # config.csv_options = { force_quotes: true } + + # == Menu System + # + # You can add a navigation menu to be used in your application, or configure a provided menu + # + # To change the default utility navigation to show a link to your website & a logout btn + # + # config.namespace :admin do |admin| + # admin.build_menu :utility_navigation do |menu| + # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank } + # admin.add_logout_button_to_menu menu + # end + # end + # + # If you wanted to add a static menu item to the default menu provided: + # + # config.namespace :admin do |admin| + # admin.build_menu :default do |menu| + # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank } + # end + # end + + # == Download Links + # + # You can disable download links on resource listing pages, + # or customize the formats shown per namespace/globally + # + # To disable/customize for the :admin namespace: + # + # config.namespace :admin do |admin| + # + # # Disable the links entirely + # admin.download_links = false + # + # # Only show XML & PDF options + # admin.download_links = [:xml, :pdf] + # + # # Enable/disable the links based on block + # # (for example, with cancan) + # admin.download_links = proc { can?(:view_download_links) } + # + # end + + # == Pagination + # + # Pagination is enabled by default for all resources. + # You can control the default per page count for all resources here. + # + # config.default_per_page = 30 + # + # You can control the max per page count too. + # + # config.max_per_page = 10_000 + + # == Filters + # + # By default the index screen includes a "Filters" sidebar on the right + # hand side with a filter for each attribute of the registered model. + # You can enable or disable them for all resources here. + # + # config.filters = true + # + # By default the filters include associations in a select, which means + # that every record will be loaded for each association (up + # to the value of config.maximum_association_filter_arity). + # You can enabled or disable the inclusion + # of those filters by default here. + # + # config.include_default_association_filters = true + + # config.maximum_association_filter_arity = 256 # default value of :unlimited will change to 256 in a future version + # config.filter_columns_for_large_association = [ + # :display_name, + # :full_name, + # :name, + # :username, + # :login, + # :title, + # :email, + # ] + # config.filter_method_for_large_association = '_starts_with' + + # == Head + # + # You can add your own content to the site head like analytics. Make sure + # you only pass content you trust. + # + # config.head = ''.html_safe + + # == Footer + # + # By default, the footer shows the current Active Admin version. You can + # override the content of the footer here. + # + # config.footer = 'my custom footer text' + + # == Sorting + # + # By default ActiveAdmin::OrderClause is used for sorting logic + # You can inherit it with own class and inject it for all resources + # + # config.order_clause = MyOrderClause + + # == Webpacker + # + # By default, Active Admin uses Sprocket's asset pipeline. + # You can switch to using Webpacker here. + # + # config.use_webpacker = true +end diff --git a/test_app/blog/config/initializers/assets.rb b/test_app/blog/config/initializers/assets.rb new file mode 100644 index 0000000..2eeef96 --- /dev/null +++ b/test_app/blog/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/blog/config/initializers/content_security_policy.rb b/test_app/blog/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..54f47cf --- /dev/null +++ b/test_app/blog/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header + +# Rails.application.configure do +# 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 +# +# # Generate session nonces for permitted importmap and inline scripts +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/test_app/blog/config/initializers/devise.rb b/test_app/blog/config/initializers/devise.rb new file mode 100644 index 0000000..bcbb7e8 --- /dev/null +++ b/test_app/blog/config/initializers/devise.rb @@ -0,0 +1,313 @@ +# frozen_string_literal: true + +# Assuming you have not yet modified this file, each configuration option below +# is set to its default value. Note that some are commented out while others +# are not: uncommented lines are intended to protect your configuration from +# breaking changes in upgrades (i.e., in the event that future versions of +# Devise change the default values for those options). +# +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. +Devise.setup do |config| + # The secret key used by Devise. Devise uses this key to generate + # random tokens. Changing this key will render invalid all existing + # confirmation, reset password and unlock tokens in the database. + # Devise will use the `secret_key_base` as its `secret_key` + # by default. You can change it below and use your own secret key. + # config.secret_key = '63bcbe7e44dca3732cdf03044e5ca304d8a1bd6615a892f964d79de0de48d7daeb12ce1478a42dffb97bd32752c2cb8c64a7ca9f434fb863f08f6d0a11a78125' + + # ==> Controller configuration + # Configure the parent class to the devise controllers. + # config.parent_controller = 'DeviseController' + + # ==> Mailer Configuration + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class + # with default "from" parameter. + config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' + + # Configure the class responsible to send e-mails. + # config.mailer = 'Devise::Mailer' + + # Configure the parent class responsible to send e-mails. + # config.parent_mailer = 'ActionMailer::Base' + + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'devise/orm/active_record' + + # ==> Configuration for any authentication mechanism + # Configure which keys are used when authenticating a user. The default is + # just :email. You can configure it to use [:username, :subdomain], so for + # authenticating a user, both parameters are required. Remember that those + # parameters are used only when authenticating and not when retrieving from + # session. If you need permissions, you should implement that in a before filter. + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. + # config.authentication_keys = [:email] + + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [:email] + + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [:email] + + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. + # config.params_authenticatable = true + + # Tell if authentication through HTTP Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:database]` will + # enable it only for database authentication. + # For API-only applications to support authentication "out-of-the-box", you will likely want to + # enable this with :database unless you are using a custom strategy. + # The supported strategies are: + # :database = Support basic authentication with authentication key + password + # config.http_authenticatable = false + + # If 401 status code should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true + + # The realm used in Http Basic Authentication. 'Application' by default. + # config.http_authentication_realm = 'Application' + + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # particular strategies by setting this option. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing skip: :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # By default, Devise cleans up the CSRF token on authentication to + # avoid CSRF token fixation attacks. This means that, when using AJAX + # requests for sign in and sign up, you need to get a new CSRF token + # from the server. You can disable this option at your own risk. + # config.clean_up_csrf_token_on_authentication = true + + # When false, Devise will not attempt to reload routes on eager load. + # This can reduce the time taken to boot the app but if your application + # requires the Devise mappings to be loaded during boot time the application + # won't boot properly. + # config.reload_routes = true + + # ==> Configuration for :database_authenticatable + # For bcrypt, this is the cost for hashing the password and defaults to 12. If + # using other algorithms, it sets how many times you want the password to be hashed. + # The number of stretches used for generating the hashed password are stored + # with the hashed password. This allows you to change the stretches without + # invalidating existing passwords. + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. Note that, for bcrypt (the default + # algorithm), the cost increases exponentially with the number of stretches (e.g. + # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). + config.stretches = Rails.env.test? ? 1 : 12 + + # Set up a pepper to generate the hashed password. + # config.pepper = 'bee4454e247381a02dd19731d7d7e11d33f1d0bdeaaa933c3fa125df42dbdb3742dd46972b0b921ece8142fa608b0d0be0e08b72ef45d514528e73a0f2f6787a' + + # Send a notification to the original email when the user's email is changed. + # config.send_email_changed_notification = false + + # Send a notification email when the user's password is changed. + # config.send_password_change_notification = false + + # ==> Configuration for :confirmable + # A period that the user is allowed to access the website even without + # confirming their account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming their account, + # access will be blocked just in the third day. + # You can also set it to nil, which will allow the user to access the website + # without confirming their account. + # Default is 0.days, meaning the user cannot access the website without + # confirming their account. + # config.allow_unconfirmed_access_for = 2.days + + # A period that the user is allowed to confirm their account before their + # token becomes invalid. For example, if set to 3.days, the user can confirm + # their account within 3 days after the mail was sent, but on the fourth day + # their account can't be confirmed with the token any more. + # Default is nil, meaning there is no restriction on how long a user can take + # before confirming their account. + # config.confirm_within = 3.days + + # If true, requires any email changes to be confirmed (exactly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed, new email is stored in + # unconfirmed_email column, and copied to email column on successful confirmation. + config.reconfirmable = true + + # Defines which key will be used when confirming an account + # config.confirmation_keys = [:email] + + # ==> Configuration for :rememberable + # The time the user will be remembered without asking for credentials again. + # config.remember_for = 2.weeks + + # Invalidates all the remember me tokens when the user signs out. + config.expire_all_remember_me_on_sign_out = true + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # Options to be passed to the created cookie. For instance, you can set + # secure: true in order to force SSL only cookies. + # config.rememberable_options = {} + + # ==> Configuration for :validatable + # Range for password length. + config.password_length = 6..128 + + # Email regex used to validate email formats. It simply asserts that + # one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ + + # ==> Configuration for :timeoutable + # The time you want to timeout the user session without activity. After this + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # ==> Configuration for :lockable + # Defines which strategy will be used to lock an account. + # :failed_attempts = Locks an account after a number of failed attempts to sign in. + # :none = No lock strategy. You should handle locking by yourself. + # config.lock_strategy = :failed_attempts + + # Defines which key will be used when locking and unlocking an account + # config.unlock_keys = [:email] + + # Defines which strategy will be used to unlock an account. + # :email = Sends an unlock link to the user email + # :time = Re-enables login after a certain amount of time (see :unlock_in below) + # :both = Enables both strategies + # :none = No unlock strategy. You should handle unlocking by yourself. + # config.unlock_strategy = :both + + # Number of authentication tries before locking an account if lock_strategy + # is failed attempts. + # config.maximum_attempts = 20 + + # Time interval to unlock the account if :time is enabled as unlock_strategy. + # config.unlock_in = 1.hour + + # Warn on the last attempt before the account is locked. + # config.last_attempt_warning = true + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + # config.reset_password_keys = [:email] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + + # When set to false, does not sign a user in automatically after their password is + # reset. Defaults to true, so a user is signed in automatically after a reset. + # config.sign_in_after_reset_password = true + + # ==> Configuration for :encryptable + # Allow you to use another hashing or encryption algorithm besides bcrypt (default). + # You can use :sha1, :sha512 or algorithms from others authentication tools as + # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 + # for default behavior) and :restful_authentication_sha1 (then you should set + # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). + # + # Require the `devise-encryptable` gem when using anything other than bcrypt + # config.encryptor = :sha512 + + # ==> Scopes configuration + # Turn scoped views on. Before rendering "sessions/new", it will first check for + # "users/sessions/new". It's turned off by default because it's slower if you + # are using only default views. + # config.scoped_views = false + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). + # config.default_scope = :user + + # Set this configuration to false if you want /users/sign_out to sign out + # only the current scope. By default, Devise signs out all scopes. + # config.sign_out_all_scopes = true + + # ==> Navigation configuration + # Lists the formats that should be treated as navigational. Formats like + # :html should redirect to the sign in page when the user does not have + # access, but formats like :xml or :json, should return 401. + # + # If you have any extra navigational formats, like :iphone or :mobile, you + # should add them to the navigational formats lists. + # + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ['*/*', :html, :turbo_stream] + + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' + + # ==> Warden configuration + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. + # + # config.warden do |manager| + # manager.intercept_401 = false + # manager.default_strategies(scope: :user).unshift :some_external_strategy + # end + + # ==> Mountable engine configurations + # When using Devise inside an engine, let's call it `MyEngine`, and this engine + # is mountable, there are some extra configurations to be taken into account. + # The following options are available, assuming the engine is mounted as: + # + # mount MyEngine, at: '/my_engine' + # + # The router that invoked `devise_for`, in the example above, would be: + # config.router_name = :my_engine + # + # When using OmniAuth, Devise cannot automatically set OmniAuth path, + # so you need to do it manually. For the users scope, it would be: + # config.omniauth_path_prefix = '/my_engine/users/auth' + + # ==> Hotwire/Turbo configuration + # When using Devise with Hotwire/Turbo, the http status for error responses + # and some redirects must match the following. The default in Devise for existing + # apps is `200 OK` and `302 Found respectively`, but new apps are generated with + # these new defaults that match Hotwire/Turbo behavior. + # Note: These might become the new default in future versions of Devise. + config.responder.error_status = :unprocessable_entity + config.responder.redirect_status = :see_other + + # ==> Configuration for :registerable + + # When set to false, does not sign a user in automatically after their password is + # changed. Defaults to true, so a user is signed in automatically after changing a password. + # config.sign_in_after_change_password = true +end diff --git a/test_app/blog/config/initializers/filter_parameter_logging.rb b/test_app/blog/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..adc6568 --- /dev/null +++ b/test_app/blog/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Configure parameters to be filtered from the log file. Use this to limit dissemination of +# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported +# notations and behaviors. +Rails.application.config.filter_parameters += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/test_app/blog/config/initializers/inflections.rb b/test_app/blog/config/initializers/inflections.rb new file mode 100644 index 0000000..3860f65 --- /dev/null +++ b/test_app/blog/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# 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(:en) do |inflect| +# inflect.acronym "RESTful" +# end diff --git a/test_app/blog/config/initializers/permissions_policy.rb b/test_app/blog/config/initializers/permissions_policy.rb new file mode 100644 index 0000000..00f64d7 --- /dev/null +++ b/test_app/blog/config/initializers/permissions_policy.rb @@ -0,0 +1,11 @@ +# Define an application-wide HTTP permissions policy. For further +# information see https://developers.google.com/web/updates/2018/06/feature-policy +# +# Rails.application.config.permissions_policy do |f| +# f.camera :none +# f.gyroscope :none +# f.microphone :none +# f.usb :none +# f.fullscreen :self +# f.payment :self, "https://secure.example.com" +# end diff --git a/test_app/blog/config/locales/devise.en.yml b/test_app/blog/config/locales/devise.en.yml new file mode 100644 index 0000000..260e1c4 --- /dev/null +++ b/test_app/blog/config/locales/devise.en.yml @@ -0,0 +1,65 @@ +# Additional translations at https://github.com/heartcombo/devise/wiki/I18n + +en: + devise: + confirmations: + confirmed: "Your email address has been successfully confirmed." + send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." + failure: + already_authenticated: "You are already signed in." + inactive: "Your account is not activated yet." + invalid: "Invalid %{authentication_keys} or password." + locked: "Your account is locked." + last_attempt: "You have one more attempt before your account is locked." + not_found_in_database: "Invalid %{authentication_keys} or password." + timeout: "Your session expired. Please sign in again to continue." + unauthenticated: "You need to sign in or sign up before continuing." + unconfirmed: "You have to confirm your email address before continuing." + mailer: + confirmation_instructions: + subject: "Confirmation instructions" + reset_password_instructions: + subject: "Reset password instructions" + unlock_instructions: + subject: "Unlock instructions" + email_changed: + subject: "Email Changed" + password_change: + subject: "Password Changed" + omniauth_callbacks: + failure: "Could not authenticate you from %{kind} because \"%{reason}\"." + success: "Successfully authenticated from %{kind} account." + passwords: + no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." + send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." + updated: "Your password has been changed successfully. You are now signed in." + updated_not_active: "Your password has been changed successfully." + registrations: + destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." + signed_up: "Welcome! You have signed up successfully." + signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." + signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." + signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address." + updated: "Your account has been updated successfully." + updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again." + sessions: + signed_in: "Signed in successfully." + signed_out: "Signed out successfully." + already_signed_out: "Signed out successfully." + unlocks: + send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." + send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." + unlocked: "Your account has been unlocked successfully. Please sign in to continue." + errors: + messages: + already_confirmed: "was already confirmed, please try signing in" + confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" + expired: "has expired, please request a new one" + not_found: "not found" + not_locked: "was not locked" + not_saved: + one: "1 error prohibited this %{resource} from being saved:" + other: "%{count} errors prohibited this %{resource} from being saved:" diff --git a/test_app/blog/config/locales/en.yml b/test_app/blog/config/locales/en.yml new file mode 100644 index 0000000..8ca56fc --- /dev/null +++ b/test_app/blog/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t "hello" +# +# In views, this is aliased to just `t`: +# +# <%= t("hello") %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# "true": "foo" +# +# To learn more, please read the Rails Internationalization guide +# available at https://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test_app/blog/config/puma.rb b/test_app/blog/config/puma.rb new file mode 100644 index 0000000..daaf036 --- /dev/null +++ b/test_app/blog/config/puma.rb @@ -0,0 +1,43 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +threads min_threads_count, max_threads_count + +# Specifies the `worker_timeout` threshold that Puma will use to wait before +# terminating a worker in development environments. +# +worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked web server processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart diff --git a/test_app/blog/config/routes.rb b/test_app/blog/config/routes.rb new file mode 100644 index 0000000..7b8395a --- /dev/null +++ b/test_app/blog/config/routes.rb @@ -0,0 +1,8 @@ +Rails.application.routes.draw do + devise_for :admin_users, ActiveAdmin::Devise.config + ActiveAdmin.routes(self) + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + + # Defines the root path route ("/") + # root "articles#index" +end diff --git a/test_app/blog/config/storage.yml b/test_app/blog/config/storage.yml new file mode 100644 index 0000000..4942ab6 --- /dev/null +++ b/test_app/blog/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket-<%= Rails.env %> + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket-<%= Rails.env %> + +# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name-<%= Rails.env %> + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/test_app/blog/db/migrate/20230425060437_devise_create_admin_users.rb b/test_app/blog/db/migrate/20230425060437_devise_create_admin_users.rb new file mode 100644 index 0000000..65e1bab --- /dev/null +++ b/test_app/blog/db/migrate/20230425060437_devise_create_admin_users.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +class DeviseCreateAdminUsers < ActiveRecord::Migration[7.0] + def change + create_table :admin_users do |t| + ## Database authenticatable + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" + + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + + ## Rememberable + t.datetime :remember_created_at + + ## Trackable + # t.integer :sign_in_count, default: 0, null: false + # t.datetime :current_sign_in_at + # t.datetime :last_sign_in_at + # t.string :current_sign_in_ip + # t.string :last_sign_in_ip + + ## Confirmable + # t.string :confirmation_token + # t.datetime :confirmed_at + # t.datetime :confirmation_sent_at + # t.string :unconfirmed_email # Only if using reconfirmable + + ## Lockable + # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts + # t.string :unlock_token # Only if unlock strategy is :email or :both + # t.datetime :locked_at + + + t.timestamps null: false + end + + add_index :admin_users, :email, unique: true + add_index :admin_users, :reset_password_token, unique: true + # add_index :admin_users, :confirmation_token, unique: true + # add_index :admin_users, :unlock_token, unique: true + end +end diff --git a/test_app/blog/db/migrate/20230425060439_create_active_admin_comments.rb b/test_app/blog/db/migrate/20230425060439_create_active_admin_comments.rb new file mode 100644 index 0000000..b0e3aa7 --- /dev/null +++ b/test_app/blog/db/migrate/20230425060439_create_active_admin_comments.rb @@ -0,0 +1,16 @@ +class CreateActiveAdminComments < ActiveRecord::Migration[7.0] + def self.up + create_table :active_admin_comments do |t| + t.string :namespace + t.text :body + t.references :resource, polymorphic: true + t.references :author, polymorphic: true + t.timestamps + end + add_index :active_admin_comments, [:namespace] + end + + def self.down + drop_table :active_admin_comments + end +end diff --git a/test_app/blog/db/migrate/20230425060707_initial_schema.rb b/test_app/blog/db/migrate/20230425060707_initial_schema.rb new file mode 100644 index 0000000..dfda567 --- /dev/null +++ b/test_app/blog/db/migrate/20230425060707_initial_schema.rb @@ -0,0 +1,17 @@ +class InitialSchema < ActiveRecord::Migration[7.0] + def change + create_table :categories do |t| + t.string :name, null: false + end + + create_table :subcategories do |t| + t.string :name, null: false + t.references :category, null: false, index: true + end + + create_table :items do |t| + t.string :name, null: false + t.references :subcategory, null: false, index: true + end + end +end diff --git a/test_app/blog/db/migrate/20230425060708_create_tags.rb b/test_app/blog/db/migrate/20230425060708_create_tags.rb new file mode 100644 index 0000000..6ea8406 --- /dev/null +++ b/test_app/blog/db/migrate/20230425060708_create_tags.rb @@ -0,0 +1,13 @@ +class CreateTags < ActiveRecord::Migration[7.0] + def change + create_table :tags do |t| + t.string :name, null: false + t.references :subcategory, null: false, index: true + end + + create_join_table :items, :tags do |t| + t.index [:item_id, :tag_id] + t.index [:tag_id, :item_id] + end + end +end diff --git a/test_app/blog/db/schema.rb b/test_app/blog/db/schema.rb new file mode 100644 index 0000000..9f5ab3f --- /dev/null +++ b/test_app/blog/db/schema.rb @@ -0,0 +1,69 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[7.0].define(version: 2023_04_25_060708) do + create_table "active_admin_comments", force: :cascade do |t| + t.string "namespace" + t.text "body" + t.string "resource_type" + t.integer "resource_id" + t.string "author_type" + t.integer "author_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author" + t.index ["namespace"], name: "index_active_admin_comments_on_namespace" + t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource" + end + + create_table "admin_users", force: :cascade do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["email"], name: "index_admin_users_on_email", unique: true + t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true + end + + create_table "categories", force: :cascade do |t| + t.string "name", null: false + end + + create_table "items", force: :cascade do |t| + t.string "name", null: false + t.integer "subcategory_id", null: false + t.index ["subcategory_id"], name: "index_items_on_subcategory_id" + end + + create_table "items_tags", id: false, force: :cascade do |t| + t.integer "item_id", null: false + t.integer "tag_id", null: false + t.index ["item_id", "tag_id"], name: "index_items_tags_on_item_id_and_tag_id" + t.index ["tag_id", "item_id"], name: "index_items_tags_on_tag_id_and_item_id" + end + + create_table "subcategories", force: :cascade do |t| + t.string "name", null: false + t.integer "category_id", null: false + t.index ["category_id"], name: "index_subcategories_on_category_id" + end + + create_table "tags", force: :cascade do |t| + t.string "name", null: false + t.integer "subcategory_id", null: false + t.index ["subcategory_id"], name: "index_tags_on_subcategory_id" + end + +end diff --git a/test_app/blog/db/seeds.rb b/test_app/blog/db/seeds.rb new file mode 100644 index 0000000..aac94e9 --- /dev/null +++ b/test_app/blog/db/seeds.rb @@ -0,0 +1,33 @@ +require 'faker' + +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) +# Character.create(name: "Luke", movie: movies.first) +# AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if Rails.env.development? + + +ActiveRecord::Base.transaction do + categories = 5.times.map { Category.create!(name: Faker::Fantasy::Tolkien.unique.location ) } + + subcategories = categories.flat_map do |category| + 3.times.map { Subcategory.create!(category: category, name: Faker::Fantasy::Tolkien.unique.location) } + end + + tags = subcategories.flat_map do |subcategory| + 3.times.map { Tag.create!(subcategory: subcategory, name: Faker::Music.unique.band) } + end + + items = subcategories.flat_map do |subcategory| + 5.times.map do + Item.create!( + subcategory: subcategory, + name: Faker::Fantasy::Tolkien.unique.character, + tags: 2.times.map { tags.sample } + ) + end + end +end diff --git a/test_app/blog/lib/assets/.keep b/test_app/blog/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/lib/tasks/.keep b/test_app/blog/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/log/.keep b/test_app/blog/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/public/404.html b/test_app/blog/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/test_app/blog/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test_app/blog/public/422.html b/test_app/blog/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/test_app/blog/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test_app/blog/public/500.html b/test_app/blog/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/test_app/blog/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test_app/blog/public/apple-touch-icon-precomposed.png b/test_app/blog/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/public/apple-touch-icon.png b/test_app/blog/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/public/favicon.ico b/test_app/blog/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/public/robots.txt b/test_app/blog/public/robots.txt new file mode 100644 index 0000000..c19f78a --- /dev/null +++ b/test_app/blog/public/robots.txt @@ -0,0 +1 @@ +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/test_app/blog/storage/.keep b/test_app/blog/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/test/application_system_test_case.rb b/test_app/blog/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/test_app/blog/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/test_app/blog/test/channels/application_cable/connection_test.rb b/test_app/blog/test/channels/application_cable/connection_test.rb new file mode 100644 index 0000000..800405f --- /dev/null +++ b/test_app/blog/test/channels/application_cable/connection_test.rb @@ -0,0 +1,11 @@ +require "test_helper" + +class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase + # test "connects with cookies" do + # cookies.signed[:user_id] = 42 + # + # connect + # + # assert_equal connection.user_id, "42" + # end +end diff --git a/test_app/blog/test/controllers/.keep b/test_app/blog/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/test/fixtures/admin_users.yml b/test_app/blog/test/fixtures/admin_users.yml new file mode 100644 index 0000000..d7a3329 --- /dev/null +++ b/test_app/blog/test/fixtures/admin_users.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test_app/blog/test/fixtures/files/.keep b/test_app/blog/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/test/helpers/.keep b/test_app/blog/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/test/integration/.keep b/test_app/blog/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/test/mailers/.keep b/test_app/blog/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/test/models/.keep b/test_app/blog/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/test/models/admin_user_test.rb b/test_app/blog/test/models/admin_user_test.rb new file mode 100644 index 0000000..718fba3 --- /dev/null +++ b/test_app/blog/test/models/admin_user_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class AdminUserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test_app/blog/test/system/.keep b/test_app/blog/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/test/test_helper.rb b/test_app/blog/test/test_helper.rb new file mode 100644 index 0000000..d713e37 --- /dev/null +++ b/test_app/blog/test/test_helper.rb @@ -0,0 +1,13 @@ +ENV["RAILS_ENV"] ||= "test" +require_relative "../config/environment" +require "rails/test_help" + +class ActiveSupport::TestCase + # Run tests in parallel with specified workers + parallelize(workers: :number_of_processors) + + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/test_app/blog/tmp/.keep b/test_app/blog/tmp/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/tmp/pids/.keep b/test_app/blog/tmp/pids/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/tmp/storage/.keep b/test_app/blog/tmp/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test_app/blog/vendor/.keep b/test_app/blog/vendor/.keep new file mode 100644 index 0000000..e69de29