diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7b159b4f7..06aed9f9a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,12 +18,12 @@ jobs: uses: actions/cache@v2.1.3 with: path: vendor/bundle - key: 2.6.5 + key: 2.7.2 - name: Setup Ruby - uses: ruby/setup-ruby@v1.59.1 + uses: ruby/setup-ruby@v1.159.0 with: - ruby-version: 2.6.5 + ruby-version: 2.7.2 - name: Install dependencies run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3cac1e93..df45daf14 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: ['2.6', '2.7'] # TODO add 3.0 compat , '3.0'] + ruby: ['2.7', '3.0'] name: Run specs with ruby ${{ matrix.ruby }} steps: - uses: actions/checkout@v2 @@ -24,7 +24,7 @@ jobs: key: ${{ matrix.ruby }} - name: Setup Ruby - uses: ruby/setup-ruby@v1.59.1 + uses: ruby/setup-ruby@v1.159.0 with: ruby-version: ${{ matrix.ruby }} @@ -37,10 +37,13 @@ jobs: bundle install - name: Migrate test database - run: bin/rails db:migrate RAILS_ENV=test + run: bundle exec rake db:migrate db:test:prepare + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 - name: Run rspec - run: bin/rspec + run: bundle exec rake - name: Upload coverage results uses: actions/upload-artifact@v2 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ad19a7fd2..3e90e131c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,73 +6,13 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Exclude: - - 'app/jobs/bulkrax/import_file_set_job.rb' - - 'app/models/bulkrax/entry.rb' - -# Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'spec/rails_helper.rb' - -# Offense count: 3 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Exclude: - - 'app/parsers/bulkrax/csv_parser.rb' - - 'spec/models/bulkrax/rdf_entry_spec.rb' - - 'spec/models/bulkrax/xml_entry_spec.rb' - -# Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: Width, AllowedPatterns, IgnoredPatterns. -Layout/IndentationWidth: - Exclude: - - 'spec/rails_helper.rb' - -# Offense count: 8 +# Offense count: 5 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns. # URISchemes: http, https Layout/LineLength: Max: 301 -# Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'app/parsers/bulkrax/csv_parser.rb' - -# Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). -Layout/RescueEnsureAlignment: - Exclude: - - 'spec/rails_helper.rb' - -# Offense count: 7 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'app/models/bulkrax/csv_entry.rb' - - 'app/parsers/bulkrax/csv_parser.rb' - - 'spec/models/bulkrax/rdf_entry_spec.rb' - - 'spec/models/bulkrax/xml_entry_spec.rb' - - 'spec/rails_helper.rb' - # Offense count: 16 # Configuration parameters: IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: @@ -81,14 +21,14 @@ Metrics/AbcSize: # Offense count: 4 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 201 + Max: 140 -# Offense count: 13 +# Offense count: 12 # Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: Max: 19 -# Offense count: 32 +# Offense count: 28 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. Metrics/MethodLength: Max: 26 @@ -96,9 +36,9 @@ Metrics/MethodLength: # Offense count: 2 # Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: - Max: 131 + Max: 130 -# Offense count: 9 +# Offense count: 10 # Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: Max: 19 @@ -110,30 +50,8 @@ Rails/HasManyOrHasOneDependent: Exclude: - 'app/models/concerns/bulkrax/status_info.rb' -# Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: Keywords, RequireColon. -# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE -Style/CommentAnnotation: - Exclude: - - 'app/models/bulkrax/xml_entry.rb' - - 'spec/models/bulkrax/oai_entry_spec.rb' - -# Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). -Style/IfUnlessModifier: - Exclude: - - 'app/models/bulkrax/csv_entry.rb' - - 'lib/generators/bulkrax/templates/config/initializers/bulkrax.rb' - # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). -Style/MultilineIfModifier: +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. +Style/GuardClause: Exclude: - 'app/models/bulkrax/csv_entry.rb' - -# Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). -Style/RedundantBegin: - Exclude: - - 'spec/rails_helper.rb' diff --git a/Gemfile b/Gemfile index 30071446e..d8f99f28f 100644 --- a/Gemfile +++ b/Gemfile @@ -12,11 +12,11 @@ gemspec # Git. Remember to move these dependencies to your gemspec before releasing # your gem to rubygems.org. -gem 'blacklight', '~> 6.25.0' +gem 'blacklight' gem 'bootstrap-sass', '~> 3.4.1' gem 'coderay' gem 'factory_bot_rails' -gem 'hyrax', '>= 2.3' +gem 'hyrax', '>= 2.3', '< 4.999' gem 'oai' gem 'rsolr', '>= 1.0' gem 'rspec-rails' @@ -29,6 +29,7 @@ group :development, :test do gem 'pry-byebug' gem 'solargraph' gem 'solr_wrapper', '>= 0.3' + gem 'sqlite3', '~> 1.4' end group :lint do diff --git a/README.md b/README.md index 3a87a03b6..bb9ec1ef9 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ Once your the exporter has run, a download icon will appear on the exporters men ## Compatibility -* Ruby 2.6 or 2.7 is required +* Ruby 2.7 or newer is required * Hyrax 2.3 or newer is required ## Contributing diff --git a/app/assets/javascripts/bulkrax/exporters.js b/app/assets/javascripts/bulkrax/exporters.js index 829ceb47b..67944d41a 100644 --- a/app/assets/javascripts/bulkrax/exporters.js +++ b/app/assets/javascripts/bulkrax/exporters.js @@ -14,7 +14,7 @@ function hideUnhide(field) { } }; -function addRequired(selectedSource) { +function addRequired(selectedSource) { selectedSource.addClass('required').attr('required', 'required'); selectedSource.parent().addClass('required'); } @@ -26,14 +26,14 @@ function removeRequired(allSources) { // hide all export_source function hide(allSources) { - allSources.addClass('hidden'); - allSources.find('#exporter_export_source').addClass('hidden').attr('type', 'hidden'); + allSources.addClass('d-none'); + allSources.find('#exporter_export_source').addClass('.d-none').attr('type', 'd-none'); } // unhide selected export_source function unhideSelected(selectedSource) { - selectedSource.removeClass('hidden').removeAttr('type'); - selectedSource.parent().removeClass('hidden').removeAttr('type'); + selectedSource.removeClass('d-none').removeAttr('type'); + selectedSource.parent().removeClass('d-none').removeAttr('type'); }; // add the autocomplete javascript diff --git a/app/factories/bulkrax/object_factory.rb b/app/factories/bulkrax/object_factory.rb index dd5d37705..ca0ba791a 100644 --- a/app/factories/bulkrax/object_factory.rb +++ b/app/factories/bulkrax/object_factory.rb @@ -123,7 +123,7 @@ def search_by_identifier def create attrs = transform_attributes @object = klass.new - object.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if object.respond_to?(:reindex_extent) + object.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if defined?(Hyrax::Adapters::NestingIndexAdapter) && object.respond_to?(:reindex_extent) run_callbacks :save do run_callbacks :create do if klass == Collection diff --git a/app/jobs/bulkrax/create_relationships_job.rb b/app/jobs/bulkrax/create_relationships_job.rb index 6e9eb77b8..e6e0415cb 100644 --- a/app/jobs/bulkrax/create_relationships_job.rb +++ b/app/jobs/bulkrax/create_relationships_job.rb @@ -158,7 +158,8 @@ def process(relationship:, importer_run_id:, parent_record:, ability:) end def add_to_collection(child_record, parent_record) - parent_record.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) + parent_record.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) if + defined?(Hyrax::Adapters::NestingIndexAdapter) child_record.member_of_collections << parent_record child_record.save! end diff --git a/app/models/bulkrax/csv_entry.rb b/app/models/bulkrax/csv_entry.rb index aaa0bc24b..a106a74bf 100644 --- a/app/models/bulkrax/csv_entry.rb +++ b/app/models/bulkrax/csv_entry.rb @@ -88,8 +88,10 @@ def build_metadata def validate_record raise StandardError, 'Record not found' if record.nil? - raise StandardError, "Missing required elements, missing element(s) are: "\ -"#{importerexporter.parser.missing_elements(record).join(', ')}" unless importerexporter.parser.required_elements?(record) + unless importerexporter.parser.required_elements?(record) + raise StandardError, "Missing required elements, missing element(s) are: "\ +"#{importerexporter.parser.missing_elements(record).join(', ')}" + end end def add_identifier diff --git a/app/services/bulkrax/remove_relationships_for_importer.rb b/app/services/bulkrax/remove_relationships_for_importer.rb index 784b5ed07..10fa92e40 100644 --- a/app/services/bulkrax/remove_relationships_for_importer.rb +++ b/app/services/bulkrax/remove_relationships_for_importer.rb @@ -63,7 +63,8 @@ def break_relationships! remove_relationships_from_work(obj) end - obj.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) if defined?(Hyrax) + obj.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) if + defined?(Hyrax::Adapters::NestingIndexAdapter) obj.save! end end diff --git a/app/views/bulkrax/exporters/_form.html.erb b/app/views/bulkrax/exporters/_form.html.erb index 4e54215b2..df3af0b38 100644 --- a/app/views/bulkrax/exporters/_form.html.erb +++ b/app/views/bulkrax/exporters/_form.html.erb @@ -33,8 +33,8 @@ label: t('bulkrax.exporter.labels.importer'), required: true, prompt: 'Select from the list', - label_html: { class: 'importer export-source-option hidden' }, - input_html: { class: 'importer export-source-option hidden form-control' }, + label_html: { class: 'importer export-source-option d-none' }, + input_html: { class: 'importer export-source-option d-none form-control' }, collection: form.object.importers_list.sort %> <%= form.input :export_source_collection, @@ -42,9 +42,9 @@ label: t('bulkrax.exporter.labels.collection'), required: true, placeholder: @collection&.title&.first, - label_html: { class: 'collection export-source-option hidden' }, + label_html: { class: 'collection export-source-option d-none' }, input_html: { - class: 'collection export-source-option hidden form-control', + class: 'collection export-source-option d-none form-control', data: { 'autocomplete-url' => '/authorities/search/collections', 'autocomplete' => 'collection' @@ -56,8 +56,8 @@ label: t('bulkrax.exporter.labels.worktype'), required: true, prompt: 'Select from the list', - label_html: { class: 'worktype export-source-option hidden' }, - input_html: { class: 'worktype export-source-option hidden form-control' }, + label_html: { class: 'worktype export-source-option d-none' }, + input_html: { class: 'worktype export-source-option d-none form-control' }, collection: Bulkrax.curation_concerns.map { |cc| [cc.to_s, cc.to_s] } %> <%= form.input :limit, @@ -80,7 +80,7 @@ as: :boolean, label: t('bulkrax.exporter.labels.filter_by_date') %> -