Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorcy committed Aug 25, 2023
1 parent 5727d27 commit 12afe8e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 52 deletions.
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_01_14_030718) do
ActiveRecord::Schema.define(version: 20_200_114_030_718) do

create_table "bookmarks", force: :cascade do |t|
t.integer "user_id", null: false
Expand Down
33 changes: 7 additions & 26 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

#
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'simplecov'
Expand All @@ -20,7 +21,7 @@

ENV['RAILS_ENV'] ||= 'test'

require File.expand_path('../../config/environment', __FILE__)
require File.expand_path('../config/environment', __dir__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
Expand All @@ -47,7 +48,7 @@
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }

# Checks for pending migration and applies them before tests are run.
# If you are not using ActiveRecord, you can remove this line.
Expand All @@ -67,9 +68,9 @@

Capybara.register_driver :selenium_chrome_headless_sandboxless do |app|
driver = Capybara::Selenium::Driver.new(app,
browser: :remote,
capabilities: capabilities,
url: ENV['HUB_URL'])
browser: :remote,
capabilities: capabilities,
url: ENV['HUB_URL'])

# Fix for capybara vs remote files. Selenium handles this for us
driver.browser.file_detector = lambda do |argss|
Expand All @@ -87,7 +88,6 @@
Capybara.app_host = "http://#{ip}:#{Capybara.server_port}"
else


# Adding chromedriver for js testing.
Capybara.register_driver :selenium_chrome_headless_sandboxless do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
Expand Down Expand Up @@ -161,10 +161,6 @@
DatabaseCleaner.clean
end

config.after(:suite) do
stop_ldap
end

config.include FactoryBot::Syntax::Methods
config.include Devise::Test::IntegrationHelpers, type: :system

Expand All @@ -180,19 +176,4 @@
config.after(:each) do
ActiveFedora::Cleaner.clean!
end

end

# Deletes everything in Fedora.
def clean_fedora
ActiveFedora::Cleaner.clean!
end

##
# Deletes everything in Solr.
def clean_solr
solr = ActiveFedora::SolrService.instance.conn
solr.delete_by_query("*:*", params: { commit: true })
end


end
51 changes: 26 additions & 25 deletions spec/support/download_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
# frozen_string_literal: true

module DownloadHelpers
TIMEOUT = 20
PATH = Rails.root.join('tmp', 'downloads')
TIMEOUT = 20
PATH = Rails.root.join('tmp', 'downloads')

def downloads
Dir[PATH.join('*')]
end
def downloads
Dir[PATH.join('*')]
end

def download
downloads.first
end
def download
downloads.first
end

def download_content
wait_for_download
File.read(download)
end
def download_content
wait_for_download
File.read(download)
end

def wait_for_download
Timeout.timeout(TIMEOUT) do
sleep 0.1 until downloaded?
end
def wait_for_download
Timeout.timeout(TIMEOUT) do
sleep 0.1 until downloaded?
end
end

def downloaded?
!downloading? && downloads.any?
end
def downloaded?
!downloading? && downloads.any?
end

def downloading?
downloads.grep(/\.crdownload$/).any?
end
def downloading?
downloads.grep(/\.crdownload$/).any?
end

def clear_downloads
FileUtils.rm_f(downloads)
end
def clear_downloads
FileUtils.rm_f(downloads)
end
end

0 comments on commit 12afe8e

Please sign in to comment.