diff --git a/.github/workflows/slovensko_digital_ci.yml b/.github/workflows/slovensko_digital_ci.yml index 024d406c..494eaa2a 100644 --- a/.github/workflows/slovensko_digital_ci.yml +++ b/.github/workflows/slovensko_digital_ci.yml @@ -17,7 +17,7 @@ jobs: services: postgres: - image: postgres:12-alpine + image: postgres:14-alpine env: POSTGRES_USER: runner POSTGRES_HOST_AUTH_METHOD: trust @@ -35,9 +35,9 @@ jobs: - run: bundle exec rails webpacker:compile env: NODE_OPTIONS: "--openssl-legacy-provider" - - run: bundle exec rails db:create db:structure:load --trace + - run: bundle exec rails db:test:prepare --trace - - uses: paambaati/codeclimate-action@v2.7.5 + - uses: paambaati/codeclimate-action@v5.0.0 env: CC_TEST_REPORTER_ID: 17d259e00bbff5b020b7f1a6abb6736e0f65b9a517afdcbaeaa79e919730835f with: diff --git a/.gitlab/auto-deploy-values.yaml b/.gitlab/auto-deploy-values.yaml index e7ef5101..6675755b 100644 --- a/.gitlab/auto-deploy-values.yaml +++ b/.gitlab/auto-deploy-values.yaml @@ -45,7 +45,7 @@ workers: memory: 300Mi worker: replicaCount: "1" - command: ["bundle", "exec", "que", "-w1", "./config/environment.rb"] + command: ["bundle", "exec", "good_job", "start"] terminationGracePeriodSeconds: 60 livenessProbe: initialDelaySeconds: 5 diff --git a/Gemfile b/Gemfile index 661419ff..c27c52c6 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '3.2.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 6.1.7.3' +gem 'rails', '~> 7.0.8' gem 'rails-i18n' # Use postgresql as the database for Active Record gem 'pg' @@ -34,7 +34,10 @@ gem 'jbuilder' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development -# Gems for tracking the statuses of jobs +# Workers +gem 'good_job' + +# Remove after migration to good_job gem 'que' gem 'que-web' @@ -80,7 +83,7 @@ group :development, :test do gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'dotenv-rails' gem 'factory_bot_rails' - gem 'rspec-rails', '4.0.2' + gem 'rspec-rails' gem 'rspec_junit_formatter' gem 'faker' end @@ -100,9 +103,8 @@ group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', "~> 3.39.2" gem 'show_me_the_cookies' - gem 'selenium-webdriver', "~> 4.9.0" - gem "webdrivers", "= 5.3.0" - gem 'simplecov', '< 0.18' # https://github.com/codeclimate/test-reporter/issues/413 + gem 'selenium-webdriver', "~> 4.13" + gem 'simplecov', '~> 0.22.0' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/Gemfile.lock b/Gemfile.lock index fad1fa79..af8ba2ad 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,111 +1,118 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.3) - actionpack (= 6.1.7.3) - activesupport (= 6.1.7.3) + actioncable (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.3) - actionpack (= 6.1.7.3) - activejob (= 6.1.7.3) - activerecord (= 6.1.7.3) - activestorage (= 6.1.7.3) - activesupport (= 6.1.7.3) + actionmailbox (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) mail (>= 2.7.1) - actionmailer (6.1.7.3) - actionpack (= 6.1.7.3) - actionview (= 6.1.7.3) - activejob (= 6.1.7.3) - activesupport (= 6.1.7.3) + net-imap + net-pop + net-smtp + actionmailer (7.0.8) + actionpack (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activesupport (= 7.0.8) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7.3) - actionview (= 6.1.7.3) - activesupport (= 6.1.7.3) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.3) - actionpack (= 6.1.7.3) - activerecord (= 6.1.7.3) - activestorage (= 6.1.7.3) - activesupport (= 6.1.7.3) + actiontext (7.0.8) + actionpack (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.3) - activesupport (= 6.1.7.3) + actionview (7.0.8) + activesupport (= 7.0.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.3) - activesupport (= 6.1.7.3) + activejob (7.0.8) + activesupport (= 7.0.8) globalid (>= 0.3.6) - activemodel (6.1.7.3) - activesupport (= 6.1.7.3) - activerecord (6.1.7.3) - activemodel (= 6.1.7.3) - activesupport (= 6.1.7.3) - activestorage (6.1.7.3) - actionpack (= 6.1.7.3) - activejob (= 6.1.7.3) - activerecord (= 6.1.7.3) - activesupport (= 6.1.7.3) + activemodel (7.0.8) + activesupport (= 7.0.8) + activerecord (7.0.8) + activemodel (= 7.0.8) + activesupport (= 7.0.8) + activestorage (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activesupport (= 7.0.8) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.3) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) aws-eventstream (1.2.0) - aws-partitions (1.734.0) - aws-record (2.10.1) - aws-sdk-dynamodb (~> 1.18) - aws-sdk-cloudwatch (1.73.0) - aws-sdk-core (~> 3, >= 3.165.0) + aws-partitions (1.834.0) + aws-record (2.12.0) + aws-sdk-dynamodb (~> 1, >= 1.85.0) + aws-sdk-cloudwatch (1.81.0) + aws-sdk-core (~> 3, >= 3.184.0) aws-sigv4 (~> 1.1) - aws-sdk-core (3.171.0) + aws-sdk-core (3.185.1) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) jmespath (~> 1, >= 1.6.1) - aws-sdk-dynamodb (1.83.0) - aws-sdk-core (~> 3, >= 3.165.0) + aws-sdk-dynamodb (1.95.0) + aws-sdk-core (~> 3, >= 3.184.0) aws-sigv4 (~> 1.1) - aws-sdk-kms (1.63.0) - aws-sdk-core (~> 3, >= 3.165.0) + aws-sdk-kms (1.72.0) + aws-sdk-core (~> 3, >= 3.184.0) aws-sigv4 (~> 1.1) - aws-sdk-rails (3.7.1) + aws-sdk-rails (3.9.0) aws-record (~> 2) - aws-sdk-ses (~> 1) - aws-sdk-sesv2 (~> 1) - aws-sdk-sqs (~> 1) + aws-sdk-ses (~> 1, >= 1.50.0) + aws-sdk-sesv2 (~> 1, >= 1.34.0) + aws-sdk-sqs (~> 1, >= 1.56.0) aws-sessionstore-dynamodb (~> 2) concurrent-ruby (~> 1) railties (>= 5.2.0) - aws-sdk-s3 (1.119.2) - aws-sdk-core (~> 3, >= 3.165.0) + aws-sdk-s3 (1.136.0) + aws-sdk-core (~> 3, >= 3.181.0) aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.4) - aws-sdk-ses (1.49.0) - aws-sdk-core (~> 3, >= 3.165.0) + aws-sigv4 (~> 1.6) + aws-sdk-ses (1.56.0) + aws-sdk-core (~> 3, >= 3.184.0) aws-sigv4 (~> 1.1) - aws-sdk-sesv2 (1.32.0) - aws-sdk-core (~> 3, >= 3.165.0) + aws-sdk-sesv2 (1.40.0) + aws-sdk-core (~> 3, >= 3.184.0) aws-sigv4 (~> 1.1) - aws-sdk-sqs (1.53.0) - aws-sdk-core (~> 3, >= 3.165.0) + aws-sdk-sqs (1.64.0) + aws-sdk-core (~> 3, >= 3.184.0) aws-sigv4 (~> 1.1) - aws-sessionstore-dynamodb (2.0.1) - aws-sdk-dynamodb (~> 1) + aws-sessionstore-dynamodb (2.1.0) + aws-sdk-dynamodb (~> 1, >= 1.85.0) rack (~> 2) - aws-sigv4 (1.5.2) + aws-sigv4 (1.6.0) aws-eventstream (~> 1, >= 1.0.2) + base64 (0.1.1) bindex (0.8.1) bootsnap (1.16.0) msgpack (~> 1.2) @@ -124,12 +131,12 @@ GEM activesupport tzinfo coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) crass (1.0.6) - css_parser (1.14.0) + css_parser (1.16.0) addressable date (3.3.3) - diff-lcs (1.5.0) + diff-lcs (1.5.1) docile (1.4.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) @@ -138,32 +145,45 @@ GEM dotenv (= 2.8.1) railties (>= 3.2) erubi (1.12.0) + et-orbi (1.2.11) + tzinfo ethon (0.16.0) ffi (>= 1.15.0) exception_handler (0.8.0.2) bundler rails (>= 4.2.0) responders - execjs (2.8.1) + execjs (2.9.1) factory_bot (6.2.1) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - faker (3.1.1) + faker (3.2.1) i18n (>= 1.8.11, < 2) - faraday (2.7.4) + faraday (2.7.11) + base64 faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) faraday-net_http (3.0.2) - ffi (1.15.5) + ffi (1.16.3) ffi-compiler (1.0.1) ffi (>= 1.0.0) rake friendly_id (5.5.0) activerecord (>= 4.0.0) - globalid (1.1.0) - activesupport (>= 5.0) + fugit (1.11.0) + et-orbi (~> 1, >= 1.2.11) + raabro (~> 1.4) + globalid (1.2.1) + activesupport (>= 6.1) + good_job (3.28.2) + activejob (>= 6.0.0) + activerecord (>= 6.0.0) + concurrent-ruby (>= 1.0.2) + fugit (>= 1.1) + railties (>= 6.0.0) + thor (>= 0.14.1) hashie (5.0.0) hirb (0.7.3) htmlentities (4.3.4) @@ -175,7 +195,7 @@ GEM http-cookie (1.0.5) domain_name (~> 0.5) http-form_data (2.3.0) - i18n (1.12.0) + i18n (1.14.4) concurrent-ruby (~> 1.0) invisible_captcha (2.1.0) rails (>= 5.2) @@ -183,12 +203,12 @@ GEM actionview (>= 5.0.0) activesupport (>= 5.0.0) jmespath (1.6.2) - jquery-rails (4.5.1) + jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.6.3) - jwt (2.7.0) + jwt (2.7.1) kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -216,9 +236,9 @@ GEM llhttp-ffi (0.4.0) ffi-compiler (~> 1.0) rake (~> 13.0) - loofah (2.19.1) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) + nokogiri (>= 1.12.0) mail (2.8.1) mini_mime (>= 0.1.1) net-imap @@ -226,25 +246,25 @@ GEM net-smtp marcel (1.0.2) matrix (0.4.2) - method_source (1.0.0) + method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.4) - minitest (5.18.0) - msgpack (1.6.1) + mini_portile2 (2.8.6) + minitest (5.22.3) + msgpack (1.7.2) multi_xml (0.6.0) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) - net-imap (0.3.4) + net-imap (0.4.0) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.1) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol nio4r (2.7.0) - nokogiri (1.15.4) + nokogiri (1.16.4) mini_portile2 (~> 2.8.2) racc (~> 1.4) oauth2 (2.0.9) @@ -254,7 +274,7 @@ GEM rack (>= 1.2, < 4) snaky_hash (~> 2.0) version_gem (~> 1.1) - oj (3.14.2) + oj (3.16.1) omniauth (2.1.1) hashie (>= 3.4.6) rack (>= 2.2.3) @@ -270,7 +290,7 @@ GEM omniauth-rails_csrf_protection (1.0.1) actionpack (>= 4.2) omniauth (~> 2.0) - pg (1.4.6) + pg (1.5.4) pg_search (2.3.6) activerecord (>= 5.2) activesupport (>= 5.2) @@ -294,76 +314,78 @@ GEM que-web (0.10.0) que (>= 1) sinatra - racc (1.7.1) - rack (2.2.8) - rack-protection (3.0.5) - rack - rack-proxy (0.7.6) + raabro (1.4.0) + racc (1.7.3) + rack (2.2.9) + rack-protection (3.1.0) + rack (~> 2.2, >= 2.2.4) + rack-proxy (0.7.7) rack rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.3) - actioncable (= 6.1.7.3) - actionmailbox (= 6.1.7.3) - actionmailer (= 6.1.7.3) - actionpack (= 6.1.7.3) - actiontext (= 6.1.7.3) - actionview (= 6.1.7.3) - activejob (= 6.1.7.3) - activemodel (= 6.1.7.3) - activerecord (= 6.1.7.3) - activestorage (= 6.1.7.3) - activesupport (= 6.1.7.3) + rails (7.0.8) + actioncable (= 7.0.8) + actionmailbox (= 7.0.8) + actionmailer (= 7.0.8) + actionpack (= 7.0.8) + actiontext (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activemodel (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) bundler (>= 1.15.0) - railties (= 6.1.7.3) - sprockets-rails (>= 2.0.0) + railties (= 7.0.8) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.5.0) - loofah (~> 2.19, >= 2.19.1) - rails-i18n (7.0.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + rails-i18n (7.0.8) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (6.1.7.3) - actionpack (= 6.1.7.3) - activesupport (= 6.1.7.3) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) method_source rake (>= 12.2) thor (~> 1.0) - rake (13.0.6) + zeitwerk (~> 2.5) + rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - recaptcha (5.12.3) - json + recaptcha (5.15.0) regexp_parser (2.8.1) responders (3.1.0) actionpack (>= 5.2) railties (>= 5.2) rexml (3.2.6) rollbar (3.4.0) - rspec-core (3.12.1) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.6) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (4.0.2) - actionpack (>= 4.2) - activesupport (>= 4.2) - railties (>= 4.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.12.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) ruby2_keywords (0.0.5) @@ -378,7 +400,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt - selenium-webdriver (4.9.1) + selenium-webdriver (4.13.1) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -389,15 +411,16 @@ GEM addressable (~> 2.3, >= 2.3.0) json (~> 2.1, >= 2.1.0) typhoeus (~> 1.0, >= 1.0.1) - simplecov (0.17.1) + simplecov (0.22.0) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - sinatra (3.0.5) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + sinatra (3.1.0) mustermann (~> 3.0) rack (~> 2.2, >= 2.2.4) - rack-protection (= 3.0.5) + rack-protection (= 3.1.0) tilt (~> 2.0) sitemap_generator (6.3.0) builder (~> 3.0) @@ -408,16 +431,16 @@ GEM spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) spring (>= 4) - sprockets (4.2.0) + sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - thor (1.2.1) - tilt (2.1.0) - timeout (0.3.2) + thor (1.3.1) + tilt (2.3.0) + timeout (0.4.0) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) @@ -433,28 +456,24 @@ GEM validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix - version_gem (1.1.2) - web-console (4.2.0) + version_gem (1.1.3) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (5.3.0) - nokogiri (~> 1.6) - rubyzip (>= 1.3.0) - selenium-webdriver (~> 4.0, < 4.11) webpacker (5.4.4) activesupport (>= 5.2) rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) - websocket (1.2.9) - websocket-driver (0.7.5) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.7) + zeitwerk (2.6.13) PLATFORMS ruby @@ -472,6 +491,7 @@ DEPENDENCIES factory_bot_rails faker friendly_id + good_job hirb http invisible_captcha @@ -493,18 +513,18 @@ DEPENDENCIES puma que que-web - rails (~> 6.1.7.3) + rails (~> 7.0.8) rails-controller-testing (~> 1.0) rails-i18n recaptcha rollbar - rspec-rails (= 4.0.2) + rspec-rails rspec_junit_formatter sass-rails - selenium-webdriver (~> 4.9.0) + selenium-webdriver (~> 4.13) show_me_the_cookies sib-api-v3-sdk - simplecov (< 0.18) + simplecov (~> 0.22.0) sitemap_generator spring spring-watcher-listen @@ -514,7 +534,6 @@ DEPENDENCIES validate_url wdm (~> 0.1.0) web-console - webdrivers (= 5.3.0) webpacker RUBY VERSION diff --git a/app/models/concerns/enums.rb b/app/models/concerns/enums.rb index d4aabca6..1495bba2 100644 --- a/app/models/concerns/enums.rb +++ b/app/models/concerns/enums.rb @@ -3,12 +3,12 @@ module Enums class_methods do def enumerates(attribute_name, with:) - enum({ - attribute_name => with.reduce({}) do |acc, item| - acc[item] = item - acc - end - }) + values = with.reduce({}) do |acc, item| + acc[item] = item + acc + end + + enum(attribute_name, values) end end -end \ No newline at end of file +end diff --git a/app/views/components/_feedbackbar.html.erb b/app/views/components/_feedbackbar.html.erb index d97f53d9..389599ce 100644 --- a/app/views/components/_feedbackbar.html.erb +++ b/app/views/components/_feedbackbar.html.erb @@ -33,7 +33,7 @@ ZatvoriƄ - <%= form_with url: feedbacks_path do |form| %> + <%= form_with url: feedbacks_path, local: false do |form| %> <%= hidden_field_tag :feedback_type, 'Useful' %> <%= hidden_field_tag :current_path, request.fullpath %>
@@ -54,7 +54,7 @@
- <%= form_with url: feedbacks_path do |form| %> + <%= form_with url: feedbacks_path, local: false do |form| %> <%= hidden_field_tag :feedback_type, 'Not useful' %> <%= hidden_field_tag :current_path, request.fullpath %>
@@ -86,7 +86,7 @@
- <%= form_with url: feedbacks_path do |form| %> + <%= form_with url: feedbacks_path, local: false do |form| %> <%= hidden_field_tag :feedback_type, 'Bug report' %> <%= hidden_field_tag :current_path, request.fullpath %>
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 065f3771..6c6524bc 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -69,7 +69,9 @@
  • <%= link_to 'Categories', admin_categories_path, class: 'govuk-header__link' %>
  • - +
  • + <%= link_to 'Good Job', '/admin/good_job', class: 'govuk-header__link' %> +
  • <%= link_to 'Que', '/admin/que', class: 'govuk-header__link' %>
  • diff --git a/bin/rails b/bin/rails index 07396602..efc03774 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake index 17240489..4fbf10b9 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -require_relative '../config/boot' -require 'rake' +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/bin/setup b/bin/setup index 5853b5ea..ec47b79b 100755 --- a/bin/setup +++ b/bin/setup @@ -1,36 +1,33 @@ #!/usr/bin/env ruby -require 'fileutils' +require "fileutils" # path to your application root. -APP_ROOT = File.expand_path('..', __dir__) +APP_ROOT = File.expand_path("..", __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end FileUtils.chdir APP_ROOT do - # This script is a way to setup or update your development environment automatically. - # This script is idempotent, so that you can run it at anytime and get an expectable outcome. + # 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') - - # Install JavaScript dependencies - # system('bin/yarn') + 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' + # 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' + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/config/application.rb b/config/application.rb index ad4ec8cd..9c6e2a74 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,6 +1,6 @@ -require_relative 'boot' +require_relative "boot" -require 'rails/all' +require "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -9,11 +9,19 @@ module NavodySlovenskoDigital class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.0 + config.load_defaults 7.0 + # remove when `config.load_defaults` changes to 7.x + config.active_support.cache_format_version = 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.i18n.default_locale = :sk - config.time_zone = 'Bratislava' + config.time_zone = "Bratislava" # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers @@ -34,15 +42,19 @@ class Application < Rails::Application options[:port] = app_port.to_i end + config.active_job.queue_adapter = :good_job + # config.active_job.default_queue_name = :medium_priority + # config.action_mailer.deliver_later_queue_name = :high_priority + config.action_mailer.default_url_options = options - config.action_mailer.deliver_later_queue_name = 'default' + config.action_mailer.deliver_later_queue_name = "default" config.active_record.schema_format = :sql config.exception_handler = { exceptions: { all: { - layout: 'errors/all' + layout: "errors/all" }, "404": { layout: "errors/404" @@ -51,5 +63,3 @@ class Application < Rails::Application } end end - -require 'que/active_record/model' diff --git a/config/boot.rb b/config/boot.rb index b9e460ce..988a5ddc 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +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. +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/environment.rb b/config/environment.rb index 426333bb..cac53157 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require_relative 'application' +require_relative "application" # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 45541f67..8e4fa98d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,8 +1,10 @@ +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 on - # every request. This slows down response time but is perfect for development + # 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 @@ -12,14 +14,18 @@ # 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? + 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}" + "Cache-Control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -43,6 +49,12 @@ # 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 @@ -58,9 +70,15 @@ config.assets.quiet = true # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index a22df796..6d647be9 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,5 +1,6 @@ +require "active_support/core_ext/integer/time" + Rails.application.configure do - app_config = Rails.application.config_for(:app) # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. @@ -21,34 +22,34 @@ # 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? + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? - # Compress JavaScripts and CSS. + # 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.action_controller.asset_host = "#{app_config['protocol']}://#{app_config['host']}" + # 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 + # 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 = :amazon # 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.*/ ] + # 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 - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. + # 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 = :debug # Prepend all log lines with the following tags. @@ -57,10 +58,6 @@ # 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 = :que - # config.active_job.queue_name_prefix = "navody_slovensko_digital_#{Rails.env}" - config.action_mailer.perform_caching = false config.action_mailer.delivery_method = :aws_sdk @@ -71,7 +68,7 @@ # 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 = [I18n.default_locale] + config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify @@ -80,8 +77,8 @@ 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') + # 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) diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 453ac4bd..9342049a 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -57,10 +57,6 @@ # 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 = :que - # config.active_job.queue_name_prefix = "navody_slovensko_digital_#{Rails.env}" - config.action_mailer.perform_caching = false config.action_mailer.delivery_method = :aws_sdk diff --git a/config/environments/test.rb b/config/environments/test.rb index ff875406..e3400634 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,3 +1,5 @@ +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 @@ -6,17 +8,18 @@ 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 = false - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. - config.eager_load = false + # 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}" + "Cache-Control" => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. @@ -47,8 +50,17 @@ # 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.action_view.raise_on_missing_translations = true + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true config.action_mailer.default_url_options = { host: 'http://localhost:3000' } end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index fff37314..071ba66f 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,12 +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' +Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path # Add Yarn node_modules folder to the asset load path. -Rails.application.config.assets.paths << Rails.root.join('node_modules') +Rails.application.config.assets.paths << Rails.root.join("node_modules") # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 35d0f26f..54f47cf1 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,30 +1,25 @@ # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# 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.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 -# # If you are using webpack-dev-server then specify webpack-dev-server host -# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? - -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" +# 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 - -# If you are using UJS then enable automatic nonce generation -# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } - -# Set the nonce only to specific directives -# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) - -# Report CSP violations to a specified URI -# For further information see the following documentation: -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only -# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1e..a9a173b9 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +# 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 += [ + :password, :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/config/initializers/good_job_admin.rb b/config/initializers/good_job_admin.rb new file mode 100644 index 00000000..2a1bd7a9 --- /dev/null +++ b/config/initializers/good_job_admin.rb @@ -0,0 +1,7 @@ +GoodJob::Engine.middleware.use(Rack::Auth::Basic) do |username, password| + admin_username = Rails.application.config_for(:app).dig(:admin, :username) + admin_password = Rails.application.config_for(:app).dig(:admin, :password) + + ActiveSupport::SecurityUtils.secure_compare(admin_username, username) && + ActiveSupport::SecurityUtils.secure_compare(admin_password, password) +end diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index ac033bf9..3860f659 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,13 @@ # 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.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' +# inflect.acronym "RESTful" # end diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb new file mode 100644 index 00000000..00f64d71 --- /dev/null +++ b/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/config/initializers/queweb.rb b/config/initializers/queweb.rb deleted file mode 100644 index 1cbdb610..00000000 --- a/config/initializers/queweb.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Authentication allowing only admin to view the que status -Que::Web.use(Rack::Auth::Basic) do |user, password| - [user, password] == [Rails.application.config_for(:app).dig(:admin, :username), - Rails.application.config_for(:app).dig(:admin, :password)] -end diff --git a/config/routes.rb b/config/routes.rb index c4c46b57..24510901 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,9 +42,7 @@ put :hide, on: :member end - # Route for que - require 'que/web' - mount Que::Web => '/admin/que' + mount GoodJob::Engine => 'good_job' end root to: 'pages#index' diff --git a/db/migrate/20231007083404_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20231007083404_add_service_name_to_active_storage_blobs.active_storage.rb new file mode 100644 index 00000000..a15c6ce8 --- /dev/null +++ b/db/migrate/20231007083404_add_service_name_to_active_storage_blobs.active_storage.rb @@ -0,0 +1,22 @@ +# This migration comes from active_storage (originally 20190112182829) +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + return unless table_exists?(:active_storage_blobs) + + unless column_exists?(:active_storage_blobs, :service_name) + add_column :active_storage_blobs, :service_name, :string + + if configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + + change_column :active_storage_blobs, :service_name, :string, null: false + end + end + + def down + return unless table_exists?(:active_storage_blobs) + + remove_column :active_storage_blobs, :service_name + end +end diff --git a/db/migrate/20231007083405_create_active_storage_variant_records.active_storage.rb b/db/migrate/20231007083405_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 00000000..94ac83af --- /dev/null +++ b/db/migrate/20231007083405_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + # Use Active Record's configured type for primary key + create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| + t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type + t.string :variation_digest, null: false + + t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end +end diff --git a/db/migrate/20231007083406_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb b/db/migrate/20231007083406_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb new file mode 100644 index 00000000..93c8b85a --- /dev/null +++ b/db/migrate/20231007083406_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb @@ -0,0 +1,8 @@ +# This migration comes from active_storage (originally 20211119233751) +class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + change_column_null(:active_storage_blobs, :checksum, true) + end +end diff --git a/db/migrate/20231007141039_create_good_jobs.rb b/db/migrate/20231007141039_create_good_jobs.rb new file mode 100644 index 00000000..72869097 --- /dev/null +++ b/db/migrate/20231007141039_create_good_jobs.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true + +class CreateGoodJobs < ActiveRecord::Migration[7.0] + def change + # Uncomment for Postgres v12 or earlier to enable gen_random_uuid() support + # enable_extension 'pgcrypto' + + create_table :good_jobs, id: :uuid do |t| + t.text :queue_name + t.integer :priority + t.jsonb :serialized_params + t.datetime :scheduled_at + t.datetime :performed_at + t.datetime :finished_at + t.text :error + + t.timestamps + + t.uuid :active_job_id + t.text :concurrency_key + t.text :cron_key + t.uuid :retried_good_job_id + t.datetime :cron_at + + t.uuid :batch_id + t.uuid :batch_callback_id + + t.boolean :is_discrete + t.integer :executions_count + t.text :job_class + t.integer :error_event, limit: 2 + end + + create_table :good_job_batches, id: :uuid do |t| + t.timestamps + t.text :description + t.jsonb :serialized_properties + t.text :on_finish + t.text :on_success + t.text :on_discard + t.text :callback_queue_name + t.integer :callback_priority + t.datetime :enqueued_at + t.datetime :discarded_at + t.datetime :finished_at + end + + create_table :good_job_executions, id: :uuid do |t| + t.timestamps + + t.uuid :active_job_id, null: false + t.text :job_class + t.text :queue_name + t.jsonb :serialized_params + t.datetime :scheduled_at + t.datetime :finished_at + t.text :error + t.integer :error_event, limit: 2 + end + + create_table :good_job_processes, id: :uuid do |t| + t.timestamps + t.jsonb :state + end + + create_table :good_job_settings, id: :uuid do |t| + t.timestamps + t.text :key + t.jsonb :value + t.index :key, unique: true + end + + add_index :good_jobs, :scheduled_at, where: "(finished_at IS NULL)", name: "index_good_jobs_on_scheduled_at" + add_index :good_jobs, [:queue_name, :scheduled_at], where: "(finished_at IS NULL)", name: :index_good_jobs_on_queue_name_and_scheduled_at + add_index :good_jobs, [:active_job_id, :created_at], name: :index_good_jobs_on_active_job_id_and_created_at + add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)", name: :index_good_jobs_on_concurrency_key_when_unfinished + add_index :good_jobs, [:cron_key, :created_at], name: :index_good_jobs_on_cron_key_and_created_at + add_index :good_jobs, [:cron_key, :cron_at], name: :index_good_jobs_on_cron_key_and_cron_at, unique: true + add_index :good_jobs, [:active_job_id], name: :index_good_jobs_on_active_job_id + add_index :good_jobs, [:finished_at], where: "retried_good_job_id IS NULL AND finished_at IS NOT NULL", name: :index_good_jobs_jobs_on_finished_at + add_index :good_jobs, [:priority, :created_at], order: { priority: "DESC NULLS LAST", created_at: :asc }, + where: "finished_at IS NULL", name: :index_good_jobs_jobs_on_priority_created_at_when_unfinished + add_index :good_jobs, [:batch_id], where: "batch_id IS NOT NULL" + add_index :good_jobs, [:batch_callback_id], where: "batch_callback_id IS NOT NULL" + + add_index :good_job_executions, [:active_job_id, :created_at], name: :index_good_job_executions_on_active_job_id_and_created_at + end +end diff --git a/db/structure.sql b/db/structure.sql index 22e99246..dad6648a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -413,7 +413,7 @@ CREATE TABLE public.active_storage_blobs ( metadata text, service_name character varying NOT NULL, byte_size bigint NOT NULL, - checksum character varying NOT NULL, + checksum character varying, created_at timestamp without time zone NOT NULL ); @@ -621,6 +621,100 @@ CREATE SEQUENCE public.current_topics_id_seq ALTER SEQUENCE public.current_topics_id_seq OWNED BY public.current_topics.id; +-- +-- Name: good_job_batches; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.good_job_batches ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + description text, + serialized_properties jsonb, + on_finish text, + on_success text, + on_discard text, + callback_queue_name text, + callback_priority integer, + enqueued_at timestamp(6) without time zone, + discarded_at timestamp(6) without time zone, + finished_at timestamp(6) without time zone +); + + +-- +-- Name: good_job_executions; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.good_job_executions ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + active_job_id uuid NOT NULL, + job_class text, + queue_name text, + serialized_params jsonb, + scheduled_at timestamp(6) without time zone, + finished_at timestamp(6) without time zone, + error text, + error_event smallint +); + + +-- +-- Name: good_job_processes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.good_job_processes ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + state jsonb +); + + +-- +-- Name: good_job_settings; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.good_job_settings ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + key text, + value jsonb +); + + +-- +-- Name: good_jobs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.good_jobs ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + queue_name text, + priority integer, + serialized_params jsonb, + scheduled_at timestamp(6) without time zone, + performed_at timestamp(6) without time zone, + finished_at timestamp(6) without time zone, + error text, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + active_job_id uuid, + concurrency_key text, + cron_key text, + retried_good_job_id uuid, + cron_at timestamp(6) without time zone, + batch_id uuid, + batch_callback_id uuid, + is_discrete boolean, + executions_count integer, + job_class text, + error_event smallint +); + + -- -- Name: journey_legal_definitions; Type: TABLE; Schema: public; Owner: - -- @@ -1325,41 +1419,6 @@ CREATE SEQUENCE upvs.form_template_related_documents_id_seq ALTER SEQUENCE upvs.form_template_related_documents_id_seq OWNED BY upvs.form_template_related_documents.id; --- --- Name: form_template_related_documents_temp; Type: TABLE; Schema: upvs; Owner: - --- - -CREATE TABLE upvs.form_template_related_documents_temp ( - id bigint NOT NULL, - posp_id character varying NOT NULL, - posp_version character varying NOT NULL, - message_type character varying NOT NULL, - xsd_schema text, - xslt_transformation text, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - --- --- Name: form_template_related_documents_temp_id_seq; Type: SEQUENCE; Schema: upvs; Owner: - --- - -CREATE SEQUENCE upvs.form_template_related_documents_temp_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: form_template_related_documents_temp_id_seq; Type: SEQUENCE OWNED BY; Schema: upvs; Owner: - --- - -ALTER SEQUENCE upvs.form_template_related_documents_temp_id_seq OWNED BY upvs.form_template_related_documents_temp.id; - - -- -- Name: submissions; Type: TABLE; Schema: upvs; Owner: - -- @@ -1616,13 +1675,6 @@ ALTER TABLE ONLY upvs.egov_application_allow_rules ALTER COLUMN id SET DEFAULT n ALTER TABLE ONLY upvs.form_template_related_documents ALTER COLUMN id SET DEFAULT nextval('upvs.form_template_related_documents_id_seq'::regclass); --- --- Name: form_template_related_documents_temp id; Type: DEFAULT; Schema: upvs; Owner: - --- - -ALTER TABLE ONLY upvs.form_template_related_documents_temp ALTER COLUMN id SET DEFAULT nextval('upvs.form_template_related_documents_temp_id_seq'::regclass); - - -- -- Name: submissions id; Type: DEFAULT; Schema: upvs; Owner: - -- @@ -1726,6 +1778,46 @@ ALTER TABLE ONLY public.current_topics ADD CONSTRAINT current_topics_pkey PRIMARY KEY (id); +-- +-- Name: good_job_batches good_job_batches_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.good_job_batches + ADD CONSTRAINT good_job_batches_pkey PRIMARY KEY (id); + + +-- +-- Name: good_job_executions good_job_executions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.good_job_executions + ADD CONSTRAINT good_job_executions_pkey PRIMARY KEY (id); + + +-- +-- Name: good_job_processes good_job_processes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.good_job_processes + ADD CONSTRAINT good_job_processes_pkey PRIMARY KEY (id); + + +-- +-- Name: good_job_settings good_job_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.good_job_settings + ADD CONSTRAINT good_job_settings_pkey PRIMARY KEY (id); + + +-- +-- Name: good_jobs good_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.good_jobs + ADD CONSTRAINT good_jobs_pkey PRIMARY KEY (id); + + -- -- Name: journey_legal_definitions journey_legal_definitions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -1902,14 +1994,6 @@ ALTER TABLE ONLY upvs.form_template_related_documents ADD CONSTRAINT form_template_related_documents_pkey PRIMARY KEY (id); --- --- Name: form_template_related_documents_temp form_template_related_documents_temp_pkey; Type: CONSTRAINT; Schema: upvs; Owner: - --- - -ALTER TABLE ONLY upvs.form_template_related_documents_temp - ADD CONSTRAINT form_template_related_documents_temp_pkey PRIMARY KEY (id); - - -- -- Name: submissions submissions_pkey; Type: CONSTRAINT; Schema: upvs; Owner: - -- @@ -1960,6 +2044,97 @@ CREATE UNIQUE INDEX index_categories_categorizations ON public.categories_catego CREATE INDEX index_categorizations_on_categorizable ON public.categorizations USING btree (categorizable_type, categorizable_id); +-- +-- Name: index_good_job_executions_on_active_job_id_and_created_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_job_executions_on_active_job_id_and_created_at ON public.good_job_executions USING btree (active_job_id, created_at); + + +-- +-- Name: index_good_job_settings_on_key; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_good_job_settings_on_key ON public.good_job_settings USING btree (key); + + +-- +-- Name: index_good_jobs_jobs_on_finished_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_jobs_jobs_on_finished_at ON public.good_jobs USING btree (finished_at) WHERE ((retried_good_job_id IS NULL) AND (finished_at IS NOT NULL)); + + +-- +-- Name: index_good_jobs_jobs_on_priority_created_at_when_unfinished; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_jobs_jobs_on_priority_created_at_when_unfinished ON public.good_jobs USING btree (priority DESC NULLS LAST, created_at) WHERE (finished_at IS NULL); + + +-- +-- Name: index_good_jobs_on_active_job_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_jobs_on_active_job_id ON public.good_jobs USING btree (active_job_id); + + +-- +-- Name: index_good_jobs_on_active_job_id_and_created_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_jobs_on_active_job_id_and_created_at ON public.good_jobs USING btree (active_job_id, created_at); + + +-- +-- Name: index_good_jobs_on_batch_callback_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_jobs_on_batch_callback_id ON public.good_jobs USING btree (batch_callback_id) WHERE (batch_callback_id IS NOT NULL); + + +-- +-- Name: index_good_jobs_on_batch_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_jobs_on_batch_id ON public.good_jobs USING btree (batch_id) WHERE (batch_id IS NOT NULL); + + +-- +-- Name: index_good_jobs_on_concurrency_key_when_unfinished; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_jobs_on_concurrency_key_when_unfinished ON public.good_jobs USING btree (concurrency_key) WHERE (finished_at IS NULL); + + +-- +-- Name: index_good_jobs_on_cron_key_and_created_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_jobs_on_cron_key_and_created_at ON public.good_jobs USING btree (cron_key, created_at); + + +-- +-- Name: index_good_jobs_on_cron_key_and_cron_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_good_jobs_on_cron_key_and_cron_at ON public.good_jobs USING btree (cron_key, cron_at); + + +-- +-- Name: index_good_jobs_on_queue_name_and_scheduled_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_jobs_on_queue_name_and_scheduled_at ON public.good_jobs USING btree (queue_name, scheduled_at) WHERE (finished_at IS NULL); + + +-- +-- Name: index_good_jobs_on_scheduled_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_good_jobs_on_scheduled_at ON public.good_jobs USING btree (scheduled_at) WHERE (finished_at IS NULL); + + -- -- Name: index_journey_legal_definitions_on_journey_id; Type: INDEX; Schema: public; Owner: - -- @@ -2486,6 +2661,10 @@ INSERT INTO "schema_migrations" (version) VALUES ('20221022143119'), ('20230325092744'), ('20230325095737'), -('20230325151049'); +('20230325151049'), +('20231007083404'), +('20231007083405'), +('20231007083406'), +('20231007141039'); diff --git a/spec/models/concerns/enums_spec.rb b/spec/models/concerns/enums_spec.rb index 39ac25c4..d0ae36b3 100644 --- a/spec/models/concerns/enums_spec.rb +++ b/spec/models/concerns/enums_spec.rb @@ -7,12 +7,11 @@ class TestClass class << self attr_reader :enum_definition - def enum(enum_definition) - @enum_definition = enum_definition + def enum(name, values) + @enum_definition = [name, values] end end - enumerates :status, with: %w{IDLE WORKING FINISHED} end @@ -20,13 +19,11 @@ def enum(enum_definition) TestClass.new end - it 'should define enum' do - expect(subject.class.enum_definition).to eq({ - status: { - 'IDLE' => 'IDLE', - 'WORKING' => 'WORKING', - 'FINISHED' => 'FINISHED', - } - }) + it 'defines enum' do + expect(subject.class.enum_definition).to eq([:status, { + 'IDLE' => 'IDLE', + 'WORKING' => 'WORKING', + 'FINISHED' => 'FINISHED', + }]) end end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index d813b946..ebaea8c7 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -1,5 +1,3 @@ -Webdrivers::Chromedriver.update - Capybara.register_driver :chrome do |app| options = Selenium::WebDriver::Chrome::Options.new(args: %w(headless disable-gpu disable-logging no-sandbox)) Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)