diff --git a/.dassie/.env b/.dassie/.env index a60efa6dad..627c864604 100644 --- a/.dassie/.env +++ b/.dassie/.env @@ -2,7 +2,7 @@ ANALYTICS_START_DATE=2021-08-21 BUNDLE_GEMFILE=Gemfile.dassie BUNDLE_PATH=/app/bundle CH12N_TOOL=fits_servlet -CHROME_HEADLESS_MODE=false +CHROME_HEADLESS_MODE=true DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true DATABASE_TEST_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax_test?pool=5 DATABASE_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax?pool=5 diff --git a/.dassie/Gemfile b/.dassie/Gemfile index c184f15fec..007e93ee0c 100644 --- a/.dassie/Gemfile +++ b/.dassie/Gemfile @@ -30,7 +30,7 @@ gem 'jbuilder', '~> 2.5' gem 'jquery-rails' gem 'pg', '~> 1.3' gem 'puma' -gem 'rails', '~> 6.1' +gem 'rails', '~> 6.1', '>= 6.1.7.10' gem 'riiif', '~> 2.1' gem 'rsolr', '>= 1.0', '< 3' gem 'sass-rails', '~> 6.0' diff --git a/.dockerignore b/.dockerignore index 87265459a7..fa9df1be04 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,9 +14,11 @@ artifacts/* coverage/* chart/* -Gemfile.lock -.dassie/Gemfile.lock -.koppie/Gemfile.lock +Gemfile*lock +*/Gemfile*lock -node_modules/* + +node_modules +*/node_modules yarn.lock +*/yarn.lock diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/lint-build-test.yml index 04be1da356..bbf42d0271 100644 --- a/.github/workflows/lint-build-test.yml +++ b/.github/workflows/lint-build-test.yml @@ -1,5 +1,5 @@ name: 'Lint Build Test' -run-name: Link Build Test of ${{ github.ref_name }} by @${{ github.actor }} +run-name: Lint Build Test of ${{ github.ref_name }} by @${{ github.actor }} on: push: branches: @@ -44,29 +44,25 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false - matrix: - ci_test_app: [dassie,koppie] steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and export - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: - build-args: | - APP_PATH=.${{ matrix.ci_test_app }} cache-from: type=gha cache-to: type=gha, mode=max context: . target: hyrax-engine-dev - tags: samvera/${{ matrix.ci_test_app }}:latest,samvera/${{ matrix.ci_test_app }}:${{ github.sha }} - outputs: type=docker,dest=/tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar + tags: samvera/hyrax-dev:latest,samvera/hyrax-dev:${{ github.sha }} + outputs: type=docker,dest=/tmp/hyrax-dev-${{ github.sha }}.tar - name: Upload built image artifact uses: actions/upload-artifact@v4 with: - name: ${{ matrix.ci_test_app }}-image - path: /tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar + name: hyrax-dev + path: /tmp/hyrax-dev-${{ github.sha }}.tar test: needs: build @@ -74,9 +70,9 @@ jobs: strategy: fail-fast: false matrix: - ci_test_app: [dassie,koppie] - ci_node_total: [8] - ci_node_index: [0,1,2,3,4,5,6,7] + ci_test_app: [dassie,koppie,sirenia] + ci_node_total: [4] + ci_node_index: [0,1,2,3] steps: - name: Checkout uses: actions/checkout@v4 @@ -89,11 +85,11 @@ jobs: - name: Download built image artifact uses: actions/download-artifact@v4 with: - name: ${{ matrix.ci_test_app }}-image + name: hyrax-dev path: /tmp - name: Start containers run: | - docker load --input /tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar + docker load --input /tmp/hyrax-dev-${{ github.sha }}.tar docker image ls -a docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml up -d --quiet-pull --pull missing --no-build - name: RSpec @@ -107,7 +103,7 @@ jobs: if: always() uses: jwalton/gh-docker-logs@v2 with: - images: 'seleniarm/standalone-chromium' + images: 'selenium/standalone-chromium,postgres,fcrepo/fcrepo,solr,bitnami/redis,ghcr.io/samvera/fitsservlet,ghcr.io/samvera/fcrepo4' - name: Move Test Files if: always() env: diff --git a/.github/workflows/test-results.yml b/.github/workflows/test-results.yml index c1c9e93220..85606861ca 100644 --- a/.github/workflows/test-results.yml +++ b/.github/workflows/test-results.yml @@ -1,5 +1,5 @@ name: Test Results - +run-name: Test Results of ${{ github.ref_name }} by @${{ github.actor }} on: workflow_run: workflows: ["Lint Build Test"] diff --git a/.koppie/.env b/.koppie/.env index 8b654ce695..96e134d12a 100644 --- a/.koppie/.env +++ b/.koppie/.env @@ -2,7 +2,7 @@ APP_NAME=koppie BUNDLE_GEMFILE=Gemfile.koppie BUNDLE_PATH=/app/bundle CH12N_TOOL=fits_servlet -CHROME_HEADLESS_MODE=false +CHROME_HEADLESS_MODE=true DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true DATABASE_TEST_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax_test?pool=5 DATABASE_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax?pool=5 @@ -29,7 +29,7 @@ POSTGRES_PASSWORD=hyrax_password POSTGRES_USER=hyrax_user RACK_ENV=development RAILS_ENV=development -RAILS_ROOT=.koppie +RAILS_ROOT=/app/samvera/hyrax-webapp RAILS_LOG_TO_STDOUT=false RAILS_QUEUE=sidekiq REDIS_HOST=redis diff --git a/.koppie/Gemfile b/.koppie/Gemfile index 8d14016f5a..0c915ab315 100644 --- a/.koppie/Gemfile +++ b/.koppie/Gemfile @@ -30,7 +30,7 @@ gem 'jbuilder', '~> 2.5' gem 'jquery-rails' gem 'pg', '~> 1.3' gem 'puma' -gem 'rails', '~> 6.1' +gem 'rails', '~> 6.1', '>= 6.1.7.10' gem 'riiif', '~> 2.1' gem 'rsolr', '>= 1.0', '< 3' gem 'sass-rails', '~> 6.0' diff --git a/.koppie/scripts/db-migrate-seed.sh b/.koppie/scripts/db-migrate-seed.sh deleted file mode 100755 index ac7f5d9f73..0000000000 --- a/.koppie/scripts/db-migrate-seed.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -e - -db-wait.sh "$DB_HOST:$DB_PORT" -bundle exec rails db:create -bundle exec rails db:migrate - -db-wait.sh "$SOLR_HOST:$SOLR_PORT" -bundle exec rails db:seed diff --git a/.koppie/scripts/entrypoint.sh b/.koppie/scripts/entrypoint.sh deleted file mode 100755 index 91444f2394..0000000000 --- a/.koppie/scripts/entrypoint.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -set -e - -mkdir -p /app/samvera/hyrax-webapp/tmp/pids -rm -f /app/samvera/hyrax-webapp/tmp/pids/* - -bundle install --quiet - -# Run the command -exec "$@" diff --git a/Dockerfile b/Dockerfile index b3c3b47a02..da25098fc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ARG ALPINE_VERSION=3.19 -ARG RUBY_VERSION=3.2.4 +ARG RUBY_VERSION=3.2.6 -FROM ruby:$RUBY_VERSION-alpine$ALPINE_VERSION as hyrax-base +FROM ruby:$RUBY_VERSION-alpine$ALPINE_VERSION AS hyrax-base ARG DATABASE_APK_PACKAGE="postgresql-dev" ARG EXTRA_APK_PACKAGES="git" @@ -49,7 +49,7 @@ ENTRYPOINT ["hyrax-entrypoint.sh"] CMD ["bundle", "exec", "puma", "-v", "-b", "tcp://0.0.0.0:3000"] -FROM hyrax-base as hyrax +FROM hyrax-base AS hyrax ARG APP_PATH=. ARG BUNDLE_WITHOUT="development test" @@ -59,7 +59,7 @@ ONBUILD RUN bundle install --jobs "$(nproc)" ONBUILD RUN RAILS_ENV=production SECRET_KEY_BASE=`bin/rake secret` DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile -FROM hyrax-base as hyrax-worker-base +FROM hyrax-base AS hyrax-worker-base USER root RUN apk --no-cache add bash \ @@ -78,10 +78,10 @@ RUN mkdir -p /app/fits && \ sed -i 's/\(\)//' /app/fits/xml/fits.xml ENV PATH="${PATH}:/app/fits" -CMD bundle exec sidekiq +CMD ["bundle", "exec", "sidekiq"] -FROM hyrax-worker-base as hyrax-worker +FROM hyrax-worker-base AS hyrax-worker ARG APP_PATH=. ARG BUNDLE_WITHOUT="development test" @@ -91,40 +91,19 @@ ONBUILD RUN bundle install --jobs "$(nproc)" ONBUILD RUN RAILS_ENV=production SECRET_KEY_BASE=`bin/rake secret` DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile -FROM hyrax-base as hyrax-engine-dev +FROM hyrax-worker-base AS hyrax-engine-dev -USER root -RUN apk --no-cache add bash \ - ffmpeg \ - mediainfo \ - perl USER app - -ARG APP_PATH=.dassie ARG BUNDLE_WITHOUT= +ENV HYRAX_ENGINE_PATH=/app/samvera/hyrax-engine -ENV HYRAX_ENGINE_PATH /app/samvera/hyrax-engine - -COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp +COPY --chown=1001:101 .dassie /app/samvera/hyrax-webapp COPY --chown=1001:101 . /app/samvera/hyrax-engine RUN bundle -v && \ - bundle install --jobs "$(nproc)" && \ - cd $HYRAX_ENGINE_PATH && \ - bundle install --jobs "$(nproc)" && \ - yarn && yarn cache clean - -RUN RAILS_ENV=production SECRET_KEY_BASE='fakesecret1234' DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile - - -FROM hyrax-worker-base as hyrax-engine-dev-worker - -ARG APP_PATH=.dassie -ARG BUNDLE_WITHOUT= - -ENV HYRAX_ENGINE_PATH /app/samvera/hyrax-engine - -COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp -COPY --chown=1001:101 . /app/samvera/hyrax-engine + BUNDLE_GEMFILE=Gemfile.dassie bundle install --jobs "$(nproc)" && yarn && \ + cd $HYRAX_ENGINE_PATH && bundle install --jobs "$(nproc)" && yarn && \ + yarn cache clean -RUN bundle install --jobs "$(nproc)" +ENTRYPOINT ["dev-entrypoint.sh"] +CMD ["bundle", "exec", "puma", "-v", "-b", "tcp://0.0.0.0:3000"] \ No newline at end of file diff --git a/app/controllers/hyrax/my/works_controller.rb b/app/controllers/hyrax/my/works_controller.rb index aefa80363a..6d2c8f9f27 100644 --- a/app/controllers/hyrax/my/works_controller.rb +++ b/app/controllers/hyrax/my/works_controller.rb @@ -51,7 +51,21 @@ def managed_works_count def admin_sets_for_select source_ids = Hyrax::Collections::PermissionsService.source_ids_for_deposit(ability: current_ability, source_type: 'admin_set') - source_ids.map { |admin_set_id| [Hyrax.query_service.find_by(id: admin_set_id).title.first, admin_set_id] } + + admin_sets_list = Hyrax.query_service.find_many_by_ids(ids: source_ids).map do |source| + [source.title.first, source.id] + end + + # Sorts the default admin set to be first, then the rest by title. + admin_sets_list.sort do |a, b| + if Hyrax::AdminSetCreateService.default_admin_set?(id: a[1]) + -1 + elsif Hyrax::AdminSetCreateService.default_admin_set?(id: b[1]) + 1 + else + a[0] <=> b[0] + end + end end end end diff --git a/app/services/hyrax/custom_queries/find_access_control.rb b/app/services/hyrax/custom_queries/find_access_control.rb index 68d3a60883..5738547850 100644 --- a/app/services/hyrax/custom_queries/find_access_control.rb +++ b/app/services/hyrax/custom_queries/find_access_control.rb @@ -20,7 +20,7 @@ def find_access_control_for(resource:) .find_inverse_references_by(resource: resource, property: :access_to) .find { |r| r.is_a?(Hyrax::AccessControl) } || raise(Valkyrie::Persistence::ObjectNotFoundError) - rescue ArgumentError, Ldp::Gone # some adapters raise ArgumentError for missing resources + rescue ArgumentError, Ldp::Gone, Ldp::NotFound # some adapters raise ArgumentError for missing resources raise(Valkyrie::Persistence::ObjectNotFoundError) end end diff --git a/app/services/hyrax/custom_queries/find_by_date_range.rb b/app/services/hyrax/custom_queries/find_by_date_range.rb index 7c138c9883..b04bd69613 100644 --- a/app/services/hyrax/custom_queries/find_by_date_range.rb +++ b/app/services/hyrax/custom_queries/find_by_date_range.rb @@ -25,30 +25,13 @@ def initialize(query_service:) # @param models [Array] # @param start_datetime [DateTime] # @param end_datetime [DateTime] + # @return [Array] def find_by_date_range(start_datetime:, end_datetime: nil, models: nil) - end_datetime = 1.second.since(Time.zone.now) if end_datetime.blank? - if models.present? - query_service.run_query(find_models_by_date_range_query, start_datetime.to_s, end_datetime.to_s, models) - else - query_service.run_query(find_by_date_range_query, start_datetime.to_s, end_datetime.to_s) - end - end - - def find_models_by_date_range_query - <<-SQL - SELECT * FROM orm_resources - WHERE created_at >= ? - AND created_at <= ? - AND internal_resource IN (?); - SQL - end - - def find_by_date_range_query - <<-SQL - SELECT * FROM orm_resources - WHERE created_at >= ? - AND created_at <= ?; - SQL + end_range = end_datetime.blank? ? '*' : end_datetime.utc.xmlschema + query = "system_create_dtsi:[#{start_datetime.utc.xmlschema} TO #{end_range}]" + query += " AND has_model_ssim: (#{models.map { |m| "\"#{m}\"" }.join(' OR ')})" unless models.empty? + ids = Hyrax::SolrService.query_result(query, fl: 'id')['response']['docs'].map { |doc| doc['id'] } + Hyrax.query_service.find_many_by_ids(ids: ids) end end end diff --git a/app/services/hyrax/custom_queries/find_count_by.rb b/app/services/hyrax/custom_queries/find_count_by.rb index 54d6297694..67a90c66c2 100644 --- a/app/services/hyrax/custom_queries/find_count_by.rb +++ b/app/services/hyrax/custom_queries/find_count_by.rb @@ -25,45 +25,10 @@ def initialize(query_service:) # @param hash [Hash] the hash representation of the query def find_count_by(hash = {}, models: nil) return nil if models.empty? && hash.blank? - return find_count_by_af(hash, models: models) unless query_service.respond_to?(:orm_class) - - internal_array = ["{ #{hash.map { |k, v| "\"#{k}\": #{v}" }.join(', ')} }"] if hash.present? - if models.empty? - query_service.orm_class.count_by_sql(([find_count_by_properties_query] + internal_array)) - elsif hash.blank? - query_service.orm_class.count_by_sql([find_count_by_models_query] + [models]) - else - query_service.orm_class.count_by_sql(([find_count_by_properties_and_models_query] + internal_array + [models])) - end - end - - def find_count_by_af(hash, models: nil) flat_hash = hash.map { |k, v| "#{k}: \"#{v}\"" }.join(' ') flat_hash += " has_model_ssim: (#{models.map { |m| "\"#{m}\"" }.join(' OR ')})" unless models.empty? Hyrax::SolrService.count(flat_hash) end - - def find_count_by_properties_and_models_query - <<-SQL - SELECT count(*) FROM orm_resources - WHERE metadata @> ? - AND internal_resource IN (?); - SQL - end - - def find_count_by_models_query - <<-SQL - SELECT count(*) FROM orm_resources - WHERE internal_resource IN (?); - SQL - end - - def find_count_by_properties_query - <<-SQL - SELECT count(*) FROM orm_resources - WHERE metadata @> ?; - SQL - end end end end diff --git a/app/services/hyrax/custom_queries/find_models_by_access.rb b/app/services/hyrax/custom_queries/find_models_by_access.rb index fa7c397372..0e3263b50d 100644 --- a/app/services/hyrax/custom_queries/find_models_by_access.rb +++ b/app/services/hyrax/custom_queries/find_models_by_access.rb @@ -24,35 +24,13 @@ def initialize(query_service:) # # @param model [Class] # @param ids [Enumerable<#to_s>, Symbol] + # @return [Array] # def find_models_by_access(mode:, models: nil, agent:, group: nil) - agent = "group/#{agent}" if group.present? - internal_array = "{\"permissions\": [{\"mode\": \"#{mode}\", \"agent\": \"#{agent}\"}]}" - if models.present? - query_service.run_query(find_models_by_access_query, internal_array, models) - else - query_service.run_query(find_by_access_query, internal_array) - end - end - - def find_models_by_access_query - <<-SQL - SELECT * FROM orm_resources - WHERE id IN ( - SELECT uuid(metadata::json#>'{access_to,0}'->>'id') FROM orm_resources - WHERE metadata @> ? - ) AND internal_resource IN (?); - SQL - end - - def find_by_access_query - <<-SQL - SELECT * FROM orm_resources - WHERE id IN ( - SELECT uuid(metadata::json#>'{access_to,0}'->>'id') FROM orm_resources - WHERE metadata @> ? - ); - SQL + query = "#{Hydra.config.permissions[mode.to_sym][(group ? 'group' : 'individual').to_sym]}:#{agent}" + query += " AND has_model_ssim: (#{models.map { |m| "\"#{m}\"" }.join(' OR ')})" unless models.empty? + ids = Hyrax::SolrService.query_result(query, fl: 'id')['response']['docs'].map { |doc| doc['id'] } + Hyrax.query_service.find_many_by_ids(ids: ids) end end end diff --git a/bin/db-migrate-seed.sh b/bin/db-migrate-seed.sh index c4910f253a..9253a3c5b8 100755 --- a/bin/db-migrate-seed.sh +++ b/bin/db-migrate-seed.sh @@ -1,13 +1,13 @@ #!/bin/sh set -e -db-wait.sh "$DB_HOST:$DB_PORT" +service-wait.sh "$DB_HOST:$DB_PORT" bundle exec rails db:create bundle exec rails db:migrate if [ "$FCREPO_HOST" ]; then - db-wait.sh "$FCREPO_HOST:$FCREPO_PORT" + service-wait.sh "$FCREPO_HOST:$FCREPO_PORT" fi -db-wait.sh "$SOLR_HOST:$SOLR_PORT" +service-wait.sh "$SOLR_HOST:$SOLR_PORT" bundle exec rails db:seed diff --git a/bin/dev-entrypoint.sh b/bin/dev-entrypoint.sh index 38659431db..4ab4deef4a 100755 --- a/bin/dev-entrypoint.sh +++ b/bin/dev-entrypoint.sh @@ -1,13 +1,18 @@ #!/bin/sh set -e -mkdir -p /app/samvera/hyrax-webapp/tmp/pids -rm -f /app/samvera/hyrax-webapp/tmp/pids/* +mkdir -p $RAILS_ROOT/tmp/pids +rm -f $RAILS_ROOT/tmp/pids/* + +RUBY_MAJOR=$(ruby -e "puts /^(?'major'\d+)\.(?'minor'\d+)\.(?'patch'\d+)/.match(RUBY_VERSION)[:major]") # Copy gems installed in the image to the dev bundle mkdir -p /app/bundle/ruby/$RUBY_MAJOR.0 cp -Rn /usr/local/bundle/* /app/bundle/ruby/$RUBY_MAJOR.0 bundle install +yarn install + +db-migrate-seed.sh # Run the command exec "$@" diff --git a/bin/db-wait.sh b/bin/service-wait.sh similarity index 80% rename from bin/db-wait.sh rename to bin/service-wait.sh index 6dc8438f76..afcac40d21 100755 --- a/bin/db-wait.sh +++ b/bin/service-wait.sh @@ -5,9 +5,9 @@ port=$(printf "%s\n" "$1"| cut -d : -f 2) shift 1 +echo "silently waiting for $host:$port" while ! nc -z "$host" "$port" do - echo "waiting for $host:$port" sleep 1 done diff --git a/bin/worker-entrypoint.sh b/bin/worker-entrypoint.sh new file mode 100755 index 0000000000..5f03d06d87 --- /dev/null +++ b/bin/worker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +# Wait for web app to avoid racing during bundle install +service-wait.sh web:3000 + +# Run the command +exec "$@" diff --git a/chart/hyrax/templates/deployment-worker.yaml b/chart/hyrax/templates/deployment-worker.yaml index 06ec990052..d140c5e5aa 100644 --- a/chart/hyrax/templates/deployment-worker.yaml +++ b/chart/hyrax/templates/deployment-worker.yaml @@ -20,7 +20,7 @@ spec: {{- include "hyrax.workerSelectorLabels" . | nindent 8 }} spec: initContainers: - - name: db-wait + - name: service-wait image: "{{ .Values.worker.image.repository }}:{{ .Values.worker.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.worker.image.pullPolicy }} envFrom: @@ -35,7 +35,7 @@ spec: command: - sh - -c - - db-wait.sh "$REDIS_HOST:6379" + - service-wait.sh "$REDIS_HOST:6379" {{- if .Values.worker.extraInitContainers }} {{- toYaml .Values.worker.extraInitContainers | nindent 8 }} {{- end }} diff --git a/docker-compose-dassie.yml b/docker-compose-dassie.yml index 7d351743aa..ced7c141ee 100644 --- a/docker-compose-dassie.yml +++ b/docker-compose-dassie.yml @@ -6,8 +6,7 @@ services: args: - EXTRA_APK_PACKAGES=git less - BUNDLE_GEMFILE=Gemfile.dassie - image: samvera/dassie - entrypoint: dev-entrypoint.sh + image: samvera/hyrax-dev command: sh -c 'bundle exec puma -v -b tcp://0.0.0.0:3000' stdin_open: true tty: true @@ -17,8 +16,8 @@ services: environment: - RAILS_ROOT=/app/samvera/hyrax-webapp depends_on: + - worker - chrome - - db_migrate - fcrepo - fits - memcached @@ -41,14 +40,13 @@ services: - hyrax worker: - image: samvera/dassie - entrypoint: dev-entrypoint.sh + image: samvera/hyrax-dev + entrypoint: worker-entrypoint.sh command: sh -c 'bundle exec sidekiq' user: root env_file: - .dassie/.env depends_on: - - db_migrate - fcrepo - fits - memcached @@ -67,35 +65,20 @@ services: networks: - hyrax - db_migrate: - image: samvera/dassie - user: root - env_file: - - .dassie/.env - entrypoint: dev-entrypoint.sh - command: db-migrate-seed.sh - depends_on: - - postgres - volumes: - - ./bin:/app/samvera - - .dassie:/app/samvera/hyrax-webapp - - .:/app/samvera/hyrax-engine - - bundle:/app/bundle - - rails-public:/app/samvera/hyrax-webapp/public - - rails-tmp:/app/samvera/hyrax-webapp/tmp - networks: - - hyrax - chrome: - image: seleniarm/standalone-chromium:4 + image: selenium/standalone-chromium:4 environment: - - START_XVFB=false +# - START_XVFB=false - SE_NODE_SESSION_TIMEOUT=800 + - SE_ENABLE_TRACING=false + - SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP=true + - SE_BROWSER_ARGS_DISABLE_DSHM=--disable-dev-shm-usage + - SE_BROWSER_ARGS_HEADLESS=--headless=new # logging: # driver: none volumes: - /dev/shm:/dev/shm - shm_size: 2G + shm_size: 2g ports: - "4445:4444" - "5960:5900" @@ -103,7 +86,7 @@ services: - hyrax postgres: - image: postgres:15 + image: postgres:15-alpine environment: - POSTGRES_USER=hyrax_user - POSTGRES_PASSWORD=hyrax_password diff --git a/docker-compose-koppie.yml b/docker-compose-koppie.yml index e8e30e902d..8e8a7df87d 100644 --- a/docker-compose-koppie.yml +++ b/docker-compose-koppie.yml @@ -7,10 +7,8 @@ services: target: hyrax-engine-dev args: - EXTRA_APK_PACKAGES=git less - - APP_PATH=.koppie - BUNDLE_GEMFILE=Gemfile.koppie - image: samvera/koppie - entrypoint: dev-entrypoint.sh + image: samvera/hyrax-dev command: sh -c 'bundle exec puma -v -b tcp://0.0.0.0:3000' stdin_open: true tty: true @@ -20,8 +18,8 @@ services: environment: - RAILS_ROOT=/app/samvera/hyrax-webapp depends_on: + - worker - chrome - - db_migrate - fits - memcached - postgres @@ -45,14 +43,13 @@ services: - koppie worker: - image: samvera/koppie - entrypoint: dev-entrypoint.sh + image: samvera/hyrax-dev + entrypoint: worker-entrypoint.sh command: sh -c 'bundle exec sidekiq' user: root env_file: - .koppie/.env depends_on: - - db_migrate - fits - memcached - postgres @@ -71,44 +68,29 @@ services: networks: - koppie - db_migrate: - image: samvera/koppie - user: root - env_file: - - .koppie/.env - entrypoint: dev-entrypoint.sh - command: db-migrate-seed.sh - depends_on: - - postgres - - solr - volumes: - - ./bin:/app/samvera - - .koppie:/app/samvera/hyrax-webapp - - .:/app/samvera/hyrax-engine - - bundle:/app/bundle - - rails-public:/app/samvera/hyrax-webapp/public - - rails-tmp:/app/samvera/hyrax-webapp/tmp - networks: - - koppie - chrome: - image: seleniarm/standalone-chromium:4 + image: selenium/standalone-chromium:4 environment: - - START_XVFB=false +# - START_XVFB=false - SE_NODE_SESSION_TIMEOUT=800 + - SE_ENABLE_TRACING=false + - SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP=true + - SE_BROWSER_ARGS_DISABLE_DSHM=--disable-dev-shm-usage + - SE_BROWSER_ARGS_HEADLESS=--headless=new # logging: # driver: none volumes: - /dev/shm:/dev/shm - shm_size: 2G + shm_size: 2g ports: - "4446:4444" - "5961:5900" + - "7961:7900" networks: - koppie postgres: - image: postgres:15 + image: postgres:15-alpine env_file: - .koppie/.env ports: diff --git a/docker-compose-sirenia.yml b/docker-compose-sirenia.yml index df9586e745..51fcf8e0a7 100644 --- a/docker-compose-sirenia.yml +++ b/docker-compose-sirenia.yml @@ -7,9 +7,8 @@ services: target: hyrax-engine-dev args: - EXTRA_APK_PACKAGES=git less - - APP_PATH=.koppie - image: samvera/koppie - entrypoint: dev-entrypoint.sh + - BUNDLE_GEMFILE=Gemfile.koppie + image: samvera/hyrax-dev command: sh -c 'bundle exec puma -v -b tcp://0.0.0.0:3000' stdin_open: true tty: true @@ -22,8 +21,8 @@ services: - VALKYRIE_METADATA_ADAPTER=fedora_metadata - VALKYRIE_STORAGE_ADAPTER=fedora_storage depends_on: + - worker - chrome - - db_migrate - fits - memcached - postgres @@ -47,18 +46,18 @@ services: - sirenia worker: - image: samvera/koppie - entrypoint: dev-entrypoint.sh + image: samvera/hyrax-dev + entrypoint: worker-entrypoint.sh command: sh -c 'bundle exec sidekiq' user: root env_file: - .koppie/.env environment: - APP_NAME=sirenia + - RAILS_ROOT=/app/samvera/hyrax-webapp - VALKYRIE_METADATA_ADAPTER=fedora_metadata - VALKYRIE_STORAGE_ADAPTER=fedora_storage depends_on: - - db_migrate - fits - memcached - postgres @@ -77,47 +76,29 @@ services: networks: - sirenia - db_migrate: - image: samvera/koppie - user: root - env_file: - - .koppie/.env - environment: - - APP_NAME=sirenia - - VALKYRIE_METADATA_ADAPTER=fedora_metadata - - VALKYRIE_STORAGE_ADAPTER=fedora_storage - entrypoint: dev-entrypoint.sh - command: db-migrate-seed.sh - depends_on: - - postgres - - solr - volumes: - - ./bin:/app/samvera - - .koppie:/app/samvera/hyrax-webapp - - .:/app/samvera/hyrax-engine - - bundle:/app/bundle - - rails-public:/app/samvera/hyrax-webapp/public - - rails-tmp:/app/samvera/hyrax-webapp/tmp - networks: - - sirenia - chrome: - image: seleniarm/standalone-chromium:114.0 + image: selenium/standalone-chromium:4 environment: - - START_XVFB=false - logging: - driver: none +# - START_XVFB=false + - SE_NODE_SESSION_TIMEOUT=800 + - SE_ENABLE_TRACING=false + - SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP=true + - SE_BROWSER_ARGS_DISABLE_DSHM=--disable-dev-shm-usage + - SE_BROWSER_ARGS_HEADLESS=--headless=new +# logging: +# driver: none volumes: - /dev/shm:/dev/shm - shm_size: 2G + shm_size: 2g ports: - "4447:4444" - "5962:5900" + - "7962:7900" networks: - sirenia postgres: - image: postgres:15 + image: postgres:15-alpine env_file: - .koppie/.env ports: @@ -128,13 +109,15 @@ services: - sirenia fcrepo: - image: fcrepo/fcrepo:6.5-tomcat9 + image: fcrepo/fcrepo:6.5.1-RC3-tomcat9 environment: - >- CATALINA_OPTS=-Dfcrepo.home=/fcrepo-home -Djava.awt.headless=true -Dfile.encoding=UTF-8 - -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m - -XX:MaxPermSize=256m -XX:+DisableExplicitGC -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true + -server -Xms1G -Xmx2G -XX:NewSize=256m -XX:MaxNewSize=1G + -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/mem + -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true -Dfcrepo.pid.minter.length=2 -Dfcrepo.pid.minter.count=4 + -Dfcrepo.jms.enabled=false -Dfcrepo.metrics.enable=true - JAVA_OPTS=-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true -Dfcrepo.pid.minter.length=2 -Dfcrepo.pid.minter.count=4 volumes: - fcrepo:/fcrepo-home @@ -184,6 +167,26 @@ services: networks: - sirenia +## Fedora Metrics Tools https://wiki.lyrasis.org/display/FEDORA6x/Metrics +# prometheus: +# image: prom/prometheus:v2.55.1 +# depends_on: +# - fcrepo +# ports: +# - "9090:9090" +# volumes: +# - ./prometheus.yml:/etc/prometheus/prometheus.yml +# networks: +# - sirenia +# grafana: +# image: grafana/grafana:11.3.1 +# depends_on: +# - fcrepo +# ports: +# - "3500:3000" +# networks: +# - sirenia + volumes: bundle: db: diff --git a/hyrax.gemspec b/hyrax.gemspec index f444e098dd..2fc2ece0b4 100644 --- a/hyrax.gemspec +++ b/hyrax.gemspec @@ -51,7 +51,6 @@ SUMMARY spec.add_dependency 'dry-events', '~> 1.0', '>= 1.0.1' spec.add_dependency 'dry-monads', '~> 1.6' spec.add_dependency 'dry-validation', '~> 1.10' - spec.add_dependency 'faraday', '2.9.1' # Pinned to avoid errors from calling start_with? on RDF::Value spec.add_dependency 'flipflop', '~> 2.3' # Pin more tightly because 0.x gems are potentially unstable spec.add_dependency 'flot-rails', '~> 0.0.6' @@ -71,7 +70,7 @@ SUMMARY spec.add_dependency 'noid-rails', '~> 3.0' spec.add_dependency 'oauth' spec.add_dependency 'oauth2', '~> 1.2' - spec.add_dependency 'openseadragon' + spec.add_dependency 'openseadragon', '~> 0.9' spec.add_dependency 'posix-spawn' spec.add_dependency 'qa', '~> 5.5', '>= 5.5.1' # questioning_authority spec.add_dependency 'rails_autolink', '~> 1.1' @@ -85,7 +84,7 @@ SUMMARY spec.add_dependency 'retriable', '>= 2.9', '< 4.0' spec.add_dependency 'signet' spec.add_dependency 'tinymce-rails', '~> 5.10' - spec.add_dependency 'valkyrie', '~> 3.3' + spec.add_dependency 'valkyrie', '~> 3.5' spec.add_dependency 'view_component', '~> 2.74.1' # Pin until blacklight is updated with workaround for https://github.com/ViewComponent/view_component/issues/1565 spec.add_dependency 'sprockets', '3.7.2' # 3.7.3 fails feature specs spec.add_dependency 'sass-rails', '~> 6.0' diff --git a/lib/hyrax/specs/capybara.rb b/lib/hyrax/specs/capybara.rb index 87d1c28146..f8d092c413 100644 --- a/lib/hyrax/specs/capybara.rb +++ b/lib/hyrax/specs/capybara.rb @@ -19,15 +19,13 @@ def after_teardown Capybara.save_path = ENV['CI'] ? "/tmp/test-results" : Rails.root.join('tmp', 'capybara') options = Selenium::WebDriver::Chrome::Options.new.tap do |opts| - opts.add_argument("--headless") if ENV["CHROME_HEADLESS_MODE"] - opts.add_argument("--no-sandbox") - opts.add_argument("--disable-dev-shm-usage") + opts.add_argument("--headless=new") if ENV["CHROME_HEADLESS_MODE"] + # opts.add_argument("--no-sandbox") + # opts.add_argument("--disable-dev-shm-usage") opts.add_argument("--disable-gpu") if Gem.win_platform? - # Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary - opts.add_argument("--disable-site-isolation-trials") opts.add_argument("--window-size=1440,1440") - opts.add_argument("--enable-features=NetworkService,NetworkServiceInProcess") - opts.add_argument("--disable-features=VizDisplayCompositor") + # opts.add_argument("--enable-features=NetworkService,NetworkServiceInProcess") + # opts.add_argument("--disable-features=VizDisplayCompositor") end Capybara.register_driver :selenium_chrome_headless_sandboxless do |app| diff --git a/lib/hyrax/specs/shared_specs/factories/hyrax_embargo.rb b/lib/hyrax/specs/shared_specs/factories/hyrax_embargo.rb index 2111df5281..c90963806f 100644 --- a/lib/hyrax/specs/shared_specs/factories/hyrax_embargo.rb +++ b/lib/hyrax/specs/shared_specs/factories/hyrax_embargo.rb @@ -5,6 +5,10 @@ visibility_after_embargo { 'open' } visibility_during_embargo { 'authenticated' } + after(:build) do |embargo, evaluator| + embargo.embargo_release_date = evaluator.embargo_release_date.to_datetime + end + to_create do |instance| saved_instance = Valkyrie.config.metadata_adapter.persister.save(resource: instance) instance.id = saved_instance.id diff --git a/lib/hyrax/specs/shared_specs/factories/hyrax_lease.rb b/lib/hyrax/specs/shared_specs/factories/hyrax_lease.rb index f8cd7ceada..70624dea3e 100644 --- a/lib/hyrax/specs/shared_specs/factories/hyrax_lease.rb +++ b/lib/hyrax/specs/shared_specs/factories/hyrax_lease.rb @@ -5,6 +5,10 @@ visibility_after_lease { 'authenticated' } visibility_during_lease { 'open' } + after(:build) do |lease, evaluator| + lease.lease_expiration_date = evaluator.lease_expiration_date.to_datetime + end + to_create do |instance| saved_instance = Valkyrie.config.metadata_adapter.persister.save(resource: instance) instance.id = saved_instance.id diff --git a/lib/hyrax/transactions/steps/delete_resource.rb b/lib/hyrax/transactions/steps/delete_resource.rb index 481010dc59..ab072ef020 100644 --- a/lib/hyrax/transactions/steps/delete_resource.rb +++ b/lib/hyrax/transactions/steps/delete_resource.rb @@ -27,8 +27,8 @@ def initialize(persister: Hyrax.persister, publisher: Hyrax.publisher) def call(resource, user: nil) return Failure(:resource_not_persisted) unless resource.persisted? - @persister.delete(resource: resource) publish_changes(resource: resource, user: user) + @persister.delete(resource: resource) Success(resource) end diff --git a/spec/abilities/ability_spec.rb b/spec/abilities/ability_spec.rb index ba351f67f3..8632453989 100644 --- a/spec/abilities/ability_spec.rb +++ b/spec/abilities/ability_spec.rb @@ -46,7 +46,7 @@ end end - describe "can?(:review, :submissions)" do + describe "can?(:review, :submissions)", :clean_repo do subject { ability.can?(:review, :submissions) } let(:role) { Sipity::Role.create(name: role_name) } diff --git a/spec/actors/hyrax/actors/generic_work_actor_spec.rb b/spec/actors/hyrax/actors/generic_work_actor_spec.rb index 17d211fba4..a8e9621b44 100644 --- a/spec/actors/hyrax/actors/generic_work_actor_spec.rb +++ b/spec/actors/hyrax/actors/generic_work_actor_spec.rb @@ -28,7 +28,7 @@ describe '#create' do let(:curation_concern) { create(:generic_work, user: user) } - let(:xmas) { DateTime.parse('2014-12-25 11:30').iso8601 } + let(:xmas) { DateTime.parse('2014-12-25 11:30') } let(:attributes) { {} } let(:file) { fixture_file_upload('/world.png', 'image/png') } let(:uploaded_file) { Hyrax::UploadedFile.create(file: file, user: user) } diff --git a/spec/authorities/qa/authorities/find_works_spec.rb b/spec/authorities/qa/authorities/find_works_spec.rb index 27c641d471..31883c56b0 100644 --- a/spec/authorities/qa/authorities/find_works_spec.rb +++ b/spec/authorities/qa/authorities/find_works_spec.rb @@ -30,7 +30,7 @@ context "when work has child works" do before do - work4.member_ids << work1.id + work4.member_ids += [work1.id] Hyrax.persister.save(resource: work4) Hyrax.index_adapter.save(resource: work4) end @@ -42,7 +42,7 @@ context "when work has parent works" do before do - work1.member_ids << work4.id + work1.member_ids += [work4.id] Hyrax.persister.save(resource: work1) Hyrax.index_adapter.save(resource: work1) end diff --git a/spec/features/create_child_work_spec.rb b/spec/features/create_child_work_spec.rb index 9c6d9ac1eb..40da36b767 100644 --- a/spec/features/create_child_work_spec.rb +++ b/spec/features/create_child_work_spec.rb @@ -45,7 +45,7 @@ let!(:new_sipity_entity) { create(:sipity_entity, proxy_for: new_parent) } before do - parent.member_ids << curation_concern.id + parent.member_ids += [curation_concern.id] persister.save(resource: parent) end @@ -57,7 +57,7 @@ end it "doesn't lose other memberships" do - new_parent.member_ids << curation_concern.id + new_parent.member_ids += [curation_concern.id] persister.save(resource: new_parent) visit "/concern/parent/#{parent.id}/monographs/#{curation_concern.id}/edit" diff --git a/spec/features/default_workflow_spec.rb b/spec/features/default_workflow_spec.rb index 7d3a1463d2..c96e4dc2e2 100644 --- a/spec/features/default_workflow_spec.rb +++ b/spec/features/default_workflow_spec.rb @@ -8,7 +8,7 @@ state: Hyrax::ResourceStatus::INACTIVE) end - describe 'initializing the workflow' do + describe 'initializing the workflow', :clean_repo do let(:attributes) { :LEGACY_UNUSED_ARGUMENT_WITH_NO_KNOWN_USE_CASE_SHOULD_NEVER_BE_REQUIRED } let(:workflow_factory) { Hyrax::Workflow::WorkflowFactory } diff --git a/spec/features/iiif_manifest_spec.rb b/spec/features/iiif_manifest_spec.rb index 91b155a4d9..000a5dbaef 100644 --- a/spec/features/iiif_manifest_spec.rb +++ b/spec/features/iiif_manifest_spec.rb @@ -53,14 +53,14 @@ def build_a_child_work title: ['supplemental object'], creator: ['Author, Samantha'], description: ['supplemental materials']) - work.member_ids << child_work.id + work.member_ids += [child_work.id] end def build_a_file_set_with_an_image file_set = valkyrie_create(:hyrax_file_set, title: ['page n'], creator: ['Jansson, Tove'], description: ['the nth page']) valkyrie_create(:hyrax_file_metadata, :original_file, :image, :with_file, original_filename: 'world.png', file_set: file_set, file: uploaded_file) persister.save(resource: file_set) - work.member_ids << file_set.id + work.member_ids += [file_set.id] end def load_manifest_check_standards diff --git a/spec/hyrax/transactions/admin_set_update_spec.rb b/spec/hyrax/transactions/admin_set_update_spec.rb index af4514e6c6..f04e4aaea2 100644 --- a/spec/hyrax/transactions/admin_set_update_spec.rb +++ b/spec/hyrax/transactions/admin_set_update_spec.rb @@ -7,7 +7,7 @@ let(:admin_set) { FactoryBot.valkyrie_create(:hyrax_admin_set) } let(:change_set) { Hyrax::Forms::AdministrativeSetForm.new(admin_set) } let(:user) { FactoryBot.create(:user) } - let(:xmas) { DateTime.parse('2022-12-25 11:30').iso8601 } + let(:xmas) { DateTime.parse('2022-12-25 11:30') } before { allow(Hyrax::TimeService).to receive(:time_in_utc).and_return(xmas) } diff --git a/spec/hyrax/transactions/apply_change_set_spec.rb b/spec/hyrax/transactions/apply_change_set_spec.rb index 1bdccf4f91..074f4ad9fa 100644 --- a/spec/hyrax/transactions/apply_change_set_spec.rb +++ b/spec/hyrax/transactions/apply_change_set_spec.rb @@ -9,7 +9,7 @@ let(:change_set) { Hyrax::ChangeSet.for(resource) } let(:resource) { build(:hyrax_work) } let(:user) { create(:user) } - let(:xmas) { DateTime.parse('2018-12-25 11:30').iso8601 } + let(:xmas) { DateTime.parse('2018-12-25 11:30') } before { allow(Hyrax::TimeService).to receive(:time_in_utc).and_return(xmas) } @@ -25,11 +25,9 @@ end it 'sets modified and uploaded date' do - expected_time = Hyrax.config.disable_wings ? DateTime.parse(xmas) : xmas - expect(tx.call(change_set).value!) - .to have_attributes(date_modified: expected_time, - date_uploaded: expected_time) + .to have_attributes(date_modified: xmas, + date_uploaded: xmas) end describe 'events' do diff --git a/spec/hyrax/transactions/file_set_update_spec.rb b/spec/hyrax/transactions/file_set_update_spec.rb index 296fb615c6..7c4835188a 100644 --- a/spec/hyrax/transactions/file_set_update_spec.rb +++ b/spec/hyrax/transactions/file_set_update_spec.rb @@ -7,7 +7,7 @@ let(:file_set) { FactoryBot.valkyrie_create(:hyrax_file_set, title: 'image.jpg') } let(:change_set) { Hyrax::Forms::AdministrativeSetForm.new(file_set) } let(:user) { FactoryBot.create(:user) } - let(:xmas) { DateTime.parse('2022-12-25 11:30').iso8601 } + let(:xmas) { DateTime.parse('2022-12-25 11:30') } before { allow(Hyrax::TimeService).to receive(:time_in_utc).and_return(xmas) } diff --git a/spec/hyrax/transactions/steps/save_spec.rb b/spec/hyrax/transactions/steps/save_spec.rb index 912f6f116b..65ab78c08b 100644 --- a/spec/hyrax/transactions/steps/save_spec.rb +++ b/spec/hyrax/transactions/steps/save_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Hyrax::Transactions::Steps::Save do subject(:step) { described_class.new(persister: persister) } - let(:adapter) { Valkyrie::MetadataAdapter.find(:test_adapter) } + let(:adapter) { Hyrax.metadata_adapter } let(:change_set) { change_set_class.new(resource) } let(:persister) { adapter.persister } let(:resource) { build(:hyrax_work) } @@ -68,13 +68,13 @@ it 'publishes object.metadata.updated with a user' do expect { step.call(change_set, user: user) } .to change { listener.object_metadata_updated&.payload } - .to match object: an_instance_of(resource.class), user: user + .to match object: a_kind_of(resource.class), user: user end it 'publishes object.deposited with a user' do expect { step.call(change_set, user: user) } .to change { listener.object_deposited&.payload } - .to match object: an_instance_of(resource.class), user: user + .to match object: a_kind_of(resource.class), user: user end end @@ -83,7 +83,7 @@ it 'publishes collection.metadata.updated with a user' do expect { step.call(change_set, user: user) } .to change { listener.collection_metadata_updated&.payload } - .to match collection: an_instance_of(resource.class), user: user + .to match collection: a_kind_of(resource.class), user: user end end end diff --git a/spec/hyrax/transactions/steps/set_modified_date_spec.rb b/spec/hyrax/transactions/steps/set_modified_date_spec.rb index 7e09eef285..45094c765a 100644 --- a/spec/hyrax/transactions/steps/set_modified_date_spec.rb +++ b/spec/hyrax/transactions/steps/set_modified_date_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Hyrax::Transactions::Steps::SetModifiedDate do subject(:step) { described_class.new } let(:work) { build(:hyrax_work) } - let(:xmas) { DateTime.parse('2018-12-25 11:30').iso8601 } + let(:xmas) { DateTime.parse('2018-12-25 11:30') } before { allow(Hyrax::TimeService).to receive(:time_in_utc).and_return(xmas) } diff --git a/spec/hyrax/transactions/steps/set_uploaded_date_unless_present_spec.rb b/spec/hyrax/transactions/steps/set_uploaded_date_unless_present_spec.rb index 1cae37ae3d..05d7152b29 100644 --- a/spec/hyrax/transactions/steps/set_uploaded_date_unless_present_spec.rb +++ b/spec/hyrax/transactions/steps/set_uploaded_date_unless_present_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Hyrax::Transactions::Steps::SetUploadedDateUnlessPresent do subject(:step) { described_class.new } let(:work) { build(:hyrax_work) } - let(:xmas) { DateTime.parse('2018-12-25 11:30').iso8601 } + let(:xmas) { DateTime.parse('2018-12-25 11:30') } before { allow(Hyrax::TimeService).to receive(:time_in_utc).and_return(xmas) } @@ -21,7 +21,7 @@ context 'when a modified date exists' do let(:work) { build(:hyrax_work, date_modified: xmas_past) } - let(:xmas_past) { DateTime.parse('2009-12-25 11:30').iso8601 } + let(:xmas_past) { DateTime.parse('2009-12-25 11:30') } it 'sets the uploaded date to the modified date' do expect { step.call(work) } @@ -51,7 +51,7 @@ end context 'when an uploaded date exists' do - let(:xmas_past) { DateTime.parse('2009-12-25 11:30').iso8601 } + let(:xmas_past) { DateTime.parse('2009-12-25 11:30') } before { change_set.date_uploaded = xmas_past } @@ -63,7 +63,7 @@ end context 'when a modified date exists' do - let(:xmas_past) { DateTime.parse('2009-12-25 11:30').iso8601 } + let(:xmas_past) { DateTime.parse('2009-12-25 11:30') } before { change_set.date_modified = xmas_past } diff --git a/spec/hyrax/transactions/work_update_spec.rb b/spec/hyrax/transactions/work_update_spec.rb index 470ebbeb44..384c57a963 100644 --- a/spec/hyrax/transactions/work_update_spec.rb +++ b/spec/hyrax/transactions/work_update_spec.rb @@ -6,10 +6,10 @@ RSpec.describe Hyrax::Transactions::WorkUpdate, valkyrie_adapter: :test_adapter do subject(:tx) { described_class.new } let(:change_set) { Hyrax::ChangeSet.for(resource) } - let(:xmas) { DateTime.parse('2018-12-25 11:30').iso8601 } + let(:xmas) { DateTime.parse('2018-12-25 11:30') } let(:resource) do - FactoryBot.valkyrie_create(:hyrax_work, date_uploaded: DateTime.parse('2018-12-01T11:30').iso8601) + FactoryBot.valkyrie_create(:hyrax_work, date_uploaded: DateTime.parse('2018-12-01T11:30')) end describe '#call' do diff --git a/spec/indexers/hyrax/indexers/file_set_indexer_spec.rb b/spec/indexers/hyrax/indexers/file_set_indexer_spec.rb index 8a929a4ba1..2fefc189a8 100644 --- a/spec/indexers/hyrax/indexers/file_set_indexer_spec.rb +++ b/spec/indexers/hyrax/indexers/file_set_indexer_spec.rb @@ -38,7 +38,7 @@ let(:metadata_attrs) do { id: SecureRandom.uuid, - file_identifier: 'versiondisk:///app/samvera/hyrax-webapp/tmp/test_adapter_uploads/VALFILEID1', + file_identifier: "versiondisk://#{Rails.root.join('tmp', 'test_adapter_uploads', 'VALFILEID1')}", alternate_ids: ['AFFILEID1'], file_set_id: fileset_id, diff --git a/spec/javascripts/jasmine_spec.rb b/spec/javascripts/jasmine_spec.rb index 1d9005cfd4..ae8b3e2eb7 100644 --- a/spec/javascripts/jasmine_spec.rb +++ b/spec/javascripts/jasmine_spec.rb @@ -4,6 +4,10 @@ # Run the jasmine tests by running the karma javascript test framework # The spec will fail if any jasmine tests fails. RSpec.describe "Jasmine" do + before do + `cd $RAILS_ROOT && bundle exec rake assets:precompile` if ENV['RAILS_ROOT'] + end + it "expects all jasmine tests to pass" do # Ensure capybara is not using the remote browser Capybara.using_driver(Capybara.javascript_driver) { Capybara.current_session.quit } diff --git a/spec/jobs/valkyrie_create_derivatives_job_spec.rb b/spec/jobs/valkyrie_create_derivatives_job_spec.rb index ad8791428a..0e27ea36cb 100644 --- a/spec/jobs/valkyrie_create_derivatives_job_spec.rb +++ b/spec/jobs/valkyrie_create_derivatives_job_spec.rb @@ -7,8 +7,8 @@ let(:work) { FactoryBot.valkyrie_create(:hyrax_work, :with_member_file_sets, :with_thumbnail) } let(:upload_0) { FactoryBot.create(:uploaded_file, file_set_uri: file_sets[0].id, file: File.open('spec/fixtures/image.png')) } let(:upload_1) { FactoryBot.create(:uploaded_file, file_set_uri: file_sets[1].id, file: File.open('spec/fixtures/world.png')) } - let(:file_id_0) { file_sets[0].file_ids.first } - let(:file_id_1) { file_sets[1].file_ids.first } + let(:file_id_0) { file_sets[0].original_file_id } + let(:file_id_1) { file_sets[1].original_file_id } let(:characterizer) { double(characterize: fits_response) } let(:fits_response) { IO.read('spec/fixtures/png_fits.xml') } diff --git a/spec/presenters/hyrax/file_usage_spec.rb b/spec/presenters/hyrax/file_usage_spec.rb index 99278f3eda..5555e4e531 100644 --- a/spec/presenters/hyrax/file_usage_spec.rb +++ b/spec/presenters/hyrax/file_usage_spec.rb @@ -6,7 +6,7 @@ let(:file) do valkyrie_create(:hyrax_file_set, date_uploaded: date_uploaded, edit_users: [user]) end - let(:date_uploaded) { (Time.zone.today - 4.days).to_s } + let(:date_uploaded) { Hyrax::TimeService.time_in_utc - 4.days } let(:dates) do ldates = [] @@ -102,14 +102,14 @@ end context "when the analytics start date is set" do - let(:earliest) { DateTime.new(2014, 1, 2).iso8601 } + let(:earliest) { DateTime.new(2014, 1, 2) } before do Hyrax.config.analytic_start_date = earliest end describe "create date before earliest date set" do - let(:date_uploaded) { DateTime.new(2014, 1, 1).iso8601 } + let(:date_uploaded) { DateTime.new(2014, 1, 1) } it "sets the created date to the earliest date not the created date" do expect(usage.created).to eq(earliest) @@ -117,7 +117,7 @@ end describe "create date after earliest" do - let(:date_uploaded) { DateTime.new(2014, 1, 3).iso8601 } + let(:date_uploaded) { DateTime.new(2014, 1, 3) } it "sets the created date to the earliest date not the created date" do expect(usage.created).to eq(file.date_uploaded) @@ -129,7 +129,7 @@ before do Hyrax.config.analytic_start_date = nil end - let(:date_uploaded) { DateTime.new(2014, 1, 1).iso8601 } + let(:date_uploaded) { DateTime.new(2014, 1, 1) } it "sets the created date to the earliest date not the created date" do expect(usage.created).to eq(date_uploaded) @@ -138,7 +138,7 @@ end describe "on a migrated file" do - let(:date_uploaded) { "2014-12-31" } + let(:date_uploaded) { DateTime.new(2014, 12, 31) } it "uses the date_uploaded for analytics" do expect(usage.created).to eq(date_uploaded) diff --git a/spec/presenters/hyrax/work_usage_spec.rb b/spec/presenters/hyrax/work_usage_spec.rb index f9a11bcbf9..45e2b0370c 100644 --- a/spec/presenters/hyrax/work_usage_spec.rb +++ b/spec/presenters/hyrax/work_usage_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe Hyrax::WorkUsage, type: :model do let!(:work) { valkyrie_create(:monograph, date_uploaded: date_uploaded) } - let(:date_uploaded) { Time.zone.today - 4.days } + let(:date_uploaded) { Hyrax::TimeService.time_in_utc - 4.days } let(:dates) do ldates = [] @@ -107,7 +107,7 @@ Hyrax.config.analytic_start_date = earliest described_class.new(work.id) end - let(:date_uploaded) { Time.zone.today - 4.days } + let(:date_uploaded) { Hyrax::TimeService.time_in_utc - 4.days } it "sets the created date to the earliest date not the created date" do expect(usage.created).to eq(work.date_uploaded) diff --git a/spec/services/hyrax/custom_queries/find_access_control_spec.rb b/spec/services/hyrax/custom_queries/find_access_control_spec.rb index 7358a12152..259c328caf 100644 --- a/spec/services/hyrax/custom_queries/find_access_control_spec.rb +++ b/spec/services/hyrax/custom_queries/find_access_control_spec.rb @@ -26,6 +26,17 @@ end end + context 'for deleted object' do + let(:resource) { persister.save(resource: Hyrax::Resource.new) } + + before { persister.delete(resource: resource) } + + it 'raises ObjectNotFoundError' do + expect { query_handler.find_access_control_for(resource: resource) } + .to raise_error Valkyrie::Persistence::ObjectNotFoundError + end + end + context 'when an acl exists' do let(:acl) { persister.save(resource: Hyrax::AccessControl.new(access_to: resource.id)) } let(:resource) { persister.save(resource: Hyrax::Resource.new) } diff --git a/spec/services/hyrax/custom_queries/navigators/child_collections_navigator_spec.rb b/spec/services/hyrax/custom_queries/navigators/child_collections_navigator_spec.rb index e12e24b17e..bf4ece083c 100644 --- a/spec/services/hyrax/custom_queries/navigators/child_collections_navigator_spec.rb +++ b/spec/services/hyrax/custom_queries/navigators/child_collections_navigator_spec.rb @@ -8,7 +8,7 @@ before do resources = [collection2, collection3] - resources.each { |res| res.member_of_collection_ids << collection1.id } + resources.each { |res| res.member_of_collection_ids += [collection1.id] } resources.each { |res| Hyrax.persister.save(resource: res) } end diff --git a/spec/services/hyrax/listeners/member_cleanup_listener_spec.rb b/spec/services/hyrax/listeners/member_cleanup_listener_spec.rb index 95bb174653..02699fdba1 100644 --- a/spec/services/hyrax/listeners/member_cleanup_listener_spec.rb +++ b/spec/services/hyrax/listeners/member_cleanup_listener_spec.rb @@ -19,7 +19,7 @@ let(:parent_work) { FactoryBot.valkyrie_create(:hyrax_work) } before do - parent_work.member_ids << child_work.id + parent_work.member_ids += [child_work.id] Hyrax.persister.save(resource: parent_work) end diff --git a/spec/services/hyrax/multiple_membership_checker_spec.rb b/spec/services/hyrax/multiple_membership_checker_spec.rb index 0514062b61..7404c3a325 100644 --- a/spec/services/hyrax/multiple_membership_checker_spec.rb +++ b/spec/services/hyrax/multiple_membership_checker_spec.rb @@ -176,7 +176,7 @@ context 'and the member is already in the other single membership collection' do before do [item, item_2].each do |work| - work.member_of_collection_ids << collection2.id + work.member_of_collection_ids += [collection2.id] Hyrax.persister.save(resource: work) Hyrax.publisher.publish('object.metadata.updated', object: work, user: user) end @@ -192,7 +192,7 @@ context 'and the member is not already in the other single membership collection' do before do - item_2.member_of_collection_ids << collection2.id + item_2.member_of_collection_ids += [collection2.id] Hyrax.persister.save(resource: item_2) Hyrax.publisher.publish('object.metadata.updated', object: item_2, user: user) diff --git a/spec/services/hyrax/statistics/works/count_spec.rb b/spec/services/hyrax/statistics/works/count_spec.rb index 67f0172098..c2eeb09af0 100644 --- a/spec/services/hyrax/statistics/works/count_spec.rb +++ b/spec/services/hyrax/statistics/works/count_spec.rb @@ -7,7 +7,14 @@ before do if wings_disabled - 3.times { valkyrie_create(:monograph, :public, depositor: user1.user_key) } + valkyrie_create(:monograph, :public, depositor: user1.user_key) + valkyrie_create(:monograph, :public, depositor: user1.user_key) + + # Valkyrie postgres adapter filters created_at letting ActiveRecord handle it. + allow(Valkyrie::Persistence::Postgres::ORM::Resource).to receive(:current_time_from_proper_timezone).and_return(2.days.ago) + valkyrie_create(:monograph, :public, depositor: user1.user_key, created_at: [2.days.ago]) + allow(Valkyrie::Persistence::Postgres::ORM::Resource).to receive(:current_time_from_proper_timezone).and_call_original + valkyrie_create(:monograph, read_groups: ['registered'], depositor: user1.user_key) valkyrie_create(:monograph, read_groups: ['private'], depositor: user1.user_key) valkyrie_create(:hyrax_collection, depositor: user1.user_key) @@ -29,17 +36,14 @@ no_date_range_given = described_class.by_permission(start_date: nil, end_date: nil) expect(no_date_range_given).to include(public: 3, private: 1, registered: 1, total: 5) - # NOTE: Since Postgres' #created_at cannot be mocked, the following two tests have been skipped for Koppie. - unless wings_disabled - start_date = yesterday.beginning_of_day - start_date_given = described_class.by_permission(start_date: start_date, end_date: nil) - expect(start_date_given).to include(public: 2, private: 1, registered: 1, total: 4) + start_date = yesterday.beginning_of_day + start_date_given = described_class.by_permission(start_date: start_date, end_date: nil) + expect(start_date_given).to include(public: 2, private: 1, registered: 1, total: 4) - start_date = 2.days.ago.beginning_of_day - end_date = yesterday.end_of_day - start_date_and_end_date_given = described_class.by_permission(start_date: start_date, end_date: end_date) - expect(start_date_and_end_date_given).to include(public: 1, private: 0, registered: 0, total: 1) - end + start_date = 2.days.ago.beginning_of_day + end_date = yesterday.end_of_day + start_date_and_end_date_given = described_class.by_permission(start_date: start_date, end_date: end_date) + expect(start_date_and_end_date_given).to include(public: 1, private: 0, registered: 0, total: 1) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a9ddfb9b0e..df6457d751 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,7 +25,7 @@ def ci_build? require 'factory_bot' -require File.expand_path("config/environment", '../hyrax-webapp') +require File.expand_path("config/environment", ENV['RAILS_ROOT']) db_config = ActiveRecord::Base.configurations[ENV['RAILS_ENV']] ActiveRecord::Tasks::DatabaseTasks.create(db_config) ActiveRecord::Migrator.migrations_paths = [Pathname.new(ENV['RAILS_ROOT']).join('db', 'migrate').to_s]