diff --git a/.docker/development/Dockerfile b/.docker/development/Dockerfile index 733b61b..9b69a7e 100644 --- a/.docker/development/Dockerfile +++ b/.docker/development/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.2.5 AS cartafact_base +FROM ruby:3.4.8 AS cartafact_base ENV HOME /cartafact diff --git a/.docker/production/Dockerfile b/.docker/production/Dockerfile index a21066b..8dc41d9 100644 --- a/.docker/production/Dockerfile +++ b/.docker/production/Dockerfile @@ -2,7 +2,7 @@ ### app config ### ######################## -FROM ruby:3.2.5 AS app +FROM ruby:3.4.8 AS app ENV HOME /cartafact diff --git a/.docker/production/Dockerfile.gha b/.docker/production/Dockerfile.gha index 2c77731..56cf457 100644 --- a/.docker/production/Dockerfile.gha +++ b/.docker/production/Dockerfile.gha @@ -3,7 +3,7 @@ ############################################ # Taken from .ruby-version -ARG RUBY_VERSION=3.2.5 +ARG RUBY_VERSION=3.4.8 FROM ruby:$RUBY_VERSION-slim-bookworm AS base LABEL author="DCHBX" diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 1841ade..e4f3fe2 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest services: mongo: - image: mongo:4.2 + image: mongo:6.0 ports: - 27017:27017 options: >- diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 543a7e9..7f12206 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -13,11 +13,11 @@ jobs: - name: Launch MongoDB uses: wbari/start-mongoDB@v0.2 with: - mongoDBVersion: 3.6 - - name: Set up Ruby 3.2.5 + mongoDBVersion: '6.0' + - name: Set up Ruby 3.4.8 uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2.5 + ruby-version: 3.4.8 - name: Cache Gems uses: actions/cache@v4 with: diff --git a/.rubocop.yml b/.rubocop.yml index 6f1d3e4..3c806e4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,6 @@ # This yaml describes our current checks. AllCops: - TargetRubyVersion: 3.2.5 + TargetRubyVersion: 3.4 SuggestExtensions: false NewCops: enable Exclude: diff --git a/.ruby-version b/.ruby-version index ac55709..a3808a4 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-3.2.5 +ruby-3.4.8 diff --git a/Gemfile b/Gemfile index 0f0b1e5..9b489db 100644 --- a/Gemfile +++ b/Gemfile @@ -3,11 +3,11 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '3.2.5' +ruby '3.4.8' -gem 'rails', '~> 7.2.0' +gem 'rails', '~> 8.0' -gem 'mongoid', '~> 8.1.5' +gem 'mongoid', '~> 9.0' # Use Puma as the app server gem 'puma', '~> 6.0' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder @@ -30,7 +30,7 @@ gem "aws-sdk-s3", "~> 1.14" # Settings, validation and dependency injection # TODO: Use tagged release for resource_registry instead of branch gem 'resource_registry', git: 'https://github.com/ideacrew/resource_registry.git', tag: 'v0.10.1' -gem 'fast_jsonapi' +gem 'jsonapi-serializer' gem 'shrine-mongoid', '~> 1.0' @@ -56,8 +56,8 @@ group :development, :test do gem 'shoulda-matchers' gem 'yard' gem 'climate_control' - gem 'factory_bot_rails', '~> 4.11' - gem 'database_cleaner', '~> 1.7' + gem 'factory_bot_rails', '~> 6.2' + gem 'database_cleaner-mongoid' gem 'pry-byebug' end diff --git a/Gemfile.lock b/Gemfile.lock index 5163669..d9e9d0b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,79 +20,80 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.2.3) - actionpack (= 7.2.3) - activesupport (= 7.2.3) + action_text-trix (2.1.16) + railties + actioncable (8.1.2) + actionpack (= 8.1.2) + activesupport (= 8.1.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.2.3) - actionpack (= 7.2.3) - activejob (= 7.2.3) - activerecord (= 7.2.3) - activestorage (= 7.2.3) - activesupport (= 7.2.3) + actionmailbox (8.1.2) + actionpack (= 8.1.2) + activejob (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) mail (>= 2.8.0) - actionmailer (7.2.3) - actionpack (= 7.2.3) - actionview (= 7.2.3) - activejob (= 7.2.3) - activesupport (= 7.2.3) + actionmailer (8.1.2) + actionpack (= 8.1.2) + actionview (= 8.1.2) + activejob (= 8.1.2) + activesupport (= 8.1.2) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.2.3) - actionview (= 7.2.3) - activesupport (= 7.2.3) - cgi + actionpack (8.1.2) + actionview (= 8.1.2) + activesupport (= 8.1.2) nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4, < 3.3) + rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (7.2.3) - actionpack (= 7.2.3) - activerecord (= 7.2.3) - activestorage (= 7.2.3) - activesupport (= 7.2.3) + actiontext (8.1.2) + action_text-trix (~> 2.1.15) + actionpack (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.2.3) - activesupport (= 7.2.3) + actionview (8.1.2) + activesupport (= 8.1.2) builder (~> 3.1) - cgi erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.2.3) - activesupport (= 7.2.3) + activejob (8.1.2) + activesupport (= 8.1.2) globalid (>= 0.3.6) - activemodel (7.2.3) - activesupport (= 7.2.3) - activerecord (7.2.3) - activemodel (= 7.2.3) - activesupport (= 7.2.3) + activemodel (8.1.2) + activesupport (= 8.1.2) + activerecord (8.1.2) + activemodel (= 8.1.2) + activesupport (= 8.1.2) timeout (>= 0.4.0) - activestorage (7.2.3) - actionpack (= 7.2.3) - activejob (= 7.2.3) - activerecord (= 7.2.3) - activesupport (= 7.2.3) + activestorage (8.1.2) + actionpack (= 8.1.2) + activejob (= 8.1.2) + activerecord (= 8.1.2) + activesupport (= 8.1.2) marcel (~> 1.0) - activesupport (7.2.3) + activesupport (8.1.2) base64 - benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json logger (>= 1.4.2) minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) addressable (2.8.8) public_suffix (>= 2.0.2, < 8.0) ast (2.4.3) @@ -116,7 +117,6 @@ GEM aws-sigv4 (1.12.1) aws-eventstream (~> 1, >= 1.0.2) base64 (0.3.0) - benchmark (0.5.0) bigdecimal (4.0.1) bindex (0.8.1) bootsnap (1.21.1) @@ -124,14 +124,16 @@ GEM bson (5.2.0) builder (3.3.0) byebug (12.0.0) - cgi (0.5.1) climate_control (1.2.0) coderay (1.1.3) concurrent-ruby (1.3.6) connection_pool (3.0.2) content_disposition (1.0.0) crass (1.0.6) - database_cleaner (1.99.0) + database_cleaner-core (2.0.1) + database_cleaner-mongoid (2.0.1) + database_cleaner-core (~> 2.0.0) + mongoid date (3.5.1) deep_merge (1.2.2) diff-lcs (1.6.2) @@ -205,14 +207,12 @@ GEM zeitwerk (~> 2.6) erb (6.0.1) erubi (1.13.1) - factory_bot (4.11.1) - activesupport (>= 3.0.0) - factory_bot_rails (4.11.1) - factory_bot (~> 4.11.1) - railties (>= 3.0.0) - fast_jsonapi (1.5) - activesupport (>= 4.2) - ffi (1.17.3) + factory_bot (6.5.6) + activesupport (>= 6.1.0) + factory_bot_rails (6.5.1) + factory_bot (~> 6.5) + railties (>= 6.1.0) + ffi (1.17.3-arm64-darwin) globalid (1.3.0) activesupport (>= 6.1) i18n (1.14.8) @@ -225,6 +225,8 @@ GEM reline (>= 0.4.2) jmespath (1.6.2) json (2.18.0) + jsonapi-serializer (2.2.0) + activesupport (>= 4.2) jwt (2.2.3) language_server-protocol (3.17.0.5) lint_roller (1.1.0) @@ -249,19 +251,17 @@ GEM mime-types-data (~> 3.2025, >= 3.2025.0507) mime-types-data (3.2026.0113) mini_mime (1.1.5) - mini_portile2 (2.8.9) minitest (6.0.1) prism (~> 1.5) - mongo (2.22.0) + mongo (2.23.0) base64 bson (>= 4.14.1, < 6.0.0) - mongoid (8.1.11) - activemodel (>= 5.1, < 8.1, != 7.0.0) + mongoid (9.0.10) + activemodel (>= 5.1, < 8.2, != 7.0.0) concurrent-ruby (>= 1.0.5, < 2.0) mongo (>= 2.18.0, < 3.0.0) - ruby2_keywords (~> 0.0.5) msgpack (1.8.0) - net-imap (0.6.2) + net-imap (0.6.3) date net-protocol net-pop (0.1.2) @@ -271,8 +271,7 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.5) - nokogiri (1.19.0) - mini_portile2 (~> 2.8.2) + nokogiri (1.19.0-arm64-darwin) racc (~> 1.4) ox (2.14.23) bigdecimal (>= 3.0) @@ -308,20 +307,20 @@ GEM rack (>= 1.3) rackup (2.3.1) rack (>= 3) - rails (7.2.3) - actioncable (= 7.2.3) - actionmailbox (= 7.2.3) - actionmailer (= 7.2.3) - actionpack (= 7.2.3) - actiontext (= 7.2.3) - actionview (= 7.2.3) - activejob (= 7.2.3) - activemodel (= 7.2.3) - activerecord (= 7.2.3) - activestorage (= 7.2.3) - activesupport (= 7.2.3) + rails (8.1.2) + actioncable (= 8.1.2) + actionmailbox (= 8.1.2) + actionmailer (= 8.1.2) + actionpack (= 8.1.2) + actiontext (= 8.1.2) + actionview (= 8.1.2) + activejob (= 8.1.2) + activemodel (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) bundler (>= 1.15.0) - railties (= 7.2.3) + railties (= 8.1.2) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest @@ -329,10 +328,9 @@ GEM rails-html-sanitizer (1.6.2) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (7.2.3) - actionpack (= 7.2.3) - activesupport (= 7.2.3) - cgi + railties (8.1.2) + actionpack (= 8.1.2) + activesupport (= 8.1.2) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -388,7 +386,6 @@ GEM lint_roller (~> 1.1) rubocop (~> 1.81) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) securerandom (0.4.1) shoulda-matchers (7.0.1) activesupport (>= 7.1) @@ -407,6 +404,7 @@ GEM unicode-display_width (3.2.0) unicode-emoji (~> 4.1) unicode-emoji (4.2.0) + uri (1.1.1) useragent (0.16.11) web-console (4.2.1) actionview (>= 6.0.0) @@ -421,14 +419,14 @@ GEM zeitwerk (2.7.4) PLATFORMS - ruby + arm64-darwin-25 DEPENDENCIES aws-sdk-s3 (~> 1.14) bootsnap (>= 1.4.2) byebug climate_control - database_cleaner (~> 1.7) + database_cleaner-mongoid dry-auto_inject (~> 0.6) dry-container (~> 0.7) dry-core (~> 0.4) @@ -442,15 +440,15 @@ DEPENDENCIES dry-transaction (~> 0.13) dry-types (~> 1.2) dry-validation (~> 1.2) - factory_bot_rails (~> 4.11) - fast_jsonapi + factory_bot_rails (~> 6.2) + jsonapi-serializer jwt (~> 2.2.1) listen (~> 3.3) - mongoid (~> 8.1.5) + mongoid (~> 9.0) pry-byebug puma (~> 6.0) rack-cors - rails (~> 7.2.0) + rails (~> 8.0) resource_registry! rspec-rails (~> 7.0) rubocop @@ -462,7 +460,7 @@ DEPENDENCIES yard RUBY VERSION - ruby 3.2.5p208 + ruby 3.4.8p72 BUNDLED WITH 2.4.19 diff --git a/app/controllers/api/v1/documents_controller.rb b/app/controllers/api/v1/documents_controller.rb index da3dc7b..9105169 100644 --- a/app/controllers/api/v1/documents_controller.rb +++ b/app/controllers/api/v1/documents_controller.rb @@ -31,7 +31,7 @@ def show if result.success? render :json => result.value!, status: :ok else - render :blank => true, status: 404 + head :not_found end end @@ -43,7 +43,7 @@ def create if result.success? render :json => result.value!, status: :created else - render :json => result.failure, status: "422" + render json: result.failure, status: :unprocessable_entity end end @@ -61,7 +61,7 @@ def download document = result.value! stream_download(document) else - render :blank => true, status: 404 + head :not_found end end @@ -73,7 +73,7 @@ def copy if result.success? render :json => result.value!, status: :ok else - render :json => result.failure, status: "422" + render json: result.failure, status: :unprocessable_entity end end diff --git a/app/domain/cartafact/entities/document.rb b/app/domain/cartafact/entities/document.rb index 16785f0..699f0bd 100644 --- a/app/domain/cartafact/entities/document.rb +++ b/app/domain/cartafact/entities/document.rb @@ -11,7 +11,7 @@ class Document < Dry::Struct attribute :subjects, ::Cartafact::Entities::Types::Coercible::Array.of(::Cartafact::Entities::Types::Hash) attribute? :creator, ::Cartafact::Entities::Types::Coercible::String attribute? :publisher, ::Cartafact::Entities::Types::Coercible::String - attribute :type, ::Cartafact::Entities::Types::DcmiType + attribute :document_content_type, ::Cartafact::Entities::Types::DcmiType attribute :format, ::Cartafact::Entities::Types::Coercible::String attribute? :source, ::Cartafact::Entities::Types::Coercible::String attribute? :language, ::Cartafact::Entities::Types::Coercible::String diff --git a/app/domain/cartafact/entities/validators/documents/create_contract.rb b/app/domain/cartafact/entities/validators/documents/create_contract.rb index be465b5..c8904ae 100644 --- a/app/domain/cartafact/entities/validators/documents/create_contract.rb +++ b/app/domain/cartafact/entities/validators/documents/create_contract.rb @@ -17,7 +17,7 @@ class CreateContract < Dry::Validation::Contract required(:path).value(:any) optional(:creator).value(:string) optional(:publisher).value(:string) - required(:type).filled(Cartafact::Entities::Types::DcmiType) + required(:document_content_type).filled(Cartafact::Entities::Types::DcmiType) required(:format).value(:string) optional(:source).value(:string) optional(:language).value(:string) diff --git a/app/models/document.rb b/app/models/document.rb index 7a7f267..d315ae4 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -31,7 +31,7 @@ class Document field :date, type: Date # Conforms to DCMI Type Vocabulary - http://dublincore.org/documents/2000/07/11/dcmi-type-vocabulary/ - field :type, type: String, default: "text" + field :document_content_type, type: String, default: "text" # Conforms to IANA mime types - http://www.iana.org/assignments/media-types/media-types.xhtml field :format, type: String, default: "application/octet-stream" @@ -90,7 +90,7 @@ class Document field :document_type, type: String - validates_presence_of :title, :creator, :publisher, :type, :format, :source, :language, :document_type + validates_presence_of :title, :creator, :publisher, :document_content_type, :format, :source, :language, :document_type index({ "subjects.subject_type" => 1, "subjects.subject_id" => 1 }, name: :document_subject_search_index) diff --git a/app/serializers/document_serializer.rb b/app/serializers/document_serializer.rb index 8a5895e..b71b967 100644 --- a/app/serializers/document_serializer.rb +++ b/app/serializers/document_serializer.rb @@ -2,7 +2,7 @@ # Serializes a represented document for JSON resource format. class DocumentSerializer - include FastJsonapi::ObjectSerializer + include JSONAPI::Serializer attributes :title, :creator, :identifier, :description, :language, :format, :source, :date, :creator diff --git a/config/application.rb b/config/application.rb index d327487..c02a9ae 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,7 +23,7 @@ module App class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.1 + config.load_defaults 8.0 # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/routes.rb b/config/routes.rb index c3f9696..9880e2f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,7 +5,7 @@ namespace :api do namespace :v1 do - resources :documents, only: [:index, :show, :create, :copy] do + resources :documents, only: [:index, :show, :create] do member do get :download get :copy diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 7979833..456967f 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -6,7 +6,7 @@ services: context: . dockerfile: ./.docker/production/Dockerfile args: - RUBY_VERSION: '3.2.5' + RUBY_VERSION: '3.4.8' BUNDLER_VERSION: '2.4.19' image: ideacrew/cartafact_app:${IMAGE_TAG:-test_prod} tmpfs: @@ -50,7 +50,7 @@ services: - 443:443 db: - image: mongo:4.2 + image: mongo:6.0 volumes: - mongodb:/data/db - mongodb_config:/data/configdb diff --git a/docker-compose.yml b/docker-compose.yml index b7b9f69..3232581 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: context: . dockerfile: ./.docker/development/Dockerfile args: - RUBY_VERSION: '3.2.5' + RUBY_VERSION: '3.4.8' BUNDLER_VERSION: '2.4.19' image: cartafact-dev:0.1.0 volumes: @@ -27,7 +27,7 @@ services: - DB_PORT=${DB_PORT:-27017} db: - image: mongo:4.2 + image: mongo:6.0 volumes: - mongodb:/data/db - mongodb_config:/data/configdb diff --git a/spec/models/document_spec.rb b/spec/models/document_spec.rb index efd8db6..a58da77 100644 --- a/spec/models/document_spec.rb +++ b/spec/models/document_spec.rb @@ -6,7 +6,7 @@ it { should validate_presence_of(:title) } it { should validate_presence_of(:creator) } it { should validate_presence_of(:publisher) } - it { should validate_presence_of(:type) } + it { should validate_presence_of(:document_content_type) } it { should validate_presence_of(:format) } it { should validate_presence_of(:source) } it { should validate_presence_of(:language) } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index a4f0316..265cc75 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -63,10 +63,10 @@ config.filter_rails_from_backtrace! # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") - DatabaseCleaner.strategy = :truncation + DatabaseCleaner[:mongoid].strategy = :deletion config.around(:each) do |example| - DatabaseCleaner.cleaning do + DatabaseCleaner[:mongoid].cleaning do example.run end end