From e8920f6b3badf0c4faa73de8df861aafb6df9250 Mon Sep 17 00:00:00 2001 From: Jay Varner Date: Wed, 28 Aug 2024 13:47:37 -0400 Subject: [PATCH] Code quality improvements --- .rubocop.yml | 4 + .ruby-version | 2 +- Capfile | 43 -- Gemfile | 19 +- Gemfile.lock | 604 ++++++++++-------- app/controllers/about_pages_controller.rb | 21 +- .../admin/about_pages_controller.rb | 2 + app/controllers/admin/languages_controller.rb | 2 + app/controllers/admin/letters_controller.rb | 1 - app/controllers/application_controller.rb | 4 +- app/controllers/letters_controller.rb | 4 + app/dashboards/about_page_dashboard.rb | 4 +- app/dashboards/language_dashboard.rb | 6 +- app/fields/rich_text_field.rb | 3 +- app/jobs/load_big_sam_job.rb | 65 +- app/models/about_page.rb | 2 + app/models/concerns/entity_common.rb | 6 +- app/models/concerns/letter_common.rb | 8 +- app/models/entity.rb | 1 - app/models/faq.rb | 4 +- app/models/file_folder.rb | 2 +- app/models/letter_repository.rb | 2 +- app/services/google_import.rb | 18 +- app/services/merge.rb | 2 + .../about_pages/_about_page.json.jbuilder | 2 + app/views/about_pages/index.json.jbuilder | 4 +- app/views/about_pages/show.json.jbuilder | 4 +- app/views/mentions/_mention.json.jbuilder | 2 +- config/credentials.yml.enc | 2 +- config/deploy.rb | 43 -- config/deploy/staging.rb | 1 + config/environments/production.rb | 2 +- config/initializers/elasticsearch.rb | 21 + config/initializers/sidekiq.rb | 4 +- lib/import.rb | 19 +- lib/tasks/big_sam.rake | 1 - lib/tasks/update.rake | 8 +- spec/acceptance/entities_spec.rb | 11 +- spec/acceptance/letters_spec.rb | 180 +++--- spec/factories/event_types.rb | 1 + spec/factories/file_folders.rb | 1 + spec/factories/letter_collections.rb | 1 + spec/factories/letter_destinations.rb | 4 +- spec/factories/letter_origins.rb | 4 +- spec/factories/letter_recipients.rb | 4 +- spec/factories/letter_repositories.rb | 5 +- spec/factories/letter_senders.rb | 4 +- spec/factories/letters.rb | 6 +- spec/factories/media.rb | 6 +- spec/factories/mentions.rb | 4 +- spec/jobs/import_data_job_spec.rb | 2 +- spec/jobs/load_big_sam_job_spec.rb | 33 +- spec/models/about_page_spec.rb | 2 +- spec/models/big_sam_spec.rb | 2 +- spec/models/collection_spec.rb | 2 +- spec/models/entity_spec.rb | 6 +- spec/models/event_type_spec.rb | 2 +- spec/models/faq_spec.rb | 2 +- spec/models/file_folder_spec.rb | 2 +- spec/models/language_spec.rb | 2 +- spec/models/letter_collection_spec.rb | 2 +- spec/models/letter_destination_spec.rb | 2 +- spec/models/letter_file_spec.rb | 2 +- spec/models/letter_origin_spec.rb | 2 +- spec/models/letter_owner_spec.rb | 2 +- spec/models/letter_publisher_spec.rb | 2 +- spec/models/letter_recipient_spec.rb | 2 +- spec/models/letter_repository_spec.rb | 2 +- spec/models/letter_sender_spec.rb | 2 +- spec/models/letter_spec.rb | 2 +- spec/models/medium_spec.rb | 2 +- spec/models/mention_spec.rb | 2 +- spec/models/published_entity_spec.rb | 2 +- spec/models/published_letter_spec.rb | 2 +- spec/models/repository_spec.rb | 2 +- spec/rails_helper.rb | 6 +- spec/requests/about_pages_spec.rb | 2 +- spec/requests/entities_spec.rb | 8 +- spec/requests/faqs_spec.rb | 8 +- spec/requests/letters_spec.rb | 18 +- spec/requests/repositories_spec.rb | 2 +- spec/routing/about_pages_routing_spec.rb | 33 +- spec/routing/entities_routing_spec.rb | 2 +- spec/routing/faqs_routing_spec.rb | 2 +- spec/routing/letters_routing_spec.rb | 2 +- spec/routing/repositories_routing_spec.rb | 2 +- 86 files changed, 677 insertions(+), 666 deletions(-) delete mode 100644 Capfile delete mode 100644 config/deploy.rb create mode 100644 config/initializers/elasticsearch.rb diff --git a/.rubocop.yml b/.rubocop.yml index ace8566..90adc5e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,16 @@ require: - rubocop-rspec + - rubocop-rspec_rails - rubocop-rails + - rubocop-factory_bot AllCops: NewCops: enable Exclude: - db/**/* + - bin/**/* + - app/services/google_import.rb # Commonly used screens these days easily fit more than 80 characters. Layout/LineLength: diff --git a/.ruby-version b/.ruby-version index ef538c2..a0891f5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.2 +3.3.4 diff --git a/Capfile b/Capfile deleted file mode 100644 index bc87ece..0000000 --- a/Capfile +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -# Load DSL and set up stages -require 'capistrano/setup' - -# Include default deployment tasks -require 'capistrano/deploy' - -# Load the SCM plugin appropriate to your project: -# -# require 'capistrano/scm/hg' -# install_plugin Capistrano::SCM::Hg -# or -# require 'capistrano/scm/svn' -# install_plugin Capistrano::SCM::Svn -# or -require 'capistrano/scm/git' -install_plugin Capistrano::SCM::Git - -# Include tasks from other gems included in your Gemfile -# -# For documentation on these, see for example: -# -# https://github.com/capistrano/rvm -# https://github.com/capistrano/rbenv -# https://github.com/capistrano/chruby -# https://github.com/capistrano/bundler -# https://github.com/capistrano/rails -# https://github.com/capistrano/passenger -# -# require 'capistrano/rvm' -require 'capistrano/rbenv' -set :rbenv_type, :user # or :system, depends on your rbenv setup -set :rbenv_ruby, '3.1.2' - -# require 'capistrano/chruby' -require 'capistrano/bundler' -# require 'capistrano/rails/assets' -require 'capistrano/rails/migrations' -# require 'capistrano/passenger' - -# Load custom tasks from `lib/capistrano/tasks` if you have any defined -Dir.glob('lib/capistrano/tasks/*.rake').each {|r| import r } diff --git a/Gemfile b/Gemfile index 0e23f9d..4d3f67d 100644 --- a/Gemfile +++ b/Gemfile @@ -3,10 +3,12 @@ source 'https://rubygems.org' git_source(:github) {|_repo| "https://github.com/#{repo}.git" } -ruby '3.1.2' +ruby '3.3.4' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' -gem 'rails', '~> 7.0.2', '>= 7.0.2.3' +gem 'rails', '~> 7.2.1' + +gem 'csv' # Use postgresql as the database for Active Record gem 'pg', '~> 1.1' @@ -53,18 +55,13 @@ group :development, :test do gem 'faker' gem 'rspec-rails' gem 'rubocop' + gem 'rubocop-factory_bot', require: false gem 'rubocop-rails', require: false gem 'rubocop-rspec', require: false + gem 'rubocop-rspec_rails', require: false gem 'shoulda-matchers' end -group :development do - gem 'capistrano', '~> 3.10', require: false - gem 'capistrano-passenger', '~> 0.2.1', require: false - gem 'capistrano-rails', '~> 1.6', require: false - gem 'capistrano-rbenv', '~> 2.2', require: false -end - gem 'pundit', '~> 2.2' gem 'kaminari', '~> 1.2' @@ -73,9 +70,9 @@ gem 'jbuilder', '~> 2.11' gem 'rspec_api_documentation', '~> 6.1' -gem 'acts-as-taggable-on', '~> 9.0' +gem 'acts-as-taggable-on', '~> 11.0.0' -gem 'administrate-field-acts_as_taggable', '~> 0.0.4' +gem 'administrate-field-acts_as_taggable' gem 'administrate-field-list', '~> 0.0.6' diff --git a/Gemfile.lock b/Gemfile.lock index ecfa248..3681cd3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,198 +1,197 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.3) - actionpack (= 7.0.3) - activesupport (= 7.0.3) + actioncable (7.2.1) + actionpack (= 7.2.1) + activesupport (= 7.2.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.3) - actionpack (= 7.0.3) - activejob (= 7.0.3) - activerecord (= 7.0.3) - activestorage (= 7.0.3) - activesupport (= 7.0.3) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.0.3) - actionpack (= 7.0.3) - actionview (= 7.0.3) - activejob (= 7.0.3) - activesupport (= 7.0.3) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.3) - actionview (= 7.0.3) - activesupport (= 7.0.3) - rack (~> 2.0, >= 2.2.0) + zeitwerk (~> 2.6) + actionmailbox (7.2.1) + actionpack (= 7.2.1) + activejob (= 7.2.1) + activerecord (= 7.2.1) + activestorage (= 7.2.1) + activesupport (= 7.2.1) + mail (>= 2.8.0) + actionmailer (7.2.1) + actionpack (= 7.2.1) + actionview (= 7.2.1) + activejob (= 7.2.1) + activesupport (= 7.2.1) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (7.2.1) + actionview (= 7.2.1) + activesupport (= 7.2.1) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4, < 3.2) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.3) - actionpack (= 7.0.3) - activerecord (= 7.0.3) - activestorage (= 7.0.3) - activesupport (= 7.0.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (7.2.1) + actionpack (= 7.2.1) + activerecord (= 7.2.1) + activestorage (= 7.2.1) + activesupport (= 7.2.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.3) - activesupport (= 7.0.3) + actionview (7.2.1) + activesupport (= 7.2.1) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - active_record_doctor (1.10.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + active_record_doctor (1.14.0) activerecord (>= 4.2.0) - activejob (7.0.3) - activesupport (= 7.0.3) + activejob (7.2.1) + activesupport (= 7.2.1) globalid (>= 0.3.6) - activemodel (7.0.3) - activesupport (= 7.0.3) - activerecord (7.0.3) - activemodel (= 7.0.3) - activesupport (= 7.0.3) - activestorage (7.0.3) - actionpack (= 7.0.3) - activejob (= 7.0.3) - activerecord (= 7.0.3) - activesupport (= 7.0.3) + activemodel (7.2.1) + activesupport (= 7.2.1) + activerecord (7.2.1) + activemodel (= 7.2.1) + activesupport (= 7.2.1) + timeout (>= 0.4.0) + activestorage (7.2.1) + actionpack (= 7.2.1) + activejob (= 7.2.1) + activerecord (= 7.2.1) + activesupport (= 7.2.1) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.3) - concurrent-ruby (~> 1.0, >= 1.0.2) + activesupport (7.2.1) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - tzinfo (~> 2.0) - acts-as-taggable-on (9.0.1) - activerecord (>= 6.0, < 7.1) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - administrate (0.17.0) - actionpack (>= 5.0) - actionview (>= 5.0) - activerecord (>= 5.0) - datetime_picker_rails (~> 0.0.7) - jquery-rails (>= 4.0) - kaminari (>= 1.0) - momentjs-rails (~> 2.8) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + acts-as-taggable-on (11.0.0) + activerecord (>= 7.0, < 8.0) + zeitwerk (>= 2.4, < 3.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + administrate (0.20.1) + actionpack (>= 6.0, < 8.0) + actionview (>= 6.0, < 8.0) + activerecord (>= 6.0, < 8.0) + jquery-rails (~> 4.6.0) + kaminari (~> 1.2.2) sassc-rails (~> 2.1) selectize-rails (~> 0.6) - administrate-field-active_storage (0.4.1) + administrate-field-active_storage (0.4.2) administrate (>= 0.2.2) rails (>= 7.0) administrate-field-acts_as_taggable (0.0.4) acts-as-taggable-on (>= 6.0) administrate (< 1.0.0) - administrate-field-jsonb (0.4.5) + administrate-field-jsonb (0.4.6) administrate (< 1.0.0) rails (>= 4.2) administrate-field-list (0.0.6) administrate rails (>= 5.0) - airbrussh (1.4.1) + airbrussh (1.5.2) sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) - bootsnap (1.12.0) + base64 (0.2.0) + bigdecimal (3.1.8) + bootsnap (1.18.4) msgpack (~> 1.2) - builder (3.2.4) - capistrano (3.17.1) + builder (3.3.0) + capistrano (3.19.1) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) sshkit (>= 1.9.0) - capistrano-bundler (2.1.0) + capistrano-bundler (2.1.1) capistrano (~> 3.1) capistrano-passenger (0.2.1) capistrano (~> 3.0) - capistrano-rails (1.6.2) + capistrano-rails (1.6.3) capistrano (~> 3.1) capistrano-bundler (>= 1.1, < 3) capistrano-rbenv (2.2.0) capistrano (~> 3.1) sshkit (~> 1.3) - concurrent-ruby (1.1.10) - connection_pool (2.3.0) + concurrent-ruby (1.3.4) + connection_pool (2.4.1) crass (1.0.6) - datetime_picker_rails (0.0.7) - momentjs-rails (>= 2.8.1) - debug (1.5.0) - irb (>= 1.3.6) - reline (>= 0.2.7) + csv (3.3.0) + date (3.3.4) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) declarative (0.0.20) - diff-lcs (1.5.0) - digest (3.1.0) - elasticsearch (7.17.1) - elasticsearch-api (= 7.17.1) - elasticsearch-transport (= 7.17.1) - elasticsearch-api (7.17.1) + diff-lcs (1.5.1) + drb (2.2.1) + elasticsearch (7.17.11) + elasticsearch-api (= 7.17.11) + elasticsearch-transport (= 7.17.11) + elasticsearch-api (7.17.11) multi_json - elasticsearch-transport (7.17.1) - faraday (~> 1) + elasticsearch-transport (7.17.11) + base64 + faraday (>= 1, < 3) multi_json - erubi (1.10.0) - factory_bot (6.2.1) + erubi (1.13.0) + factory_bot (6.4.6) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.3) + factory_bot (~> 6.4) railties (>= 5.0.0) - faker (2.21.0) + faker (3.4.2) i18n (>= 1.8.11, < 2) - faraday (1.10.0) - faraday-em_http (~> 1.0) - faraday-em_synchrony (~> 1.0) - faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0) - faraday-multipart (~> 1.0) - faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.0) - faraday-patron (~> 1.0) - faraday-rack (~> 1.0) - faraday-retry (~> 1.0) - ruby2_keywords (>= 0.0.4) - faraday-em_http (1.0.0) - faraday-em_synchrony (1.0.0) - faraday-excon (1.1.0) - faraday-httpclient (1.0.1) - faraday-multipart (1.0.4) - multipart-post (~> 2) - faraday-net_http (1.0.1) - faraday-net_http_persistent (1.2.0) - faraday-patron (1.0.0) - faraday-rack (1.0.0) - faraday-retry (1.0.3) - ffi (1.15.5) + faraday (2.11.0) + faraday-net_http (>= 2.0, < 3.4) + logger + faraday-net_http (3.3.0) + net-http + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-aarch64-linux-musl) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm-linux-musl) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86-linux-musl) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.0-x86_64-linux-musl) gems (1.2.0) - globalid (1.0.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) google-api-client (0.53.0) google-apis-core (~> 0.1) google-apis-generator (~> 0.1) - google-apis-core (0.7.0) + google-apis-core (0.15.1) addressable (~> 2.5, >= 2.5.1) - googleauth (>= 0.16.2, < 2.a) - httpclient (>= 2.8.1, < 3.a) + googleauth (~> 1.9) + httpclient (>= 2.8.3, < 3.a) mini_mime (~> 1.0) + mutex_m representable (~> 3.0) retriable (>= 2.0, < 4.a) - rexml - webrick - google-apis-discovery_v1 (0.11.0) - google-apis-core (>= 0.7, < 2.a) - google-apis-generator (0.9.0) + google-apis-discovery_v1 (0.19.0) + google-apis-core (>= 0.15.0, < 2.a) + google-apis-generator (0.15.1) activesupport (>= 5.0) gems (~> 1.2) - google-apis-core (>= 0.7, < 2.a) - google-apis-discovery_v1 (~> 0.5) + google-apis-core (>= 0.15.0, < 2.a) + google-apis-discovery_v1 (~> 0.18) thor (>= 0.20, < 2.a) - googleauth (1.2.0) - faraday (>= 0.17.3, < 3.a) + google-cloud-env (2.1.1) + faraday (>= 1.0, < 3.a) + googleauth (1.11.0) + faraday (>= 1.0, < 3.a) + google-cloud-env (~> 2.1) jwt (>= 1.4, < 3.0) - memoist (~> 0.16) multi_json (~> 1.11) os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) @@ -201,22 +200,25 @@ GEM mime-types (~> 3.0) multi_xml (>= 0.5.2) httpclient (2.8.3) - i18n (1.12.0) + i18n (1.14.5) concurrent-ruby (~> 1.0) - image_processing (1.12.1) + image_processing (1.13.0) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - io-console (0.5.11) - irb (1.4.1) - reline (>= 0.3.0) - jbuilder (2.11.5) + io-console (0.7.2) + irb (1.14.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) - jquery-rails (4.5.0) + jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jwt (2.4.1) + json (2.7.2) + jwt (2.8.2) + base64 kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -229,155 +231,187 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - loofah (2.18.0) + language_server-protocol (3.17.0.3) + logger (1.6.0) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) + nokogiri (>= 1.12.0) macaddr (1.7.2) systemu (~> 2.6.5) - mail (2.7.1) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (1.0.2) - memoist (0.16.2) - method_source (1.0.0) - mime-types (3.4.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) - mini_magick (4.11.0) - mini_mime (1.1.2) - minitest (5.16.3) - momentjs-rails (2.29.1.1) - railties (>= 3.1) - msgpack (1.5.2) + mime-types-data (3.2024.0820) + mini_magick (4.13.2) + mini_mime (1.1.5) + minitest (5.25.1) + msgpack (1.7.2) multi_json (1.15.0) - multi_xml (0.6.0) - multipart-post (2.2.3) + multi_xml (0.7.1) + bigdecimal (~> 3.1) mustache (1.1.1) - namae (1.1.1) - net-imap (0.2.3) - digest + mutex_m (0.2.0) + namae (1.2.0) + racc (~> 1.7) + net-http (0.4.1) + uri + net-imap (0.4.14) + date net-protocol - strscan - net-pop (0.1.1) - digest + net-pop (0.1.2) net-protocol + net-protocol (0.2.2) timeout - net-protocol (0.1.3) - timeout - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-smtp (0.3.1) - digest + net-scp (4.0.0) + net-ssh (>= 2.6.5, < 8.0.0) + net-sftp (4.0.0) + net-ssh (>= 5.0.0, < 8.0.0) + net-smtp (0.5.0) net-protocol - timeout - net-ssh (7.0.1) - nio4r (2.5.8) - nokogiri (1.13.6-x86_64-darwin) + net-ssh (7.2.3) + nio4r (2.7.3) + nokogiri (1.16.7-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86-linux) racc (~> 1.4) - nokogiri (1.13.6-x86_64-linux) + nokogiri (1.16.7-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) os (1.1.4) - parallel (1.22.1) - parser (3.1.2.0) + parallel (1.26.3) + parser (3.3.4.2) ast (~> 2.4.1) - pg (1.4.2) - public_suffix (4.0.7) - puma (5.6.4) + racc + pg (1.5.7) + psych (5.1.2) + stringio + public_suffix (6.0.1) + puma (5.6.8) nio4r (~> 2.0) - pundit (2.2.0) + pundit (2.4.0) activesupport (>= 3.0.0) - racc (1.6.0) - rack (2.2.3.1) - rack-cors (1.1.1) + racc (1.8.1) + rack (2.2.9) + rack-cors (2.0.2) rack (>= 2.0.0) - rack-test (2.0.0) + rack-session (1.0.2) + rack (< 3) + rack-test (2.1.0) rack (>= 1.3) - rails (7.0.3) - actioncable (= 7.0.3) - actionmailbox (= 7.0.3) - actionmailer (= 7.0.3) - actionpack (= 7.0.3) - actiontext (= 7.0.3) - actionview (= 7.0.3) - activejob (= 7.0.3) - activemodel (= 7.0.3) - activerecord (= 7.0.3) - activestorage (= 7.0.3) - activesupport (= 7.0.3) + rackup (1.0.0) + rack (< 3) + webrick + rails (7.2.1) + actioncable (= 7.2.1) + actionmailbox (= 7.2.1) + actionmailer (= 7.2.1) + actionpack (= 7.2.1) + actiontext (= 7.2.1) + actionview (= 7.2.1) + activejob (= 7.2.1) + activemodel (= 7.2.1) + activerecord (= 7.2.1) + activestorage (= 7.2.1) + activesupport (= 7.2.1) bundler (>= 1.15.0) - railties (= 7.0.3) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + railties (= 7.2.1) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.3) - loofah (~> 2.3) - railties (7.0.3) - actionpack (= 7.0.3) - activesupport (= 7.0.3) - method_source + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.2.1) + actionpack (= 7.2.1) + activesupport (= 7.2.1) + irb (~> 1.13) + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.0.6) - redis (4.8.0) - regexp_parser (2.5.0) - reline (0.3.1) + rake (13.2.1) + rdoc (6.7.0) + psych (>= 4.0.0) + redis (4.8.1) + regexp_parser (2.9.2) + reline (0.5.9) io-console (~> 0.5) representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) retriable (3.1.2) - rexml (3.2.5) - roo (2.9.0) + rexml (3.3.6) + strscan + roo (2.10.1) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-mocks (3.11.1) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-rails (5.1.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.11.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.4) + 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_api_documentation (6.1.0) activesupport (>= 3.0.0) mustache (~> 1.0, >= 0.99.4) rspec (~> 3.0) - rubocop (1.31.0) + rubocop (1.65.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) + regexp_parser (>= 2.4, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.18.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.18.0) - parser (>= 3.1.1.0) - rubocop-rails (2.15.1) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.1) + parser (>= 3.3.1.0) + rubocop-factory_bot (2.26.1) + rubocop (~> 1.61) + rubocop-rails (2.26.0) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-rspec (2.11.1) - rubocop (~> 1.19) - ruby-progressbar (1.11.0) - ruby-vips (2.1.3) + rubocop (>= 1.52.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rspec (3.0.4) + rubocop (~> 1.61) + rubocop-rspec_rails (2.30.0) + rubocop (~> 1.61) + rubocop-rspec (~> 3, >= 3.0.1) + ruby-progressbar (1.13.0) + ruby-vips (2.2.2) ffi (~> 1.12) - ruby2_keywords (0.0.5) + logger rubyzip (2.3.2) sassc (2.4.0) ffi (~> 1.9) @@ -387,61 +421,78 @@ GEM sprockets (> 3.0) sprockets-rails tilt - searchkick (5.1.0) - activemodel (>= 5.2) + searchkick (5.3.1) + activemodel (>= 6.1) hashie + securerandom (0.3.1) selectize-rails (0.12.6) - shoulda-matchers (5.1.0) + shoulda-matchers (6.4.0) activesupport (>= 5.2.0) - sidekiq (6.5.8) + sidekiq (6.5.12) connection_pool (>= 2.2.5, < 3) rack (~> 2.0) redis (>= 4.5.0, < 5) - signet (0.17.0) + signet (0.19.0) addressable (~> 2.8) faraday (>= 0.17.5, < 3.a) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) - sprockets (4.1.1) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) - sshkit (1.21.2) + sshkit (1.23.0) + base64 net-scp (>= 1.1.2) + net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) - strscan (3.0.3) + stringio (3.1.1) + strscan (3.1.0) systemu (2.6.5) - thor (1.2.1) - tilt (2.0.10) - timeout (0.3.0) + thor (1.3.1) + tilt (2.4.0) + timeout (0.4.1) trailblazer-option (0.1.2) trix-rails (2.4.0) rails (> 4.1) - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) - unicode-display_width (2.2.0) + unicode-display_width (2.5.0) + uri (0.13.0) + useragent (0.16.10) uuid (2.3.9) macaddr (~> 1.0) - webrick (1.7.0) - websocket-driver (0.7.5) + webrick (1.8.1) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.0) + zeitwerk (2.6.17) PLATFORMS - x86_64-darwin-21 - x86_64-linux + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86-linux + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES active_record_doctor (~> 1.10) - acts-as-taggable-on (~> 9.0) + acts-as-taggable-on (~> 11.0.0) administrate administrate-field-active_storage (~> 0.4.1) - administrate-field-acts_as_taggable (~> 0.0.4) + administrate-field-acts_as_taggable administrate-field-jsonb administrate-field-list (~> 0.0.6) bootsnap @@ -450,6 +501,7 @@ DEPENDENCIES capistrano-passenger (~> 0.2.1) capistrano-rails (~> 1.6) capistrano-rbenv (~> 2.2) + csv debug elasticsearch (~> 7.17.1) factory_bot_rails @@ -464,13 +516,15 @@ DEPENDENCIES puma (~> 5.0) pundit (~> 2.2) rack-cors - rails (~> 7.0.2, >= 7.0.2.3) + rails (~> 7.2.1) roo (~> 2.9) rspec-rails rspec_api_documentation (~> 6.1) rubocop + rubocop-factory_bot rubocop-rails rubocop-rspec + rubocop-rspec_rails searchkick shoulda-matchers sidekiq (~> 6.5.8) @@ -479,7 +533,7 @@ DEPENDENCIES uuid (~> 2.3) RUBY VERSION - ruby 3.1.2p20 + ruby 3.3.4p94 BUNDLED WITH - 2.3.19 + 2.5.11 diff --git a/app/controllers/about_pages_controller.rb b/app/controllers/about_pages_controller.rb index 612e85a..2e9b14b 100644 --- a/app/controllers/about_pages_controller.rb +++ b/app/controllers/about_pages_controller.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class AboutPagesController < ApplicationController - before_action :set_about_page, only: %i[ show update destroy ] + before_action :set_about_page, only: %i[show update destroy] # GET /about_pages # GET /about_pages.json @@ -8,13 +10,14 @@ def index end private - # Use callbacks to share common setup or constraints between actions. - def set_about_page - @about_page = AboutPage.find(params[:id]) - end - # Only allow a list of trusted parameters through. - def about_page_params - params.fetch(:about_page, {}) - end + # Use callbacks to share common setup or constraints between actions. + def set_about_page + @about_page = AboutPage.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def about_page_params + params.fetch(:about_page, {}) + end end diff --git a/app/controllers/admin/about_pages_controller.rb b/app/controllers/admin/about_pages_controller.rb index 1100e86..6f74b10 100644 --- a/app/controllers/admin/about_pages_controller.rb +++ b/app/controllers/admin/about_pages_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class AboutPagesController < Admin::ApplicationController def valid_action?(name, resource = resource_class) diff --git a/app/controllers/admin/languages_controller.rb b/app/controllers/admin/languages_controller.rb index 5751763..f3af910 100644 --- a/app/controllers/admin/languages_controller.rb +++ b/app/controllers/admin/languages_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class LanguagesController < Admin::ApplicationController # Overwrite any of the RESTful controller actions to implement custom behavior diff --git a/app/controllers/admin/letters_controller.rb b/app/controllers/admin/letters_controller.rb index 0049b2c..18a9fd7 100644 --- a/app/controllers/admin/letters_controller.rb +++ b/app/controllers/admin/letters_controller.rb @@ -141,4 +141,3 @@ def original_params # for more information end end - diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a9c948b..60628e3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -33,6 +33,7 @@ def render_not_found private + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def include_pagination(scope) request_params = request.query_parameters url_without_params = unless request_params.empty? @@ -60,11 +61,12 @@ def include_pagination(scope) new_request_hash = request_params.merge({ page: v }) page_url = "#{url_without_params}?#{new_request_hash.to_param}" pagination_links[k] = page_url - pagination_header_links << "<#{page_url}>; rel=\'#{k}\'" + pagination_header_links << "<#{page_url}>; rel='#{k}'" end headers['Link'] = pagination_header_links.join(', ') headers['X-Total-Count'] = scope.total_count @pagination_meta[:links] = pagination_links end + # rubocop:enable Metrics/AbcSize, Metrics/MethodLength end diff --git a/app/controllers/letters_controller.rb b/app/controllers/letters_controller.rb index 1067014..e4dd11e 100644 --- a/app/controllers/letters_controller.rb +++ b/app/controllers/letters_controller.rb @@ -36,6 +36,7 @@ def set_letter @letter = Letter.find(params[:id]) end + # rubocop:disable Metrics/MethodLength def letters_from_results(results) letters = results.map do |letter| { @@ -62,6 +63,7 @@ def letters_from_results(results) letters end + # rubocop:enable Metrics/MethodLength def facets { @@ -77,6 +79,7 @@ def facets } end + # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity def set_filters @where = { published: true, _and: [] } @@ -120,6 +123,7 @@ def set_filters @where[:volume] = { in: params[:volumes].split(',').map(&:to_i) } if params[:volumes].present? end + # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity def reindex Letter.reindex if ENV['RAILS_ENV'] == 'test' diff --git a/app/dashboards/about_page_dashboard.rb b/app/dashboards/about_page_dashboard.rb index ddc9656..b98af51 100644 --- a/app/dashboards/about_page_dashboard.rb +++ b/app/dashboards/about_page_dashboard.rb @@ -1,4 +1,6 @@ -require "administrate/base_dashboard" +# frozen_string_literal: true + +require 'administrate/base_dashboard' class AboutPageDashboard < Administrate::BaseDashboard # ATTRIBUTE_TYPES diff --git a/app/dashboards/language_dashboard.rb b/app/dashboards/language_dashboard.rb index 84dd9e2..7abe52c 100644 --- a/app/dashboards/language_dashboard.rb +++ b/app/dashboards/language_dashboard.rb @@ -1,4 +1,6 @@ -require "administrate/base_dashboard" +# frozen_string_literal: true + +require 'administrate/base_dashboard' class LanguageDashboard < Administrate::BaseDashboard # ATTRIBUTE_TYPES @@ -14,7 +16,7 @@ class LanguageDashboard < Administrate::BaseDashboard label: Field::String, code: Field::String, created_at: Field::DateTime, - updated_at: Field::DateTime, + updated_at: Field::DateTime }.freeze # COLLECTION_ATTRIBUTES diff --git a/app/fields/rich_text_field.rb b/app/fields/rich_text_field.rb index b92e9ec..efab759 100644 --- a/app/fields/rich_text_field.rb +++ b/app/fields/rich_text_field.rb @@ -9,7 +9,8 @@ def to_s sanitize( data, tags: %w[svg div strong p h1 h2 br a ul li em path], - attributes: %w[href d fill viewbox role alt focusable stroke-width alt class aria-hidden height width xmlns stroke] + attributes: %w[href d fill viewbox role alt focusable stroke-width alt class aria-hidden height width xmlns + stroke] ) end end diff --git a/app/jobs/load_big_sam_job.rb b/app/jobs/load_big_sam_job.rb index 9ed5b95..37fc226 100644 --- a/app/jobs/load_big_sam_job.rb +++ b/app/jobs/load_big_sam_job.rb @@ -8,7 +8,7 @@ class LoadBigSamJob < ApplicationJob include ActionView::Helpers::SanitizeHelper queue_as :default - def perform(*_args) + def self.perform(*_args) FileUtils.touch('big_sam_loading') logger.debug 'statring big sam load' @@ -26,7 +26,7 @@ def perform(*_args) load_letters(rows) end - def load_letters(rows) + def self.load_letters(rows) rows.each do |row| letter = get_letter(row) @@ -115,7 +115,6 @@ def load_letters(rows) entity = get_entity(label: recipient, type: 'organization', return_nil: true) if entity.nil? entity = Entity.create(label: recipient) if entity.nil? LetterRecipient.find_or_create_by(letter:, entity:) - rescue ActiveRecord::RecordInvalid, Elasticsearch::Transport::Transport::Errors::BadRequest, Elasticsearch::Transport::Transport::Errors::NotFound @@ -274,9 +273,7 @@ def load_letters(rows) logger.info { "#{Time.zone.now} ALL DONE" } end - private - - def get_letter(row) + def self.get_letter(row) if row[:exclude] == 'y' letter = Letter.find_by(legacy_pk: row[:id]) letter&.destroy @@ -286,10 +283,9 @@ def get_letter(row) Letter.find_or_create_by(legacy_pk: row[:id]) end - def get_entity(label: nil, type: nil, return_nil: false) + def self.get_entity(label: nil, type: nil, return_nil: false) logger.error("Get Entity with label: #{label} or type #{type}") label = label.strip.gsub(/[\[!@%&?"\]]/, '').titleize - label = mac?(label) entity = Entity.public_send(type) .where('label ILIKE:prefix', prefix: "%#{label}%") .or( @@ -304,17 +300,18 @@ def get_entity(label: nil, type: nil, return_nil: false) entity end - def get_person(name) + def self.get_person(name) entity = nil names = Namae.parse(name).first if names&.given && names&.family - names.family = "van #{names.family}" if names.particle&.downcase == 'van' - names = o?(names) + names.family = "Van #{names.family}" if names.particle&.downcase == 'van' + names.family = "von #{names.family}" if names.particle&.downcase == 'von' + names = mac_name?(names) names = o?(names) entity = Entity.find_by(first_name: names.given, last_name: names.family) end - if entity.nil? && entity.nil? + if entity.nil? entity = Entity.find_or_create_by(first_name: names.given, last_name: names.family, e_type: 'person') end @@ -322,7 +319,7 @@ def get_person(name) entity end - def fix_date(row) + def self.fix_date(row) row[:day] = '1' if row[:day] == '0' row[:month] = '1' if row[:month] == '0' row[:year] = '99' if row[:year] == '0' @@ -334,36 +331,20 @@ def fix_date(row) row end - def mac?(label) - parts = label.split - - return label if parts.count < 3 - - if parts.any? {|p| p == 'Mc' } - mc = parts.find_index('Mc') - last = parts.delete_at(mc + 1) - parts.delete_at(mc) - parts.insert(mc, "Mc#{last}") - end - - if parts.any? {|p| p == 'Mac' } - mac = parts.find_index('Mac') - last = parts.delete_at(mac + 1) - parts.delete_at(mac) - parts.insert(mac, "Mac#{last}") - end - - parts.join(' ') - end + def self.mac_name?(names) + return names if names.family.starts_with?('Mc') || names.given.starts_with?('Mac') - def mac_name?(names) if names.family.starts_with?('Mac ') || names.family.starts_with?('Mc ') names.family = names.family.split.map(&:titleize).join + elsif names.given.split.last.starts_with?('Mc') || names.given.split.last.starts_with?('Mac') + parts = names.given.split + names.family = "#{parts.pop}#{names.family}" + names.given = parts.join(' ') end names end - def o?(names) + def self.o?(names) return names unless names.family.starts_with?("O'") names.family = names.family.split("'").map(&:titleize).join("'") @@ -372,15 +353,3 @@ def o?(names) end # rubocop:enable Metrics/BlockLength, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity -# to_merge = [] -# generics.each do |g| -# name = mac?(g.label).split -# e = Entity.find_by(first_name: name[0], last_name: name[1]) -# next if e.nil? -# # to_merge.push({ keep: e.id, discard: g.id }) -# puts e.id -# end; nil - -# to_merge.each do |e| -# Entity.find(e[:keep]).all_letters.each {|l| l.save } -# end diff --git a/app/models/about_page.rb b/app/models/about_page.rb index cf1e33e..f5bdcec 100644 --- a/app/models/about_page.rb +++ b/app/models/about_page.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class AboutPage < ApplicationRecord end diff --git a/app/models/concerns/entity_common.rb b/app/models/concerns/entity_common.rb index 9a0d607..86adf35 100644 --- a/app/models/concerns/entity_common.rb +++ b/app/models/concerns/entity_common.rb @@ -11,7 +11,7 @@ module EntityCommon include ActiveSupport::Inflector included do - enum e_type: { + enum :e_type, { attendance: 0, music: 1, organization: 2, @@ -27,7 +27,7 @@ module EntityCommon generic: 12 } - enum event_type: { + enum :event_type, { theatre: 0, _reading: 1, rehearsal: 2, @@ -65,7 +65,7 @@ module EntityCommon cricket_match: 34 } - enum translated_into: { + enum :translated_into, { arabic: 0, braille: 1, danish: 2, diff --git a/app/models/concerns/letter_common.rb b/app/models/concerns/letter_common.rb index b482b20..8cb701d 100644 --- a/app/models/concerns/letter_common.rb +++ b/app/models/concerns/letter_common.rb @@ -25,16 +25,16 @@ module LetterCommon scope :published, -> { where(published: true) } scope :between, lambda {|start_date, _end_date| - where('date >= ? AND date <= ?', start_date, end_date) + where(date: start_date..end_date) } scope :between, lambda {|min, max| - where('letters.date >= ? AND letters.date <= ?', min, max) + where(letters: { date: min..max }) } # TODO: What to do about bad dates? def should_index? - return if date.nil? + return false if date.nil? published # date.between? DateTime.new(1957), DateTime.new(1965, 12).at_end_of_month and repositories.any?(&:published) @@ -96,7 +96,7 @@ def volume_title when 4 '1966-1989' end - return "The Letters of Samuel Beckett, #{years}" if years + "The Letters of Samuel Beckett, #{years}" if years end end end diff --git a/app/models/entity.rb b/app/models/entity.rb index 91927e8..dafc7b7 100644 --- a/app/models/entity.rb +++ b/app/models/entity.rb @@ -116,7 +116,6 @@ def concat_label self.life_dates = nil if life_dates == 'nd' self.life_dates = life_dates.gsub(/[()]/, '') if life_dates end - # self.label = 'ZZZ' if self.label.nil? end # rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity diff --git a/app/models/faq.rb b/app/models/faq.rb index cf9d2b3..8778860 100644 --- a/app/models/faq.rb +++ b/app/models/faq.rb @@ -13,10 +13,8 @@ def initial_position Faq.count + 1 elsif position.zero? 1 - elsif position > Faq.count - Faq.count else - position + [position, Faq.count].min end # updateif position > Faq.count end diff --git a/app/models/file_folder.rb b/app/models/file_folder.rb index c8aac87..222e2f6 100644 --- a/app/models/file_folder.rb +++ b/app/models/file_folder.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class FileFolder < ApplicationRecord - has_many :letters + has_many :letters, dependent: :nullify end diff --git a/app/models/letter_repository.rb b/app/models/letter_repository.rb index 8a4b0b4..df75b02 100644 --- a/app/models/letter_repository.rb +++ b/app/models/letter_repository.rb @@ -6,7 +6,7 @@ class LetterRepository < ApplicationRecord belongs_to :collection, optional: true - enum placement: { + enum :placement, { premiere: 1, deuxieme: 2, troisieme: 3 diff --git a/app/services/google_import.rb b/app/services/google_import.rb index af53a1c..6264093 100644 --- a/app/services/google_import.rb +++ b/app/services/google_import.rb @@ -82,13 +82,13 @@ def initialize(options) @orgs_profiles = '1jwgrdOzDVU36pmwNAdhJ2MGR8-IGQa4BZthwDiniy6c' @people_sheet = '1lrbBrMM3cV9d_foQfi5VyJO4gwtl4UkL4N3JWa-fjeo' - if options[:type] - @options[:entity_type] = options[:type] - sheet_meta = @sheets.select {|sheet| sheet[:type] == options[:type] }.first - response = @service.get_spreadsheet(sheet_meta[:sheet_id], ranges: sheet_meta[:range], include_grid_data: true) - @sheet = response.sheets[0] - Rails.logger.debug @sheet.data[0].row_data[0].values - end + return unless options[:type] + + @options[:entity_type] = options[:type] + sheet_meta = @sheets.select {|sheet| sheet[:type] == options[:type] }.first + response = @service.get_spreadsheet(sheet_meta[:sheet_id], ranges: sheet_meta[:range], include_grid_data: true) + @sheet = response.sheets[0] + Rails.logger.debug @sheet.data[0].row_data[0].values end def bulk_import @@ -124,8 +124,8 @@ def import # p "#{column.text_format_runs} : #{column.formatted_value}" value = column.text_format_runs ? format_column(column) : column.formatted_value - value = value.instance_of?(String) ? value.strip : value - value = column.effective_format.text_format.italic ? "#{value}" : value + value = value.strip if value.instance_of?(String) + value = "#{value}" if column.effective_format.text_format.italic row_values = { entity:, index:, diff --git a/app/services/merge.rb b/app/services/merge.rb index 856263f..b9f939f 100644 --- a/app/services/merge.rb +++ b/app/services/merge.rb @@ -102,6 +102,8 @@ def merge_received end def uuid?(value) + return false if value.is_a?(Integer) + value =~ /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/ end end diff --git a/app/views/about_pages/_about_page.json.jbuilder b/app/views/about_pages/_about_page.json.jbuilder index c6b7442..fd01c5b 100644 --- a/app/views/about_pages/_about_page.json.jbuilder +++ b/app/views/about_pages/_about_page.json.jbuilder @@ -1,2 +1,4 @@ +# frozen_string_literal: true + json.extract! about_page, :title, :body json.url about_page_url(about_page, format: :json) diff --git a/app/views/about_pages/index.json.jbuilder b/app/views/about_pages/index.json.jbuilder index 8719a51..a7e7891 100644 --- a/app/views/about_pages/index.json.jbuilder +++ b/app/views/about_pages/index.json.jbuilder @@ -1 +1,3 @@ -json.array! @about_pages, partial: "about_pages/about_page", as: :about_page +# frozen_string_literal: true + +json.array! @about_pages, partial: 'about_pages/about_page', as: :about_page diff --git a/app/views/about_pages/show.json.jbuilder b/app/views/about_pages/show.json.jbuilder index 2115fe6..1b6c902 100644 --- a/app/views/about_pages/show.json.jbuilder +++ b/app/views/about_pages/show.json.jbuilder @@ -1 +1,3 @@ -json.partial! "about_pages/about_page", about_page: @about_page +# frozen_string_literal: true + +json.partial! 'about_pages/about_page', about_page: @about_page diff --git a/app/views/mentions/_mention.json.jbuilder b/app/views/mentions/_mention.json.jbuilder index cc8741b..402fb0d 100644 --- a/app/views/mentions/_mention.json.jbuilder +++ b/app/views/mentions/_mention.json.jbuilder @@ -1,4 +1,4 @@ # frozen_string_literal: true -json.partial! 'entities/entity', entity: mention.entity, request: request +json.partial!('entities/entity', entity: mention.entity, request:) json.set! 'tags', mention.tag_list diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 842732d..5ef68eb 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -zUjm4VzRunIIP8iu+TtzRoPx7wqPH5/SprC+8r5QvLytUErD57J36LqgQuc0A+wULAI+h3FM9chTQiPd4o8Vg9++uJwNp7nlX2uqiSW7pHj5mQcIhbJEqx2tds+ly2LR3vURz7P3UE3nElcp6qTg0Nr4ZDyjdLAtFAArDDfLwN2DjJUsR4Gbzaydrz93mit/NG2Qqs78C6yHmjtCTFi6uZUaNMcPST4v/cBrnqjSknqNeCjadbOGemueNHt4CeU5inom1KPKW4x4JhkaCSBxLVIBYbxUb+Fosl0LB8CROX7f/TYIxufqzsBPYV+eyc6gVD1XCBck2PvIkAyTH2JgHT+RgOOfQAEhPAjKLC6GtfVZQEndiho3YNQQsAbZF8gJTeEd9F3KLcwOutlfsuZQSXYcJWQinznEmJAgAiCEP9uiU6y/QHD4Gn7kBSfAtKjjSumNTHjLVHQgWNRHKUJaAGFTTzPOBy72InvP/InXiYkzqNlL73ruPZNpW++BDhGFcblj1UUdnxIi7+tox12bnRO9QrhPVOtTNvgJtGDQqPRKMv4gCMvAThnzMWCnRQZ+r7QqxMfDo4oRFJJ8c+SAAMxPrQOhvNXUDyiChm2GoYvB/GmyjFxzpmtrYlb30kMxLoGqhshMGREijlnqYoPR4BMjDNafsAgjKIYmkG7GD3t39b2grDW01R56573Fswvau4WLRYdV5uOfTc6LVGL+Av6bmSsSuoVBUJ1zTBKlpGW0nGRldRIVEEAGhlamuI6urxtABAQ3C0t+Zey4vsQ7Owbrvxqo9UFyONYIZFsa28gVilH2c6rKkGnxtBthWguZs+hrONpna4dIdU0V6sVj7uvrsi27PDiX/Sv6u9n1V4XUzn8=--4989Wd7ILOKVz3ck--sp175pneedkOeunzjB0Yug== \ No newline at end of file +Uquii+3ncBL//Mr+J4z2OBqESug9u1ImtyXGThndkcW+0bXZ8di9BI55uyWPozK9oj6XwSKuftBN+/H5bWTajJPUkbyd8Idj/xsJnOw8oiCWrRLHGp+QXQOc5COPd+egEGbXIRhanhqgxYJVT9+pvon5W1COR90PJyx+CXbF7MSDn9n8nZvUiTm8GkXyA/wtpYID4szaIw9BEYHGPlHF1vnt4Kf/mULXg3OtuWQ5v2M2EpHMag+rIeQyJwLhVPZtNfY6ePbeu3riakQrITAlg4SgN86dqKrpui3B8VvRIKYx2d2grO0sAjiKbt+f1b/83TyymtYb8lqyh05oJJ+DOWldDDBS4CXaQ6FAX4K1v+iLgnotOP9qtI/mCBeesz3F3vh1GBAseWD93SCgIYRO4SkM7d1c7qkEz+buupAAfQiFj6bVanSiRmyVAFqN/BOfhMoFTswGLdkORhh7nRkgLkOySDl5cIzdlPZzAVB+1kqB9QS/UIVR20HfQf57UTUiMdNn8835ZOqVx9CqP69RYhi0L8VyEA3bGB1f8J4GpdNFA9zz+QXn/hJYfVRO0mgNQTLwhbqG2aNuDy9bJrGdRqNDe8v3RSYLYAhbEB3vsxVOaNtZB9urb9XMdYbn1K+ALZvDIJjEVxELlZb2Bu1Vi5VLr+Ki9vCSvo+9uqMS2VrSoUXBsLWIJPaDdGP9m0zBUt6qQZXbqwTpt/aONFCzzaKBSUdmBIoyTFtDAbae3foZaFaEH7vUSmCdNs5VcnvbrOhsxSERVhnKKEGFlC+82qGEoZcaAeaWU6mnoYReJUmgn67a7Pr3rfi0a9393gFARfggoemSWakP4tBEW7fRoSGxrARbe9Ml898/TbyurPRLNC5ctKnRvoiTEoHzRVRFDM33Y4vCBT0Ub/U8Aoz+R2XzQfvlnG/4tY8JQT7qth0Vy9V4INvrtQWZb5LnhFODUwgIaBeB2SWb/e4NigIBG12s8fK+XClShirGigQ3GEcwUfcPe6L/8E8Qs8a5rsfD9VWSCIY=--NlmcMiWD++QVmqZI--oXsGcOVDtqR/n7nqAiy65Q== \ No newline at end of file diff --git a/config/deploy.rb b/config/deploy.rb deleted file mode 100644 index 58e4c43..0000000 --- a/config/deploy.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -# config valid for current version and patch releases of Capistrano -lock '~> 3.17.1' - -set :application, 'beckett-data-api' -set :repo_url, 'git@github.com:ecds/beckett-data-api.git' - -append :linked_files, 'config/master.key', 'credentials.json', 'token.yaml', 'config/initializers/elasticsearch.rb' - -# Default branch is :master -# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp - -# Default deploy_to directory is /var/www/my_app_name -# set :deploy_to, "/var/www/my_app_name" - -# Default value for :format is :airbrussh. -# set :format, :airbrussh - -# You can configure the Airbrussh format using :format_options. -# These are the defaults. -# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto - -# Default value for :pty is false -# set :pty, true - -# Default value for :linked_files is [] -# append :linked_files, "config/database.yml", 'config/master.key' - -# Default value for linked_dirs is [] -# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "tmp/webpacker", "public/system", "vendor", "storage" - -# Default value for default_env is {} -# set :default_env, { path: "/opt/ruby/bin:$PATH" } - -# Default value for local_user is ENV['USER'] -# set :local_user, -> { `git config user.name`.chomp } - -# Default value for keep_releases is 5 -# set :keep_releases, 5 - -# Uncomment the following to require manually verifying the host key before first deploy. -# set :ssh_options, verify_host_key: :secure diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index a0ea5a4..2ae0bd3 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # server-based syntax # ====================== # Defines a single server with a list of roles and multiple properties. diff --git a/config/environments/production.rb b/config/environments/production.rb index 4e7725f..4cdf8ae 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -71,7 +71,7 @@ config.active_support.report_deprecations = false # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new + config.log_formatter = Logger::Formatter.new # Use a different logger for distributed setups. # require "syslog/logger" diff --git a/config/initializers/elasticsearch.rb b/config/initializers/elasticsearch.rb new file mode 100644 index 0000000..4364c3d --- /dev/null +++ b/config/initializers/elasticsearch.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'searchkick' + +timeout = 10 + +case ENV.fetch('RAILS_ENV', nil) +when 'production' + SearchKick.client = Elasticsearch::Client.new( + host: 'https://search.ecds.io', + api_key: 'SGw4a21aRUJGTGpFWTRVbEVFREk6bnZRQU9JblFTdWEwYkpuaW02X2Z3UQ==', + transport_options: { request: { timeout: }, headers: { content_type: 'application/json' } }, + retry_on_failure: 2 + ) + +else + Searchkick.client = Elasticsearch::Client.new( + host: 'localhost', + transport_options: { request: { timeout: }, headers: { content_type: 'application/json' } } + ) +end diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 062a119..c70b035 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Sidekiq.configure_server do |config| config.logger.level = Logger::ERROR -end \ No newline at end of file +end diff --git a/lib/import.rb b/lib/import.rb index 3aa4f59..391ef38 100644 --- a/lib/import.rb +++ b/lib/import.rb @@ -17,7 +17,7 @@ end entity = Entity.update(e) Rails.logger.debug entity.label -end; nil +end entities = HTTParty.get('https://ot-api.ecdsdev.org/list-entities', timeout: 1000) ids = Entity.all.map(&:id) @@ -36,9 +36,7 @@ entity.update(label: e['label'], legacy_pk: e['legacy_pk']) end Rails.logger.debug entity.label -end; nil -entities.each do |p| next unless p['e_type'] == 'person' Entity.find(p['id']).update(legacy_pk: p['legacy_pk']) @@ -46,8 +44,8 @@ letters = HTTParty.get('https://ot-api.ecdsdev.org/list-letters', timeout: 1000) letters.each do |letter| - l = Letter.find_or_create_by(id: letter['id'], legacy_pk: letter['legacy_pk'], date: letter['date']) -end; nil + Letter.find_or_create_by(id: letter['id'], legacy_pk: letter['legacy_pk'], date: letter['date']) +end recipients = HTTParty.get('https://ot-api.ecdsdev.org/list-recipients', timeout: 1000) recipients.each do |r| @@ -59,7 +57,7 @@ next if letter.recipients.include? entity letter.recipients << entity -end; nil +end destinations = HTTParty.get('https://ot-api.ecdsdev.org/list-destinations', timeout: 1000) destinations.each do |r| @@ -69,7 +67,7 @@ next if letter.destinations.include? entity letter.destinations << entity -end; nil +end origins = HTTParty.get('https://ot-api.ecdsdev.org/list-origins', timeout: 1000) origins.each do |r| @@ -82,7 +80,7 @@ next if letter.origins.include? entity letter.origins << entity -end; nil +end senders = HTTParty.get('https://ot-api.ecdsdev.org/list-senders', timeout: 1000) senders.each do |r| @@ -99,7 +97,7 @@ rescue ActiveRecord::RecordNotFound Rails.logger.debug 'poop' end -end; nil +end mentions = HTTParty.get('https://ot-api.ecdsdev.org/list-senders', timeout: 1000) mentions.each do |m| @@ -117,12 +115,11 @@ ) m['tags'].each {|tag| mention.tag_list.add(tag) } mention.save -end; nil +end def poo opts = { sheet_id: '1HeTeJqueJR4TWqgSCMJOgOglLLyYGfKux8YL57OYfg8', range: 'A2:G', entity_type: 'publication' } i = GoogleImport.new(opts) - nil i.import nil end diff --git a/lib/tasks/big_sam.rake b/lib/tasks/big_sam.rake index 728e0d4..37d693a 100644 --- a/lib/tasks/big_sam.rake +++ b/lib/tasks/big_sam.rake @@ -120,7 +120,6 @@ namespace :big_sam do entity = Entity.organization.find_by(label: recipient.strip.titleize) entity = get_entity(recipient, 'person') if entity.nil? LetterRecipient.find_or_create_by(letter:, entity:) - rescue ActiveRecord::RecordInvalid, Elasticsearch::Transport::Transport::Errors::BadRequest, Elasticsearch::Transport::Transport::Errors::NotFound diff --git a/lib/tasks/update.rake b/lib/tasks/update.rake index b59f1f1..fc527d5 100644 --- a/lib/tasks/update.rake +++ b/lib/tasks/update.rake @@ -2,21 +2,21 @@ namespace :update_records do task update_all: :environment do - Letter.all.each do |letter| + Letter.find_each do |letter| letter.save rescue StandardError end - Entity.all.each do |entity| + Entity.find_each do |entity| entity.save rescue StandardError end - Entity.where(published: false).each do |entity| + Entity.where(published: false).find_each do |entity| PublishedEntity.searchkick_index.remove(entity) end - Letter.where(published: false).each do |letter| + Letter.where(published: false).find_each do |letter| PublishedLetter.searchkick_index.remove(letter) end end diff --git a/spec/acceptance/entities_spec.rb b/spec/acceptance/entities_spec.rb index 8dc3e6e..04a6e8b 100644 --- a/spec/acceptance/entities_spec.rb +++ b/spec/acceptance/entities_spec.rb @@ -39,7 +39,7 @@ get "#{type} Entity" do let(:id) { create( - "#{type}_entity".to_sym, + :"#{type}_entity", :published, letters_received: create_list(:published_letter, 1), letters_sent_to: create_list(:published_letter, 1), @@ -91,7 +91,9 @@ "Limit responses by single type. Options are #{Entity.e_types.keys.join(', ')}.", { default: 'null' } + # rubocop:disable FactoryBot/ExcessiveCreateList before { create_list(:person_entity, 50, :published) } + # rubocop:enable FactoryBot/ExcessiveCreateList get 'GET /entities/autocomplete' do let(:search) { Entity.all.sample.clean_label[0..1].downcase } @@ -112,7 +114,7 @@ let(:relation) { relation } let(:id) { create( - "#{Entity.e_types.keys[0..11].sample}_entity".to_sym, + :"#{Entity.e_types.keys[0..11].sample}_entity", :published, letters: create_list(:published_letter, rand(1..4)), letters_received: create_list(:published_letter, rand(1..4)), @@ -152,14 +154,13 @@ end end - route 'entities/:id/letters', 'GET /entities/:id/letters?relation=mention&start_date=1963-01-01&end_date=1965-12-30' do - # rubocop:disable RSpec/FactoryBot/CreateList + route 'entities/:id/letters', + 'GET /entities/:id/letters?relation=mention&start_date=1963-01-01&end_date=1965-12-30' do # Each letter needs to have a random year. Using `create_list` will result is all letters having # the same random year. before { 10.times { create(:published_letter, date: Faker::Date.in_date_period(year: rand(1962..1965))) } } - # rubocop:enable RSpec/FactoryBot/CreateList parameter :relation, 'relation' parameter :page, 'Page of results.' diff --git a/spec/acceptance/letters_spec.rb b/spec/acceptance/letters_spec.rb index 4f2a243..1d6927f 100644 --- a/spec/acceptance/letters_spec.rb +++ b/spec/acceptance/letters_spec.rb @@ -34,96 +34,96 @@ 'Comma sperated list of volumes. Options are 0, 1, 2, 3, and 4. Zero means no volume.', { default: 'null' } - # before { - # create_list(:repository, 4, published: true) - # create_list(:published_letter_existing_repos, 30) - # Letter.published.order(:date).limit(25).sample(6).each do |letter| - # letter.mentions.shuffle[0..(letter.mentions.count / 3)].each do |mention| - # mention.tag_list.add Faker::Movies::HitchhikersGuideToTheGalaxy.planet - # mention.save - # end - # end - # } - - # get 'All letters' do - # example_request 'GET /letters - All' do - # expect(status).to eq(200) - # end - # end - - # get 'letters query' do - # let(:search) { LetterRecipient.all.sample.entity.label.split[-1].downcase } - # example_request 'GET /letters?search=:search_terms - Keyword search' do - # expect(status).to eq(200) - # end - # end - - # get 'letters by recipients' do - # let(:recipients) { [LetterRecipient.first.entity.label, LetterRecipient.last.entity.label].join(',') } - # example_request 'GET /letters?recipients=:recipient_labels - Recipients search' do - # expect(status).to eq(200) - # end - # end - - # get 'letters by repository' do - # let(:repositories) { Repository.all.sample.label } - # example_request 'GET /letters?repositories=:repository_labels - Repository Search' do - # expect(status).to eq(200) - # end - # end - - # get 'letters from start date' do - # let(:dates) { Letter.all.map(&:date) } - # let(:start_date) { dates[dates.count / 3].strftime('%Y-%m-%d') } - # example_request 'GET /letters?start_date=:YYYY-MM-DD - On or After Date' do - # expect(status).to eq(200) - # end - # end - - # get 'letters before end date' do - # let(:dates) { Letter.all.map(&:date) } - # let(:end_date) { dates[(dates.count / 2) + 3].strftime('%Y-%m-%d') } - # example_request 'GET /letters?end_date=:YYYY-MM-DD - On or Before Date' do - # expect(status).to eq(200) - # end - # end - - # get 'letters betwen start and end dates' do - # let(:dates) { Letter.all.map(&:date) } - # let(:start_date) { dates[dates.count / 3].strftime('%Y-%m-%d') } - # let(:end_date) { dates[(dates.count / 2) + 3].strftime('%Y-%m-%d') } - # example_request 'GET /letters?start_date=:YYYY-MM-DD&end_date=:YYYY-MM-DD - On or Between Dates' do - # expect(status).to eq(200) - # end - # end - - # # get 'letters by volume' do - # # example_request 'Volume facet' do - # # expect(status).to eq(200) - # # end - # # end - - # get 'letters by language' do - # let(:languages) { 'German, italian' } - # example_request 'GET /letters?languages=:list_of_languages' do - # expect(status).to eq(200) - # end - # end - - # get 'letters by volume' do - # let(:volumes) { '1, 3' } - # example_request 'GET /letters?volumes=:list_of_volumes' do - # expect(status).to eq(200) - # end - # end - - # get 'Paginated letters' do - # let(:page) { 2 } - # let(:per_page) { 10 } - # example_request 'GET /letters?per_page=:results_per_page&page=:offset - Paginated results' do - # expect(status).to eq(200) - # end - # end + # before { + # create_list(:repository, 4, published: true) + # create_list(:published_letter_existing_repos, 30) + # Letter.published.order(:date).limit(25).sample(6).each do |letter| + # letter.mentions.shuffle[0..(letter.mentions.count / 3)].each do |mention| + # mention.tag_list.add Faker::Movies::HitchhikersGuideToTheGalaxy.planet + # mention.save + # end + # end + # } + + # get 'All letters' do + # example_request 'GET /letters - All' do + # expect(status).to eq(200) + # end + # end + + # get 'letters query' do + # let(:search) { LetterRecipient.all.sample.entity.label.split[-1].downcase } + # example_request 'GET /letters?search=:search_terms - Keyword search' do + # expect(status).to eq(200) + # end + # end + + # get 'letters by recipients' do + # let(:recipients) { [LetterRecipient.first.entity.label, LetterRecipient.last.entity.label].join(',') } + # example_request 'GET /letters?recipients=:recipient_labels - Recipients search' do + # expect(status).to eq(200) + # end + # end + + # get 'letters by repository' do + # let(:repositories) { Repository.all.sample.label } + # example_request 'GET /letters?repositories=:repository_labels - Repository Search' do + # expect(status).to eq(200) + # end + # end + + # get 'letters from start date' do + # let(:dates) { Letter.all.map(&:date) } + # let(:start_date) { dates[dates.count / 3].strftime('%Y-%m-%d') } + # example_request 'GET /letters?start_date=:YYYY-MM-DD - On or After Date' do + # expect(status).to eq(200) + # end + # end + + # get 'letters before end date' do + # let(:dates) { Letter.all.map(&:date) } + # let(:end_date) { dates[(dates.count / 2) + 3].strftime('%Y-%m-%d') } + # example_request 'GET /letters?end_date=:YYYY-MM-DD - On or Before Date' do + # expect(status).to eq(200) + # end + # end + + # get 'letters betwen start and end dates' do + # let(:dates) { Letter.all.map(&:date) } + # let(:start_date) { dates[dates.count / 3].strftime('%Y-%m-%d') } + # let(:end_date) { dates[(dates.count / 2) + 3].strftime('%Y-%m-%d') } + # example_request 'GET /letters?start_date=:YYYY-MM-DD&end_date=:YYYY-MM-DD - On or Between Dates' do + # expect(status).to eq(200) + # end + # end + + # # get 'letters by volume' do + # # example_request 'Volume facet' do + # # expect(status).to eq(200) + # # end + # # end + + # get 'letters by language' do + # let(:languages) { 'German, italian' } + # example_request 'GET /letters?languages=:list_of_languages' do + # expect(status).to eq(200) + # end + # end + + # get 'letters by volume' do + # let(:volumes) { '1, 3' } + # example_request 'GET /letters?volumes=:list_of_volumes' do + # expect(status).to eq(200) + # end + # end + + # get 'Paginated letters' do + # let(:page) { 2 } + # let(:per_page) { 10 } + # example_request 'GET /letters?per_page=:results_per_page&page=:offset - Paginated results' do + # expect(status).to eq(200) + # end + # end end route '/letters/:id', 'Single Letter' do diff --git a/spec/factories/event_types.rb b/spec/factories/event_types.rb index 889b6bf..4af04e6 100644 --- a/spec/factories/event_types.rb +++ b/spec/factories/event_types.rb @@ -2,5 +2,6 @@ FactoryBot.define do factory :event_type do + label { Faker::Nation.language } end end diff --git a/spec/factories/file_folders.rb b/spec/factories/file_folders.rb index a706189..a178334 100644 --- a/spec/factories/file_folders.rb +++ b/spec/factories/file_folders.rb @@ -2,5 +2,6 @@ FactoryBot.define do factory :file_folder do + label { Faker::Nation.language } end end diff --git a/spec/factories/letter_collections.rb b/spec/factories/letter_collections.rb index c298e8f..7f32e6d 100644 --- a/spec/factories/letter_collections.rb +++ b/spec/factories/letter_collections.rb @@ -2,5 +2,6 @@ FactoryBot.define do factory :letter_collection do + label { Faker::Nation.language } end end diff --git a/spec/factories/letter_destinations.rb b/spec/factories/letter_destinations.rb index c3543a3..c37bd10 100644 --- a/spec/factories/letter_destinations.rb +++ b/spec/factories/letter_destinations.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :letter_destination do - association :letter, factory: :letter - association :entity, factory: :place_entity + letter + entity factory: %i[entity place_entity] end end diff --git a/spec/factories/letter_origins.rb b/spec/factories/letter_origins.rb index 3ba4c00..5cefeab 100644 --- a/spec/factories/letter_origins.rb +++ b/spec/factories/letter_origins.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :letter_origin do - association :letter, factory: :letter - association :entity, factory: :place_entity + letter + entity factory: %i[entity place_entity] end end diff --git a/spec/factories/letter_recipients.rb b/spec/factories/letter_recipients.rb index abc9882..d0c82e8 100644 --- a/spec/factories/letter_recipients.rb +++ b/spec/factories/letter_recipients.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :letter_recipient do - association :letter, factory: :letter - association :entity, factory: :person_entity + letter + entity factory: %i[entity person_entity] end end diff --git a/spec/factories/letter_repositories.rb b/spec/factories/letter_repositories.rb index 7dbf553..809caa5 100644 --- a/spec/factories/letter_repositories.rb +++ b/spec/factories/letter_repositories.rb @@ -2,9 +2,8 @@ FactoryBot.define do factory :letter_repository do - association :letter, factory: :letter - association :repository, factory: :published_repository - # association :collection, factory: :collection + letter + repository factory: %i[repository published_repository] format { Faker::Hipster.word } placement { 'premiere' } diff --git a/spec/factories/letter_senders.rb b/spec/factories/letter_senders.rb index 584339c..9c82e07 100644 --- a/spec/factories/letter_senders.rb +++ b/spec/factories/letter_senders.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :letter_sender do - association :letter, factory: :letter - association :entity, factory: :person_entity + letter + entity factory: %i[entity person_entity] end end diff --git a/spec/factories/letters.rb b/spec/factories/letters.rb index 1659998..75a4abf 100644 --- a/spec/factories/letters.rb +++ b/spec/factories/letters.rb @@ -24,14 +24,14 @@ destinations { create_list(:place_entity, 1) } origins { create_list(:place_entity, 1) } # letter_file { create(:letter_file) } - letter_owner { create(:letter_owner) } - letter_publisher { create(:letter_publisher) } + letter_owner + letter_publisher volume { rand(1..4) } volume_pages { nil } after :create do |letter| Entity.e_types.keys[0..11].sample(4).each {|type| - letter.entities << create_list("#{type}_entity".to_sym, rand(1..3)) + letter.entities << create_list(:"#{type}_entity", rand(1..3)) } end diff --git a/spec/factories/media.rb b/spec/factories/media.rb index 20b491d..577618e 100644 --- a/spec/factories/media.rb +++ b/spec/factories/media.rb @@ -6,13 +6,11 @@ attribution { Faker::Movies::Lebowski.character } caption { Faker::Movies::Lebowski.quote } link { Faker::Internet.url } - entity { create(:person_entity) } + entity factory: %i[entity person_entity] after(:build) do |medium| medium.image.attach( - io: File.open( - Rails.root.join('spec', 'factories', 'images', 'beckett.png') - ), + io: Rails.root.join('spec', 'factories', 'images', 'beckett.png').open, filename: 'beckett.png', content_type: 'image/png' ) diff --git a/spec/factories/mentions.rb b/spec/factories/mentions.rb index 3a651ce..f214710 100644 --- a/spec/factories/mentions.rb +++ b/spec/factories/mentions.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :mention do - association :entity, factory: :entity - association :letter, factory: :letter + entity + letter end end diff --git a/spec/jobs/import_data_job_spec.rb b/spec/jobs/import_data_job_spec.rb index 89a71c4..b858132 100644 --- a/spec/jobs/import_data_job_spec.rb +++ b/spec/jobs/import_data_job_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe ImportDataJob, type: :job do +RSpec.describe ImportDataJob do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/jobs/load_big_sam_job_spec.rb b/spec/jobs/load_big_sam_job_spec.rb index e1f3d65..85bca0a 100644 --- a/spec/jobs/load_big_sam_job_spec.rb +++ b/spec/jobs/load_big_sam_job_spec.rb @@ -2,6 +2,35 @@ require 'rails_helper' -RSpec.describe LoadBigSamJob, type: :job do - pending "add some examples to (or delete) #{__FILE__}" +RSpec.describe LoadBigSamJob do + it "parses a name starting with O'" do + person = described_class.get_person('Seumas O’Sullivan') + expect(person.last_name).to eq('O’Sullivan') + end + + it 'parses a name that starts with Mc' do + person = described_class.get_person('Donald McWhinnie') + expect(person.last_name).to eq('McWhinnie') + end + + it 'parses a name that starts with Mac' do + person = described_class.get_person('Gloria MacGowran'.strip.titleize) + expect(person.last_name).to eq('MacGowran') + end + + it 'parses a name that starts with mac in a name' do + person = described_class.mac_name?(Namae.parse('Pauline Maccaulay McWhinnie').first) + expect(person.given).to eq('Pauline Maccaulay'.strip.titleize) + expect(person.family).to eq('McWhinnie') + end + + it 'parses a name that starts with Van preceeding the last name' do + person = described_class.get_person('Jacoba Van Velde'.strip.titleize) + expect(person.last_name).to eq('Van Velde') + end + + it 'parses a name that starts with Von preceeding the last name' do + person = described_class.get_person('Rudolf Von Abele'.strip.titleize) + expect(person.last_name).to eq('von Abele') + end end diff --git a/spec/models/about_page_spec.rb b/spec/models/about_page_spec.rb index e2e0249..1a75429 100644 --- a/spec/models/about_page_spec.rb +++ b/spec/models/about_page_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe AboutPage, type: :model do +RSpec.describe AboutPage do it 'has a title and body' do about = create(:about_page) expect(about.title).not_to be_nil diff --git a/spec/models/big_sam_spec.rb b/spec/models/big_sam_spec.rb index 41176ac..8cb2214 100644 --- a/spec/models/big_sam_spec.rb +++ b/spec/models/big_sam_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe BigSam, type: :model do +RSpec.describe BigSam do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/collection_spec.rb b/spec/models/collection_spec.rb index b6c419b..c6bfd2c 100644 --- a/spec/models/collection_spec.rb +++ b/spec/models/collection_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe Collection, type: :model do +RSpec.describe Collection do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/entity_spec.rb b/spec/models/entity_spec.rb index 50e9f1c..619ed43 100644 --- a/spec/models/entity_spec.rb +++ b/spec/models/entity_spec.rb @@ -5,7 +5,7 @@ require 'rails_helper' require 'action_view' -RSpec.describe Entity, type: :model do +RSpec.describe Entity do include ActionView::Helpers::SanitizeHelper include ActiveSupport::Inflector @@ -152,7 +152,7 @@ # short descriptions it 'has short display' do described_class.e_types.keys[0..11].each do |type| - create("#{type}_entity".to_sym) + create(:"#{type}_entity") expect(described_class.public_send(type).first.short_display).not_to be_nil end end @@ -160,7 +160,7 @@ # long descriptions it 'has full display' do described_class.e_types.keys[0..11].each do |type| - create("#{type}_entity".to_sym) + create(:"#{type}_entity") expect(described_class.public_send(type).first.full_display).not_to be_nil end end diff --git a/spec/models/event_type_spec.rb b/spec/models/event_type_spec.rb index 29b969d..042fcf6 100644 --- a/spec/models/event_type_spec.rb +++ b/spec/models/event_type_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe EventType, type: :model do +RSpec.describe EventType do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/faq_spec.rb b/spec/models/faq_spec.rb index d8906ce..fc293f8 100644 --- a/spec/models/faq_spec.rb +++ b/spec/models/faq_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Faq, type: :model do +RSpec.describe Faq do it 'creates faqs in order' do create_list(:faq, 10) expect(described_class.all.map(&:position)).to eq((1..10).to_a) diff --git a/spec/models/file_folder_spec.rb b/spec/models/file_folder_spec.rb index 835e9d8..751e941 100644 --- a/spec/models/file_folder_spec.rb +++ b/spec/models/file_folder_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe FileFolder, type: :model do +RSpec.describe FileFolder do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/language_spec.rb b/spec/models/language_spec.rb index a10a9d9..b1e5654 100644 --- a/spec/models/language_spec.rb +++ b/spec/models/language_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Language, type: :model do +RSpec.describe Language do it 'has a label' do lang = create(:language) expect(lang.label).not_to be_nil diff --git a/spec/models/letter_collection_spec.rb b/spec/models/letter_collection_spec.rb index 194f9ce..33ff10f 100644 --- a/spec/models/letter_collection_spec.rb +++ b/spec/models/letter_collection_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe LetterCollection, type: :model do +RSpec.describe LetterCollection do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/letter_destination_spec.rb b/spec/models/letter_destination_spec.rb index 013cb0a..61fd41f 100644 --- a/spec/models/letter_destination_spec.rb +++ b/spec/models/letter_destination_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe LetterDestination, type: :model do +RSpec.describe LetterDestination do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/letter_file_spec.rb b/spec/models/letter_file_spec.rb index 4cc455d..5db75d9 100644 --- a/spec/models/letter_file_spec.rb +++ b/spec/models/letter_file_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe LetterFile, type: :model do +RSpec.describe LetterFile do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/letter_origin_spec.rb b/spec/models/letter_origin_spec.rb index 5b9a70a..69658c6 100644 --- a/spec/models/letter_origin_spec.rb +++ b/spec/models/letter_origin_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe LetterOrigin, type: :model do +RSpec.describe LetterOrigin do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/letter_owner_spec.rb b/spec/models/letter_owner_spec.rb index f5dd5c6..bbab35d 100644 --- a/spec/models/letter_owner_spec.rb +++ b/spec/models/letter_owner_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe LetterOwner, type: :model do +RSpec.describe LetterOwner do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/letter_publisher_spec.rb b/spec/models/letter_publisher_spec.rb index fa7e197..b136a6c 100644 --- a/spec/models/letter_publisher_spec.rb +++ b/spec/models/letter_publisher_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe LetterPublisher, type: :model do +RSpec.describe LetterPublisher do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/letter_recipient_spec.rb b/spec/models/letter_recipient_spec.rb index 561136a..356335d 100644 --- a/spec/models/letter_recipient_spec.rb +++ b/spec/models/letter_recipient_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe LetterRecipient, type: :model do +RSpec.describe LetterRecipient do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/letter_repository_spec.rb b/spec/models/letter_repository_spec.rb index 7db64ff..e4908c5 100644 --- a/spec/models/letter_repository_spec.rb +++ b/spec/models/letter_repository_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe LetterRepository, type: :model do +RSpec.describe LetterRepository do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/letter_sender_spec.rb b/spec/models/letter_sender_spec.rb index 34e09f7..29a3ed8 100644 --- a/spec/models/letter_sender_spec.rb +++ b/spec/models/letter_sender_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe LetterSender, type: :model do +RSpec.describe LetterSender do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/letter_spec.rb b/spec/models/letter_spec.rb index e362851..0651534 100644 --- a/spec/models/letter_spec.rb +++ b/spec/models/letter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Letter, type: :model do +RSpec.describe Letter do it 'scopes publicly avaliable letters' do create_list( :letter, diff --git a/spec/models/medium_spec.rb b/spec/models/medium_spec.rb index 277e32f..9ac04a7 100644 --- a/spec/models/medium_spec.rb +++ b/spec/models/medium_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Medium, type: :model do +RSpec.describe Medium do it 'has file attacthed' do ActiveStorage::Current.url_options = { host: ENV.fetch('RAILS_HOST', 'localhost:3000') } medium = build(:medium) diff --git a/spec/models/mention_spec.rb b/spec/models/mention_spec.rb index 18dac1d..a302cff 100644 --- a/spec/models/mention_spec.rb +++ b/spec/models/mention_spec.rb @@ -2,6 +2,6 @@ require 'rails_helper' -RSpec.describe Mention, type: :model do +RSpec.describe Mention do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/published_entity_spec.rb b/spec/models/published_entity_spec.rb index 7e239a6..80c8c9b 100644 --- a/spec/models/published_entity_spec.rb +++ b/spec/models/published_entity_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require 'action_view' -RSpec.describe PublishedEntity, type: :model do +RSpec.describe PublishedEntity do it 'only returns published entities' do create_list(:entity, 5, :published) create_list(:entity, 3, :unpublished) diff --git a/spec/models/published_letter_spec.rb b/spec/models/published_letter_spec.rb index b8e8d31..e3ab63f 100644 --- a/spec/models/published_letter_spec.rb +++ b/spec/models/published_letter_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require 'action_view' -RSpec.describe PublishedLetter, type: :model do +RSpec.describe PublishedLetter do it 'only returns published entities' do create_list(:published_letter, 5) create_list(:letter, 3, published: false) diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index f3fd41f..db5cf7f 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Repository, type: :model do +RSpec.describe Repository do it 'updates entity and letter published status' do repo = create(:repository, published: false) create_list(:letter, 3, repositories: [repo]) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 918d670..3fa8274 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -41,14 +41,14 @@ end end -Dir[Rails.root.join('spec/support/**/*.rb')].each {|f| require f } +Rails.root.glob('spec/support/**/*.rb').each {|f| require f } ENV['RAILS_HOST'] = 'example.com' ActiveStorage::Current.url_options = { host: ENV.fetch('RAILS_HOST', 'localhost:3000') } RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_paths = ["#{Rails.root}/spec/fixtures"] # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false @@ -80,7 +80,7 @@ config.include FactoryBot::Syntax::Methods - config.include RequestSpecHelper, type: :request + config.include RequestSpecHelper config.before(:suite) do Entity.reindex diff --git a/spec/requests/about_pages_spec.rb b/spec/requests/about_pages_spec.rb index f959126..c311793 100644 --- a/spec/requests/about_pages_spec.rb +++ b/spec/requests/about_pages_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe '/about_pages', type: :request do +RSpec.describe '/about_pages' do let(:valid_attributes) { {} } let(:invalid_attributes) { {} } diff --git a/spec/requests/entities_spec.rb b/spec/requests/entities_spec.rb index 2849563..1701958 100644 --- a/spec/requests/entities_spec.rb +++ b/spec/requests/entities_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe '/entities', type: :request do +RSpec.describe '/entities' do let(:valid_attributes) { {} } let(:invalid_attributes) { {} } @@ -19,7 +19,7 @@ it 'returns entities by type' do types = Entity.e_types.keys[0..11].sample(4) types.each do |type| - create_list("#{type}_entity".to_sym, rand(3..6), :published) + create_list(:"#{type}_entity", rand(3..6), :published) get entities_url, params: { type: } expect(json[:entities].pluck(:type)).to all eq(type) expect(json[:meta][:total_count]).to be < Entity.count @@ -93,13 +93,12 @@ entity = create(:entity) expect(entity.published).to be(false) get entity_url(entity) - expect(response.status).to eq 404 + expect(response).to eq have_http_status :not_found end end describe 'GET /entities/:id/letters' do it 'returns letters for an entity with start_date param' do - # rubocop:disable RSpec/FactoryBot/CreateList # Each letter needs to have a random year. Using `create_list` will result is all letters having # the same random year. 10.times { create(:published_letter, date: Faker::Date.in_date_period(year: rand(1962..1965))) } @@ -136,7 +135,6 @@ expect(json[:letters].map {|letter| Date.parse(letter[:date]) }.min).to be <= DateTime.new(1974, 6, 1) expect(json[:letters].count).to be < entity.letters_sent.count end - # rubocop:enable RSpec/FactoryBot/CreateList it 'returns paginated letters for an entity' do create_list(:published_letter, 10) diff --git a/spec/requests/faqs_spec.rb b/spec/requests/faqs_spec.rb index 18acb04..91c6372 100644 --- a/spec/requests/faqs_spec.rb +++ b/spec/requests/faqs_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe '/faqs', type: :request do +RSpec.describe '/faqs' do let(:valid_attributes) { {} } let(:invalid_attributes) { {} } @@ -11,11 +11,11 @@ describe 'GET /index' do it 'renders a successful response' do - create_list(:faq, 20) + create_list(:faq, 9) get faqs_url, headers: valid_headers, as: :json expect(response).to be_successful - expect(json.count).to eq(20) - expect(json.pluck(:position)).to eq((1..20).to_a) + expect(json.count).to eq(9) + expect(json.pluck(:position)).to eq((1..9).to_a) end end diff --git a/spec/requests/letters_spec.rb b/spec/requests/letters_spec.rb index 9ce55ae..1b12083 100644 --- a/spec/requests/letters_spec.rb +++ b/spec/requests/letters_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe '/letters', type: :request do +RSpec.describe '/letters' do let(:valid_attributes) { {} } let(:invalid_attributes) { {} } @@ -41,26 +41,26 @@ end it 'includes pagination information in the headers' do - create_list(:published_letter, 20) - get "#{letters_url}.json?page=3&per_page=5" + create_list(:published_letter, 9) + get "#{letters_url}.json?page=3&per_page=2" links = response.headers['Link'].split(',') expect(links.count).to eq(5) expect(links[0]).to include('self') - expect(links[0]).to include('letters.json?page=3&per_page=5') + expect(links[0]).to include('letters.json?page=3&per_page=2') expect(links[1]).to include('first') - expect(links[1]).to include('letters.json?page=1&per_page=5') + expect(links[1]).to include('letters.json?page=1&per_page=2') expect(links[2]).to include('last') - expect(links[2]).to include('letters.json?page=4&per_page=5') + expect(links[2]).to include('letters.json?page=5&per_page=2') expect(links[3]).to include('next') - expect(links[3]).to include('letters.json?page=4&per_page=5') + expect(links[3]).to include('letters.json?page=4&per_page=2') expect(links[4]).to include('prev') - expect(links[4]).to include('letters.json?page=2&per_page=5') + expect(links[4]).to include('letters.json?page=2&per_page=2') - expect(response.headers['X-Total-Count']).to eq(20) + expect(response.headers['X-Total-Count']).to eq(9) end it 'renders letters from specific recipients' do diff --git a/spec/requests/repositories_spec.rb b/spec/requests/repositories_spec.rb index 0fa02ac..4f3cd24 100644 --- a/spec/requests/repositories_spec.rb +++ b/spec/requests/repositories_spec.rb @@ -14,7 +14,7 @@ # of tools you can use to make these specs even more expressive, but we're # sticking to rails and rspec-rails APIs to keep things simple and stable. -RSpec.describe '/repositories', type: :request do +RSpec.describe '/repositories' do # This should return the minimal set of attributes required to create a valid # Repository. As you add validations to Repository, be sure to # adjust the attributes here as well. diff --git a/spec/routing/about_pages_routing_spec.rb b/spec/routing/about_pages_routing_spec.rb index 395437e..e8b7333 100644 --- a/spec/routing/about_pages_routing_spec.rb +++ b/spec/routing/about_pages_routing_spec.rb @@ -1,30 +1,31 @@ -require "rails_helper" +# frozen_string_literal: true -RSpec.describe AboutPagesController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/about_pages").to route_to("about_pages#index") - end +require 'rails_helper' - it "routes to #show" do - expect(get: "/about_pages/1").to route_to("about_pages#show", id: "1") +RSpec.describe AboutPagesController do + describe 'routing' do + it 'routes to #index' do + expect(get: '/about_pages').to route_to('about_pages#index') end + it 'routes to #show' do + expect(get: '/about_pages/1').to route_to('about_pages#show', id: '1') + end - it "routes to #create" do - expect(post: "/about_pages").to route_to("about_pages#create") + it 'routes to #create' do + expect(post: '/about_pages').to route_to('about_pages#create') end - it "routes to #update via PUT" do - expect(put: "/about_pages/1").to route_to("about_pages#update", id: "1") + it 'routes to #update via PUT' do + expect(put: '/about_pages/1').to route_to('about_pages#update', id: '1') end - it "routes to #update via PATCH" do - expect(patch: "/about_pages/1").to route_to("about_pages#update", id: "1") + it 'routes to #update via PATCH' do + expect(patch: '/about_pages/1').to route_to('about_pages#update', id: '1') end - it "routes to #destroy" do - expect(delete: "/about_pages/1").to route_to("about_pages#destroy", id: "1") + it 'routes to #destroy' do + expect(delete: '/about_pages/1').to route_to('about_pages#destroy', id: '1') end end end diff --git a/spec/routing/entities_routing_spec.rb b/spec/routing/entities_routing_spec.rb index 061fcb4..489aa8e 100644 --- a/spec/routing/entities_routing_spec.rb +++ b/spec/routing/entities_routing_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe EntitiesController, type: :routing do +RSpec.describe EntitiesController do describe 'routing' do it 'routes to #index' do expect(get: '/entities').to route_to('entities#index', format: :json) diff --git a/spec/routing/faqs_routing_spec.rb b/spec/routing/faqs_routing_spec.rb index 53965e7..1eaa842 100644 --- a/spec/routing/faqs_routing_spec.rb +++ b/spec/routing/faqs_routing_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe FaqsController, type: :routing do +RSpec.describe FaqsController do describe 'routing' do it 'routes to #index' do expect(get: '/faqs').to route_to('faqs#index') diff --git a/spec/routing/letters_routing_spec.rb b/spec/routing/letters_routing_spec.rb index af6c3a0..0803d70 100644 --- a/spec/routing/letters_routing_spec.rb +++ b/spec/routing/letters_routing_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe LettersController, type: :routing do +RSpec.describe LettersController do describe 'routing' do it 'routes to #index' do expect(get: '/letters').to route_to('letters#index', format: :json) diff --git a/spec/routing/repositories_routing_spec.rb b/spec/routing/repositories_routing_spec.rb index 54427d9..3e0652e 100644 --- a/spec/routing/repositories_routing_spec.rb +++ b/spec/routing/repositories_routing_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe RepositoriesController, type: :routing do +RSpec.describe RepositoriesController do describe 'routing' do it 'routes to #index' do expect(get: '/repositories').to route_to('repositories#index')