Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alinvetian committed Jan 21, 2025
1 parent b87b8bf commit 7a3fdf4
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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] %>
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20200805213525_add_fos_to_subjects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/stash/compressed/zip_info.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'http'
require 'stringio'
# require 'charlock_holmes/string'
require 'charlock_holmes/string'
require 'zip'
require 'down/http'
require 'open3'
Expand Down
102 changes: 51 additions & 51 deletions spec/models/fix_in_progress_versions_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7a3fdf4

Please sign in to comment.