From 7a3fdf484fffc71033d750ca8391ae1e956cd26c Mon Sep 17 00:00:00 2001 From: Alin Vetian Date: Tue, 21 Jan 2025 15:04:46 +0200 Subject: [PATCH] updates --- Gemfile | 2 +- Gemfile.lock | 2 + config/database.yml | 2 +- .../20200805213525_add_fos_to_subjects.rb | 4 +- lib/stash/compressed/zip_info.rb | 2 +- spec/models/fix_in_progress_versions_spec.rb | 102 +++++++++--------- 6 files changed, 58 insertions(+), 56 deletions(-) diff --git a/Gemfile b/Gemfile index d14c0b9ce3..22aa1f08f5 100644 --- a/Gemfile +++ b/Gemfile @@ -50,7 +50,7 @@ gem 'aws-sdk-s3', '~> 1.113' gem 'blacklight', '~> 8.7.0' gem 'bootsnap', require: false gem 'bootstrap', '~> 4.6' -# gem 'charlock_holmes', '~> 0.7.7' +gem 'charlock_holmes', '~> 0.7.9' gem 'concurrent-ruby', '~> 1.3.4' gem 'daemons', '~> 1.4.1' gem 'database_cleaner', '~> 2.0.1' diff --git a/Gemfile.lock b/Gemfile.lock index 8ccb33afd3..2e12122951 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -175,6 +175,7 @@ GEM capybara-screenshot (1.0.26) capybara (>= 1.0, < 4) launchy + charlock_holmes (0.7.9) childprocess (5.1.0) logger (~> 1.5) coderay (1.1.3) @@ -776,6 +777,7 @@ DEPENDENCIES capistrano-yarn capybara capybara-screenshot + charlock_holmes (~> 0.7.9) coffee-rails (~> 5.0) colorize concurrent-ruby (~> 1.3.4) diff --git a/config/database.yml b/config/database.yml index 4be6c7c541..81b6e7f424 100644 --- a/config/database.yml +++ b/config/database.yml @@ -14,7 +14,7 @@ default: &default pool: 40 timeout: 10000 adapter: mysql2 - database: dryad + database: dryad_2 host: <%= Rails.application.credentials[Rails.env.to_sym][:database_host] %> username: <%= Rails.application.credentials[Rails.env.to_sym][:database_username] %> password: <%= Rails.application.credentials[Rails.env.to_sym][:database_password] %> diff --git a/db/migrate/20200805213525_add_fos_to_subjects.rb b/db/migrate/20200805213525_add_fos_to_subjects.rb index b1e022a6ce..288540e81e 100644 --- a/db/migrate/20200805213525_add_fos_to_subjects.rb +++ b/db/migrate/20200805213525_add_fos_to_subjects.rb @@ -55,8 +55,8 @@ class AddFosToSubjects < ActiveRecord::Migration[5.0] def up # it can have unexpected consequences to use ActiveRecord models directly in a migration, so using SQL, # btw, no values have an apostrophe or other weird characters in them and a controlled list - results = ActiveRecord::Base.connection - .query("SELECT * FROM dcs_subjects WHERE subject_scheme = 'fos'", as: :hash) + results = ActiveRecord::Base.connection.instance_variable_get('@connection') + .query("SELECT * FROM dcs_subjects WHERE subject_scheme = 'fos'") existing_subjects = results.map { |i| i['subject'] } # can't use a symbol here for more compact notation need_insertion = SUBJECT_LIST - existing_subjects diff --git a/lib/stash/compressed/zip_info.rb b/lib/stash/compressed/zip_info.rb index e62296a9c4..dc236fca57 100644 --- a/lib/stash/compressed/zip_info.rb +++ b/lib/stash/compressed/zip_info.rb @@ -1,6 +1,6 @@ require 'http' require 'stringio' -# require 'charlock_holmes/string' +require 'charlock_holmes/string' require 'zip' require 'down/http' require 'open3' diff --git a/spec/models/fix_in_progress_versions_spec.rb b/spec/models/fix_in_progress_versions_spec.rb index 734b59ff27..87f93d69b1 100644 --- a/spec/models/fix_in_progress_versions_spec.rb +++ b/spec/models/fix_in_progress_versions_spec.rb @@ -1,51 +1,51 @@ -require Rails.root.join('db/migrate/20170329190235_fix_in_progress_resources.rb') - -describe FixInProgressResources do - include Mocks::Datacite - include Mocks::RSolr - include Mocks::Salesforce - include Mocks::Stripe - - attr_reader :in_progress_resources - - before(:each) do - mock_solr! - mock_datacite! - mock_salesforce! - mock_stripe! - - @in_progress_resources = [] - ident_count = 3 - identifiers = Array.new(ident_count) { |i| create(:identifier, identifier: "10.123/#{i}") } - identifiers.each do |ident| - Timecop.travel(Time.now.utc - 1.minute) - r1 = create(:resource, identifier_id: ident.id) - r1.current_state = 'submitted' - r1.save - v1 = r1.stash_version - expect(v1.version).to eq(1) # just to be sure - expect(v1.merritt_version).to eq(1) # just to be sure - Timecop.return - r2 = r1.amoeba_dup - r2.save - expect(r2.current_state).to eq('in_progress') # just to be sure - v2 = r2.stash_version - v2.version = 1 - v2.merritt_version = 1 - v2.save - - in_progress_resources << v2 - end - expect(in_progress_resources.size).to eq(ident_count) # just to be sure - end - - it 'fixes all in-progress versions' do - fix = FixInProgressResources.new - fix.change - in_progress_resources.each do |v| - v.reload - expect(v.version).to eq(2) # just to be sure - expect(v.merritt_version).to eq(2) # just to be sure - end - end -end +# require Rails.root.join('db/migrate/20170329190235_fix_in_progress_resources.rb') +# +# describe FixInProgressResources do +# include Mocks::Datacite +# include Mocks::RSolr +# include Mocks::Salesforce +# include Mocks::Stripe +# +# attr_reader :in_progress_resources +# +# before(:each) do +# mock_solr! +# mock_datacite! +# mock_salesforce! +# mock_stripe! +# +# @in_progress_resources = [] +# ident_count = 3 +# identifiers = Array.new(ident_count) { |i| create(:identifier, identifier: "10.123/#{i}") } +# identifiers.each do |ident| +# Timecop.travel(Time.now.utc - 1.minute) +# r1 = create(:resource, identifier_id: ident.id) +# r1.current_state = 'submitted' +# r1.save +# v1 = r1.stash_version +# expect(v1.version).to eq(1) # just to be sure +# expect(v1.merritt_version).to eq(1) # just to be sure +# Timecop.return +# r2 = r1.amoeba_dup +# r2.save +# expect(r2.current_state).to eq('in_progress') # just to be sure +# v2 = r2.stash_version +# v2.version = 1 +# v2.merritt_version = 1 +# v2.save +# +# in_progress_resources << v2 +# end +# expect(in_progress_resources.size).to eq(ident_count) # just to be sure +# end +# +# it 'fixes all in-progress versions' do +# fix = FixInProgressResources.new +# fix.change +# in_progress_resources.each do |v| +# v.reload +# expect(v.version).to eq(2) # just to be sure +# expect(v.merritt_version).to eq(2) # just to be sure +# end +# end +# end